Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/service/restore/helper_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ func defaultTestBackupProperties(loc backupspec.Location, ks string) map[string]
func (h *testHelper) runBackup(t *testing.T, props map[string]any) string {
Printf("Run backup with properties: %v", props)
ctx := context.Background()
h.srcCluster.TaskID = uuid.NewTime()
h.srcCluster.RunID = uuid.NewTime()

rawProps, err := json.Marshal(props)
Expand Down Expand Up @@ -286,7 +285,6 @@ func (h *testHelper) runBackup(t *testing.T, props map[string]any) string {
func (h *testHelper) runRestore(t *testing.T, props map[string]any) {
Printf("Run restore with properties: %v", props)
ctx := context.Background()
h.dstCluster.TaskID = uuid.NewTime()
h.dstCluster.RunID = uuid.NewTime()

rawProps, err := json.Marshal(props)
Expand Down
74 changes: 74 additions & 0 deletions pkg/service/restore/restore_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,80 @@ func TestRestoreTablesMethodIntegration(t *testing.T) {
}
}

func TestRestoreFullChangingMethodIntegration(t *testing.T) {
h := newTestHelper(t, ManagedClusterHosts(), ManagedSecondClusterHosts())
ctx := context.Background()

ni, err := h.srcCluster.Client.AnyNodeInfo(ctx)
if err != nil {
t.Fatal(err)
}
if ok, err := ni.SupportsNativeBackupAPI(); err != nil {
t.Fatal(err)
} else if !ok || IsIPV6Network() {
t.Skip("Test assumes native backup usage")
}

Print("Keyspace setup")
ksStmt := "CREATE KEYSPACE %q WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': %d}"
ks := randomizedName("changing_method_")
ExecStmt(t, h.srcCluster.rootSession, fmt.Sprintf(ksStmt, ks, 2))

Print("Table setup")
tabStmt := "CREATE TABLE %q.%q (id int PRIMARY KEY, data int)"
tab := randomizedName("tab_")
ExecStmt(t, h.srcCluster.rootSession, fmt.Sprintf(tabStmt, ks, tab))

Print("Location and permissions setup")
loc := testLocation("changing-method", "")
S3InitBucket(t, loc.Path)
ksFilter := []string{ks}
backupProps := defaultTestBackupProperties(loc, ks)
// Configure retention policy so that the last backup happens after purge
backupProps["retention"] = 3
backupProps["retention_days"] = 0
backupProps["retention_map"] = backup.RetentionMap{
h.srcCluster.TaskID: backup.RetentionPolicy{
RetentionDays: 0,
Retention: 3,
},
}
grantRestoreSchemaPermissions(t, h.dstCluster.rootSession, h.dstUser)
grantRestoreTablesPermissions(t, h.dstCluster.rootSession, ksFilter, h.dstUser)

type testIter struct {
backupMethod backup.Method
rowCnt int
}
testCases := []testIter{
{backupMethod: backup.MethodRclone, rowCnt: 50},
{backupMethod: backup.MethodNative, rowCnt: 100},
{backupMethod: backup.MethodRclone, rowCnt: 150},
{backupMethod: backup.MethodNative, rowCnt: 200},
{backupMethod: backup.MethodRclone, rowCnt: 250},
}
for i, tc := range testCases {
t.Log("Fill: ", i)
fillTable(t, h.srcCluster.rootSession, tc.rowCnt, ks, tab)

t.Log("Backup: ", i)
backupProps["method"] = tc.backupMethod
tag := h.runBackup(t, backupProps)

t.Log("Restore schema: ", i)
ExecStmt(t, h.dstCluster.rootSession, fmt.Sprintf("DROP KEYSPACE IF EXISTS %q", ks))
restoreProps := defaultTestProperties(loc, tag, false)
h.runRestore(t, restoreProps)

t.Log("Restore tables: ", i)
restoreProps = defaultTestProperties(loc, tag, true)
h.runRestore(t, restoreProps)

t.Log("Validate: ", i)
h.validateIdenticalTables(t, []table{{ks: ks, tab: tab}})
}
}

func TestRestoreFullAlternatorIntegration(t *testing.T) {
h := newTestHelper(t, ManagedSecondClusterHosts(), ManagedClusterHosts())

Expand Down