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 bdc7272
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 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,35 @@ func replicationTestSuite() {
})
})
}

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

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

secondaryPods, _, err := kubectl(secondaryK8sCluster, nil, "get", "pod", "-A")
if err != nil {
return err
}
logger.Info("CLUSTER STATUS: SECONDARY: kubectl get pod -A\n" + string(secondaryPods))

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

return nil
}

0 comments on commit bdc7272

Please sign in to comment.