Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix idxInSync, WaitUntilIndexesAreSynced, and TestNames #301

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion sbot/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,18 @@ func (s *Sbot) serveIndexFrom(name string, snk librarian.SinkIndex, msgs margare
s.indexStates[name] = "live"
s.indexStateMu.Unlock()

err = luigi.Pump(s.rootCtx, snk, src)
startWaiting := func() {
}
doneWaiting := func() {
}
startProcessing := func() {
s.idxInSync.Add(1)
}
doneProcessing := func() {
s.idxInSync.Done()
}

err = luigi.PumpWithStatus(s.rootCtx, snk, src, startWaiting, doneWaiting, startProcessing, doneProcessing)
if errors.Is(err, ssb.ErrShuttingDown) || errors.Is(err, context.Canceled) {
return nil
}
Expand Down
9 changes: 2 additions & 7 deletions sbot/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ import (
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb/client"
"github.com/ssbc/go-ssb/internal/leakcheck"
"github.com/ssbc/go-ssb/internal/testutils"
"github.com/ssbc/go-ssb/repo"
)

func TestNames(t *testing.T) {
if testutils.SkipOnCI(t) {
// https://github.com/ssbc/go-ssb/pull/170
return
}

if os.Getenv("LIBRARIAN_WRITEALL") != "0" {
t.Fatal("please 'export LIBRARIAN_WRITEALL=0' for this test to pass")
// TODO: expose index flushing
Expand Down Expand Up @@ -100,7 +94,8 @@ func TestNames(t *testing.T) {

checkLogSeq(mainbot.ReceiveLog, len(intros)-1) // got all the messages

// TODO: flush indexes
// flush indexes
mainbot.WaitUntilIndexesAreSynced()

c, err := client.NewUnix(filepath.Join(tRepoPath, "socket"))
r.NoError(err)
Expand Down