@@ -1454,6 +1454,80 @@ func TestRestoreTablesMethodIntegration(t *testing.T) {
14541454 }
14551455}
14561456
1457+ func TestRestoreFullChangingMethodIntegration (t * testing.T ) {
1458+ h := newTestHelper (t , ManagedClusterHosts (), ManagedSecondClusterHosts ())
1459+ ctx := context .Background ()
1460+
1461+ ni , err := h .srcCluster .Client .AnyNodeInfo (ctx )
1462+ if err != nil {
1463+ t .Fatal (err )
1464+ }
1465+ if ok , err := ni .SupportsNativeBackupAPI (); err != nil {
1466+ t .Fatal (err )
1467+ } else if ! ok {
1468+ t .Skip ("Test assumes native backup api support" )
1469+ }
1470+
1471+ Print ("Keyspace setup" )
1472+ ksStmt := "CREATE KEYSPACE %q WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': %d}"
1473+ ks := randomizedName ("changing_method_" )
1474+ ExecStmt (t , h .srcCluster .rootSession , fmt .Sprintf (ksStmt , ks , 2 ))
1475+
1476+ Print ("Table setup" )
1477+ tabStmt := "CREATE TABLE %q.%q (id int PRIMARY KEY, data int)"
1478+ tab := randomizedName ("tab_" )
1479+ ExecStmt (t , h .srcCluster .rootSession , fmt .Sprintf (tabStmt , ks , tab ))
1480+
1481+ Print ("Location and permissions setup" )
1482+ loc := testLocation ("changing-method" , "" )
1483+ S3InitBucket (t , loc .Path )
1484+ ksFilter := []string {ks }
1485+ backupProps := defaultTestBackupProperties (loc , ks )
1486+ // Configure retention policy so that the last backup happens after purge
1487+ backupProps ["retention" ] = 3
1488+ backupProps ["retention_days" ] = 0
1489+ backupProps ["retention_map" ] = backup.RetentionMap {
1490+ h .srcCluster .TaskID : backup.RetentionPolicy {
1491+ RetentionDays : 0 ,
1492+ Retention : 3 ,
1493+ },
1494+ }
1495+ grantRestoreSchemaPermissions (t , h .dstCluster .rootSession , h .dstUser )
1496+ grantRestoreTablesPermissions (t , h .dstCluster .rootSession , ksFilter , h .dstUser )
1497+
1498+ type testIter struct {
1499+ backupMethod backup.Method
1500+ rowCnt int
1501+ }
1502+ testCases := []testIter {
1503+ {backupMethod : backup .MethodRclone , rowCnt : 50 },
1504+ {backupMethod : backup .MethodNative , rowCnt : 100 },
1505+ {backupMethod : backup .MethodRclone , rowCnt : 150 },
1506+ {backupMethod : backup .MethodNative , rowCnt : 200 },
1507+ {backupMethod : backup .MethodRclone , rowCnt : 250 },
1508+ }
1509+ for i , tc := range testCases {
1510+ t .Log ("Fill: " , i )
1511+ fillTable (t , h .srcCluster .rootSession , tc .rowCnt , ks , tab )
1512+
1513+ t .Log ("Backup: " , i )
1514+ backupProps ["method" ] = tc .backupMethod
1515+ tag := h .runBackup (t , backupProps )
1516+
1517+ t .Log ("Restore schema: " , i )
1518+ ExecStmt (t , h .dstCluster .rootSession , fmt .Sprintf ("DROP KEYSPACE IF EXISTS %q" , ks ))
1519+ restoreProps := defaultTestProperties (loc , tag , false )
1520+ h .runRestore (t , restoreProps )
1521+
1522+ t .Log ("Restore tables: " , i )
1523+ restoreProps = defaultTestProperties (loc , tag , true )
1524+ h .runRestore (t , restoreProps )
1525+
1526+ t .Log ("Validate: " , i )
1527+ h .validateIdenticalTables (t , []table {{ks : ks , tab : tab }})
1528+ }
1529+ }
1530+
14571531func TestRestoreFullAlternatorIntegration (t * testing.T ) {
14581532 h := newTestHelper (t , ManagedSecondClusterHosts (), ManagedClusterHosts ())
14591533
0 commit comments