Skip to content

Commit d077119

Browse files
fix: test bootstrapping with PITR issue
1 parent 3df1629 commit d077119

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

tests/e2e/backup_restore_test.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Copyright (C) 2019-2022 EnterpriseDB Corporation.
77
package e2e
88

99
import (
10+
"fmt"
1011
"os"
1112

1213
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -482,7 +483,9 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
482483
azuriteBlobSampleFile = fixturesDir + "/backup/azurite/cluster-backup.yaml"
483484
externalClusterFileMinio = fixturesBackupDir + "external-clusters-minio-03.yaml"
484485
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"
486489
clusterSourceFileMinio = fixturesBackupDir + "source-cluster-minio-01.yaml"
487490
sourceBackupFileAzure = fixturesBackupDir + "backup-azure-blob-02.yaml"
488491
clusterSourceFileAzure = fixturesBackupDir + "source-cluster-azure-blob-01.yaml"
@@ -602,7 +605,7 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
602605

603606
// There should be a backup resource and
604607
By("backing up a cluster and verifying it exists on minio", func() {
605-
testUtils.ExecuteBackup(namespace, sourceBackupFileMinio, env)
608+
testUtils.ExecuteBackup(namespace, sourceTakeFirstBackupFileMinio, env)
606609
AssertBackupConditionInClusterStatus(namespace, clusterName)
607610
Eventually(func() (int, error) {
608611
return testUtils.CountFilesOnMinio(namespace, minioClientName, "data.tar")
@@ -629,15 +632,34 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
629632
It("restores a cluster with 'PITR' from barman object using 'barmanObjectStore' "+
630633
" option in 'externalClusters' section", func() {
631634
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
632637

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+
})
639660
AssertClusterRestorePITR(namespace, externalClusterRestoreName, tableName, "00000002")
640661
})
662+
641663
It("restore cluster from barman object using replica option in spec", func() {
642664
// Write a table and some data on the "app" database
643665
AssertCreateTestData(namespace, clusterName, "for_restore_repl")
@@ -646,11 +668,11 @@ var _ = Describe("Clusters Recovery From Barman Object Store", Label(tests.Label
646668

647669
// There should be a backup resource and
648670
By("backing up a cluster and verifying it exists on minio", func() {
649-
testUtils.ExecuteBackup(namespace, sourceBackupFileMinio, env)
671+
testUtils.ExecuteBackup(namespace, sourceTakeThirdBackupFileMinio, env)
650672
AssertBackupConditionInClusterStatus(namespace, clusterName)
651673
Eventually(func() (int, error) {
652674
return testUtils.CountFilesOnMinio(namespace, minioClientName, "data.tar")
653-
}, 30).Should(BeEquivalentTo(1))
675+
}, 30).Should(BeEquivalentTo(3))
654676
})
655677

656678
// Replicating a cluster with asynchronous replication
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: postgresql.k8s.enterprisedb.io/v1
2+
kind: Backup
3+
metadata:
4+
name: cluster-backup-03
5+
spec:
6+
cluster:
7+
name: source-cluster-minio
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: postgresql.k8s.enterprisedb.io/v1
2+
kind: Backup
3+
metadata:
4+
name: cluster-backup-04
5+
spec:
6+
cluster:
7+
name: source-cluster-minio

tests/e2e/fixtures/config_update/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66
06-blocked-params.yaml
77
07-restart-decrease.yaml
88
08-restart-decrease-removing.yaml
9-

0 commit comments

Comments
 (0)