Skip to content

Commit

Permalink
test/e2e: dump cluster status when SyncedToRemote doesn't become True
Browse files Browse the repository at this point in the history
Signed-off-by: Ryotaro Banno <[email protected]>
  • Loading branch information
ushitora-anqou committed Dec 5, 2024
1 parent d9c983e commit cc33f09
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/e2e/multik8s/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/cybozu-go/mantle/test/util"
"github.com/go-logr/logr"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -80,12 +81,17 @@ func replicationTestSuite() {
}).Should(Succeed())

By("checking MantleBackup's SyncedToRemote status")
repeatCount := 0
Eventually(func() error {
repeatCount++
mb, err := getMB(primaryK8sCluster, namespace, backupName)
if err != nil {
return err
}
if !meta.IsStatusConditionTrue(mb.Status.Conditions, mantlev1.BackupConditionSyncedToRemote) {
if repeatCount == 500 {
_ = dumpClusterStatus(GinkgoLogr)
}
return errors.New("status of SyncedToRemote condition is not True")
}
return nil
Expand Down Expand Up @@ -181,3 +187,31 @@ func replicationTestSuite() {
})
})
}

func dumpClusterStatus(logger logr.Logger) error {
primaryPods, _, err := kubectl(primaryK8sCluster, nil, "get", "pod", "-A")
if err != nil {
return err
}
logger.Info(">>> PRIMARY: kubectl get pod -A", "pods", string(primaryPods))

primaryControllerLog, _, err := kubectl(primaryK8sCluster, nil, "logs", "-n", "rook-ceph", "deploy/mantle-controller")
if err != nil {
return err
}
logger.Info(">>> PRIMARY: kubectl logs -n rook-ceph deploy/mantle-controller", "logs", string(primaryControllerLog))

secondaryPods, _, err := kubectl(secondaryK8sCluster, nil, "get pod -A")
if err != nil {
return err
}
logger.Info(">>> SECONDARY: kubectl get pod -A", "pods", string(secondaryPods))

secondaryControllerLog, _, err := kubectl(secondaryK8sCluster, nil, "logs", "-n", "rook-ceph", "deploy/mantle-controller")
if err != nil {
return err
}
logger.Info(">>> SECONDARY: kubectl logs -n rook-ceph deploy/mantle-controller", "logs", string(secondaryControllerLog))

return nil
}

0 comments on commit cc33f09

Please sign in to comment.