Skip to content

Commit

Permalink
Merge pull request scylladb#391 from sylwiaszunejko/lwt-tablets-disabled
Browse files Browse the repository at this point in the history
Disable tablets for tests with LWT
  • Loading branch information
dkropachev authored Feb 15, 2025
2 parents eef107d + 2d2a924 commit 93ff201
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func TestPagingWithBind(t *testing.T) {
func TestCAS(t *testing.T) {
cluster := createCluster()
cluster.SerialConsistency = LocalSerial
session := createSessionFromCluster(cluster, t)
session := createSessionFromClusterTabletsDisabled(cluster, t)
defer session.Close()

if session.cfg.ProtoVersion == 1 {
Expand Down Expand Up @@ -669,7 +669,7 @@ func TestDurationType(t *testing.T) {
}

func TestMapScanCAS(t *testing.T) {
session := createSession(t)
session := createSessionFromClusterTabletsDisabled(createCluster(), t)
defer session.Close()

if session.cfg.ProtoVersion == 1 {
Expand Down Expand Up @@ -1240,7 +1240,7 @@ func TestScanWithNilArguments(t *testing.T) {
}

func TestScanCASWithNilArguments(t *testing.T) {
session := createSession(t)
session := createSessionFromClusterTabletsDisabled(createCluster(), t)
defer session.Close()

if session.cfg.ProtoVersion == 1 {
Expand Down Expand Up @@ -1709,7 +1709,7 @@ func TestPrepare_PreparedCacheKey(t *testing.T) {

// create a second keyspace
cluster2 := createCluster()
createKeyspace(t, cluster2, "gocql_test2")
createKeyspace(t, cluster2, "gocql_test2", false)
cluster2.Keyspace = "gocql_test2"
session2, err := cluster2.CreateSession()
if err != nil {
Expand Down
24 changes: 19 additions & 5 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func createMultiNodeCluster(opts ...func(*ClusterConfig)) *ClusterConfig {
return cluster
}

func createKeyspace(tb testing.TB, cluster *ClusterConfig, keyspace string) {
func createKeyspace(tb testing.TB, cluster *ClusterConfig, keyspace string, disableTablets bool) {
// TODO: tb.Helper()
c := *cluster
c.Keyspace = "system"
Expand All @@ -152,22 +152,28 @@ func createKeyspace(tb testing.TB, cluster *ClusterConfig, keyspace string) {
panic(fmt.Sprintf("unable to drop keyspace: %v", err))
}

err = createTable(session, fmt.Sprintf(`CREATE KEYSPACE %s
query := fmt.Sprintf(`CREATE KEYSPACE %s
WITH replication = {
'class' : 'NetworkTopologyStrategy',
'replication_factor' : %d
}`, keyspace, *flagRF))
}`, keyspace, *flagRF)

if disableTablets {
query += " AND tablets = {'enabled': false}"
}

err = createTable(session, query)

if err != nil {
panic(fmt.Sprintf("unable to create keyspace: %v", err))
}
}

func createSessionFromCluster(cluster *ClusterConfig, tb testing.TB) *Session {
func createSessionFromClusterHelper(cluster *ClusterConfig, tb testing.TB, tabletsDisabled bool) *Session {
// Drop and re-create the keyspace once. Different tests should use their own
// individual tables, but can assume that the table does not exist before.
initOnce.Do(func() {
createKeyspace(tb, cluster, "gocql_test")
createKeyspace(tb, cluster, "gocql_test", tabletsDisabled)
})

cluster.Keyspace = "gocql_test"
Expand All @@ -183,6 +189,14 @@ func createSessionFromCluster(cluster *ClusterConfig, tb testing.TB) *Session {
return session
}

func createSessionFromClusterTabletsDisabled(cluster *ClusterConfig, tb testing.TB) *Session {
return createSessionFromClusterHelper(cluster, tb, true)
}

func createSessionFromCluster(cluster *ClusterConfig, tb testing.TB) *Session {
return createSessionFromClusterHelper(cluster, tb, false)
}

func createSessionFromMultiNodeCluster(cluster *ClusterConfig, tb testing.TB) *Session {
keyspace := "test1"

Expand Down
2 changes: 1 addition & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestHostFilterInitial(t *testing.T) {
func TestWriteFailure(t *testing.T) {
t.Skip("skipped due to unknown purpose")
cluster := createCluster()
createKeyspace(t, cluster, "test")
createKeyspace(t, cluster, "test", false)
cluster.Keyspace = "test"
session, err := cluster.CreateSession()
if err != nil {
Expand Down

0 comments on commit 93ff201

Please sign in to comment.