Skip to content

Commit c8858d6

Browse files
Merge pull request #538 from typeid/fix_e2e_retry
Fix: e2e tests should restore configmap without metadata to avoid conflict
2 parents b71cc1e + fba4104 commit c8858d6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test/e2e/configuration_anomaly_detection_tests.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,17 +535,16 @@ var _ = Describe("Configuration Anomaly Detection", Ordered, func() {
535535

536536
defer func() {
537537
fmt.Println("Restore: Restore backup configmap")
538-
err = k8s.Update(ctx, backupCM)
538+
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
539+
currentCM := &corev1.ConfigMap{}
540+
if err := k8s.Get(ctx, configMapName, namespace, currentCM); err != nil {
541+
return err
542+
}
543+
currentCM.Data = backupCM.Data
544+
currentCM.BinaryData = backupCM.BinaryData
545+
return k8s.Update(ctx, currentCM)
546+
})
539547
Expect(err).ToNot(HaveOccurred(), "Restore the backup ConfigMap")
540-
541-
fmt.Println("Restore: Get restore backup configmap")
542-
restoreBackupCM := &corev1.ConfigMap{}
543-
err = k8s.Get(ctx, configMapName, namespace, restoreBackupCM)
544-
Expect(err).ToNot(HaveOccurred(), "Failed to backup original ConfigMap")
545-
546-
fmt.Println("Restore: Comparing backup and restored ConfigMaps")
547-
Expect(restoreBackupCM.Data).To(Equal(backupCM.Data), "Restored ConfigMap data does not match the backup")
548-
Expect(restoreBackupCM.BinaryData).To(Equal(backupCM.BinaryData), "Restored ConfigMap binary data does not match the backup")
549548
}()
550549

551550
fmt.Println("Step 3: Injecting invalid config to simulate misconfiguration")

0 commit comments

Comments
 (0)