Skip to content

Commit

Permalink
[qe] ensure all crc start commands set the bundle if it is passed thr…
Browse files Browse the repository at this point in the history
…ough the params

integration tests offers a parameter to setup a custom bundle. Previous code made use of the custom bundle on some of the start commands but missed to use it on others. As so the tests end failing due to bundle missmatch versions. This commit refactor the method used to test the setup and start commands making sure if custom bundle parameter is passed it is used always

Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
  • Loading branch information
adrianriobo authored and praveenkumar committed May 23, 2024
1 parent 15df284 commit 0a7c02c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 39 deletions.
17 changes: 13 additions & 4 deletions test/integration/podman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ var _ = Describe("podman-remote", Serial, Ordered, Label("microshift-preset"), f
})

It("setup CRC", func() {
Expect(RunCRCExpectSuccess("setup")).To(ContainSubstring("Your system is correctly setup for using CRC"))
Expect(
crcSuccess("setup")).
To(ContainSubstring("Your system is correctly setup for using CRC"))
})

It("start CRC", func() {
Expect(RunCRCExpectSuccess("start", "-p", pullSecretPath)).To(ContainSubstring("Started the MicroShift cluster"))
// default values: "--memory", "10752", "--cpus", "4", "disk-size", "31"
Expect(
crcSuccess("start", "-p", pullSecretPath)).
To(ContainSubstring("Started the MicroShift cluster"))
})

It("podman-env", func() {
Expand Down Expand Up @@ -79,11 +84,15 @@ var _ = Describe("podman-remote", Serial, Ordered, Label("microshift-preset"), f
})

It("cleanup CRC", func() {
Expect(RunCRCExpectSuccess("cleanup")).To(MatchRegexp("Cleanup finished"))
Expect(
crcSuccess("cleanup")).
To(MatchRegexp("Cleanup finished"))
})

It("unset preset in config", func() {
Expect(RunCRCExpectSuccess("config", "unset", "preset")).To(ContainSubstring("Successfully unset configuration property 'preset'"))
Expect(
crcSuccess("config", "unset", "preset")).
To(ContainSubstring("Successfully unset configuration property 'preset'"))
})
})
})
28 changes: 14 additions & 14 deletions test/integration/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os/exec"
"runtime"

crcCmd "github.com/crc-org/crc/v2/test/extended/crc/cmd"
crc "github.com/crc-org/crc/v2/test/extended/crc/cmd"
"github.com/crc-org/crc/v2/test/extended/util"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -59,24 +59,20 @@ var _ = Describe("", Serial, Ordered, Label("openshift-preset", "goproxy"), func
})

It("setup CRC", func() {
if bundlePath == "" {
Expect(RunCRCExpectSuccess("setup")).To(ContainSubstring("Your system is correctly setup for using CRC"))
} else {
Expect(RunCRCExpectSuccess("setup", "-b", bundlePath)).To(ContainSubstring("Your system is correctly setup for using CRC"))
}
Expect(
crcSuccess("setup")).
To(ContainSubstring("Your system is correctly setup for using CRC"))
})

It("start CRC", func() {
// default values: "--memory", "10752", "--cpus", "4", "disk-size", "31"
if bundlePath == "" {
Expect(RunCRCExpectSuccess("start", "-p", pullSecretPath)).To(ContainSubstring("Started the OpenShift cluster"))
} else {
Expect(RunCRCExpectSuccess("start", "-b", bundlePath, "-p", pullSecretPath)).To(ContainSubstring("Started the OpenShift cluster"))
}
Expect(
crcSuccess("start", "-p", pullSecretPath)).
To(ContainSubstring("Started the OpenShift cluster"))
})

It("wait for cluster in Running state", func() {
err := crcCmd.WaitForClusterInState("running")
err := crc.WaitForClusterInState("running")
Expect(err).NotTo(HaveOccurred())
})

Expand All @@ -100,11 +96,15 @@ var _ = Describe("", Serial, Ordered, Label("openshift-preset", "goproxy"), func
})

It("stop CRC", func() {
Expect(RunCRCExpectSuccess("stop", "-f")).To(MatchRegexp("[Ss]topped the instance"))
Expect(
crcSuccess("stop", "-f")).
To(MatchRegexp("[Ss]topped the instance"))
})

It("cleanup CRC", func() {
Expect(RunCRCExpectSuccess("cleanup")).To(MatchRegexp("Cleanup finished"))
Expect(
crcSuccess("cleanup")).
To(MatchRegexp("Cleanup finished"))
})

})
Expand Down
53 changes: 32 additions & 21 deletions test/integration/resize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,15 @@ var _ = Describe("vary VM parameters: memory cpus, disk", Serial, Ordered, Label
Describe("use default values", Serial, Ordered, func() {

It("setup CRC", func() {
if bundlePath == "" {
Expect(RunCRCExpectSuccess("setup")).To(ContainSubstring("Your system is correctly setup for using CRC"))
} else {
Expect(RunCRCExpectSuccess("setup", "-b", bundlePath)).To(ContainSubstring("Your system is correctly setup for using CRC"))
}
Expect(
crcSuccess("setup")).
To(ContainSubstring("Your system is correctly setup for using CRC"))
})

It("start CRC", func() {
// default values: "--memory", "10752", "--cpus", "4", "disk-size", "31"
if bundlePath == "" {
Expect(RunCRCExpectSuccess("start", "--memory", "12000", "--cpus", "5", "--disk-size", "40", "-p", pullSecretPath)).To(ContainSubstring("Started the OpenShift cluster"))
} else {
Expect(RunCRCExpectSuccess("start", "--memory", "12000", "--cpus", "5", "--disk-size", "40", "-b", bundlePath, "-p", pullSecretPath)).To(ContainSubstring("Started the OpenShift cluster"))
}
Expect(
crcSuccess("start", "--memory", "12000", "--cpus", "5", "--disk-size", "40", "-p", pullSecretPath)).
To(ContainSubstring("Started the OpenShift cluster"))
})

It("login to cluster using crc-admin context", func() {
Expand Down Expand Up @@ -81,15 +76,19 @@ var _ = Describe("vary VM parameters: memory cpus, disk", Serial, Ordered, Label
})

It("stop CRC", func() {
Expect(RunCRCExpectSuccess("stop", "-f")).To(MatchRegexp("[Ss]topped the instance"))
Expect(
crcSuccess("stop", "-f")).
To(MatchRegexp("[Ss]topped the instance"))
})

})

Describe("use custom values", Serial, Ordered, func() {

It("start CRC", func() {
Expect(RunCRCExpectSuccess("start", "--memory", "13000", "--cpus", "6", "--disk-size", "50")).To(ContainSubstring("Started the OpenShift cluster"))
Expect(
crcSuccess("start", "--memory", "13000", "--cpus", "6", "--disk-size", "50")).
To(ContainSubstring("Started the OpenShift cluster"))
})

It("check VM's memory size", func() {
Expand All @@ -112,34 +111,46 @@ var _ = Describe("vary VM parameters: memory cpus, disk", Serial, Ordered, Label
})

It("stop CRC", func() {
Expect(RunCRCExpectSuccess("stop", "-f")).To(MatchRegexp("[Ss]topped the instance"))
Expect(
crcSuccess("stop", "-f")).
To(MatchRegexp("[Ss]topped the instance"))
})
})

Describe("use flawed values", Serial, Ordered, func() {

It("start CRC with sub-minimum memory", func() { // less than min = 10752
Expect(RunCRCExpectFail("start", "--memory", "9000")).To(ContainSubstring("requires memory in MiB >= 10752"))
Expect(
crcFails("start", "--memory", "9000")).
To(ContainSubstring("requires memory in MiB >= 10752"))
})
It("start CRC with sub-minimum cpus", func() { // fewer than min
Expect(RunCRCExpectFail("start", "--cpus", "3")).To(ContainSubstring("requires CPUs >= 4"))
Expect(
crcFails("start", "--cpus", "3")).
To(ContainSubstring("requires CPUs >= 4"))
})
It("start CRC with smaller disk", func() { // bigger than default && smaller than current
diskSizeOutput := "current disk image capacity is bigger than the requested size"
if runtime.GOOS == "windows" {
Expect(RunCRCExpectFail("start", "--disk-size", "35")).To(ContainSubstring("Failed to set disk size to"))
} else {
Expect(RunCRCExpectFail("start", "--disk-size", "35")).To(ContainSubstring("current disk image capacity is bigger than the requested size"))
diskSizeOutput = "Failed to set disk size to"
}
Expect(
crcFails("start", "--disk-size", "35")).
To(ContainSubstring(diskSizeOutput))
})
It("start CRC with sub-minimum disk", func() { // smaller than min = default = 31GiB
Expect(RunCRCExpectFail("start", "--disk-size", "30")).To(ContainSubstring("requires disk size in GiB >= 31")) // TODO: message should be different on macOS!
Expect(
crcFails("start", "--disk-size", "30")).
To(ContainSubstring("requires disk size in GiB >= 31"))
})
})

Describe("use default values again", Serial, Ordered, func() {

It("start CRC", func() {
Expect(RunCRCExpectSuccess("start")).To(ContainSubstring("Started the OpenShift cluster")) // default values: "--memory", "10752", "--cpus", "4", "disk-size", "31"
Expect(
crcSuccess("start")).
To(ContainSubstring("Started the OpenShift cluster"))
})

It("check VM's memory size", func() {
Expand Down
24 changes: 24 additions & 0 deletions test/integration/utilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,27 @@ func RunCRCExpectFail(args ...string) (string, error) {

return stderr, nil
}

// Helper function to run crc setup or start commands expecting success
func crcSuccess(op string, args ...string) string {
return RunCRCExpectSuccess(
crcCmd(op, args...)...)
}

// Helper function to run crc setup or start commands expecting fails
func crcFails(op string, args ...string) string {
output, _ := RunCRCExpectFail(
crcCmd(op, args...)...)
return output
}

// Helper function to add custom parameters if required
func crcCmd(op string, args ...string) []string {
cmd := []string{op}
if op == "start" || op == "setup" {
if len(bundlePath) > 0 {
cmd = append(cmd, "-b", bundlePath)
}
}
return append(cmd, args...)
}

0 comments on commit 0a7c02c

Please sign in to comment.