diff --git a/.github/workflows/master_e2e.yaml b/.github/workflows/master_e2e.yaml index 7e1be31c7..9b18d199b 100644 --- a/.github/workflows/master_e2e.yaml +++ b/.github/workflows/master_e2e.yaml @@ -9,8 +9,8 @@ on: description: Version of backup-restore-operator to use type: string boot_type: - description: Choose booting type (pxe, iso, raw) - default: pxe + description: Choose booting type (pxe, iso, raw) + default: pxe type: string ca_type: description: CA type to use (selfsigned or private) diff --git a/tests/assets/osChannel.yaml b/tests/assets/osChannel.yaml new file mode 100644 index 000000000..8dc633969 --- /dev/null +++ b/tests/assets/osChannel.yaml @@ -0,0 +1,11 @@ +apiVersion: elemental.cattle.io/v1beta1 +kind: ManagedOSVersionChannel +metadata: + name: os-channel-to-test + # namespace: fleet-default +spec: + deleteNoLongerInSyncVersions: true + options: + image: %OS_CHANNEL% + syncInterval: 1h + type: custom diff --git a/tests/e2e/seedImage_test.go b/tests/e2e/seedImage_test.go index 405e3cc64..e1da72f9b 100644 --- a/tests/e2e/seedImage_test.go +++ b/tests/e2e/seedImage_test.go @@ -18,6 +18,7 @@ import ( "os" "os/exec" "strconv" + "strings" "time" . "github.com/onsi/ginkgo/v2" @@ -42,6 +43,62 @@ var _ = Describe("E2E - Creating ISO image", Label("iso-image"), func() { // Report to Qase testCaseID = 38 + // If registry keyword is found this means that we have to test a specific OS channel + if strings.Contains(os2Test, "registry") { + // Get default channel image + defChannel, err := kubectl.RunWithoutErr("get", "managedOSVersionChannel", + "--namespace", clusterNS, + "-o", "jsonpath={.items[0].spec.options.image}") + Expect(err).To(Not(HaveOccurred())) + Expect(defChannel).To(Not(BeEmpty())) + + // Add channel to test if needed + if !strings.Contains(defChannel, os2Test) { + By("Adding OSChannel to test", func() { + // Get channel name (to be able to remove it later) + channelName, err := kubectl.RunWithoutErr("get", "managedOSVersionChannel", + "--namespace", clusterNS, + "-o", "jsonpath={.items[0].metadata.name}") + Expect(err).To(Not(HaveOccurred())) + Expect(channelName).To(Not(BeEmpty())) + + // Set temporary file + osChannelTmp, err := tools.CreateTemp("osChannel") + Expect(err).To(Not(HaveOccurred())) + defer os.Remove(osChannelTmp) + + // Save original file as it can be modified multiple time + err = tools.CopyFile(osChannelYaml, osChannelTmp) + Expect(err).To(Not(HaveOccurred())) + + // Set the OS channel to test + err = tools.Sed("%OS_CHANNEL%", os2Test, osChannelTmp) + Expect(err).To(Not(HaveOccurred())) + + // Apply to k8s + err = kubectl.Apply(clusterNS, osChannelTmp) + Expect(err).To(Not(HaveOccurred())) + + // Check that the OS channel to test has been added + const channel = "os-channel-to-test" + newChannel, err := kubectl.RunWithoutErr("get", "managedOSVersionChannel", + "--namespace", clusterNS, channel, + "-o", "jsonpath={.spec.options.image}") + Expect(err).To(Not(HaveOccurred())) + Expect(newChannel).To(Equal(os2Test)) + + // Delete the default channel (to be sure that it can't be used) + out, err := kubectl.RunWithoutErr("delete", "managedOSVersionChannel", + "--namespace", clusterNS, channelName) + Expect(err).To(Not(HaveOccurred())) + Expect(out).To(ContainSubstring("deleted")) + }) + } + + // Clear OS_TO_TEST, as Staging and Dev channels manually added do not contain "unstable" tag + os2Test = "" + } + By("Adding SeedImage", func() { var ( baseImageURL string diff --git a/tests/e2e/suite_test.go b/tests/e2e/suite_test.go index 296cd18e6..a48dfea8a 100644 --- a/tests/e2e/suite_test.go +++ b/tests/e2e/suite_test.go @@ -49,6 +49,7 @@ const ( localStorageYaml = "../assets/local-storage.yaml" metallbRscYaml = "../assets/metallb_rsc.yaml" numberOfNodesMax = 30 + osChannelYaml = "../assets/osChannel.yaml" resetMachineInv = "../assets/reset_machine_inventory.yaml" restoreYaml = "../assets/restore.yaml" sshConfigFile = "../assets/ssh_config"