mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Label ServiceBinding tests, so we can run them separately They require installing additional components in the cluster (OLM, SBO, ...). * Add GH Workflow for most of our tests (including cluster-related tests) This allows to easily test even multiple versions of Kubernetes if needed. For easier reporting and visualisation (and also avoid rebuilding odo many times), Podman tests have also been relocated in this same Workflow. Notes: I tried to spin up lightweight OpenShift clusters but gave up because of several issues: - MicroShift: I tried to use the aio container image, but this one is no longer maintained and is pretty old version of OCP. Trying to follow the official guidelines did not work either because a base RHEL OS is mandatory - CRC/OpenShiftLocal with Microshift preset: didnt pass the pre-checks because it detected an issue with nested virtualization on the GH Runner. * Drop unused code in helper_oc and use namespace instead of project When testing on Microshift, it seems that the Project API is purposely not implemented on MicroShift
86 lines
2.8 KiB
Go
86 lines
2.8 KiB
Go
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
|
|
"github.com/redhat-developer/odo/tests/helper"
|
|
)
|
|
|
|
var _ = Describe("odo remove binding command tests", Label(helper.LabelServiceBinding), func() {
|
|
var commonVar helper.CommonVar
|
|
|
|
var _ = BeforeEach(func() {
|
|
skipLogin := os.Getenv("SKIP_SERVICE_BINDING_TESTS")
|
|
if skipLogin == "true" {
|
|
Skip("Skipping service binding tests as SKIP_SERVICE_BINDING_TESTS is true")
|
|
}
|
|
|
|
commonVar = helper.CommonBeforeEach()
|
|
helper.Chdir(commonVar.Context)
|
|
// Note: We do not add any operators here because `odo remove binding` is simply about removing the ServiceBinding from devfile.
|
|
})
|
|
|
|
// This is run after every Spec (It)
|
|
var _ = AfterEach(func() {
|
|
helper.CommonAfterEach(commonVar)
|
|
})
|
|
|
|
for _, bindingName := range []string{"my-nodejs-app-cluster-sample-k8s", "my-nodejs-app-cluster-sample-ocp"} {
|
|
bindingName := bindingName
|
|
When(fmt.Sprintf("the component with binding is bootstrapped (bindingName=%s)", bindingName), func() {
|
|
BeforeEach(func() {
|
|
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
|
|
helper.Cmd("odo", "init", "--name", "mynode", "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-service-binding-files.yaml")).ShouldPass()
|
|
})
|
|
|
|
for _, label := range []string{
|
|
helper.LabelNoCluster, helper.LabelUnauth,
|
|
} {
|
|
label := label
|
|
When("removing the binding", Label(label), func() {
|
|
BeforeEach(func() {
|
|
helper.Cmd("odo", "remove", "binding", "--name", bindingName).ShouldPass()
|
|
})
|
|
It("should successfully remove binding between component and service in the devfile", func() {
|
|
components := helper.GetDevfileComponents(filepath.Join(commonVar.Context, "devfile.yaml"), bindingName)
|
|
Expect(components).To(BeNil())
|
|
})
|
|
})
|
|
}
|
|
|
|
It("should fail to remove binding that does not exist", func() {
|
|
helper.Cmd("odo", "remove", "binding", "--name", "my-binding").ShouldFail()
|
|
})
|
|
|
|
When("odo dev is running", func() {
|
|
var devSession helper.DevSession
|
|
BeforeEach(func() {
|
|
var err error
|
|
devSession, err = helper.StartDevMode(helper.DevSessionOpts{})
|
|
Expect(err).ToNot(HaveOccurred())
|
|
})
|
|
AfterEach(func() {
|
|
devSession.Stop()
|
|
devSession.WaitEnd()
|
|
})
|
|
When("binding is removed", func() {
|
|
BeforeEach(func() {
|
|
helper.Cmd("odo", "remove", "binding", "--name", bindingName).ShouldPass()
|
|
err := devSession.WaitSync()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
})
|
|
It("should have led odo dev to delete ServiceBinding from the cluster", func() {
|
|
_, errOut := commonVar.CliRunner.GetServiceBinding(bindingName, commonVar.Project)
|
|
Expect(errOut).To(ContainSubstring("not found"))
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}
|
|
})
|