-
Notifications
You must be signed in to change notification settings - Fork 28
Create Makefile target to install operator & test #33
Conversation
Can one of the admins verify this patch? |
This is a draft. There are a few hard coded variables which need to be fixed. The operator image should be available as a prerequisite for this PR. |
@@ -127,6 +127,53 @@ e2e-cleanup: | |||
oc login -u system:admin | |||
oc delete project devconsole-e2e-test || true | |||
|
|||
.PHONY: test-olm-integration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move this to a bash script and call it from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makefiles and complicated scripts are not best friends. But if you can split those make targets into multiple ones that depend on each other, it is superior to having a big bash file IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will split it into smaller multiple targets.
@@ -127,6 +127,53 @@ e2e-cleanup: | |||
oc login -u system:admin | |||
oc delete project devconsole-e2e-test || true | |||
|
|||
.PHONY: test-olm-integration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makefiles and complicated scripts are not best friends. But if you can split those make targets into multiple ones that depend on each other, it is superior to having a big bash file IMHO.
make/test.mk
Outdated
cp $(CUR_DIR)/manifests/devopsconsole/$(devopsconsole_version)/$(devopsconsole_csv).clusterserviceversion.yaml $(CUR_DIR)/devopsconsole_tmp.yaml | ||
|
||
sed -e "s,REPLACE_IMAGE,quay.io/baijum/devopsconsole-operator:0.1.0," -i $(CUR_DIR)/manifests/devopsconsole/${devopsconsole_version}/${devopsconsole_csv}.clusterserviceversion.yaml | ||
docker build -f $(CUR_DIR)/test/olm/Dockerfile $(CUR_DIR) -t $(DEVOPSCONSOLE_OPERATOR_REGISTRY):$(devopsconsole_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we have multiple more simply steps that are testable on their own? For example, build the docker image, then you can do docker images
to see if it is there. If this remains in a makefile I think we should have targets depend on each other.
If one of those commands in this target fails, you probably have a hard time finding out how to test only one bit in particular.
make/test.mk
Outdated
|
||
operator-sdk test local ./test/olm/ --go-test-flags "-v -parallel=1" | ||
|
||
#TODO: the below command should be replaced with the actual test command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use #TODO(Avni-Sharma): ...
to help others know that it is @Avni-Sharma who's supposed to fix this or who added this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
make/test.mk
Outdated
#TODO: the below command should be replaced with the actual test command. | ||
#go test ./test/olm/... -root=$(PWD) -kubeconfig=$(HOME)/.kube/config -globalMan deploy/test/global-manifests.yaml -namespacedMan deploy/test/namespace-manifests.yaml -v -parallel=1 -singleNamespace | ||
|
||
# .PHONY: olm-integration-setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I meant by have the make targets depend on each other.
/shrug |
Following the operator-sdk testing framework. Referred Corrine's/Tina's PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today I spent quite some time debugging the absence of a rolebinding which was present in deploy/..
but absent when deployed using the registry.
And then I realized that our csv yaml needed a fix.
Doesn't necessarily have to be a part of this PR, but a validation to check if the service account can see relevant resources in a different namespace is going to be very useful.
make/test.mk
Outdated
oc login -u system:admin | ||
oc create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/olm.yaml | ||
#Baiju's image. Replace it with the actual image | ||
$(eval image := "quay.io/baijum/devopsconsole-operator:0.1.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, you could tag it as quay.io/redhat-developers/devopsconsole-operator:test{commitid}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be coming through DEVOPSCONSOLE_OPERATOR_IMAGE
environment variable
make/test.mk
Outdated
|
||
#oc tag 172.30.1.1:5000/$(namespace)/operator-registry:latest $(DEVOPSCONSOLE_OPERATOR_REGISTRY):$(devopsconsole_version) | ||
sed -e "s,REPLACE_IMAGE,$(DEVOPSCONSOLE_OPERATOR_REGISTRY):$(devopsconsole_version)," $(CUR_DIR)/test/olm/catalog_source.yaml | oc create -f - | ||
oc create -f $(CUR_DIR)/test/olm/subscription.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation of the CatalogSource
is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous line creates CatalogSource
.
make/test.mk
Outdated
oc create -f $(CUR_DIR)/test/olm/subscription.yaml | ||
sleep 1m | ||
oc get catalogsources -n olm | ||
oc get subscriptions -n operators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate the status of the subscription?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. and valid that the 'deployment' is 'ready'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All validation will be moved to test written in Go.
make/test.mk
Outdated
|
||
# .PHONY: olm-integration-setup | ||
# olm-integration-setup: e2e-cleanup | ||
# oc new-project devconsole-e2e-test || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, it has been seen that deletion of the namespace at the end of the test takes time , which sometimes blocks the next test run because creation of the namespace with the same name is attempted.
You could consider creating a unique namespace name every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ideally when should a cleanup happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could create a namespace with a random string appended to it "devconsole-e2e-test-xyz" and delete it. Let the 'garbage collection' happen at its own pace by openshift.
make/test.mk
Outdated
@@ -88,6 +88,9 @@ ALL_PKGS_EXCLUDE_PATTERN = 'vendor\|app\|tool\/cli\|design\|client\|test' | |||
GOANALYSIS_PKGS_EXCLUDE_PATTERN="vendor|app|client|tool/cli" | |||
GOANALYSIS_DIRS=$(shell go list -f {{.Dir}} ./... | grep -v -E $(GOANALYSIS_PKGS_EXCLUDE_PATTERN)) | |||
|
|||
RANDOM := $(shell uuidgen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once PR #34 is merged, remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed duplicate.
/assign @baijum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@Avni-Sharma Let's wait for one more approval before merging.
make/test.mk
Outdated
@docker login -u $(QUAY_USERNAME) -p $(QUAY_PASSWORD) $(REGISTRY_URI) | ||
docker push $(DEVOPSCONSOLE_OPERATOR_REGISTRY_IMAGE):$(devopsconsole_version) | ||
|
||
sed -e "s,REPLACE_IMAGE,$(DEVOPSCONSOLE_OPERATOR_REGISTRY_IMAGE):$(devopsconsole_version)," $(CUR_DIR)/test/olm/catalog_source.yaml | oc apply -f - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need some if/else to keep Makefile macOS compatible. See we did with Tina did on previous test PR.
@baiju if that's a tiny change, you could. Otherwise we could merge this PR and consider doing that in a separate PR. |
@sbose78 That |
/ok-to-test |
@@ -56,6 +56,32 @@ e2e-cleanup: get-test-namespace | |||
$(Q)-oc delete -f ./deploy/test/role_binding_test.yaml --namespace $(TEST_NAMESPACE) | |||
$(Q)-oc delete -f ./deploy/test/operator_test.yaml --namespace $(TEST_NAMESPACE) | |||
|
|||
.PHONY: test-olm-integration | |||
## Runs the OLM integration tests without coverage | |||
test-olm-integration: push-operator-image olm-integration-setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This calls
.PHONY: build-operator-image
## Build and create the operator container image
build-operator-image:
operator-sdk build $(DEVCONSOLE_OPERATOR_IMAGE)
The CI test pushing to the latest
tag can be disastrous :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. d27da00
On Mac
|
@sbose78 Can you check the permission of the For me it shows something like this:
I just freshly cloned a new repo, I got the same permission. |
|
On re-running:
Need to verify if we are cleaning up the subscription. |
|
The |
.. although it would be fair to have this PR focus on openshift 3 with OLM, and then make this test work for openshift 4 in a different PR. |
All version numbers can be a derivative of the commit id . |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Avni-Sharma, baijum, sbose78 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Refer: https://jira.coreos.com/browse/ODC-189
This pull request introduces a new Makefile target to run the Operator Lifecycle Manager (OLM) integration test. The target is
test-olm-integration
, and you can run it like this:Before running the above, you should set environment variables listed here:
The
QUAY_USERNAME
andQUAY_PASSWORD
is used to login to Quay. TheDEVCONSOLE_OPERATOR_IMAGE
environment variable is pointing to the operator image location without the tag. TheDEVCONSOLE_OPERATOR_REGISTRY_IMAGE
is pointing to the registry image without the tag.