Skip to content

Commit

Permalink
Fix the golden image test (#2593)
Browse files Browse the repository at this point in the history
The test compared two string slices. One with the expected golden image
names, and one with the actual ones. This is failing when the order is
not the same.

This fix sorts the expected image names before using them.

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
  • Loading branch information
nunnatsa authored Nov 6, 2023
1 parent 3223ad1 commit e688b7c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/func-tests/golden_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var _ = Describe("golden image test", Label("data-import-cron"), Serial, Ordered
if expectedImagesFromConfig := tests.GetConfig().DataImportCron.ExpectedDataImportCrons; len(expectedImagesFromConfig) > 0 {
expectedImages = expectedImagesFromConfig
}
sort.Strings(expectedImages)

if expectedISFromConfig := tests.GetConfig().DataImportCron.ExpectedImageStream; len(expectedISFromConfig) > 0 {
expectedImageStreams = expectedISFromConfig
Expand Down Expand Up @@ -147,12 +148,12 @@ var _ = Describe("golden image test", Label("data-import-cron"), Serial, Ordered
It("should propagate the DICT to SSP", func() {
Eventually(func(g Gomega) []string {
unstructured, err := cli.DynamicClient().Resource(sspGVR).Namespace(flags.KubeVirtInstallNamespace).Get(ctx, "ssp-kubevirt-hyperconverged", metav1.GetOptions{})
Expect(err).ShouldNot(HaveOccurred())
g.Expect(err).ShouldNot(HaveOccurred())

ssp := &v1beta2.SSP{}
Expect(runtime.DefaultUnstructuredConverter.FromUnstructured(unstructured.Object, ssp)).To(Succeed())
g.Expect(runtime.DefaultUnstructuredConverter.FromUnstructured(unstructured.Object, ssp)).To(Succeed())

Expect(ssp.Spec.CommonTemplates.DataImportCronTemplates).Should(HaveLen(len(expectedImages)))
g.Expect(ssp.Spec.CommonTemplates.DataImportCronTemplates).Should(HaveLen(len(expectedImages)))

imageNames := make([]string, len(expectedImages))
for i, image := range ssp.Spec.CommonTemplates.DataImportCronTemplates {
Expand All @@ -167,7 +168,7 @@ var _ = Describe("golden image test", Label("data-import-cron"), Serial, Ordered
Eventually(func(g Gomega) []string {
hco := tests.GetHCO(ctx, cli)

Expect(hco.Status.DataImportCronTemplates).Should(HaveLen(len(expectedImages)))
g.Expect(hco.Status.DataImportCronTemplates).Should(HaveLen(len(expectedImages)))

imageNames := make([]string, len(expectedImages))
for i, image := range hco.Status.DataImportCronTemplates {
Expand Down

0 comments on commit e688b7c

Please sign in to comment.