chores(deps): dump namespace for test case

Signed-off-by: Tao Li <tao.li@enterprisedb.com>
This commit is contained in:
Tao Li 2026-07-15 19:51:48 +08:00
parent 3813ce8cfd
commit d9bb4d7b7e
No known key found for this signature in database
GPG Key ID: 02D7CBDD527BEF02
5 changed files with 43 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import (
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/diagnostics"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/e2etestenv"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/kustomize"
@ -131,6 +132,28 @@ var _ = SynchronizedBeforeSuite(func(ctx SpecContext) []byte {
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.
func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)

View File

@ -26,11 +26,13 @@ import (
v1 "github.com/cloudnative-pg/api/pkg/api/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/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"
"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"
. "github.com/onsi/ginkgo/v2"
@ -40,14 +42,18 @@ import (
var _ = Describe("Backup and restore", func() {
var namespace *corev1.Namespace
var cl client.Client
var diagClientSet *kubernetes.Clientset
BeforeEach(func(ctx SpecContext) {
var err error
cl, _, err = internalClient.NewClient()
Expect(err).NotTo(HaveOccurred())
diagClientSet, _, err = internalClient.NewClientSet()
Expect(err).NotTo(HaveOccurred())
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "backup-restore")
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func(ctx SpecContext) {
diagnostics.DumpNamespace(ctx, cl, diagClientSet, namespace.Name)
Expect(cl.Delete(ctx, namespace)).To(Succeed())
})

View File

@ -27,6 +27,7 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
@ -34,6 +35,7 @@ import (
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/specs"
internalClient "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/client"
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"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/objectstore"
@ -51,16 +53,20 @@ const (
var _ = Describe("Credential rotation", func() {
var namespace *corev1.Namespace
var cl client.Client
var diagClientSet *kubernetes.Clientset
BeforeEach(func(ctx SpecContext) {
var err error
cl, _, err = internalClient.NewClient()
Expect(err).NotTo(HaveOccurred())
diagClientSet, _, err = internalClient.NewClientSet()
Expect(err).NotTo(HaveOccurred())
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "cred-rotation")
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func(ctx SpecContext) {
diagnostics.DumpNamespace(ctx, cl, diagClientSet, namespace.Name)
Expect(cl.Delete(ctx, namespace)).To(Succeed())
})

View File

@ -27,12 +27,14 @@ import (
cloudnativepgv1 "github.com/cloudnative-pg/api/pkg/api/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/ptr"
"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"
"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"
. "github.com/onsi/ginkgo/v2"
@ -42,14 +44,18 @@ import (
var _ = Describe("Replica cluster", func() {
var namespace *corev1.Namespace
var cl client.Client
var diagClientSet *kubernetes.Clientset
BeforeEach(func(ctx SpecContext) {
var err error
cl, _, err = internalClient.NewClient()
Expect(err).NotTo(HaveOccurred())
diagClientSet, _, err = internalClient.NewClientSet()
Expect(err).NotTo(HaveOccurred())
namespace, err = nmsp.CreateUniqueNamespace(ctx, cl, "replica-cluster")
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func(ctx SpecContext) {
diagnostics.DumpNamespace(ctx, cl, diagClientSet, namespace.Name)
Expect(cl.Delete(ctx, namespace)).To(Succeed())
})
DescribeTable("can switchover to a replica cluster",

View File

@ -38,6 +38,7 @@ import (
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/deployment"
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/diagnostics"
nmsp "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/namespace"
. "github.com/onsi/ginkgo/v2"
@ -128,6 +129,7 @@ var _ = Describe("Parallel WAL restore", func() {
})
AfterEach(func(ctx SpecContext) {
diagnostics.DumpNamespace(ctx, cl, clientSet, namespace.Name)
Expect(cl.Delete(ctx, namespace)).To(Succeed())
})