Skip to content

Commit

Permalink
fix(service_test): don't assume that system_auth always exist
Browse files Browse the repository at this point in the history
Starting with Scylla 6.0, system_auth is moved to system/system_auth_v2 and is handled by raft.
New clusters won't have the old system_auth tables, so the tests should be adjusted accordingly.
  • Loading branch information
Michal-Leszczynski committed Jun 4, 2024
1 parent a560f44 commit 48a1ee2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
20 changes: 12 additions & 8 deletions pkg/scyllaclient/client_scylla_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ func TestClientSnapshotIntegration(t *testing.T) {
ctx := context.Background()
host := ManagedClusterHost()
tag := "sm_" + timeutc.Now().Format("20060102150405") + "UTC"
const ks = "system_schema"
const tab = "tables"

Print("When: snapshot is taken")
if err := client.TakeSnapshot(ctx, host, tag, "system_auth"); err != nil {
if err := client.TakeSnapshot(ctx, host, tag, ks); err != nil {
t.Fatal(err)
}

Expand All @@ -227,12 +229,12 @@ func TestClientSnapshotIntegration(t *testing.T) {

Print("When: snapshot is taken again with the same tag")
Print("Then: nothing happens")
if err := client.TakeSnapshot(ctx, host, tag, "system_auth"); err != nil {
if err := client.TakeSnapshot(ctx, host, tag, ks); err != nil {
t.Fatal(err)
}

Print("When: table snapshot is removed")
if err := client.DeleteTableSnapshot(ctx, host, tag, "system_auth", "roles"); err != nil {
if err := client.DeleteTableSnapshot(ctx, host, tag, ks, tab); err != nil {
t.Fatal(err)
}

Expand All @@ -243,14 +245,14 @@ func TestClientSnapshotIntegration(t *testing.T) {
}
var u scyllaclient.Unit
for _, u = range units {
if u.Keyspace == "system_auth" {
if u.Keyspace == ks {
break
}
}
if u.Keyspace == "" {
t.Fatal("missing snapshot")
}
if slice.ContainsString(u.Tables, "roles") {
if slice.ContainsString(u.Tables, tab) {
t.Fatal("table snapshot not deleted")
}

Expand All @@ -270,6 +272,8 @@ func TestClientSnapshotIntegration(t *testing.T) {
}

func TestClientTableExistsIntegration(t *testing.T) {
const ks = "system_schema"
const tab = "tables"
table := []struct {
Name string
Keyspace string
Expand All @@ -278,13 +282,13 @@ func TestClientTableExistsIntegration(t *testing.T) {
}{
{
Name: "Valid",
Keyspace: "system_auth",
Table: "roles",
Keyspace: ks,
Table: tab,
Exists: true,
},
{
Name: "No table",
Keyspace: "system_auth",
Keyspace: ks,
Table: "aaa",
Exists: false,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/backup/service_backup_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func TestGetTargetIntegration(t *testing.T) {
if diff := cmp.Diff(golden, v,
cmpopts.SortSlices(func(a, b string) bool { return a < b }),
cmpopts.IgnoreUnexported(backup.Target{}),
cmpopts.IgnoreSliceElements(func(u backup.Unit) bool { return u.Keyspace == "system_replicated_keys" }),
cmpopts.IgnoreSliceElements(func(u backup.Unit) bool { return u.Keyspace == "system_replicated_keys" || u.Keyspace == "system_auth" }),
cmpopts.IgnoreSliceElements(func(t string) bool { return t == "dicts" })); diff != "" {
t.Fatal(diff)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"units": [
{
"keyspace": "system_auth",
"keyspace": "system_distributed_everywhere",
"tables": [
"role_attributes",
"role_members",
"roles",
"role_permissions"
"cdc_generation_descriptions_v2"
],
"all_tables": true
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"keyspace": ["system_auth.*"], "location": ["s3:backuptest-get-target"]}
{"keyspace": ["system_distributed_everywhere.*"], "location": ["s3:backuptest-get-target"]}
4 changes: 1 addition & 3 deletions pkg/service/repair/service_repair_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func TestServiceGetTargetIntegration(t *testing.T) {
cmpopts.SortSlices(func(a, b string) bool { return a < b }),
cmpopts.SortSlices(func(u1, u2 repair.Unit) bool { return u1.Keyspace < u2.Keyspace }),
cmpopts.IgnoreUnexported(repair.Target{}),
cmpopts.IgnoreSliceElements(func(u repair.Unit) bool { return u.Keyspace == "system_replicated_keys" }),
cmpopts.IgnoreSliceElements(func(u repair.Unit) bool { return u.Keyspace == "system_replicated_keys" || u.Keyspace == "system_auth" }),
cmpopts.IgnoreSliceElements(func(t string) bool { return t == "dicts" })); diff != "" {
t.Fatal(diff)
}
Expand Down Expand Up @@ -706,8 +706,6 @@ func TestServiceRepairOrderIntegration(t *testing.T) {
FlushTable(t, c, ManagedClusterHosts(), ks3, t1)

expectedRepairOrder := []string{
"system_auth.role_attributes",
"system_auth.role_members",
"system_auth.*",
"system_replicated_keys.*",
"system_distributed.*",
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/restore/service_restore_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func TestRestoreGetTargetUnitsViewsIntegration(t *testing.T) {
cmpopts.SortSlices(func(a, b Table) bool { return a.Table < b.Table }),
cmpopts.IgnoreFields(Unit{}, "Size"),
cmpopts.IgnoreFields(Table{}, "Size"),
cmpopts.IgnoreSliceElements(func(u Unit) bool { return u.Keyspace == "system_replicated_keys" }),
cmpopts.IgnoreSliceElements(func(u Unit) bool { return u.Keyspace == "system_replicated_keys" || u.Keyspace == "system_auth" }),
cmpopts.IgnoreSliceElements(func(t Table) bool { return t.Table == "dicts" })); diff != "" {
t.Fatal(tc.units, diff)
}
Expand Down

0 comments on commit 48a1ee2

Please sign in to comment.