@@ -36,6 +36,11 @@ import (
3636 driver "github.com/arangodb/go-driver"
3737)
3838
39+ func waitForHealthyClusterAfterBackup (t * testing.T , client driver.Client ) {
40+ time .Sleep (5 * time .Second )
41+ waitForHealthyCluster (t , client , 2 * time .Second ).RetryT (t , 125 * time .Millisecond , 10 * time .Second )
42+ }
43+
3944var backupAPIAvailable * bool
4045
4146func setBackupAvailable (av bool ) {
@@ -421,6 +426,7 @@ func TestBackupRestore(t *testing.T) {
421426 if err := b .Restore (ctx , id , nil ); err != nil {
422427 t .Fatalf ("Failed to restore backup: %s" , describe (err ))
423428 }
429+ defer waitForHealthyClusterAfterBackup (t , c )
424430
425431 if isSingle {
426432 waitctx , cancel := context .WithTimeout (ctx , 30 * time .Second )
@@ -672,6 +678,7 @@ func TestBackupCompleteCycle(t *testing.T) {
672678 if err := b .Restore (ctx , id , nil ); err != nil {
673679 t .Fatalf ("Failed to restore backup: %s" , describe (err ))
674680 }
681+ defer waitForHealthyClusterAfterBackup (t , c )
675682
676683 if isSingle {
677684 waitctx , cancel := context .WithTimeout (ctx , 30 * time .Second )
@@ -759,75 +766,6 @@ func TestBackupCreateManyBackupsFast(t *testing.T) {
759766 }
760767}
761768
762- func TestBackupCreateRestoreParallel (t * testing.T ) {
763- c := createClientFromEnv (t , true )
764- skipIfNoBackup (c , t )
765-
766- ctx := context .Background ()
767- b := c .Backup ()
768- id := ensureBackup (ctx , b , t )
769-
770- isSingle := false
771- if role , err := c .ServerRole (ctx ); err != nil {
772- t .Fatalf ("Failed to obtain server role: %s" , describe (err ))
773- } else {
774- isSingle = role == driver .ServerRoleSingle
775- }
776-
777- errchan := make (chan error )
778- defer close (errchan )
779- var wg sync.WaitGroup
780-
781- wg .Add (1 )
782- go func () {
783- defer wg .Done ()
784- if _ , _ , err := b .Create (ctx , nil ); err == nil {
785- errchan <- nil
786- } else {
787- errchan <- err
788- t .Logf ("Create failed: %s" , describe (err ))
789- }
790- }()
791- wg .Add (1 )
792- go func () {
793- defer wg .Done ()
794- if err := b .Restore (ctx , id , nil ); err == nil {
795- errchan <- nil
796- if isSingle {
797- waitctx , cancel := context .WithTimeout (ctx , 30 * time .Second )
798- defer cancel ()
799- c = waitForServerRestart (waitctx , c , t )
800- }
801- } else {
802- errchan <- err
803- t .Logf ("Restore failed: %s" , describe (err ))
804- }
805- }()
806-
807- errCount := 0
808- for i := 0 ; i < 2 ; i ++ {
809- err := <- errchan
810- if err != nil {
811- errCount ++
812- }
813- }
814-
815- wg .Wait ()
816-
817- if errCount >= 2 {
818- t .Fatalf ("Both operation failed!" )
819- }
820- }
821-
822- func ensureRemoteBackup (ctx context.Context , b driver.ClientBackup , t * testing.T ) driver.BackupID {
823- id := ensureBackup (ctx , b , t )
824- uploadBackupWaitForCompletion (ctx , id , b , t )
825- if err := b .Delete (ctx , id ); err != nil {
826- t .Fatalf ("Failed to remove backup: %s" , err )
827- }
828- return id
829- }
830-
831769func TestBackupRestoreWithViews (t * testing.T ) {
832770 c := createClientFromEnv (t , true )
833771 skipIfNoBackup (c , t )
@@ -890,6 +828,7 @@ func TestBackupRestoreWithViews(t *testing.T) {
890828 if err := b .Restore (ctx , id , nil ); err != nil {
891829 t .Fatalf ("Failed to restore backup: %s" , describe (err ))
892830 }
831+ defer waitForHealthyClusterAfterBackup (t , c )
893832
894833 if isSingle {
895834 waitctx , cancel := context .WithTimeout (ctx , 30 * time .Second )
0 commit comments