@@ -2037,6 +2037,7 @@ func TestCheckSystemPartsColumns(t *testing.T) {
2037
2037
env .Cleanup (t , r )
2038
2038
}
2039
2039
2040
+ // // https://github.com/Altinity/clickhouse-backup/issues/871
2040
2041
func TestKeepBackupRemoteAndDiffFromRemote (t * testing.T ) {
2041
2042
if isTestShouldSkip ("RUN_ADVANCED_TESTS" ) {
2042
2043
t .Skip ("Skipping Advanced integration tests..." )
@@ -2056,27 +2057,37 @@ func TestKeepBackupRemoteAndDiffFromRemote(t *testing.T) {
2056
2057
for backupNumber , backupName := range backupNames {
2057
2058
if backupNumber == 0 {
2058
2059
env .DockerExecNoError (r , "clickhouse-backup" , "bash" , "-ce" , fmt .Sprintf ("BACKUPS_TO_KEEP_REMOTE=3 CLICKHOUSE_BACKUP_CONFIG=/etc/clickhouse-backup/config-s3.yml clickhouse-backup create_remote %s" , backupName ))
2060
+ } else if backupNumber == 3 {
2061
+ env .DockerExecNoError (r , "clickhouse-backup" , "bash" , "-ce" , fmt .Sprintf ("BACKUPS_TO_KEEP_REMOTE=3 CLICKHOUSE_BACKUP_CONFIG=/etc/clickhouse-backup/config-s3.yml clickhouse-backup create_remote --diff-from-remote=%s %s" , backupNames [backupNumber - 1 ], backupName ))
2059
2062
} else {
2060
2063
incrementData = generateIncrementTestData (t , r , env , "S3" , false , incrementData , backupNumber )
2061
2064
env .DockerExecNoError (r , "clickhouse-backup" , "bash" , "-ce" , fmt .Sprintf ("BACKUPS_TO_KEEP_REMOTE=3 CLICKHOUSE_BACKUP_CONFIG=/etc/clickhouse-backup/config-s3.yml clickhouse-backup create_remote --diff-from-remote=%s %s" , backupNames [backupNumber - 1 ], backupName ))
2062
2065
}
2063
2066
}
2064
2067
out , err := env .DockerExecOut ("clickhouse-backup" , "bash" , "-ce" , "clickhouse-backup -c /etc/clickhouse-backup/config-s3.yml list local" )
2065
2068
r .NoError (err , "%s\n unexpected list local error: %v" , out , err )
2066
- // shall not delete any backup, cause all deleted backups have links as required in other backups
2067
2069
for _ , backupName := range backupNames {
2068
2070
r .Contains (out , backupName )
2069
2071
env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/config-s3.yml" , "delete" , "local" , backupName )
2070
2072
}
2073
+ out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ce" , "clickhouse-backup -c /etc/clickhouse-backup/config-s3.yml list remote" )
2074
+ r .NoError (err , "%s\n unexpected list remote error: %v" , out , err )
2075
+ // shall not delete any backup on remote, cause all deleted backups have links as required in other backups
2076
+ for _ , backupName := range backupNames {
2077
+ r .Regexp ("(?m)^" + backupName , out )
2078
+ }
2079
+
2071
2080
latestIncrementBackup := fmt .Sprintf ("keep_remote_backup_%d" , len (backupNames )- 1 )
2072
2081
env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/config-s3.yml" , "download" , latestIncrementBackup )
2073
2082
out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ce" , "clickhouse-backup -c /etc/clickhouse-backup/config-s3.yml list local" )
2074
2083
r .NoError (err , "%s\n unexpected list local error: %v" , out , err )
2075
2084
prevIncrementBackup := fmt .Sprintf ("keep_remote_backup_%d" , len (backupNames )- 2 )
2076
2085
for _ , backupName := range backupNames {
2077
2086
if backupName == latestIncrementBackup {
2078
- r .Contains (out , backupName )
2087
+ r .Regexp ("(?m)^" + backupName , out )
2088
+ r .NotContains (out , "+" + backupName )
2079
2089
} else if backupName == prevIncrementBackup {
2090
+ r .NotRegexp ("(?m)^" + backupName , out )
2080
2091
r .Contains (out , "+" + backupName )
2081
2092
} else {
2082
2093
r .NotContains (out , backupName )
@@ -2085,7 +2096,8 @@ func TestKeepBackupRemoteAndDiffFromRemote(t *testing.T) {
2085
2096
env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/config-s3.yml" , "restore" , "--rm" , latestIncrementBackup )
2086
2097
var res uint64
2087
2098
r .NoError (env .ch .SelectSingleRowNoCtx (& res , fmt .Sprintf ("SELECT count() FROM `%s_%s`.`%s_%s`" , Issue331Issue1091Atomic , t .Name (), Issue331Issue1091Atomic , t .Name ())))
2088
- r .Equal (uint64 (100 + 20 * 4 ), res )
2099
+ numBackupsWithData := 3
2100
+ r .Equal (uint64 (100 + 20 * numBackupsWithData ), res )
2089
2101
fullCleanup (t , r , env , []string {latestIncrementBackup }, []string {"local" }, nil , true , true , "config-s3.yml" )
2090
2102
fullCleanup (t , r , env , backupNames , []string {"remote" }, databaseList , true , true , "config-s3.yml" )
2091
2103
env .checkObjectStorageIsEmpty (t , r , "S3" )
@@ -2626,7 +2638,6 @@ func (env *TestEnvironment) runMainIntegrationScenario(t *testing.T, remoteStora
2626
2638
// main test scenario
2627
2639
fullBackupName := fmt .Sprintf ("%s_full_%d" , t .Name (), rand .Int ())
2628
2640
incrementBackupName := fmt .Sprintf ("%s_increment_%d" , t .Name (), rand .Int ())
2629
- incrementBackupNameEmpty := fmt .Sprintf ("%s_incrementEmpty_%d" , t .Name (), rand .Int ())
2630
2641
incrementBackupName2 := fmt .Sprintf ("%s_increment2_%d" , t .Name (), rand .Int ())
2631
2642
databaseList := []string {dbNameOrdinary , dbNameAtomic , dbNameMySQL , dbNamePostgreSQL , Issue331Issue1091Atomic , Issue331Issue1091Ordinary }
2632
2643
tablesPattern := fmt .Sprintf ("*_%s.*" , t .Name ())
@@ -2643,37 +2654,6 @@ func (env *TestEnvironment) runMainIntegrationScenario(t *testing.T, remoteStora
2643
2654
uploadCmd := fmt .Sprintf ("%s_COMPRESSION_FORMAT=zstd CLICKHOUSE_BACKUP_CONFIG=/etc/clickhouse-backup/%s clickhouse-backup upload --resume %s" , remoteStorageType , backupConfig , fullBackupName )
2644
2655
env .checkResumeAlreadyProcessed (uploadCmd , fullBackupName , "upload" , r , remoteStorageType )
2645
2656
2646
- // https://github.com/Altinity/clickhouse-backup/issues/871
2647
- if ! strings .Contains (remoteStorageType , "CUSTOM" ) {
2648
- log .Debug ().Msg ("Create+upload incrementEmpty without data" )
2649
- env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "create" , "--tables" , tablesPattern , "--diff-from-remote" , fullBackupName , incrementBackupNameEmpty )
2650
- out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ec" , "clickhouse-backup -c /etc/clickhouse-backup/" + backupConfig + " list local | grep " + incrementBackupNameEmpty )
2651
- r .NoError (err , out )
2652
- r .Contains (out , "+" + fullBackupName )
2653
- r .Contains (out , incrementBackupNameEmpty )
2654
- if ! strings .Contains (remoteStorageType , "EMBEDDED" ) {
2655
- r .Contains (out , "data:0B" )
2656
- } else {
2657
- r .Contains (out , "arch:0B" )
2658
- }
2659
- env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "upload" , "--env" , "BACKUPS_TO_KEEP_REMOTE=2" , "--env" , "ALLOW_EMPTY_BACKUPS=1" , "--diff-from-remote" , fullBackupName , incrementBackupNameEmpty )
2660
- out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ec" , "clickhouse-backup -c /etc/clickhouse-backup/" + backupConfig + " list remote | grep '^" + fullBackupName + "'" )
2661
- r .NoError (err , out )
2662
- r .Contains (out , fullBackupName )
2663
- r .NotContains (out , "data:0B" )
2664
- out , err = env .DockerExecOut ("clickhouse-backup" , "bash" , "-ec" , "clickhouse-backup -c /etc/clickhouse-backup/" + backupConfig + " list remote | grep " + incrementBackupNameEmpty )
2665
- r .NoError (err , out )
2666
- r .Contains (out , "+" + fullBackupName )
2667
- r .Contains (out , incrementBackupNameEmpty )
2668
- if ! strings .Contains (remoteStorageType , "EMBEDDED" ) {
2669
- r .Contains (out , "data:0B" )
2670
- } else {
2671
- r .Contains (out , "arch:0B" )
2672
- }
2673
- env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "delete" , "remote" , incrementBackupNameEmpty )
2674
- env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "delete" , "local" , incrementBackupNameEmpty )
2675
- }
2676
-
2677
2657
log .Debug ().Msg ("Create increment1 with data" )
2678
2658
incrementData := generateIncrementTestData (t , r , env , remoteStorageType , createAllTypesOfObjectTables , defaultIncrementData , 1 )
2679
2659
env .DockerExecNoError (r , "clickhouse-backup" , "clickhouse-backup" , "-c" , "/etc/clickhouse-backup/" + backupConfig , "create" , "--tables" , tablesPattern , incrementBackupName )
@@ -3084,8 +3064,9 @@ func (env *TestEnvironment) checkResumeAlreadyProcessed(backupCmd, testBackupNam
3084
3064
r .NotContains (out , resumableWarning )
3085
3065
r .NotContains (out , resumableCleanup )
3086
3066
r .Contains (out , alreadyProcesses )
3067
+ } else {
3068
+ log .Debug ().Msg (out )
3087
3069
}
3088
- log .Debug ().Msg (out )
3089
3070
}
3090
3071
3091
3072
func fullCleanup (t * testing.T , r * require.Assertions , env * TestEnvironment , backupNames , backupTypes , databaseList []string , checkDeleteErr , checkDeleteOtherErr bool , backupConfig string ) {
0 commit comments