@@ -2619,12 +2619,11 @@ func (env *TestEnvironment) runMainIntegrationScenario(t *testing.T, remoteStora
26192619 var err error
26202620 r := require .New (t )
26212621 env .connectWithWait (r , 500 * time .Millisecond , 1500 * time .Millisecond , 3 * time .Minute )
2622- // test for specified partitions backup
2623- testBackupSpecifiedPartitions (t , r , env , remoteStorageType , backupConfig )
26242622
26252623 // main test scenario
26262624 fullBackupName := fmt .Sprintf ("%s_full_%d" , t .Name (), rand .Int ())
26272625 incrementBackupName := fmt .Sprintf ("%s_increment_%d" , t .Name (), rand .Int ())
2626+ incrementBackupNameEmpty := fmt .Sprintf ("%s_incrementEmpty_%d" , t .Name (), rand .Int ())
26282627 incrementBackupName2 := fmt .Sprintf ("%s_increment2_%d" , t .Name (), rand .Int ())
26292628 databaseList := []string {dbNameOrdinary , dbNameAtomic , dbNameMySQL , dbNamePostgreSQL , Issue331Issue1091Atomic , Issue331Issue1091Ordinary }
26302629 tablesPattern := fmt .Sprintf ("*_%s.*" , t .Name ())
@@ -2633,17 +2632,39 @@ func (env *TestEnvironment) runMainIntegrationScenario(t *testing.T, remoteStora
26332632 createAllTypesOfObjectTables := ! strings .Contains (remoteStorageType , "CUSTOM" )
26342633 testData := generateTestData (t , r , env , remoteStorageType , createAllTypesOfObjectTables , defaultTestData )
26352634
2636- log .Debug ().Msg ("Create backup" )
2635+ log .Debug ().Msg ("Create full backup" )
26372636 createCmd := "clickhouse-backup -c /etc/clickhouse-backup/" + backupConfig + " create --resume --tables=" + tablesPattern + " " + fullBackupName
26382637 env .checkResumeAlreadyProcessed (createCmd , fullBackupName , "create" , r , remoteStorageType )
26392638
2640- incrementData := generateIncrementTestData (t , r , env , remoteStorageType , createAllTypesOfObjectTables , defaultIncrementData , 1 )
2641- env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "create" , "--tables" , tablesPattern , incrementBackupName )
2642-
2643- log .Debug ().Msg ("Upload full" )
2639+ log .Debug ().Msg ("Upload full backup" )
26442640 uploadCmd := fmt .Sprintf ("%s_COMPRESSION_FORMAT=zstd CLICKHOUSE_BACKUP_CONFIG=/etc/clickhouse-backup/%s clickhouse-backup upload --resume %s" , remoteStorageType , backupConfig , fullBackupName )
26452641 env .checkResumeAlreadyProcessed (uploadCmd , fullBackupName , "upload" , r , remoteStorageType )
26462642
2643+ // https://github.com/Altinity/clickhouse-backup/issues/871
2644+ log .Debug ().Msg ("Create+upload incrementEmpty without data" )
2645+ env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "create" , "--tables" , tablesPattern , "--diff-from-remote" , fullBackupName , incrementBackupNameEmpty )
2646+ out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ec" , "clickhouse-backup -c /etc/clickhouse-backup/" + backupConfig + " list local | grep " + incrementBackupNameEmpty )
2647+ r .NoError (err )
2648+ r .Contains (out , "+" + fullBackupName )
2649+ r .Contains (out , incrementBackupNameEmpty )
2650+ r .Contains (out , "data:0B" )
2651+ env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "upload" , "--env" , "BACKUPS_TO_KEEP_REMOTE=1" , "--env" , "BACKUPS_TO_KEEP_REMOTE=2" , "--env" , "ALLOW_EMPTY_BACKUPS=1" , "--diff-from-remote" , fullBackupName , incrementBackupNameEmpty )
2652+ out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ec" , "clickhouse-backup -c /etc/clickhouse-backup/" + backupConfig + " list remote | grep '^" + fullBackupName + "'" )
2653+ r .NoError (err )
2654+ r .Contains (out , fullBackupName )
2655+ r .NotContains (out , "data:0B" )
2656+ out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ec" , "clickhouse-backup -c /etc/clickhouse-backup/" + backupConfig + " list remote | grep " + incrementBackupNameEmpty )
2657+ r .NoError (err )
2658+ r .Contains (out , "+" + fullBackupName )
2659+ r .Contains (out , incrementBackupNameEmpty )
2660+ r .Contains (out , "data:0B" )
2661+ env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "delete" , "remote" , incrementBackupNameEmpty )
2662+ env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "delete" , "local" , incrementBackupNameEmpty )
2663+
2664+ log .Debug ().Msg ("Create increment1 with data" )
2665+ incrementData := generateIncrementTestData (t , r , env , remoteStorageType , createAllTypesOfObjectTables , defaultIncrementData , 1 )
2666+ env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "create" , "--tables" , tablesPattern , incrementBackupName )
2667+
26472668 // https://github.com/Altinity/clickhouse-backup/pull/900
26482669 if compareVersion (os .Getenv ("CLICKHOUSE_VERSION" ), "21.8" ) >= 0 {
26492670 log .Debug ().Msg ("create --diff-from-remote backup" )
@@ -2667,9 +2688,9 @@ func (env *TestEnvironment) runMainIntegrationScenario(t *testing.T, remoteStora
26672688 log .Debug ().Msg ("Delete backup" )
26682689 env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "delete" , "local" , fullBackupName )
26692690 env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "delete" , "local" , incrementBackupName )
2670- out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ce" , "ls -lha " + backupDir + " | grep " + t . Name () )
2671- r .NotNil (err )
2672- r .Equal ( "" , strings .Trim (out , " \t \r \n " ), "expect '0' backup exists in backup directory" )
2691+ out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ce" , "ls -lha " + backupDir )
2692+ r .NoError (err )
2693+ r .NotContains ( strings .Trim (out , " \t \r \n " ), t . Name (), "expect no backup exists in backup directory" )
26732694
26742695 dropDatabasesFromTestDataDataSet (t , r , env , databaseList )
26752696
@@ -2740,6 +2761,10 @@ func (env *TestEnvironment) runMainIntegrationScenario(t *testing.T, remoteStora
27402761 fullCleanup (t , r , env , []string {incrementBackupName }, []string {"local" }, nil , true , false , backupConfig )
27412762 fullCleanup (t , r , env , []string {fullBackupName , incrementBackupName }, []string {"remote" }, databaseList , true , true , backupConfig )
27422763 replaceStorageDiskNameForReBalance (r , env , remoteStorageType , true )
2764+
2765+ // test for specified partitions backup
2766+ testBackupSpecifiedPartitions (t , r , env , remoteStorageType , backupConfig )
2767+
27432768 env .checkObjectStorageIsEmpty (t , r , remoteStorageType )
27442769}
27452770
0 commit comments