Merge pull request #1550 from ajnavarro/fix/use-at-least-3-nodes-on-cluster-tests

[CORE-432] Add at least 3 nodes on test clusters.
This commit is contained in:
Kuba Podgórski 2021-03-27 17:07:17 +01:00 committed by GitHub
commit 8948c4531a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 81 additions and 50 deletions

View file

@ -46,7 +46,7 @@ func TestAPI_ImportColumnAttrs(t *testing.T) {
10000 5.156
100000 38.179
*/
c := test.MustRunCluster(t, 2,
c := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node0"),
@ -57,11 +57,17 @@ func TestAPI_ImportColumnAttrs(t *testing.T) {
pilosa.OptServerNodeID("node1"),
pilosa.OptServerClusterHasher(&offsetModHasher{}),
)},
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node2"),
pilosa.OptServerClusterHasher(&offsetModHasher{}),
)},
)
defer c.Close()
m0 := c.GetNode(0)
m1 := c.GetNode(1)
t.Run("ImportColumnAttrs", func(t *testing.T) {
ctx := context.Background()
indexName := "i"
@ -111,7 +117,7 @@ func TestAPI_ImportColumnAttrs(t *testing.T) {
IndexCreatedAt: index.CreatedAt(),
}
if err := m1.API.ImportColumnAttrs(ctx, req); err != nil {
if err := m0.API.ImportColumnAttrs(ctx, req); err != nil {
t.Fatal(err)
}
@ -125,7 +131,7 @@ func TestAPI_ImportColumnAttrs(t *testing.T) {
IndexCreatedAt: index.CreatedAt(),
}
if err := m0.API.ImportColumnAttrs(ctx, req); err != nil {
if err := m1.API.ImportColumnAttrs(ctx, req); err != nil {
t.Fatal(err)
}
@ -166,7 +172,7 @@ func TestAPI_ImportColumnAttrs(t *testing.T) {
}
func TestAPI_Import(t *testing.T) {
c := test.MustRunCluster(t, 2,
c := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node0"),
@ -181,6 +187,13 @@ func TestAPI_Import(t *testing.T) {
pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore),
pilosa.OptServerOpenTranslateReader(http.GetOpenTranslateReaderFunc(nil)),
)},
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node2"),
pilosa.OptServerClusterHasher(&offsetModHasher{}),
pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore),
pilosa.OptServerOpenTranslateReader(http.GetOpenTranslateReaderFunc(nil)),
)},
)
defer c.Close()
@ -287,7 +300,7 @@ func TestAPI_Import(t *testing.T) {
}
func TestAPI_ImportValue(t *testing.T) {
c := test.MustRunCluster(t, 2,
c := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node0"),
@ -300,12 +313,19 @@ func TestAPI_ImportValue(t *testing.T) {
pilosa.OptServerClusterHasher(&offsetModHasher{}),
pilosa.OptServerOpenTranslateReader(http.GetOpenTranslateReaderFunc(nil)),
)},
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node2"),
pilosa.OptServerClusterHasher(&offsetModHasher{}),
pilosa.OptServerOpenTranslateReader(http.GetOpenTranslateReaderFunc(nil)),
)},
)
defer c.Close()
coord := c.GetPrimary()
m0 := c.GetNode(0)
m1 := c.GetNode(1)
m2 := c.GetNode(2)
t.Run("ValColumnKey", func(t *testing.T) {
ctx := context.Background()
@ -371,16 +391,14 @@ func TestAPI_ImportValue(t *testing.T) {
ctx := context.Background()
index := "valdec"
field := "fdec"
_, err := m1.API.CreateIndex(ctx, index, pilosa.IndexOptions{})
_, err := m2.API.CreateIndex(ctx, index, pilosa.IndexOptions{})
if err != nil {
t.Fatalf("creating index: %v", err)
}
_, err = m1.API.CreateField(ctx, index, field, pilosa.OptFieldTypeDecimal(1))
_, err = m2.API.CreateField(ctx, index, field, pilosa.OptFieldTypeDecimal(1))
if err != nil {
t.Fatalf("creating field: %v", err)
}
// Generate some records.
values := []float64{}
colIDs := []uint64{}
@ -388,7 +406,6 @@ func TestAPI_ImportValue(t *testing.T) {
values = append(values, float64(i)+0.1)
colIDs = append(colIDs, uint64(i))
}
// Import data with keys to node1 and verify that it gets translated and
// forwarded to the owner of shard 0 (node0; because of offsetModHasher)
req := &pilosa.ImportValueRequest{
@ -397,15 +414,12 @@ func TestAPI_ImportValue(t *testing.T) {
ColumnIDs: colIDs,
FloatValues: values,
}
qcx := m1.API.Txf().NewQcx()
if err := m1.API.ImportValue(ctx, qcx, req); err != nil {
qcx := m0.API.Txf().NewQcx()
if err := m0.API.ImportValue(ctx, qcx, req); err != nil {
t.Fatal(err)
}
panicOn(qcx.Finish())
query := fmt.Sprintf("Row(%s>6)", field)
// Query node0.
if res, err := m0.API.Query(ctx, &pilosa.QueryRequest{Index: index, Query: query}); err != nil {
t.Fatal(err)

View file

@ -270,7 +270,7 @@ func TestImportCommand_KeyReplication(t *testing.T) {
}
ctx := context.Background()
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
cmd0 := c.GetNode(0)
cmd1 := c.GetNode(1)

View file

@ -69,7 +69,7 @@ func getTempDirString() (td *string) {
}
func TestExecutor_Execute_ConstRow(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
c.CreateField(t, "i", pilosa.IndexOptions{}, "h")
@ -1058,7 +1058,7 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) {
}
func TestExecutor_Execute_TopK_Set(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Load some test data into a set field.
@ -1089,7 +1089,7 @@ func TestExecutor_Execute_TopK_Set(t *testing.T) {
}
func TestExecutor_Execute_TopK_Time(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Load some test data into a time field.
@ -3033,15 +3033,18 @@ func TestExecutor_Execute_Range_BSIGroup_Deprecated(t *testing.T) {
// Ensure a remote query can return a row.
func TestExecutor_Execute_Remote_Row(t *testing.T) {
c := test.MustRunCluster(t, 2,
c := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(pilosa.OptServerNodeID("node0"), pilosa.OptServerClusterHasher(&test.ModHasher{}))},
[]server.CommandOption{
server.OptCommandServerOptions(pilosa.OptServerNodeID("node1"), pilosa.OptServerClusterHasher(&test.ModHasher{}))},
[]server.CommandOption{
server.OptCommandServerOptions(pilosa.OptServerNodeID("node2"), pilosa.OptServerClusterHasher(&test.ModHasher{}))},
)
defer c.Close()
hldr0 := c.GetHolder(0)
hldr1 := c.GetHolder(1)
hldr2 := c.GetHolder(2)
_, err := c.GetPrimary().API.CreateIndex(context.Background(), "i", pilosa.IndexOptions{})
if err != nil {
@ -3051,10 +3054,8 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
if err != nil {
t.Fatalf("creating field: %v", err)
}
hldr1.MustSetBits("i", "f", 10, ShardWidth+1, ShardWidth+2, (3*ShardWidth)+4)
hldr0.SetBit("i", "f", 10, 1)
hldr0.MustSetBits("i", "f", 10, ShardWidth+1, ShardWidth+2, (3*ShardWidth)+4)
hldr2.SetBit("i", "f", 10, 1)
if res, err := c.GetNode(0).API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Row(f=10)`}); err != nil {
t.Fatal(err)
} else if columns := res.Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, ShardWidth + 1, ShardWidth + 2, (3 * ShardWidth) + 4}) {
@ -3074,7 +3075,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
t.Fatalf("querying remote: %v", err)
}
if !reflect.DeepEqual(hldr1.Row("i", "f", 7).Columns(), []uint64{pilosa.ShardWidth + 1}) {
if !reflect.DeepEqual(hldr0.Row("i", "f", 7).Columns(), []uint64{pilosa.ShardWidth + 1}) {
t.Fatalf("unexpected cols from row 7: %v", hldr1.Row("i", "f", 7).Columns())
}
})
@ -3089,7 +3090,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
t.Fatalf("quuerying remote: %v", err)
}
if !reflect.DeepEqual(hldr1.RowTime("i", "z", 5, time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC), "Y").Columns(), []uint64{pilosa.ShardWidth + 1}) {
if !reflect.DeepEqual(hldr0.RowTime("i", "z", 5, time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC), "Y").Columns(), []uint64{pilosa.ShardWidth + 1}) {
t.Fatalf("unexpected cols from row 7: %v", hldr1.RowTime("i", "z", 5, time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC), "Y").Columns())
}
})
@ -3165,12 +3166,12 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
if _, err := c.GetNode(0).API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `
Set(0, fint=1)
Set(1, fint=2)
Set(2,fint=-2)
Set(3,fint=-1)
Set(4,fint=4)
Set(10, fint=0)
Set(100, fint=0)
Set(1000, fint=0)
@ -3786,7 +3787,7 @@ func TestExecutor_Execute_Not(t *testing.T) {
// Ensure an all query can be executed.
func TestExecutor_Execute_FieldValue(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
node0 := c.GetNode(0)
@ -3879,7 +3880,7 @@ func TestExecutor_Execute_FieldValue(t *testing.T) {
// Ensure a Limit query can be executed.
func TestExecutor_Execute_Limit(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
c.CreateField(t, "i", pilosa.IndexOptions{TrackExistence: true}, "f")
@ -6735,7 +6736,7 @@ func TestExecutor_Execute_CountDistinct(t *testing.T) {
// is handled correctly.
func TestExecutor_BareDistinct(t *testing.T) {
t.Helper()
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
c.CreateField(t, "i", pilosa.IndexOptions{}, "ints",
@ -6816,7 +6817,7 @@ func TestExecutor_Execute_TopNDistinct(t *testing.T) {
}
func Test_Executor_Execute_UnionRows(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
c.CreateField(t, "i", pilosa.IndexOptions{}, "s",

View file

@ -470,11 +470,13 @@ func TestClient_ImportColumnAttrs(t *testing.T) {
// Ensure client can bulk import data.
func TestClient_ImportRoaring(t *testing.T) {
cluster := test.MustRunCluster(t, 2,
cluster := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(pilosa.OptServerReplicaN(2))},
server.OptCommandServerOptions(pilosa.OptServerReplicaN(3))},
[]server.CommandOption{
server.OptCommandServerOptions(pilosa.OptServerReplicaN(2))},
server.OptCommandServerOptions(pilosa.OptServerReplicaN(3))},
[]server.CommandOption{
server.OptCommandServerOptions(pilosa.OptServerReplicaN(3))},
)
defer cluster.Close()
@ -722,7 +724,7 @@ func TestClient_ImportKeys(t *testing.T) {
})
t.Run("MultiNode", func(t *testing.T) {
cluster := test.MustRunCluster(t, 2)
cluster := test.MustRunCluster(t, 3)
defer cluster.Close()
cmd0 := cluster.GetNode(0)
cmd1 := cluster.GetNode(1)

View file

@ -33,7 +33,7 @@ import (
// Ensure program can send/receive broadcast messages.
func TestMain_SendReceiveMessage(t *testing.T) {
ms := test.MustRunCluster(t, 2)
ms := test.MustRunCluster(t, 3)
m0, m1 := ms.GetNode(0), ms.GetNode(1)
defer ms.Close()
@ -128,7 +128,7 @@ func TestClusterResize_EmptyNode(t *testing.T) {
// Ensure that a cluster of empty nodes comes up in a NORMAL state.
func TestClusterResize_EmptyNodes(t *testing.T) {
clus := test.MustRunCluster(t, 2)
clus := test.MustRunCluster(t, 3)
defer clus.Close()
state0, err0 := clus.GetNode(0).API.State()
@ -156,7 +156,7 @@ func TestClusterResize_AddNode(t *testing.T) {
skipTestUnderBlueGreenWithRoaring(t)
t.Run("NoData", func(t *testing.T) {
clus := test.MustRunCluster(t, 2)
clus := test.MustRunCluster(t, 3)
defer clus.Close()
state0, err0 := clus.GetNode(0).API.State()
@ -218,7 +218,7 @@ func TestClusterResize_AddNode(t *testing.T) {
t.Run("ContinuousShards", func(t *testing.T) {
// Configure node0
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
m0 := c.GetNode(0)
@ -268,7 +268,7 @@ func TestClusterResize_AddNode(t *testing.T) {
t.Run("OneShard", func(t *testing.T) {
// Configure node0
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Configure node0
@ -316,7 +316,7 @@ func TestClusterResize_AddNode(t *testing.T) {
t.Run("SkippedShard", func(t *testing.T) {
// same reason as the ContinuousShards test above.
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Configure node0
@ -372,7 +372,7 @@ func TestClusterResize_AddNodeConcurrentIndex(t *testing.T) {
skipTestUnderBlueGreenWithRoaring(t)
t.Run("WithIndex", func(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Configure node0
@ -413,7 +413,7 @@ func TestClusterResize_AddNodeConcurrentIndex(t *testing.T) {
})
t.Run("ContinuousShards", func(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Configure node0
@ -464,7 +464,7 @@ func TestClusterResize_AddNodeConcurrentIndex(t *testing.T) {
})
t.Run("SkippedShard", func(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Configure node0
@ -515,7 +515,7 @@ func TestClusterResize_AddNodeConcurrentIndex(t *testing.T) {
})
t.Run("WithIndexKeys", func(t *testing.T) {
c := test.MustRunCluster(t, 2)
c := test.MustRunCluster(t, 3)
defer c.Close()
// Configure node0

View file

@ -1540,7 +1540,7 @@ func TestCluster_TranslateStore(t *testing.T) {
}
func TestClusterTranslator(t *testing.T) {
cluster := test.MustRunCluster(t, 2,
cluster := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore),
@ -1550,6 +1550,10 @@ func TestClusterTranslator(t *testing.T) {
pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore),
pilosa.OptServerOpenTranslateReader(http.GetOpenTranslateReaderWithLockerFunc(nil, &sync.Mutex{})),
)},
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore),
)},
)
defer cluster.Close()
@ -1591,7 +1595,7 @@ func TestClusterTranslator(t *testing.T) {
}
func TestQueryHistory(t *testing.T) {
cluster := test.MustRunCluster(t, 2,
cluster := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("1"),
@ -1600,6 +1604,10 @@ func TestQueryHistory(t *testing.T) {
server.OptCommandServerOptions(
pilosa.OptServerNodeID("0"),
)},
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("2"),
)},
)
defer cluster.Close()

View file

@ -534,7 +534,7 @@ func TestTranslation_Primary(t *testing.T) {
t.Run("ForwardFieldKey", func(t *testing.T) {
t.Skip("Short term skip to avoid go 1.13 test Should remove ASAP")
// Start a 2-node cluster.
c := test.MustRunCluster(t, 2,
c := test.MustRunCluster(t, 3,
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node0"),
@ -547,6 +547,12 @@ func TestTranslation_Primary(t *testing.T) {
pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore),
pilosa.OptServerOpenTranslateReader(http.GetOpenTranslateReaderFunc(nil)),
)},
[]server.CommandOption{
server.OptCommandServerOptions(
pilosa.OptServerNodeID("node2"),
pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore),
pilosa.OptServerOpenTranslateReader(http.GetOpenTranslateReaderFunc(nil)),
)},
)
defer c.Close()