Skip to content

Commit

Permalink
Merge pull request #301 from KyleMaas/fix-names-test
Browse files Browse the repository at this point in the history
Fix idxInSync, WaitUntilIndexesAreSynced, and TestNames
  • Loading branch information
decentral1se committed Jan 19, 2023
2 parents e478d24 + c82cf59 commit 0639c52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
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

0 comments on commit 0639c52

Please sign in to comment.