mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 13:23:09 +01:00
test(e2e): parallelise test execution (#94)
Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
This commit is contained in:
parent
9ed845c10f
commit
781a2f7401
12
Taskfile.yml
12
Taskfile.yml
@ -204,7 +204,17 @@ tasks:
|
|||||||
deps:
|
deps:
|
||||||
- build-images
|
- build-images
|
||||||
cmds:
|
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:
|
ci:
|
||||||
desc: Run the CI pipeline
|
desc: Run the CI pipeline
|
||||||
|
|||||||
@ -22,20 +22,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"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"
|
apimachineryTypes "k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
kustomizeTypes "sigs.k8s.io/kustomize/api/types"
|
kustomizeTypes "sigs.k8s.io/kustomize/api/types"
|
||||||
"sigs.k8s.io/kustomize/kyaml/resid"
|
"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/deployment"
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/e2etestenv"
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/e2etestenv"
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/kustomize"
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/kustomize"
|
||||||
@ -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 {
|
if err := kustomize.ApplyKustomization(ctx, cl, barmanCloudKustomization); err != nil {
|
||||||
Fail(fmt.Sprintf("failed to apply kustomization: %v", err))
|
Fail(fmt.Sprintf("failed to apply kustomization: %v", err))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,19 @@ package client
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"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/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client/config"
|
"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.
|
// NewClient creates a new controller-runtime Kubernetes client.
|
||||||
@ -38,6 +47,10 @@ func NewClient() (client.Client, *rest.Config, error) {
|
|||||||
return nil, nil, fmt.Errorf("failed to create Kubernetes client: %w", err)
|
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
|
return cl, cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,3 +67,33 @@ func NewClientSet() (*kubernetes.Clientset, *rest.Config, error) {
|
|||||||
|
|
||||||
return clientSet, cfg, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
internalClient "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/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"
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/command"
|
||||||
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ var _ = Describe("Backup and restore", func() {
|
|||||||
Namespace: src.Namespace,
|
Namespace: src.Namespace,
|
||||||
},
|
},
|
||||||
src)).To(Succeed())
|
src)).To(Succeed())
|
||||||
g.Expect(cluster2.IsReady(*src)).To(BeTrue())
|
g.Expect(internalCluster.IsReady(*src)).To(BeTrue())
|
||||||
}).WithTimeout(15 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
|
}).WithTimeout(10 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())
|
||||||
|
|
||||||
By("Adding data to PostgreSQL")
|
By("Adding data to PostgreSQL")
|
||||||
clientSet, cfg, err := internalClient.NewClientSet()
|
clientSet, cfg, err := internalClient.NewClientSet()
|
||||||
@ -143,8 +143,8 @@ var _ = Describe("Backup and restore", func() {
|
|||||||
g.Expect(cl.Get(ctx,
|
g.Expect(cl.Get(ctx,
|
||||||
types.NamespacedName{Name: dst.Name, Namespace: dst.Namespace},
|
types.NamespacedName{Name: dst.Name, Namespace: dst.Namespace},
|
||||||
dst)).To(Succeed())
|
dst)).To(Succeed())
|
||||||
g.Expect(cluster2.IsReady(*dst)).To(BeTrue())
|
g.Expect(internalCluster.IsReady(*dst)).To(BeTrue())
|
||||||
}).WithTimeout(15 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
|
}).WithTimeout(10 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())
|
||||||
|
|
||||||
By("Verifying the data exists in the restored instance")
|
By("Verifying the data exists in the restored instance")
|
||||||
output, _, err := command.ExecuteInContainer(ctx,
|
output, _, err := command.ExecuteInContainer(ctx,
|
||||||
@ -169,7 +169,7 @@ var _ = Describe("Backup and restore", func() {
|
|||||||
g.Expect(cl.Get(ctx, types.NamespacedName{Name: backup.Name, Namespace: backup.Namespace},
|
g.Expect(cl.Get(ctx, types.NamespacedName{Name: backup.Name, Namespace: backup.Namespace},
|
||||||
backup)).To(Succeed())
|
backup)).To(Succeed())
|
||||||
g.Expect(backup.Status.Phase).To(BeEquivalentTo(v1.BackupPhaseCompleted))
|
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(
|
Entry(
|
||||||
"using the plugin for backup and restore on S3",
|
"using the plugin for backup and restore on S3",
|
||||||
|
|||||||
@ -81,7 +81,7 @@ var _ = Describe("Replica cluster", func() {
|
|||||||
},
|
},
|
||||||
src)).To(Succeed())
|
src)).To(Succeed())
|
||||||
g.Expect(cluster2.IsReady(*src)).To(BeTrue())
|
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")
|
By("Adding data to PostgreSQL")
|
||||||
clientSet, cfg, err := internalClient.NewClientSet()
|
clientSet, cfg, err := internalClient.NewClientSet()
|
||||||
@ -107,7 +107,7 @@ var _ = Describe("Replica cluster", func() {
|
|||||||
g.Expect(cl.Get(ctx, types.NamespacedName{Name: backup.Name, Namespace: backup.Namespace},
|
g.Expect(cl.Get(ctx, types.NamespacedName{Name: backup.Name, Namespace: backup.Namespace},
|
||||||
backup)).To(Succeed())
|
backup)).To(Succeed())
|
||||||
g.Expect(backup.Status.Phase).To(BeEquivalentTo(cloudnativepgv1.BackupPhaseCompleted))
|
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")
|
By("Creating a replica cluster")
|
||||||
replica := testResources.ReplicaCluster
|
replica := testResources.ReplicaCluster
|
||||||
@ -123,7 +123,7 @@ var _ = Describe("Replica cluster", func() {
|
|||||||
},
|
},
|
||||||
replica)).To(Succeed())
|
replica)).To(Succeed())
|
||||||
g.Expect(cluster2.IsReady(*replica)).To(BeTrue())
|
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")
|
By("Checking the data in the replica cluster")
|
||||||
output, _, err := command.ExecuteInContainer(ctx,
|
output, _, err := command.ExecuteInContainer(ctx,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user