Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion test/e2e/multik8s/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ s5cmd(){

By("waiting for the part=1 Job to fail")
var backup *mantlev1.MantleBackup
var debugJobs []byte // for debugging
Eventually(ctx, func(g Gomega) {
primaryMB, err := GetMB(PrimaryK8sCluster, namespace, backupName)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -270,10 +271,12 @@ s5cmd(){
g.Expect(err).NotTo(HaveOccurred())
jobName := makeJobName(backup, partNumFailed)

debugJobs, _, _ = Kubectl(clusterOfJob, nil, "get", "jobs", "-n", CephClusterNamespace)

job, err := GetJob(clusterOfJob, CephClusterNamespace, jobName)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(IsJobConditionTrue(job.Status.Conditions, batchv1.JobComplete)).To(BeFalse())
}).Should(Succeed())
}).Should(Succeed(), "jobs:\n", string(debugJobs))

Copilot AI Nov 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Should() method is being called with multiple separate string arguments, but Gomega expects a single concatenated message string. This will not produce the expected failure message format.

Change this to:

}).Should(Succeed(), "jobs:\n"+string(debugJobs))
Suggested change
}).Should(Succeed(), "jobs:\n", string(debugJobs))
}).Should(Succeed(), "jobs:\n"+string(debugJobs))

Copilot uses AI. Check for mistakes.

By("ensuring the part=1 Job continues to fail")
Consistently(ctx, func(g Gomega) {
Expand Down
11 changes: 7 additions & 4 deletions test/e2e/multik8s/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,15 @@ func ApplyRBDPoolAndSCTemplate(clusterNo int, namespace string) error { //nolint

func GetObject[T any](clusterNo int, kind, namespace, name string) (*T, error) {
var stdout []byte
var stderr []byte
var err error
if namespace == "" {
stdout, _, err = Kubectl(clusterNo, nil, "get", kind, name, "-o", "json")
stdout, stderr, err = Kubectl(clusterNo, nil, "get", kind, name, "-o", "json")
} else {
stdout, _, err = Kubectl(clusterNo, nil, "get", kind, "-n", namespace, name, "-o", "json")
stdout, stderr, err = Kubectl(clusterNo, nil, "get", kind, "-n", namespace, name, "-o", "json")
}
if err != nil {
return nil, err
return nil, fmt.Errorf("kubectl get %s failed. stderr: %s, err: %w", kind, string(stderr), err)
}

var obj T
Expand Down Expand Up @@ -478,11 +479,13 @@ func WriteRandomDataToPV(ctx SpecContext, cluster int, namespace, pvcName string
Eventually(ctx, func() error {
return ApplyWriteJobTemplate(cluster, namespace, writeJobName, pvcName)
}).Should(Succeed())
var debugJob string // for debugging
Eventually(ctx, func(g Gomega) {
job, err := GetJob(cluster, namespace, writeJobName)
g.Expect(err).NotTo(HaveOccurred())
debugJob = job.String() // for debugging

Copilot AI Nov 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The job.String() method call is invalid. Kubernetes *batchv1.Job objects don't have a String() method, so this will use Go's default string representation which produces unhelpful output like &{...}.

To get useful debugging information, consider using json.Marshal() to serialize the job object:

debugJobBytes, _ := json.Marshal(job)
debugJob = string(debugJobBytes)
Suggested change
debugJob = job.String() // for debugging
debugJobBytes, _ := json.Marshal(job)
debugJob = string(debugJobBytes) // for debugging

Copilot uses AI. Check for mistakes.
g.Expect(IsJobConditionTrue(job.Status.Conditions, batchv1.JobComplete)).To(BeTrue())
}).Should(Succeed())
}).Should(Succeed(), "Failed job:"+debugJob)
stdout, _, err := Kubectl(cluster, nil, "logs", "-n", namespace, "job/"+writeJobName)
Expect(err).NotTo(HaveOccurred())
Expect(len(stdout)).NotTo(Equal(0))
Expand Down
Loading