mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-09-06 23:12:21 +02:00
chores(deps): dump namespace for test case
Signed-off-by: Tao Li <tao.li@enterprisedb.com>
This commit is contained in:
parent
3813ce8cfd
commit
d9bb4d7b7e
@ -33,6 +33,7 @@ import (
|
|||||||
|
|
||||||
internalClient "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/client"
|
internalClient "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/client"
|
||||||
"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/diagnostics"
|
||||||
"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"
|
||||||
|
|
||||||
@ -131,6 +132,28 @@ var _ = SynchronizedBeforeSuite(func(ctx SpecContext) []byte {
|
|||||||
logFlags.ConfigureLogging()
|
logFlags.ConfigureLogging()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// The ephemeral cluster the suite runs against is torn down right after this
|
||||||
|
// process exits, so this is the only chance to capture the CloudNativePG
|
||||||
|
// operator and barman-cloud plugin logs for a failed run.
|
||||||
|
var _ = ReportAfterSuite("dump cnpg-system diagnostics on failure", func(report Report) {
|
||||||
|
if report.SuiteSucceeded {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cl, _, err := internalClient.NewClient()
|
||||||
|
if err != nil {
|
||||||
|
_, _ = fmt.Fprintf(GinkgoWriter, "failed to create Kubernetes client for diagnostics: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
clientSet, _, err := internalClient.NewClientSet()
|
||||||
|
if err != nil {
|
||||||
|
_, _ = fmt.Fprintf(GinkgoWriter, "failed to create Kubernetes clientset for diagnostics: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics.DumpOperatorNamespace(context.Background(), cl, clientSet, "cnpg-system")
|
||||||
|
})
|
||||||
|
|
||||||
// Run e2e tests using the Ginkgo runner.
|
// Run e2e tests using the Ginkgo runner.
|
||||||
func TestE2E(t *testing.T) {
|
func TestE2E(t *testing.T) {
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
|
|||||||
@ -26,11 +26,13 @@ import (
|
|||||||
v1 "github.com/cloudnative-pg/api/pkg/api/v1"
|
v1 "github.com/cloudnative-pg/api/pkg/api/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
"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"
|
||||||
internalCluster "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"
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/diagnostics"
|
||||||
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
@ -40,14 +42,18 @@ import (
|
|||||||
var _ = Describe("Backup and restore", func() {
|
var _ = Describe("Backup and restore", func() {
|
||||||
var namespace *corev1.Namespace
|
var namespace *corev1.Namespace
|
||||||
var cl client.Client
|
var cl client.Client
|
||||||
|
var diagClientSet *kubernetes.Clientset
|
||||||
BeforeEach(func(ctx SpecContext) {
|
BeforeEach(func(ctx SpecContext) {
|
||||||
var err error
|
var err error
|
||||||
cl, _, err = internalClient.NewClient()
|
cl, _, err = internalClient.NewClient()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
diagClientSet, _, err = internalClient.NewClientSet()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "backup-restore")
|
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "backup-restore")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
AfterEach(func(ctx SpecContext) {
|
AfterEach(func(ctx SpecContext) {
|
||||||
|
diagnostics.DumpNamespace(ctx, cl, diagClientSet, namespace.Name)
|
||||||
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import (
|
|||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ import (
|
|||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/specs"
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/specs"
|
||||||
internalClient "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/client"
|
internalClient "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/client"
|
||||||
internalCluster "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/diagnostics"
|
||||||
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/objectstore"
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/objectstore"
|
||||||
|
|
||||||
@ -51,16 +53,20 @@ const (
|
|||||||
var _ = Describe("Credential rotation", func() {
|
var _ = Describe("Credential rotation", func() {
|
||||||
var namespace *corev1.Namespace
|
var namespace *corev1.Namespace
|
||||||
var cl client.Client
|
var cl client.Client
|
||||||
|
var diagClientSet *kubernetes.Clientset
|
||||||
|
|
||||||
BeforeEach(func(ctx SpecContext) {
|
BeforeEach(func(ctx SpecContext) {
|
||||||
var err error
|
var err error
|
||||||
cl, _, err = internalClient.NewClient()
|
cl, _, err = internalClient.NewClient()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
diagClientSet, _, err = internalClient.NewClientSet()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "cred-rotation")
|
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "cred-rotation")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func(ctx SpecContext) {
|
AfterEach(func(ctx SpecContext) {
|
||||||
|
diagnostics.DumpNamespace(ctx, cl, diagClientSet, namespace.Name)
|
||||||
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -27,12 +27,14 @@ import (
|
|||||||
cloudnativepgv1 "github.com/cloudnative-pg/api/pkg/api/v1"
|
cloudnativepgv1 "github.com/cloudnative-pg/api/pkg/api/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
"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"
|
cluster2 "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"
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/diagnostics"
|
||||||
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
@ -42,14 +44,18 @@ import (
|
|||||||
var _ = Describe("Replica cluster", func() {
|
var _ = Describe("Replica cluster", func() {
|
||||||
var namespace *corev1.Namespace
|
var namespace *corev1.Namespace
|
||||||
var cl client.Client
|
var cl client.Client
|
||||||
|
var diagClientSet *kubernetes.Clientset
|
||||||
BeforeEach(func(ctx SpecContext) {
|
BeforeEach(func(ctx SpecContext) {
|
||||||
var err error
|
var err error
|
||||||
cl, _, err = internalClient.NewClient()
|
cl, _, err = internalClient.NewClient()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
diagClientSet, _, err = internalClient.NewClientSet()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "replica-cluster")
|
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "replica-cluster")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
AfterEach(func(ctx SpecContext) {
|
AfterEach(func(ctx SpecContext) {
|
||||||
|
diagnostics.DumpNamespace(ctx, cl, diagClientSet, namespace.Name)
|
||||||
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
||||||
})
|
})
|
||||||
DescribeTable("can switchover to a replica cluster",
|
DescribeTable("can switchover to a replica cluster",
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import (
|
|||||||
internalCluster "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"
|
||||||
"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/diagnostics"
|
||||||
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
@ -128,6 +129,7 @@ var _ = Describe("Parallel WAL restore", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func(ctx SpecContext) {
|
AfterEach(func(ctx SpecContext) {
|
||||||
|
diagnostics.DumpNamespace(ctx, cl, clientSet, namespace.Name)
|
||||||
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
Expect(cl.Delete(ctx, namespace)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user