diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..15c0338 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +--- +name: 'test' + +on: + push: + branches: + - master + tags: + - '*' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Test + run: | + make kind-e2e-tests \ No newline at end of file diff --git a/tests/e2e/e2e_simple_test.go b/tests/e2e/e2e_simple_test.go new file mode 100644 index 0000000..469e431 --- /dev/null +++ b/tests/e2e/e2e_simple_test.go @@ -0,0 +1,39 @@ +package e2e_test + +import ( + "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + kubectl "github.com/rancher-sandbox/ele-testhelpers/kubectl" +) + +var _ = Describe("ISO build test", func() { + //k := kubectl.New() + Context("registration", func() { + + AfterEach(func() { + kubectl.New().Delete("osartifacts", "-n", "default", "hello-c3os") + }) + + It("creates a simple iso", func() { + err := kubectl.Apply("", "../../tests/fixtures/simple.yaml") + Expect(err).ToNot(HaveOccurred()) + + Eventually(func() string { + b, _ := kubectl.GetData("default", "osartifacts", "hello-c3os", "jsonpath={.spec.imageName}") + return string(b) + }, 2*time.Minute, 2*time.Second).Should(Equal("quay.io/c3os/c3os:opensuse-latest")) + + Eventually(func() string { + b, _ := kubectl.GetData("default", "deployments", "hello-c3os", "jsonpath={.spec.template.metadata.labels.osbuild}") + return string(b) + }, 2*time.Minute, 2*time.Second).Should(Equal("workloadhello-c3os")) + Eventually(func() string { + b, _ := kubectl.GetData("default", "deployments", "hello-c3os", "jsonpath={.spec.status.unavailableReplicas}") + return string(b) + }, 15*time.Minute, 2*time.Second).ShouldNot(Equal("1")) + }) + }) + +}) diff --git a/tests/e2e/e2e_suite_test.go b/tests/e2e/e2e_suite_test.go index 469e431..2f4045f 100644 --- a/tests/e2e/e2e_suite_test.go +++ b/tests/e2e/e2e_suite_test.go @@ -1,39 +1,13 @@ package e2e_test import ( - "time" + "testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - kubectl "github.com/rancher-sandbox/ele-testhelpers/kubectl" ) -var _ = Describe("ISO build test", func() { - //k := kubectl.New() - Context("registration", func() { - - AfterEach(func() { - kubectl.New().Delete("osartifacts", "-n", "default", "hello-c3os") - }) - - It("creates a simple iso", func() { - err := kubectl.Apply("", "../../tests/fixtures/simple.yaml") - Expect(err).ToNot(HaveOccurred()) - - Eventually(func() string { - b, _ := kubectl.GetData("default", "osartifacts", "hello-c3os", "jsonpath={.spec.imageName}") - return string(b) - }, 2*time.Minute, 2*time.Second).Should(Equal("quay.io/c3os/c3os:opensuse-latest")) - - Eventually(func() string { - b, _ := kubectl.GetData("default", "deployments", "hello-c3os", "jsonpath={.spec.template.metadata.labels.osbuild}") - return string(b) - }, 2*time.Minute, 2*time.Second).Should(Equal("workloadhello-c3os")) - Eventually(func() string { - b, _ := kubectl.GetData("default", "deployments", "hello-c3os", "jsonpath={.spec.status.unavailableReplicas}") - return string(b) - }, 15*time.Minute, 2*time.Second).ShouldNot(Equal("1")) - }) - }) - -}) +func TestE2e(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "c3os-operator e2e test Suite") +} diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go deleted file mode 100644 index 2f4045f..0000000 --- a/tests/e2e/e2e_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package e2e_test - -import ( - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" -) - -func TestE2e(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "c3os-operator e2e test Suite") -}