@@ -7,6 +7,7 @@ Copyright (C) 2019-2022 EnterpriseDB Corporation.
7
7
package e2e
8
8
9
9
import (
10
+ "fmt"
10
11
"os"
11
12
12
13
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -482,7 +483,9 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
482
483
azuriteBlobSampleFile = fixturesDir + "/backup/azurite/cluster-backup.yaml"
483
484
externalClusterFileMinio = fixturesBackupDir + "external-clusters-minio-03.yaml"
484
485
externalClusterFileMinioReplica = fixturesBackupDir + "external-clusters-minio-replica-04.yaml"
485
- sourceBackupFileMinio = fixturesBackupDir + "backup-minio-02.yaml"
486
+ sourceTakeFirstBackupFileMinio = fixturesBackupDir + "backup-minio-02.yaml"
487
+ sourceTakeSecondBackupFileMinio = fixturesBackupDir + "backup-minio-03.yaml"
488
+ sourceTakeThirdBackupFileMinio = fixturesBackupDir + "backup-minio-04.yaml"
486
489
clusterSourceFileMinio = fixturesBackupDir + "source-cluster-minio-01.yaml"
487
490
sourceBackupFileAzure = fixturesBackupDir + "backup-azure-blob-02.yaml"
488
491
clusterSourceFileAzure = fixturesBackupDir + "source-cluster-azure-blob-01.yaml"
@@ -602,7 +605,7 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
602
605
603
606
// There should be a backup resource and
604
607
By ("backing up a cluster and verifying it exists on minio" , func () {
605
- testUtils .ExecuteBackup (namespace , sourceBackupFileMinio , env )
608
+ testUtils .ExecuteBackup (namespace , sourceTakeFirstBackupFileMinio , env )
606
609
AssertBackupConditionInClusterStatus (namespace , clusterName )
607
610
Eventually (func () (int , error ) {
608
611
return testUtils .CountFilesOnMinio (namespace , minioClientName , "data.tar" )
@@ -629,15 +632,34 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
629
632
It ("restores a cluster with 'PITR' from barman object using 'barmanObjectStore' " +
630
633
" option in 'externalClusters' section" , func () {
631
634
externalClusterRestoreName := "restore-external-cluster-pitr"
635
+ // We have already written 2 rows in test table 'to_restore' in above test now we will take current
636
+ // timestamp. It will use to restore cluster from source using PITR
632
637
633
- prepareClusterForPITROnMinio (namespace , clusterName , sourceBackupFileMinio , 1 , currentTimestamp )
634
-
635
- err := testUtils .CreateClusterFromExternalClusterBackupWithPITROnMinio (
636
- namespace , externalClusterRestoreName , clusterName , * currentTimestamp , env )
637
-
638
- Expect (err ).NotTo (HaveOccurred ())
638
+ By ("getting currentTimestamp" , func () {
639
+ ts , err := testUtils .GetCurrentTimestamp (namespace , clusterName , env )
640
+ * currentTimestamp = ts
641
+ Expect (err ).ToNot (HaveOccurred ())
642
+ })
643
+ By (fmt .Sprintf ("writing 2 more entries in table '%v'" , tableName ), func () {
644
+ // insert 2 more rows entries 3,4 on the "app" database
645
+ insertRecordIntoTable (namespace , clusterName , tableName , 3 )
646
+ insertRecordIntoTable (namespace , clusterName , tableName , 4 )
647
+ })
648
+ By ("creating second backup and verifying it exists on minio" , func () {
649
+ testUtils .ExecuteBackup (namespace , sourceTakeSecondBackupFileMinio , env )
650
+ AssertBackupConditionInClusterStatus (namespace , clusterName )
651
+ Eventually (func () (int , error ) {
652
+ return testUtils .CountFilesOnMinio (namespace , minioClientName , "data.tar" )
653
+ }, 30 ).Should (BeEquivalentTo (2 ))
654
+ })
655
+ By ("create a cluster from backup with PITR" , func () {
656
+ err := testUtils .CreateClusterFromExternalClusterBackupWithPITROnMinio (
657
+ namespace , externalClusterRestoreName , clusterName , * currentTimestamp , env )
658
+ Expect (err ).NotTo (HaveOccurred ())
659
+ })
639
660
AssertClusterRestorePITR (namespace , externalClusterRestoreName , tableName , "00000002" )
640
661
})
662
+
641
663
It ("restore cluster from barman object using replica option in spec" , func () {
642
664
// Write a table and some data on the "app" database
643
665
AssertCreateTestData (namespace , clusterName , "for_restore_repl" )
@@ -646,11 +668,11 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
646
668
647
669
// There should be a backup resource and
648
670
By ("backing up a cluster and verifying it exists on minio" , func () {
649
- testUtils .ExecuteBackup (namespace , sourceBackupFileMinio , env )
671
+ testUtils .ExecuteBackup (namespace , sourceTakeThirdBackupFileMinio , env )
650
672
AssertBackupConditionInClusterStatus (namespace , clusterName )
651
673
Eventually (func () (int , error ) {
652
674
return testUtils .CountFilesOnMinio (namespace , minioClientName , "data.tar" )
653
- }, 30 ).Should (BeEquivalentTo (1 ))
675
+ }, 30 ).Should (BeEquivalentTo (3 ))
654
676
})
655
677
656
678
// Replicating a cluster with asynchronous replication
0 commit comments