Skip to content
quarry Artifact [9c42393896]
Login

Artifact [9c42393896]

Artifact 9c42393896b22cc37bfc426b0ee2e6efddddcab6edfa1a6c3f6779cd83a4d5a2:


package ingest

import (
	"errors"
	"testing"
	"time"
)

// A write op's TrySync never waits on a round that holds the pipeline:
// it answers ErrRoundBusy at once (#481), and runs a round when none is.
func TestTrySyncAnswersBusyWhileARoundHoldsThePipeline(t *testing.T) {
	pipe, _, _ := testPipeline(t)
	pipe.mu.Lock()
	start := time.Now()
	_, err := pipe.TrySync()
	took := time.Since(start)
	pipe.mu.Unlock()
	if !errors.Is(err, ErrRoundBusy) {
		t.Errorf("FAIL: TrySync while held = %v, want ErrRoundBusy", err)
	}
	if took > time.Second {
		t.Errorf("FAIL: TrySync waited %v on a held pipeline", took)
	}
	if _, err := pipe.TrySync(); err != nil {
		t.Errorf("FAIL: TrySync on a free pipeline = %v", err)
	}
	if !t.Failed() {
		t.Log("ok")
	}
}