Skip to content

Commit

Permalink
fix: owner set, e2e and conflict after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Quaresima <[email protected]>
  • Loading branch information
gabriele-wolfox committed Oct 15, 2024
1 parent 82c0177 commit 5467bcb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
4 changes: 2 additions & 2 deletions internal/cmd/manager/instance/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func runSubCommand(ctx context.Context, instance *postgres.Instance) error {
For(&apiv1.Publication{}).
Complete(publicationReconciler)
if err != nil {
setupLog.Error(err, "unable to create publication controller")
contextLogger.Error(err, "unable to create publication controller")
return err
}

Expand All @@ -241,7 +241,7 @@ func runSubCommand(ctx context.Context, instance *postgres.Instance) error {
For(&apiv1.Subscription{}).
Complete(subscriptionReconciler)
if err != nil {
setupLog.Error(err, "unable to create subscription controller")
contextLogger.Error(err, "unable to create subscription controller")
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func toPublicationCreateSQL(obj *apiv1.Publication) []string {
fmt.Sprintf(
"ALTER PUBLICATION %s OWNER to %s",
pgx.Identifier{obj.Spec.Name}.Sanitize(),
toPublicationTargetSQL(&obj.Spec.Target),
pgx.Identifier{obj.Spec.Owner}.Sanitize(),
),
)
}
Expand Down
25 changes: 2 additions & 23 deletions tests/e2e/declarative_pub_sub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,6 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
})
})

assertDatabaseExists := func(namespace, primaryPod, dbname string) {
Eventually(func(g Gomega) {
stdout, _, err := env.ExecQueryInInstancePod(
utils.PodLocator{
Namespace: namespace,
PodName: primaryPod,
},
"postgres",
"\\l")
g.Expect(err).ToNot(HaveOccurred())
g.Expect(stdout).Should(ContainSubstring(dbname))
}, 300).Should(Succeed())
}

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

It("can add a declarative database", func() { //nolint:dupl
It("can add a declarative database, publication and subscription", func() { //nolint:dupl
By("applying Database CRD manifest", func() {
CreateResourceFromFile(namespace, databaseManifest)
databaseObjectName, err = env.GetResourceNameFromYAML(databaseManifest)
Expand All @@ -152,15 +138,12 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
g.Expect(database.Status.Ready).Should(BeTrue())
}, 300).WithPolling(10 * time.Second).Should(Succeed())
})

By("verifying new database has been created", func() {
primaryPodInfo, err := env.GetClusterPrimary(namespace, sourceClusterName)
Expect(err).ToNot(HaveOccurred())

assertDatabaseExists(namespace, primaryPodInfo.Name, dbname)
AssertDatabaseExists(namespace, primaryPodInfo.Name, dbname, true)
})
})
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 @@ -180,15 +163,12 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
g.Expect(pub.Status.Ready).Should(BeTrue())
}, 300).WithPolling(10 * time.Second).Should(Succeed())
})

By("verifying new publication has been created", func() {
primaryPodInfo, err := env.GetClusterPrimary(namespace, sourceClusterName)
Expect(err).ToNot(HaveOccurred())

assertPublicationExists(namespace, primaryPodInfo.Name, pub)
})
})
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 @@ -208,7 +188,6 @@ var _ = Describe("Declarative publication and subscription test", Label(tests.La
g.Expect(sub.Status.Ready).Should(BeTrue())
}, 300).WithPolling(10 * time.Second).Should(Succeed())
})

By("verifying new subscription has been created", func() {
primaryPodInfo, err := env.GetClusterPrimary(namespace, destinationClusterName)
Expect(err).ToNot(HaveOccurred())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ metadata:
name: destination-cluster
spec:
instances: 3
externalClusters:
- name: source-cluster
connectionParameters:
host: source-cluster-rw
user: app
dbname: declarative
port: "5432"

postgresql:
parameters:
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/fixtures/declarative_pub_sub/sub.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
spec:
name: sub
dbname: declarative
owner: app
publicationName: pub
cluster:
name: destination-cluster
Expand Down

0 comments on commit 5467bcb

Please sign in to comment.