Skip to content

Commit

Permalink
ci/cli: add support to test specific OS channel
Browse files Browse the repository at this point in the history
Signed-off-by: Loic Devulder <[email protected]>
  • Loading branch information
ldevulder committed Feb 10, 2025
1 parent 8d82119 commit 266fa79
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/master_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions tests/assets/osChannel.yaml
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions tests/e2e/seedImage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"os"
"os/exec"
"strconv"
"strings"
"time"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 266fa79

Please sign in to comment.