2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-12-14 20:17:30 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package statdb_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"storj.io/storj/internal/testcontext"
|
2019-03-01 17:46:34 +00:00
|
|
|
"storj.io/storj/pkg/pb"
|
2018-12-14 20:17:30 +00:00
|
|
|
"storj.io/storj/pkg/statdb"
|
|
|
|
"storj.io/storj/pkg/storj"
|
2018-12-27 09:56:25 +00:00
|
|
|
"storj.io/storj/satellite"
|
2018-12-14 20:17:30 +00:00
|
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
|
|
|
)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
func getRatio(success, total int64) (ratio float64) {
|
|
|
|
ratio = float64(success) / float64(total)
|
|
|
|
return ratio
|
2018-12-14 20:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestStatdb(t *testing.T) {
|
2018-12-27 09:56:25 +00:00
|
|
|
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
2018-12-14 20:17:30 +00:00
|
|
|
ctx := testcontext.New(t)
|
|
|
|
defer ctx.Cleanup()
|
|
|
|
|
|
|
|
testDatabase(ctx, t, db.StatDB())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testDatabase(ctx context.Context, t *testing.T, sdb statdb.DB) {
|
2018-12-17 18:47:04 +00:00
|
|
|
nodeID := storj.NodeID{1, 2, 3, 4, 5}
|
2018-12-19 18:44:03 +00:00
|
|
|
currAuditSuccess := int64(4)
|
|
|
|
currAuditCount := int64(10)
|
|
|
|
currUptimeSuccess := int64(8)
|
|
|
|
currUptimeCount := int64(25)
|
2018-12-17 18:47:04 +00:00
|
|
|
|
|
|
|
{ // TestCreateNewAndWithStats
|
2018-12-19 18:44:03 +00:00
|
|
|
auditSuccessRatio := getRatio(currAuditSuccess, currAuditCount)
|
|
|
|
uptimeRatio := getRatio(currUptimeSuccess, currUptimeCount)
|
|
|
|
|
|
|
|
nodeStats := &statdb.NodeStats{
|
2018-12-14 20:17:30 +00:00
|
|
|
AuditSuccessRatio: auditSuccessRatio,
|
|
|
|
UptimeRatio: uptimeRatio,
|
2018-12-19 18:44:03 +00:00
|
|
|
AuditCount: currAuditCount,
|
|
|
|
AuditSuccessCount: currAuditSuccess,
|
|
|
|
UptimeCount: currUptimeCount,
|
|
|
|
UptimeSuccessCount: currUptimeSuccess,
|
2018-12-14 20:17:30 +00:00
|
|
|
}
|
2018-12-19 18:44:03 +00:00
|
|
|
|
|
|
|
stats, err := sdb.Create(ctx, nodeID, nodeStats)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, auditSuccessRatio, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, uptimeRatio, stats.UptimeRatio)
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
stats, err = sdb.Get(ctx, nodeID)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, nodeID, stats.NodeID)
|
|
|
|
assert.EqualValues(t, currAuditCount, stats.AuditCount)
|
|
|
|
assert.EqualValues(t, currAuditSuccess, stats.AuditSuccessCount)
|
|
|
|
assert.EqualValues(t, auditSuccessRatio, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, currUptimeCount, stats.UptimeCount)
|
|
|
|
assert.EqualValues(t, currUptimeSuccess, stats.UptimeSuccessCount)
|
|
|
|
assert.EqualValues(t, uptimeRatio, stats.UptimeRatio)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-17 18:47:04 +00:00
|
|
|
{ // TestCreateExists
|
2018-12-19 18:44:03 +00:00
|
|
|
auditSuccessRatio := getRatio(currAuditSuccess, currAuditCount)
|
|
|
|
uptimeRatio := getRatio(currUptimeSuccess, currUptimeCount)
|
|
|
|
|
|
|
|
nodeStats := &statdb.NodeStats{
|
2018-12-14 20:17:30 +00:00
|
|
|
AuditSuccessRatio: auditSuccessRatio,
|
|
|
|
UptimeRatio: uptimeRatio,
|
2018-12-19 18:44:03 +00:00
|
|
|
AuditCount: currAuditCount,
|
|
|
|
AuditSuccessCount: currAuditSuccess,
|
|
|
|
UptimeCount: currUptimeCount,
|
|
|
|
UptimeSuccessCount: currUptimeSuccess,
|
2018-12-14 20:17:30 +00:00
|
|
|
}
|
2019-03-01 17:46:34 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
_, err := sdb.Create(ctx, nodeID, nodeStats)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.Error(t, err)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-17 18:47:04 +00:00
|
|
|
{ // TestGetDoesNotExist
|
|
|
|
noNodeID := storj.NodeID{255, 255, 255, 255}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
_, err := sdb.Get(ctx, noNodeID)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.Error(t, err)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-17 18:47:04 +00:00
|
|
|
{ // TestFindInvalidNodes
|
2018-12-14 20:17:30 +00:00
|
|
|
for _, tt := range []struct {
|
|
|
|
nodeID storj.NodeID
|
|
|
|
auditSuccessCount int64
|
|
|
|
auditCount int64
|
|
|
|
auditSuccessRatio float64
|
|
|
|
uptimeSuccessCount int64
|
|
|
|
uptimeCount int64
|
|
|
|
uptimeRatio float64
|
|
|
|
}{
|
2018-12-17 18:47:04 +00:00
|
|
|
{storj.NodeID{1}, 20, 20, 1, 20, 20, 1}, // good audit success
|
|
|
|
{storj.NodeID{2}, 5, 20, 0.25, 20, 20, 1}, // bad audit success, good uptime
|
|
|
|
{storj.NodeID{3}, 20, 20, 1, 5, 20, 0.25}, // good audit success, bad uptime
|
|
|
|
{storj.NodeID{4}, 0, 0, 0, 20, 20, 1}, // "bad" audit success, no audits
|
|
|
|
{storj.NodeID{5}, 20, 20, 1, 0, 0, 0.25}, // "bad" uptime success, no checks
|
|
|
|
{storj.NodeID{6}, 0, 1, 0, 5, 5, 1}, // bad audit success exactly one audit
|
|
|
|
{storj.NodeID{7}, 0, 20, 0, 20, 20, 1}, // bad ratios, excluded from query
|
2018-12-14 20:17:30 +00:00
|
|
|
} {
|
2018-12-19 18:44:03 +00:00
|
|
|
nodeStats := &statdb.NodeStats{
|
2018-12-14 20:17:30 +00:00
|
|
|
AuditSuccessRatio: tt.auditSuccessRatio,
|
|
|
|
UptimeRatio: tt.uptimeRatio,
|
|
|
|
AuditCount: tt.auditCount,
|
|
|
|
AuditSuccessCount: tt.auditSuccessCount,
|
|
|
|
UptimeCount: tt.uptimeCount,
|
|
|
|
UptimeSuccessCount: tt.uptimeSuccessCount,
|
|
|
|
}
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
_, err := sdb.Create(ctx, tt.nodeID, nodeStats)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
nodeIds := storj.NodeIDList{
|
|
|
|
storj.NodeID{1}, storj.NodeID{2},
|
|
|
|
storj.NodeID{3}, storj.NodeID{4},
|
|
|
|
storj.NodeID{5}, storj.NodeID{6},
|
|
|
|
}
|
|
|
|
maxStats := &statdb.NodeStats{
|
|
|
|
AuditSuccessRatio: 0.5,
|
|
|
|
UptimeRatio: 0.5,
|
2018-12-14 20:17:30 +00:00
|
|
|
}
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
invalid, err := sdb.FindInvalidNodes(ctx, nodeIds, maxStats)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-17 18:47:04 +00:00
|
|
|
assert.Contains(t, invalid, storj.NodeID{2})
|
|
|
|
assert.Contains(t, invalid, storj.NodeID{3})
|
|
|
|
assert.Contains(t, invalid, storj.NodeID{6})
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.Len(t, invalid, 3)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2019-03-01 17:46:34 +00:00
|
|
|
{ // TestUpdateOperator
|
|
|
|
nodeID := storj.NodeID{10}
|
|
|
|
stats, err := sdb.CreateEntryIfNotExists(ctx, nodeID)
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, stats.Operator.Wallet, "")
|
|
|
|
assert.Equal(t, stats.Operator.Email, "")
|
|
|
|
|
|
|
|
update, err := sdb.UpdateOperator(ctx, nodeID, pb.NodeOperator{
|
|
|
|
Wallet: "0x1111111111111111111111111111111111111111",
|
|
|
|
Email: "abc123@gmail.com",
|
|
|
|
})
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, update)
|
|
|
|
|
|
|
|
found, err := sdb.Get(ctx, nodeID)
|
|
|
|
assert.NotNil(t, found)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, "0x1111111111111111111111111111111111111111", found.Operator.Wallet)
|
|
|
|
assert.Equal(t, "abc123@gmail.com", found.Operator.Email)
|
|
|
|
|
|
|
|
updateEmail, err := sdb.UpdateOperator(ctx, nodeID, pb.NodeOperator{
|
|
|
|
Email: "def456@gmail.com",
|
|
|
|
})
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, updateEmail)
|
|
|
|
assert.Equal(t, updateEmail.Operator.Email, "def456@gmail.com")
|
|
|
|
|
|
|
|
updateWallet, err := sdb.UpdateOperator(ctx, nodeID, pb.NodeOperator{
|
|
|
|
Wallet: "0x2222222222222222222222222222222222222222",
|
|
|
|
})
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, updateWallet)
|
|
|
|
assert.Equal(t, updateWallet.Operator.Wallet, "0x2222222222222222222222222222222222222222")
|
|
|
|
}
|
|
|
|
|
2018-12-17 18:47:04 +00:00
|
|
|
{ // TestUpdateExists
|
2018-12-19 18:44:03 +00:00
|
|
|
auditSuccessRatio := getRatio(currAuditSuccess, currAuditCount)
|
|
|
|
uptimeRatio := getRatio(currUptimeSuccess, currUptimeCount)
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
stats, err := sdb.Get(ctx, nodeID)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, nodeID, stats.NodeID)
|
|
|
|
assert.EqualValues(t, currAuditCount, stats.AuditCount)
|
|
|
|
assert.EqualValues(t, currAuditSuccess, stats.AuditSuccessCount)
|
|
|
|
assert.EqualValues(t, auditSuccessRatio, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, currUptimeCount, stats.UptimeCount)
|
|
|
|
assert.EqualValues(t, currUptimeSuccess, stats.UptimeSuccessCount)
|
|
|
|
assert.EqualValues(t, uptimeRatio, stats.UptimeRatio)
|
2018-12-14 20:17:30 +00:00
|
|
|
|
|
|
|
updateReq := &statdb.UpdateRequest{
|
2018-12-19 18:44:03 +00:00
|
|
|
NodeID: nodeID,
|
|
|
|
AuditSuccess: true,
|
|
|
|
IsUp: false,
|
2018-12-14 20:17:30 +00:00
|
|
|
}
|
2018-12-19 18:44:03 +00:00
|
|
|
stats, err = sdb.Update(ctx, updateReq)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
currAuditSuccess++
|
|
|
|
currAuditCount++
|
|
|
|
currUptimeCount++
|
|
|
|
newAuditRatio := getRatio(currAuditSuccess, currAuditCount)
|
|
|
|
newUptimeRatio := getRatio(currUptimeSuccess, currUptimeCount)
|
|
|
|
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.EqualValues(t, newAuditRatio, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, newUptimeRatio, stats.UptimeRatio)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-17 18:47:04 +00:00
|
|
|
{ // TestUpdateUptimeExists
|
2018-12-19 18:44:03 +00:00
|
|
|
auditSuccessRatio := getRatio(currAuditSuccess, currAuditCount)
|
|
|
|
uptimeRatio := getRatio(currUptimeSuccess, currUptimeCount)
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
stats, err := sdb.Get(ctx, nodeID)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, nodeID, stats.NodeID)
|
|
|
|
assert.EqualValues(t, currAuditCount, stats.AuditCount)
|
|
|
|
assert.EqualValues(t, currAuditSuccess, stats.AuditSuccessCount)
|
|
|
|
assert.EqualValues(t, auditSuccessRatio, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, currUptimeCount, stats.UptimeCount)
|
|
|
|
assert.EqualValues(t, currUptimeSuccess, stats.UptimeSuccessCount)
|
|
|
|
assert.EqualValues(t, uptimeRatio, stats.UptimeRatio)
|
|
|
|
|
|
|
|
stats, err = sdb.UpdateUptime(ctx, nodeID, false)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
currUptimeCount++
|
|
|
|
newUptimeRatio := getRatio(currUptimeSuccess, currUptimeCount)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.EqualValues(t, auditSuccessRatio, stats.AuditSuccessRatio)
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, currAuditCount, stats.AuditCount)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.EqualValues(t, newUptimeRatio, stats.UptimeRatio)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-17 18:47:04 +00:00
|
|
|
{ // TestUpdateAuditSuccessExists
|
2018-12-19 18:44:03 +00:00
|
|
|
auditSuccessRatio := getRatio(currAuditSuccess, currAuditCount)
|
|
|
|
uptimeRatio := getRatio(currUptimeSuccess, currUptimeCount)
|
|
|
|
|
|
|
|
stats, err := sdb.Get(ctx, nodeID)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, nodeID, stats.NodeID)
|
|
|
|
assert.EqualValues(t, currAuditCount, stats.AuditCount)
|
|
|
|
assert.EqualValues(t, currAuditSuccess, stats.AuditSuccessCount)
|
|
|
|
assert.EqualValues(t, auditSuccessRatio, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, currUptimeCount, stats.UptimeCount)
|
|
|
|
assert.EqualValues(t, currUptimeSuccess, stats.UptimeSuccessCount)
|
|
|
|
assert.EqualValues(t, uptimeRatio, stats.UptimeRatio)
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
stats, err = sdb.UpdateAuditSuccess(ctx, nodeID, false)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
currAuditCount++
|
|
|
|
newAuditRatio := getRatio(currAuditSuccess, currAuditCount)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.EqualValues(t, newAuditRatio, stats.AuditSuccessRatio)
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, currAuditCount, stats.AuditCount)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.EqualValues(t, uptimeRatio, stats.UptimeRatio)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{ // TestUpdateBatchExists
|
|
|
|
nodeID1 := storj.NodeID{255, 1}
|
|
|
|
nodeID2 := storj.NodeID{255, 2}
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
auditSuccessCount1 := int64(4)
|
|
|
|
auditCount1 := int64(10)
|
|
|
|
auditRatio1 := getRatio(auditSuccessCount1, auditCount1)
|
|
|
|
|
|
|
|
uptimeSuccessCount1 := int64(8)
|
|
|
|
uptimeCount1 := int64(25)
|
|
|
|
uptimeRatio1 := getRatio(uptimeSuccessCount1, uptimeCount1)
|
|
|
|
|
|
|
|
nodeStats := &statdb.NodeStats{
|
2018-12-14 20:17:30 +00:00
|
|
|
AuditSuccessCount: auditSuccessCount1,
|
|
|
|
AuditCount: auditCount1,
|
|
|
|
AuditSuccessRatio: auditRatio1,
|
|
|
|
UptimeSuccessCount: uptimeSuccessCount1,
|
|
|
|
UptimeCount: uptimeCount1,
|
|
|
|
UptimeRatio: uptimeRatio1,
|
|
|
|
}
|
2018-12-19 18:44:03 +00:00
|
|
|
|
|
|
|
stats, err := sdb.Create(ctx, nodeID1, nodeStats)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, auditRatio1, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, uptimeRatio1, stats.UptimeRatio)
|
|
|
|
|
|
|
|
auditSuccessCount2 := int64(7)
|
|
|
|
auditCount2 := int64(10)
|
|
|
|
auditRatio2 := getRatio(auditSuccessCount2, auditCount2)
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
uptimeSuccessCount2 := int64(8)
|
|
|
|
uptimeCount2 := int64(20)
|
|
|
|
uptimeRatio2 := getRatio(uptimeSuccessCount2, uptimeCount2)
|
|
|
|
|
|
|
|
nodeStats = &statdb.NodeStats{
|
2018-12-14 20:17:30 +00:00
|
|
|
AuditSuccessCount: auditSuccessCount2,
|
|
|
|
AuditCount: auditCount2,
|
|
|
|
AuditSuccessRatio: auditRatio2,
|
|
|
|
UptimeSuccessCount: uptimeSuccessCount2,
|
|
|
|
UptimeCount: uptimeCount2,
|
|
|
|
UptimeRatio: uptimeRatio2,
|
|
|
|
}
|
2018-12-19 18:44:03 +00:00
|
|
|
|
|
|
|
stats, err = sdb.Create(ctx, nodeID2, nodeStats)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, auditRatio2, stats.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, uptimeRatio2, stats.UptimeRatio)
|
|
|
|
|
|
|
|
updateReqList := []*statdb.UpdateRequest{
|
|
|
|
&statdb.UpdateRequest{
|
|
|
|
NodeID: nodeID1,
|
|
|
|
AuditSuccess: true,
|
|
|
|
IsUp: false,
|
|
|
|
},
|
|
|
|
&statdb.UpdateRequest{
|
|
|
|
NodeID: nodeID2,
|
|
|
|
AuditSuccess: true,
|
|
|
|
IsUp: true,
|
|
|
|
},
|
2018-12-14 20:17:30 +00:00
|
|
|
}
|
2018-12-19 18:44:03 +00:00
|
|
|
statsList, _, err := sdb.UpdateBatch(ctx, updateReqList)
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2018-12-19 18:44:03 +00:00
|
|
|
newAuditRatio1 := getRatio(auditSuccessCount1+1, auditCount1+1)
|
|
|
|
newUptimeRatio1 := getRatio(uptimeSuccessCount1, uptimeCount1+1)
|
|
|
|
newAuditRatio2 := getRatio(auditSuccessCount2+1, auditCount2+1)
|
|
|
|
newUptimeRatio2 := getRatio(uptimeSuccessCount2+1, uptimeCount2+1)
|
|
|
|
stats1 := statsList[0]
|
|
|
|
stats2 := statsList[1]
|
2018-12-14 20:17:30 +00:00
|
|
|
assert.EqualValues(t, newAuditRatio1, stats1.AuditSuccessRatio)
|
|
|
|
assert.EqualValues(t, newUptimeRatio1, stats1.UptimeRatio)
|
|
|
|
assert.EqualValues(t, newAuditRatio2, stats2.AuditSuccessRatio)
|
2018-12-19 18:44:03 +00:00
|
|
|
assert.EqualValues(t, newUptimeRatio2, stats2.UptimeRatio)
|
2018-12-17 18:47:04 +00:00
|
|
|
}
|
2018-12-14 20:17:30 +00:00
|
|
|
}
|