Skip to content

Commit 2e0a379

Browse files
feat(treewide): move from SimpleStrategy to NetworkTopologyStrategy in tests
Because of #4555, but also because it's better to test recommended keyspace replication strategy, we need to replace SimpleStrategy with NetworkTopologyStrategy in tests wherever possible. In case test is aiming to run against SimpleStrategy specifically, it needs to be adjusted so that it ensures that keyspace with SimpleStrategy does not use tablets. Refs #4555
1 parent 9dba132 commit 2e0a379

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

pkg/scyllaclient/client_scylla_integration_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2017 ScyllaDB
1+
// Copyright (C) 2025 ScyllaDB
22

33
//go:build all || integration
44

@@ -125,10 +125,20 @@ func TestClientDescribeRingIntegration(t *testing.T) {
125125
clusterSession := db.CreateSessionAndDropAllKeyspaces(t, client)
126126
defer clusterSession.Close()
127127

128+
ni, err := client.AnyNodeInfo(t.Context())
129+
if err != nil {
130+
t.Fatal(err)
131+
}
132+
128133
ringDescriber := scyllaclient.NewRingDescriber(context.Background(), client)
129134
for i := range testCases {
130135
tc := testCases[i]
131136
t.Run(tc.name, func(t *testing.T) {
137+
if CheckConstraint(t, ni.ScyllaVersion, ">= 2025.1") && tc.replication != scyllaclient.NetworkTopologyStrategy {
138+
// Tablets need to be manually disabled when using non
139+
// NetworkTopologyStrategy keyspace replication strategy.
140+
tc.replicationStmt += " AND tablets = {'enabled': false}"
141+
}
132142
if err := clusterSession.ExecStmt(fmt.Sprintf("CREATE KEYSPACE %s WITH replication = %s", tc.name, tc.replicationStmt)); err != nil {
133143
t.Fatal(err)
134144
}

pkg/service/restore/restore_integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestRestoreTablesUserIntegration(t *testing.T) {
6565
Print("Log in via restored user and check permissions")
6666
userSession := CreateManagedClusterSession(t, false, h.dstCluster.Client, user, pass)
6767
newKs := randomizedName("ks_")
68-
ExecStmt(t, userSession, fmt.Sprintf("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2}", newKs))
68+
ExecStmt(t, userSession, fmt.Sprintf("CREATE KEYSPACE %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 2}", newKs))
6969
}
7070

7171
func TestRestoreTablesNoReplicationIntegration(t *testing.T) {
@@ -74,7 +74,7 @@ func TestRestoreTablesNoReplicationIntegration(t *testing.T) {
7474
ks := randomizedName("no_rep_ks_")
7575
tab := randomizedName("tab_")
7676
Printf("Create non replicated %s.%s in both cluster", ks, tab)
77-
ksStmt := fmt.Sprintf("CREATE KEYSPACE %q WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}", ks)
77+
ksStmt := fmt.Sprintf("CREATE KEYSPACE %q WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': 1}", ks)
7878
tabStmt := fmt.Sprintf("CREATE TABLE %q.%q (id int PRIMARY KEY, data int)", ks, tab)
7979
ExecStmt(t, h.srcCluster.rootSession, ksStmt)
8080
ExecStmt(t, h.srcCluster.rootSession, tabStmt)

pkg/testutils/db/db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2017 ScyllaDB
1+
// Copyright (C) 2025 ScyllaDB
22

33
package db
44

@@ -154,7 +154,7 @@ func createTestKeyspace(tb testing.TB, cluster *gocql.ClusterConfig, keyspace st
154154

155155
ExecStmt(tb, session, fmt.Sprintf(`CREATE KEYSPACE %s
156156
WITH replication = {
157-
'class' : 'SimpleStrategy',
157+
'class' : 'NetworkTopologyStrategy',
158158
'replication_factor' : %d
159159
}`, keyspace, 1))
160160
}

0 commit comments

Comments
 (0)