Skip to content

Commit

Permalink
test_e2e is back
Browse files Browse the repository at this point in the history
  • Loading branch information
sleshchenko committed Nov 3, 2020
1 parent c5bd795 commit 99cbe80
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 31 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ test: generate fmt vet manifests
test -f $(ENVTEST_ASSETS_DIR)/setup-envtest.sh || curl -sSLo $(ENVTEST_ASSETS_DIR)/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.6.3/hack/setup-envtest.sh
source $(ENVTEST_ASSETS_DIR)/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test $(shell go list ./... | grep -v test/e2e) -coverprofile cover.out

### test_e2e: runs e2e test on the cluster set in context. Includes deploying devworkspace-controller, run test workspace, uninstall devworkspace-controller
test_e2e: generate fmt vet manifests
CGO_ENABLED=0 go test -v -c -o bin/devworkspace-controller-e2e ./test/e2e/cmd/workspaces_test.go
./bin/devworkspace-controller-e2e

### manager: Build manager binary
manager: generate fmt vet
go build -o bin/manager main.go
Expand Down
5 changes: 0 additions & 5 deletions test/e2e/cmd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
panic(err)
}

if err := controller.CreateAdditionalControllerResources(); err != nil {
fmt.Println("Failed to create additional controller resources in clusters")
panic(err)
}

if err := controller.CustomResourceDefinitions(); err != nil {
fmt.Println("Failed to add custom resources definitions to cluster")
panic(err)
Expand Down
33 changes: 7 additions & 26 deletions test/e2e/pkg/deploy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"os/exec"
"strings"

"k8s.io/apimachinery/pkg/api/errors"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand All @@ -30,12 +32,15 @@ func (w *Deployment) CreateNamespace() error {
Name: config.Namespace,
},
}, metav1.CreateOptions{})
if errors.IsAlreadyExists(err) {
return nil
}
return err
}

func (w *Deployment) DeployWorkspacesController() error {
label := "app.kubernetes.io/name=devworkspace-controller"
cmd := exec.Command("oc", "apply", "--namespace", config.Namespace, "-f", "deploy")
cmd := exec.Command("make", "deploy")
output, err := cmd.CombinedOutput()
fmt.Println(string(output))
if err != nil && !strings.Contains(string(output), "AlreadyExists") {
Expand All @@ -60,36 +65,12 @@ func (w *Deployment) DeployWorkspacesController() error {
return nil
}

func (w *Deployment) CreateAdditionalControllerResources() error {
//sed "s/\${NAMESPACE}/config.Namespace/g" <<< cat *.yaml | oc apply -f -
cmd := exec.Command(
"bash", "-c",
"sed 's/\\${NAMESPACE}/"+config.Namespace+"/g' <<< "+
"cat deploy/*.yaml | "+
"oc apply --namespace "+config.Namespace+" -f -")
output, err := cmd.CombinedOutput()
fmt.Println(string(output))
if err != nil {
fmt.Println(err)
return err
}
return nil
}

func (w *Deployment) CustomResourceDefinitions() error {
devWorkspaceCRD := exec.Command("oc", "apply", "-f", "devworkspace-crds/deploy/crds")
devWorkspaceCRD := exec.Command("make", "install")
output, err := devWorkspaceCRD.CombinedOutput()
if err != nil && !strings.Contains(string(output), "AlreadyExists") {
fmt.Println(err)
return err
}

eclipseCRD := exec.Command("oc", "apply", "-f", "deploy/crds")
output, err = eclipseCRD.CombinedOutput()
if err != nil && !strings.Contains(string(output), "AlreadyExists") {
fmt.Println(err)
return err
}

return nil
}

0 comments on commit 99cbe80

Please sign in to comment.