Skip to content

Commit 313fd63

Browse files
committed
Explicitly disable tablets for SimpleStrategy replication
Currently, tablets enabled by default are not enforced. Thus, creating keyspaces that do not support tablets, silently disable them and use vnodes. This patch adds `AND tablets = {'enabled': false}` to explicitly disable tablets for keyspaces using SimpleStrategy replication. This is a preparation step for scylladb/scylladb#25342 that changes the current behaviour and forces users to explicitly disable tablets when enabled by default. Refs: scylladb/scylladb#25340
1 parent c0c8556 commit 313fd63

File tree

6 files changed

+39
-20
lines changed

6 files changed

+39
-20
lines changed

.github/workflows/integration-tests-2024.1.21-IPV4.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
ssl-enabled: ${{ env.ssl-enabled }}
2424
tablets: ${{ env.tablets }}
2525
- name: Run tests
26-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/backup
26+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/backup
2727
repair:
2828
name: Test repair
2929
runs-on: ubuntu-latest
@@ -39,7 +39,7 @@ jobs:
3939
ssl-enabled: ${{ env.ssl-enabled }}
4040
tablets: ${{ env.tablets }}
4141
- name: Run tests
42-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} PKG=./pkg/service/repair
42+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} PKG=./pkg/service/repair
4343
restore-schema:
4444
name: Test restore schema
4545
runs-on: ubuntu-latest
@@ -55,7 +55,7 @@ jobs:
5555
ssl-enabled: ${{ env.ssl-enabled }}
5656
tablets: ${{ env.tablets }}
5757
- name: Run tests
58-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestore([^T]|.{1}[^a]|.{2}[^b]|.{3}[^l]|.{4}[^e]|.{5}[^s]).*Integration"'
58+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestore([^T]|.{1}[^a]|.{2}[^b]|.{3}[^l]|.{4}[^e]|.{5}[^s]).*Integration"'
5959
restore-tables:
6060
name: Test restore tables
6161
runs-on: ubuntu-latest
@@ -71,17 +71,18 @@ jobs:
7171
ssl-enabled: ${{ env.ssl-enabled }}
7272
tablets: ${{ env.tablets }}
7373
- name: Run tests
74-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestoreTables.*Integration"'
74+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestoreTables.*Integration"'
7575
small-pkg:
7676
name: Test other, smaller packages
7777
runs-on: ubuntu-latest
7878
steps:
7979
- name: Check out code into the Go module directory
8080
uses: actions/checkout@v3
81-
- name: Set IP_FAMILY and SSL_ENABLED var for all tests
81+
- name: Set IP_FAMILY, SSL_ENABLED and TABLETS var for all tests
8282
run: |
8383
echo "IP_FAMILY=${{ env.ip-family }}" >> $GITHUB_ENV
8484
echo "SSL_ENABLED=${{ env.ssl-enabled }}" >> $GITHUB_ENV
85+
echo "TABLETS=${{ env.tablets }}" >> $GITHUB_ENV
8586
- name: Setup testing dependencies
8687
uses: ./.github/actions/test-setup
8788
with:
@@ -107,7 +108,7 @@ jobs:
107108
- name: Run migrate tests
108109
run: make pkg-integration-test PKG=./pkg/schema/migrate
109110
- name: Run 1-1-restore tests
110-
run: make pkg-integration-test TABLETS=${{ env.tablets }} PKG=./pkg/service/one2onerestore
111+
run: make pkg-integration-test PKG=./pkg/service/one2onerestore
111112
name: integration-tests-2024.1.21-IPV4
112113
"on":
113114
pull_request:

.github/workflows/integration-tests-2024.1.21-IPV6-raftschema-nossl.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
ssl-enabled: ${{ env.ssl-enabled }}
2424
tablets: ${{ env.tablets }}
2525
- name: Run tests
26-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/backup
26+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/backup
2727
repair:
2828
name: Test repair
2929
runs-on: ubuntu-latest
@@ -39,7 +39,7 @@ jobs:
3939
ssl-enabled: ${{ env.ssl-enabled }}
4040
tablets: ${{ env.tablets }}
4141
- name: Run tests
42-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} PKG=./pkg/service/repair
42+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} PKG=./pkg/service/repair
4343
restore-schema:
4444
name: Test restore schema
4545
runs-on: ubuntu-latest
@@ -55,7 +55,7 @@ jobs:
5555
ssl-enabled: ${{ env.ssl-enabled }}
5656
tablets: ${{ env.tablets }}
5757
- name: Run tests
58-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestore([^T]|.{1}[^a]|.{2}[^b]|.{3}[^l]|.{4}[^e]|.{5}[^s]).*Integration"'
58+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestore([^T]|.{1}[^a]|.{2}[^b]|.{3}[^l]|.{4}[^e]|.{5}[^s]).*Integration"'
5959
restore-tables:
6060
name: Test restore tables
6161
runs-on: ubuntu-latest
@@ -71,17 +71,18 @@ jobs:
7171
ssl-enabled: ${{ env.ssl-enabled }}
7272
tablets: ${{ env.tablets }}
7373
- name: Run tests
74-
run: make pkg-integration-test IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestoreTables.*Integration"'
74+
run: make pkg-integration-test TABLETS=${{ env.tablets }} IP_FAMILY=${{ env.ip-family }} SSL_ENABLED=${{ env.ssl-enabled}} BACKUP_METHOD=${{ env.backup-method }} RESTORE_METHOD=${{ env.restore-method }} PKG=./pkg/service/restore RUN='"TestRestoreTables.*Integration"'
7575
small-pkg:
7676
name: Test other, smaller packages
7777
runs-on: ubuntu-latest
7878
steps:
7979
- name: Check out code into the Go module directory
8080
uses: actions/checkout@v3
81-
- name: Set IP_FAMILY and SSL_ENABLED var for all tests
81+
- name: Set IP_FAMILY, SSL_ENABLED and TABLETS var for all tests
8282
run: |
8383
echo "IP_FAMILY=${{ env.ip-family }}" >> $GITHUB_ENV
8484
echo "SSL_ENABLED=${{ env.ssl-enabled }}" >> $GITHUB_ENV
85+
echo "TABLETS=${{ env.tablets }}" >> $GITHUB_ENV
8586
- name: Setup testing dependencies
8687
uses: ./.github/actions/test-setup
8788
with:
@@ -107,7 +108,7 @@ jobs:
107108
- name: Run migrate tests
108109
run: make pkg-integration-test PKG=./pkg/schema/migrate
109110
- name: Run 1-1-restore tests
110-
run: make pkg-integration-test TABLETS=${{ env.tablets }} PKG=./pkg/service/one2onerestore
111+
run: make pkg-integration-test PKG=./pkg/service/one2onerestore
111112
name: integration-tests-2024.1.21-IPV6-raftschema-nossl
112113
"on":
113114
pull_request:

pkg/cmd/scylla-manager/db.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func createKeyspace(ctx context.Context, c config.Config, logger log.Logger) err
6161
return session.Query(mustEvaluateCreateKeyspaceStmt(c)).Exec()
6262
}
6363

64-
const createKeyspaceStmt = "CREATE KEYSPACE {{.Keyspace}} WITH replication = {'class': 'SimpleStrategy', 'replication_factor': {{.ReplicationFactor}}}"
64+
const createKeyspaceStmt = "CREATE KEYSPACE {{.Keyspace}} WITH replication = {'class': 'SimpleStrategy', 'replication_factor': {{.ReplicationFactor}}}" +
65+
" AND tablets = {'enabled': false}"
6566

6667
func mustEvaluateCreateKeyspaceStmt(c config.Config) string {
6768
t := template.New("")

pkg/scyllaclient/client_scylla_integration_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"net"
1313
"net/http"
14+
"os"
1415
"strings"
1516
"testing"
1617
"time"
@@ -130,7 +131,12 @@ func TestClientDescribeRingIntegration(t *testing.T) {
130131
for i := range testCases {
131132
tc := testCases[i]
132133
t.Run(tc.name, func(t *testing.T) {
133-
if err := clusterSession.ExecStmt(fmt.Sprintf("CREATE KEYSPACE %s WITH replication = %s", tc.name, tc.replicationStmt)); err != nil {
134+
ksStmt := fmt.Sprintf("CREATE KEYSPACE %s WITH replication = %s", tc.name, tc.replicationStmt)
135+
if tablets := os.Getenv("TABLETS"); tablets == "enabled" && tc.replication == scyllaclient.SimpleStrategy {
136+
ksStmt += " AND tablets = {'enabled': false}"
137+
}
138+
139+
if err := clusterSession.ExecStmt(ksStmt); err != nil {
134140
t.Fatal(err)
135141
}
136142
defer func() {

pkg/service/restore/restore_integration_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"fmt"
1313
"maps"
1414
"net/http"
15+
"os"
1516
"regexp"
1617
"runtime"
1718
"slices"
@@ -66,7 +67,12 @@ func TestRestoreTablesUserIntegration(t *testing.T) {
6667
Print("Log in via restored user and check permissions")
6768
userSession := CreateManagedClusterSession(t, false, h.dstCluster.Client, user, pass)
6869
newKs := randomizedName("ks_")
69-
ExecStmt(t, userSession, fmt.Sprintf("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2}", newKs))
70+
ksStmt := fmt.Sprintf("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2}", newKs)
71+
if tablets := os.Getenv("TABLETS"); tablets == "enabled" {
72+
ksStmt += " AND tablets = {'enabled': false}"
73+
}
74+
75+
ExecStmt(t, userSession, ksStmt)
7076
}
7177

7278
func TestRestoreTablesNoReplicationIntegration(t *testing.T) {
@@ -76,6 +82,10 @@ func TestRestoreTablesNoReplicationIntegration(t *testing.T) {
7682
tab := randomizedName("tab_")
7783
Printf("Create non replicated %s.%s in both cluster", ks, tab)
7884
ksStmt := fmt.Sprintf("CREATE KEYSPACE %q WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}", ks)
85+
if tablets := os.Getenv("TABLETS"); tablets == "enabled" {
86+
ksStmt += " AND tablets = {'enabled': false}"
87+
}
88+
7989
tabStmt := fmt.Sprintf("CREATE TABLE %q.%q (id int PRIMARY KEY, data int)", ks, tab)
8090
ExecStmt(t, h.srcCluster.rootSession, ksStmt)
8191
ExecStmt(t, h.srcCluster.rootSession, tabStmt)

pkg/testutils/db/db.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ func createTestKeyspace(tb testing.TB, cluster *gocql.ClusterConfig, keyspace st
152152

153153
dropAllKeyspaces(tb, session)
154154

155-
ExecStmt(tb, session, fmt.Sprintf(`CREATE KEYSPACE %s
156-
WITH replication = {
157-
'class' : 'SimpleStrategy',
158-
'replication_factor' : %d
159-
}`, keyspace, 1))
155+
ksStmt := fmt.Sprintf(`CREATE KEYSPACE %s WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : %d }`, keyspace, 1)
156+
if tablets := os.Getenv("TABLETS"); tablets == "enabled" {
157+
ksStmt += " AND tablets = {'enabled': false}"
158+
}
159+
ExecStmt(tb, session, ksStmt)
160160
}
161161

162162
func dropAllKeyspaces(tb testing.TB, session gocqlx.Session) {

0 commit comments

Comments
 (0)