Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,17 @@ tasks:
deps:
- build-images
cmds:
- go test -timeout 60m -v ./test/e2e
- >
go run github.com/onsi/ginkgo/v2/ginkgo
--procs=8
--randomize-all
--randomize-suites
--fail-on-pending
--fail-on-empty
--keep-going
--timeout=30m
--github-output
./test/e2e

ci:
desc: Run the CI pipeline
Expand Down
34 changes: 0 additions & 34 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,12 @@ import (
"testing"
"time"

certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
cloudnativepgv1 "github.com/cloudnative-pg/api/pkg/api/v1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apimachineryTypes "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
kustomizeTypes "sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kyaml/resid"

pluginBarmanCloudV1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/deployment"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/e2etestenv"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/kustomize"
Expand Down Expand Up @@ -96,32 +88,6 @@ var _ = SynchronizedBeforeSuite(func(ctx SpecContext) []byte {
},
}

scheme := cl.Scheme()
if err := corev1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add core/v1 to scheme: %v", err))
}
if err := apiextensionsv1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add apiextensions/v1 to scheme: %v", err))
}
if err := admissionregistrationv1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add admissionregistration/v1 to scheme: %v", err))
}
if err := rbacv1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add rbac/v1 to scheme: %v", err))
}
if err := appsv1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add apps/v1 to scheme: %v", err))
}
if err := certmanagerv1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add cert-manager.io/v1 to scheme: %v", err))
}
if err := pluginBarmanCloudV1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add plugin-barman-cloud/v1 to scheme: %v", err))
}
if err := cloudnativepgv1.AddToScheme(scheme); err != nil {
Fail(fmt.Sprintf("failed to add postgresql.cnpg.io/v1 to scheme: %v", err))
}

if err := kustomize.ApplyKustomization(ctx, cl, barmanCloudKustomization); err != nil {
Fail(fmt.Sprintf("failed to apply kustomization: %v", err))
}
Expand Down
43 changes: 43 additions & 0 deletions test/e2e/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ package client
import (
"fmt"

certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
cloudnativepgv1 "github.com/cloudnative-pg/api/pkg/api/v1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"

pluginBarmanCloudV1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
)

// NewClient creates a new controller-runtime Kubernetes client.
Expand All @@ -38,6 +47,10 @@ func NewClient() (client.Client, *rest.Config, error) {
return nil, nil, fmt.Errorf("failed to create Kubernetes client: %w", err)
}

if err := addScheme(cl); err != nil {
return nil, nil, fmt.Errorf("failed to add scheme: %w", err)
}

return cl, cfg, nil
}

Expand All @@ -54,3 +67,33 @@ func NewClientSet() (*kubernetes.Clientset, *rest.Config, error) {

return clientSet, cfg, nil
}

func addScheme(cl client.Client) error {
scheme := cl.Scheme()
if err := corev1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add core/v1 to scheme: %w", err)
}
if err := apiextensionsv1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add apiextensions/v1 to scheme: %w", err)
}
if err := admissionregistrationv1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add admissionregistration/v1 to scheme: %w", err)
}
if err := rbacv1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add rbac/v1 to scheme: %w", err)
}
if err := appsv1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add apps/v1 to scheme: %w", err)
}
if err := certmanagerv1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add cert-manager/v1 to scheme: %w", err)
}
if err := pluginBarmanCloudV1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add plugin-barman-cloud/v1 to scheme: %w", err)
}
if err := cloudnativepgv1.AddToScheme(scheme); err != nil {
return fmt.Errorf("failed to add cloudnativepg/v1 to scheme: %w", err)
}

return nil
}
12 changes: 6 additions & 6 deletions test/e2e/internal/tests/backup/backup_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

internalClient "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/client"
cluster2 "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/cluster"
internalCluster "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/cluster"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/command"
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"

Expand Down Expand Up @@ -74,8 +74,8 @@ var _ = Describe("Backup and restore", func() {
Namespace: src.Namespace,
},
src)).To(Succeed())
g.Expect(cluster2.IsReady(*src)).To(BeTrue())
}).WithTimeout(15 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
g.Expect(internalCluster.IsReady(*src)).To(BeTrue())
}).WithTimeout(10 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())

By("Adding data to PostgreSQL")
clientSet, cfg, err := internalClient.NewClientSet()
Expand Down Expand Up @@ -143,8 +143,8 @@ var _ = Describe("Backup and restore", func() {
g.Expect(cl.Get(ctx,
types.NamespacedName{Name: dst.Name, Namespace: dst.Namespace},
dst)).To(Succeed())
g.Expect(cluster2.IsReady(*dst)).To(BeTrue())
}).WithTimeout(15 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
g.Expect(internalCluster.IsReady(*dst)).To(BeTrue())
}).WithTimeout(10 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())

By("Verifying the data exists in the restored instance")
output, _, err := command.ExecuteInContainer(ctx,
Expand All @@ -169,7 +169,7 @@ var _ = Describe("Backup and restore", func() {
g.Expect(cl.Get(ctx, types.NamespacedName{Name: backup.Name, Namespace: backup.Namespace},
backup)).To(Succeed())
g.Expect(backup.Status.Phase).To(BeEquivalentTo(v1.BackupPhaseCompleted))
}).Within(2 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
}).Within(3 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
},
Entry(
"using the plugin for backup and restore on S3",
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/internal/tests/replicacluster/replica_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var _ = Describe("Replica cluster", func() {
},
src)).To(Succeed())
g.Expect(cluster2.IsReady(*src)).To(BeTrue())
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
}).WithTimeout(10 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())

By("Adding data to PostgreSQL")
clientSet, cfg, err := internalClient.NewClientSet()
Expand All @@ -107,7 +107,7 @@ var _ = Describe("Replica cluster", func() {
g.Expect(cl.Get(ctx, types.NamespacedName{Name: backup.Name, Namespace: backup.Namespace},
backup)).To(Succeed())
g.Expect(backup.Status.Phase).To(BeEquivalentTo(cloudnativepgv1.BackupPhaseCompleted))
}).Within(2 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
}).Within(3 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())

By("Creating a replica cluster")
replica := testResources.ReplicaCluster
Expand All @@ -123,7 +123,7 @@ var _ = Describe("Replica cluster", func() {
},
replica)).To(Succeed())
g.Expect(cluster2.IsReady(*replica)).To(BeTrue())
}).WithTimeout(15 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
}).WithTimeout(10 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())

By("Checking the data in the replica cluster")
output, _, err := command.ExecuteInContainer(ctx,
Expand Down
Loading