2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-03 12:17:14 +00:00
|
|
|
// See LICENSE for copying information
|
|
|
|
|
|
|
|
package testplanet_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-02-04 15:40:37 +00:00
|
|
|
"time"
|
2018-11-03 12:17:14 +00:00
|
|
|
|
2019-02-04 15:40:37 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/pb"
|
|
|
|
"storj.io/common/storj"
|
|
|
|
"storj.io/common/testcontext"
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/testplanet"
|
2018-11-03 12:17:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBasic(t *testing.T) {
|
2019-12-06 18:03:22 +00:00
|
|
|
for _, version := range storj.IDVersions {
|
|
|
|
version := version
|
|
|
|
testplanet.Run(t, testplanet.Config{
|
|
|
|
SatelliteCount: 2, StorageNodeCount: 4, UplinkCount: 1,
|
|
|
|
IdentityVersion: &version,
|
|
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
|
|
for _, satellite := range planet.Satellites {
|
|
|
|
t.Log("SATELLITE", satellite.ID(), satellite.Addr())
|
|
|
|
}
|
|
|
|
for _, storageNode := range planet.StorageNodes {
|
|
|
|
t.Log("STORAGE", storageNode.ID(), storageNode.Addr())
|
|
|
|
}
|
|
|
|
for _, uplink := range planet.Uplinks {
|
|
|
|
t.Log("UPLINK", uplink.ID(), uplink.Addr())
|
2019-09-20 21:02:23 +01:00
|
|
|
}
|
2019-04-08 19:15:19 +01:00
|
|
|
|
2019-12-06 18:03:22 +00:00
|
|
|
for _, sat := range planet.Satellites {
|
|
|
|
for _, sn := range planet.StorageNodes {
|
2020-11-10 11:56:30 +00:00
|
|
|
func() {
|
|
|
|
node := sn.Contact.Service.Local()
|
|
|
|
conn, err := sn.Dialer.DialNodeURL(ctx, sat.NodeURL())
|
2020-05-19 16:49:13 +01:00
|
|
|
|
2020-11-10 11:56:30 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
defer ctx.Check(conn.Close)
|
|
|
|
_, err = pb.NewDRPCNodeClient(conn).CheckIn(ctx, &pb.CheckInRequest{
|
|
|
|
Address: node.Address,
|
|
|
|
Version: &node.Version,
|
|
|
|
Capacity: &node.Capacity,
|
|
|
|
Operator: &node.Operator,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
}()
|
2019-12-06 18:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// wait a bit to see whether some failures occur
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
})
|
2019-04-08 19:15:19 +01:00
|
|
|
}
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// test that nodes get put into each satellite's overlay cache.
|
2019-09-19 20:56:34 +01:00
|
|
|
func TestContact(t *testing.T) {
|
|
|
|
testplanet.Run(t, testplanet.Config{
|
|
|
|
SatelliteCount: 2, StorageNodeCount: 5, UplinkCount: 0,
|
|
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
|
|
satellite0 := planet.Satellites[0]
|
|
|
|
satellite1 := planet.Satellites[1]
|
|
|
|
|
|
|
|
for _, n := range planet.StorageNodes {
|
|
|
|
_, err := satellite0.Overlay.Service.Get(ctx, n.ID())
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = satellite1.Overlay.Service.Get(ctx, n.ID())
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|