2019-03-18 10:55:06 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package monitor_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/memory"
|
|
|
|
"storj.io/common/testcontext"
|
|
|
|
"storj.io/common/testrand"
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/testplanet"
|
2020-10-30 12:51:26 +00:00
|
|
|
"storj.io/storj/storagenode/internalpb"
|
2019-03-18 10:55:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMonitor(t *testing.T) {
|
2019-04-22 10:07:50 +01:00
|
|
|
testplanet.Run(t, testplanet.Config{
|
|
|
|
SatelliteCount: 1, StorageNodeCount: 6, UplinkCount: 1,
|
|
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
|
|
for _, storageNode := range planet.StorageNodes {
|
|
|
|
storageNode.Storage2.Monitor.Loop.Pause()
|
|
|
|
}
|
2019-03-18 10:55:06 +00:00
|
|
|
|
2019-06-26 11:38:51 +01:00
|
|
|
expectedData := testrand.Bytes(100 * memory.KiB)
|
2019-03-18 10:55:06 +00:00
|
|
|
|
2019-06-26 11:38:51 +01:00
|
|
|
err := planet.Uplinks[0].Upload(ctx, planet.Satellites[0], "testbucket", "test/path", expectedData)
|
2019-04-22 10:07:50 +01:00
|
|
|
require.NoError(t, err)
|
2019-03-18 10:55:06 +00:00
|
|
|
|
2019-04-22 10:07:50 +01:00
|
|
|
nodeAssertions := 0
|
|
|
|
for _, storageNode := range planet.StorageNodes {
|
|
|
|
storageNode.Storage2.Monitor.Loop.TriggerWait()
|
2020-08-07 17:19:37 +01:00
|
|
|
storageNode.Storage2.Monitor.VerifyDirReadableLoop.TriggerWait()
|
|
|
|
storageNode.Storage2.Monitor.VerifyDirWritableLoop.TriggerWait()
|
2020-10-30 12:51:26 +00:00
|
|
|
stats, err := storageNode.Storage2.Inspector.Stats(ctx, &internalpb.StatsRequest{})
|
2019-04-22 10:07:50 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
if stats.UsedSpace > 0 {
|
|
|
|
nodeAssertions++
|
|
|
|
}
|
2019-03-18 10:55:06 +00:00
|
|
|
}
|
2019-04-22 10:07:50 +01:00
|
|
|
assert.NotZero(t, nodeAssertions, "No storage node were verifed")
|
|
|
|
})
|
2019-03-18 10:55:06 +00:00
|
|
|
}
|