Skip to content

Commit

Permalink
satellite/durability: observer must reset between executions
Browse files Browse the repository at this point in the history
Change-Id: I8f5b951beba513b219c4bb5680658f5e8b54538d
  • Loading branch information
elek authored and Storj Robot committed Nov 20, 2023
1 parent 866780b commit 0fdacfe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions satellite/durability/observer.go
Expand Up @@ -126,10 +126,16 @@ func (c *Report) Start(ctx context.Context, startTime time.Time) error {
return errs.Wrap(err)
}
c.aliasMap = aliasMap
c.resetStat()
c.classifyNodeAliases()
return nil
}

func (c *Report) resetStat() {
c.healthStat = make(map[string]*HealthStat)
c.busFactor = HealthStat{}
}

func (c *Report) classifyNodeAliases() {
c.classID = make(map[string]classID, len(c.classifiers))
c.className = make(map[classID]string, len(c.classifiers))
Expand Down
12 changes: 12 additions & 0 deletions satellite/durability/observer_test.go
Expand Up @@ -103,6 +103,18 @@ func TestDurability(t *testing.T) {
require.Equal(t, segment1.StreamID.String()+"/0", c.healthStat["net:127.0.0.0"].Exemplar)
require.Equal(t, 2, c.healthStat["net:127.0.1.0"].Min())
require.Equal(t, 3, c.healthStat["net:127.0.2.0"].Min())

// usually called with c.Start()
c.resetStat()

fork, err = c.Fork(ctx)
require.NoError(t, err)
err = c.Join(ctx, fork)
require.NoError(t, err)

// second run supposed to have zero stat.
require.Nil(t, c.healthStat["net:127.0.0.0"])

}

func TestDurabilityUnknownNode(t *testing.T) {
Expand Down

0 comments on commit 0fdacfe

Please sign in to comment.