Skip to content

Commit 144766d

Browse files
committed
controllers: Fix helmchart values file merge test
Test case "Setting valid valuesFile attribute" and the tests around it aren't isolated and most of the time pass because of the results from the previous tests being re-read as the test expectation match the previous test results. Failures are very rare to reproduce, even in the CI they aren't seen but it failed very frequently on my computer, especially this specific case because unlike the other cases, there is just one file to be merged, which invalidates the chart result from the previous cases. In order to ensure the test wait for the chart to be updated by its action and not by any other previous updates, status condition message seems to be the most reliable way, as it also contains the paths of the files that were merged. With this change, I could no longer reproduce the failure on my computer. Reordering the tests makes this issue more clear. Signed-off-by: Sunny <darkowlzz@protonmail.com>
1 parent d5e0598 commit 144766d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

controllers/helmchart_controller_test.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,17 @@ var _ = Describe("HelmChartReconciler", func() {
828828
got := &sourcev1.HelmChart{}
829829
Eventually(func() bool {
830830
_ = k8sClient.Get(context.Background(), key, got)
831-
return got.Status.Artifact.Checksum != updated.Status.Artifact.Checksum &&
832-
storage.ArtifactExist(*got.Status.Artifact)
831+
// Since a lot of chart updates took place above, checking
832+
// artifact checksum isn't the most reliable way to find out
833+
// if the artifact was changed due to the current update.
834+
// Use status condition to be sure.
835+
for _, condn := range got.Status.Conditions {
836+
if strings.Contains(condn.Message, "with merged values files [./testdata/charts/helmchart/override.yaml]") &&
837+
storage.ArtifactExist(*got.Status.Artifact) {
838+
return true
839+
}
840+
}
841+
return false
833842
}, timeout, interval).Should(BeTrue())
834843
f, err := os.Stat(storage.LocalPath(*got.Status.Artifact))
835844
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)