@@ -1454,6 +1454,83 @@ func TestRestoreTablesMethodIntegration(t *testing.T) {
14541454 }
14551455}
14561456
1457+ func TestRestoreFullAlternatorIntegration (t * testing.T ) {
1458+ h := newTestHelper (t , ManagedSecondClusterHosts (), ManagedClusterHosts ())
1459+
1460+ ni , err := h .srcCluster .Client .AnyNodeInfo (context .Background ())
1461+ if err != nil {
1462+ t .Fatal (err )
1463+ }
1464+ if ok , err := ni .SupportsAlternatorSchemaBackupFromAPI (); err != nil {
1465+ t .Fatal (err )
1466+ } else if ! ok {
1467+ t .Skip ("This test assumes that alternator tables are backed up and restored with alternator api" )
1468+ }
1469+
1470+ Print ("Prepare alternator schema" )
1471+ altTab1 := "alt_full_1_" + AlternatorProblematicTableChars
1472+ altTab2 := "alt_full_2_" + AlternatorProblematicTableChars
1473+ altGSI1 := "gsi_1_" + AlternatorProblematicTableChars
1474+ altGSI2 := "gsi_2_" + AlternatorProblematicTableChars
1475+ CreateAlternatorTable (t , h .srcCluster .altClient , 2 , altTab1 , altTab2 )
1476+ CreateAlternatorGSI (t , h .srcCluster .altClient , altTab1 , altGSI1 , altGSI2 )
1477+ CreateAlternatorGSI (t , h .srcCluster .altClient , altTab2 , altGSI1 , altGSI2 )
1478+
1479+ Print ("Insert alternator rows" )
1480+ const rowCnt = 100
1481+ InsertAlternatorTableData (t , h .srcCluster .altClient , rowCnt , altTab1 , altTab2 )
1482+
1483+ Print ("Prepare simple clq schema" )
1484+ ExecStmt (t , h .srcCluster .rootSession , "CREATE KEYSPACE cql_ks WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': 2} and tablets = {'enabled': false}" )
1485+ createTable (t , h .srcCluster .rootSession , "cql_ks" , "cql_tab" )
1486+ CreateMaterializedView (t , h .srcCluster .rootSession , "cql_ks" , "cql_tab" , "cql_mv_1" )
1487+ CreateMaterializedView (t , h .srcCluster .rootSession , "cql_ks" , "cql_tab" , "cql_mv_2" )
1488+ CreateSecondaryIndex (t , h .srcCluster .rootSession , "cql_ks" , "cql_tab" , "cql_si_1" )
1489+
1490+ Print ("Insert simple cql rows" )
1491+ fillTable (t , h .srcCluster .rootSession , rowCnt , "cql_ks" , "cql_tab" )
1492+
1493+ Print ("Run backup" )
1494+ loc := testLocation ("alternator-full" , "" )
1495+ S3InitBucket (t , loc .Path )
1496+ backupProps := defaultTestBackupProperties (loc , "" )
1497+ tag := h .runBackup (t , backupProps )
1498+
1499+ Print ("Restore schema" )
1500+ grantRestoreSchemaPermissions (t , h .dstCluster .rootSession , h .dstUser )
1501+ props := defaultTestProperties (loc , tag , false )
1502+ h .runRestore (t , props )
1503+
1504+ Print ("Reset user permissions" )
1505+ dropNonSuperUsers (t , h .dstCluster .rootSession )
1506+ createUser (t , h .dstCluster .rootSession , h .dstUser , h .dstPass )
1507+
1508+ Print ("Restore data" )
1509+ grantRestoreTablesPermissions (t , h .dstCluster .rootSession , nil , h .dstUser )
1510+ props = defaultTestProperties (loc , tag , true )
1511+ h .runRestore (t , props )
1512+
1513+ Print ("Validate restored alternator data" )
1514+ ValidateAlternatorTableData (t , h .dstCluster .altClient , rowCnt , 2 , altTab1 , altTab2 )
1515+ ValidateAlternatorGSIData (t , h .dstCluster .altClient , rowCnt , altTab1 , altGSI1 , altGSI2 )
1516+ ValidateAlternatorGSIData (t , h .dstCluster .altClient , rowCnt , altTab2 , altGSI1 , altGSI2 )
1517+
1518+ Print ("Validate restored simple cql data" )
1519+ cqlTabs := []table {
1520+ {ks : "cql_ks" , tab : "cql_tab" },
1521+ {ks : "cql_ks" , tab : "cql_mv_1" },
1522+ {ks : "cql_ks" , tab : "cql_mv_2" },
1523+ {ks : "cql_ks" , tab : "cql_si_1_index" },
1524+ }
1525+ for _ , tab := range cqlTabs {
1526+ srcCnt := rowCount (t , h .srcCluster .rootSession , tab .ks , tab .tab )
1527+ dstCnt := rowCount (t , h .dstCluster .rootSession , tab .ks , tab .tab )
1528+ if srcCnt != dstCnt {
1529+ t .Fatalf ("Expected %d rows in cql table %q.%q, got %d" , srcCnt , tab .ks , tab .tab , dstCnt )
1530+ }
1531+ }
1532+ }
1533+
14571534func getDCFromRemoteSSTableDir (t * testing.T , remoteSSTableDir string ) string {
14581535 t .Helper ()
14591536 // hacky way of extracting value of dc_name from /dc/{dc_name}/node/
0 commit comments