satellite/durability: observer must reset between executions

Change-Id: I8f5b951beba513b219c4bb5680658f5e8b54538d
This commit is contained in:
Márton Elek 2023-11-20 09:46:06 +01:00 committed by Storj Robot
parent 866780bcde
commit 0fdacfed8f
2 changed files with 18 additions and 0 deletions

View File

@ -126,10 +126,16 @@ func (c *Report) Start(ctx context.Context, startTime time.Time) error {
return errs.Wrap(err) return errs.Wrap(err)
} }
c.aliasMap = aliasMap c.aliasMap = aliasMap
c.resetStat()
c.classifyNodeAliases() c.classifyNodeAliases()
return nil return nil
} }
func (c *Report) resetStat() {
c.healthStat = make(map[string]*HealthStat)
c.busFactor = HealthStat{}
}
func (c *Report) classifyNodeAliases() { func (c *Report) classifyNodeAliases() {
c.classID = make(map[string]classID, len(c.classifiers)) c.classID = make(map[string]classID, len(c.classifiers))
c.className = make(map[classID]string, len(c.classifiers)) c.className = make(map[classID]string, len(c.classifiers))

View File

@ -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, 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, 2, c.healthStat["net:127.0.1.0"].Min())
require.Equal(t, 3, c.healthStat["net:127.0.2.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) { func TestDurabilityUnknownNode(t *testing.T) {