Skip to content

Commit

Permalink
test: add basic e2e
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com>
  • Loading branch information
gabriele-wolfox committed Oct 14, 2024
1 parent 3b8d353 commit afae552
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
24 changes: 10 additions & 14 deletions tests/e2e/declarative_pub_sub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
})
})

assertDatabaseExists := func(namespace, primaryPod, dbname string, shouldContain bool) {
assertDatabaseExists := func(namespace, primaryPod, dbname string) {
Eventually(func(g Gomega) {
stdout, _, err := env.ExecQueryInInstancePod(
utils.PodLocator{
Expand All @@ -96,15 +96,11 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
"postgres",
"\\l")
g.Expect(err).ToNot(HaveOccurred())
if shouldContain {
g.Expect(stdout).Should(ContainSubstring(dbname))
} else {
g.Expect(stdout).ShouldNot(ContainSubstring(dbname))
}
g.Expect(stdout).Should(ContainSubstring(dbname))
}, 300).Should(Succeed())
}

assertPublicationExists := func(namespace, primaryPod string, pub *apiv1.Publication, shouldContain bool) {
assertPublicationExists := func(namespace, primaryPod string, pub *apiv1.Publication) {
query := fmt.Sprintf("select count(*) from pg_publication where pubname = '%s'",
pub.Spec.Name)
Eventually(func(g Gomega) {
Expand All @@ -120,7 +116,7 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
}, 30).Should(Succeed())
}

assertSubscriptionExists := func(namespace, primaryPod string, sub *apiv1.Subscription, shouldContain bool) {
assertSubscriptionExists := func(namespace, primaryPod string, sub *apiv1.Subscription) {
query := fmt.Sprintf("select count(*) from subscription where subname = '%s'",
sub.Spec.Name)
Eventually(func(g Gomega) {
Expand All @@ -136,7 +132,7 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
}, 30).Should(Succeed())
}

It("can add a declarative database", func() {
It("can add a declarative database", func() { //nolint:dupl
By("applying Database CRD manifest", func() {
CreateResourceFromFile(namespace, databaseManifest)
databaseObjectName, err = env.GetResourceNameFromYAML(databaseManifest)
Expand All @@ -161,10 +157,10 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
primaryPodInfo, err := env.GetClusterPrimary(namespace, sourceClusterName)
Expect(err).ToNot(HaveOccurred())

assertDatabaseExists(namespace, primaryPodInfo.Name, dbname, true)
assertDatabaseExists(namespace, primaryPodInfo.Name, dbname)
})
})
It("can add a declarative publication", func() {
It("can add a declarative publication", func() { //nolint:dupl
By("applying Publication CRD manifest", func() {
CreateResourceFromFile(namespace, pubManifest)
pubObjectName, err = env.GetResourceNameFromYAML(pubManifest)
Expand All @@ -189,10 +185,10 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
primaryPodInfo, err := env.GetClusterPrimary(namespace, sourceClusterName)
Expect(err).ToNot(HaveOccurred())

assertPublicationExists(namespace, primaryPodInfo.Name, pub, true)
assertPublicationExists(namespace, primaryPodInfo.Name, pub)
})
})
It("can add a declarative subscription", func() {
It("can add a declarative subscription", func() { //nolint:dupl
By("applying Subscription CRD manifest", func() {
CreateResourceFromFile(namespace, subManifest)
subObjectName, err = env.GetResourceNameFromYAML(subManifest)
Expand All @@ -217,7 +213,7 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
primaryPodInfo, err := env.GetClusterPrimary(namespace, destinationClusterName)
Expect(err).ToNot(HaveOccurred())

assertSubscriptionExists(namespace, primaryPodInfo.Name, sub, true)
assertSubscriptionExists(namespace, primaryPodInfo.Name, sub)
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/fixtures/declarative_pub_sub/pub.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
cluster:
name: source-cluster
target:
allTables: {}
allTables: {}
2 changes: 1 addition & 1 deletion tests/e2e/fixtures/declarative_pub_sub/sub.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
publicationName: pub
cluster:
name: destination-cluster
externalClusterName: source-cluster
externalClusterName: source-cluster

0 comments on commit afae552

Please # to comment.