-
Notifications
You must be signed in to change notification settings - Fork 78
SANDBOX-1371: prepare enablement of ui e2e tests #1180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
289d1ab
5645463
181065c
e5e582d
481e279
439bbf9
2362c47
f3349f5
ea95cae
aa9536a
e84b951
75fecdd
7228cc1
5a4cce6
622a774
beb7403
129654e
20494ca
c6ab616
0f14ffc
a97cf54
e16c223
9760f20
29111a1
90ec11f
e6291ed
e947f20
2611cc7
e4a310b
589e2d6
058e278
66752ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,36 @@ SANDBOX_UI_NS := sandbox-ui | |
| SANDBOX_PLUGIN_IMAGE_NAME := sandbox-rhdh-plugin | ||
| TAG := latest | ||
| PLATFORM ?= linux/amd64 | ||
| RHDH_PLUGINS_DIR ?= $(TMPDIR)rhdh-plugins | ||
| RHDH_PLUGINS_TMP ?= $(TMPDIR)rhdh-plugins | ||
| AUTH_FILE := /tmp/auth.json | ||
| IMAGE_TO_PUSH_IN_QUAY ?= quay.io/$(QUAY_NAMESPACE)/sandbox-rhdh-plugin:$(TAG) | ||
| OPENID_SECRET_NAME=openid-sandbox-public-client-secret | ||
| PUSH_SANDBOX_IMAGE ?= true | ||
| PUSH_SANDBOX_IMAGE ?= false | ||
| UI_ENVIRONMENT := ui-e2e-tests | ||
| SSO_USERNAME_READ := $(shell if [ -n "$(CI)" ]; then cat /usr/local/sandbox-secrets/SSO_USERNAME 2>/dev/null || echo ""; else echo "${SSO_USERNAME}"; fi) | ||
| SSO_PASSWORD_READ := $(shell if [ -n "$(CI)" ]; then cat /usr/local/sandbox-secrets/SSO_PASSWORD 2>/dev/null || echo ""; else echo "${SSO_PASSWORD}"; fi) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| TAG := $(shell \ | ||
| if [ -n "$(CI)$(CLONEREFS_OPTIONS)" ]; then \ | ||
| if [ -n "$(GITHUB_ACTIONS)" ]; then \ | ||
| REPOSITORY_NAME=$$(basename "$(GITHUB_REPOSITORY)"); \ | ||
| COMMIT_ID_SUFFIX=$$(echo "$(PULL_PULL_SHA)" | cut -c1-7); \ | ||
| echo "from.$${REPOSITORY_NAME}.PR$(PULL_NUMBER).$${COMMIT_ID_SUFFIX}"; \ | ||
| else \ | ||
| AUTHOR=$$(jq -r '.refs[0].pulls[0].author' <<< $${CLONEREFS_OPTIONS} | tr -d '[:space:]'); \ | ||
| PULL_PULL_SHA=$${PULL_PULL_SHA:-$$(jq -r '.refs[0].pulls[0].sha' <<< $${CLONEREFS_OPTIONS} | tr -d '[:space:]')}; \ | ||
| COMMIT_ID_SUFFIX=$$(echo "$${PULL_PULL_SHA}" | cut -c1-7); \ | ||
| echo "from.$(REPO_NAME).PR$(PULL_NUMBER).$${COMMIT_ID_SUFFIX}"; \ | ||
| fi; \ | ||
| else \ | ||
| echo "latest"; \ | ||
| fi) | ||
|
Comment on lines
+13
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand this correctly the tags will be something like :
I'm wondering if we really need to add all this information to the image tag or if just the short commit sha ( 7 chars ) would be enough ? In order to simplify a bit the code and the tag names. Also I'f I'm not mistaken there is a limit in the length of the tag which is 128 chars.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mfrancisc thanks for all your suggestions!
Yes, exactly!
I used the same approach as we use for pushing host and member images.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense! Thanks for your additional details. Let's keep it consistent with the other tags than I agree 👍 |
||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| IMAGE_TO_PUSH_IN_QUAY ?= quay.io/$(QUAY_NAMESPACE)/sandbox-rhdh-plugin:$(TAG) | ||
|
|
||
|
|
||
| .PHONY: deploy-sandbox-ui | ||
| deploy-sandbox-ui: HOST_NS=$(shell oc get projects -l app=host-operator --output=name -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | sort | tail -n 1) | ||
| deploy-sandbox-ui: REGISTRATION_SERVICE_API=https://$(shell oc get route registration-service -n ${HOST_NS} -o custom-columns=":spec.host" | tr -d '\n')/api/v1 | ||
| deploy-sandbox-ui: HOST_OPERATOR_API=https://$(shell oc get route api -n ${HOST_NS} -o custom-columns=":spec.host" | tr -d '\n') | ||
| deploy-sandbox-ui: RHDH=https://rhdh-${SANDBOX_UI_NS}.$(shell oc get ingress.config.openshift.io/cluster -o jsonpath='{.spec.domain}') | ||
|
|
@@ -21,34 +43,46 @@ ifeq ($(PUSH_SANDBOX_IMAGE),true) | |
| $(MAKE) push-sandbox-plugin | ||
| endif | ||
| kustomize build deploy/sandbox-ui/ui-e2e-tests | REGISTRATION_SERVICE_API=${REGISTRATION_SERVICE_API} \ | ||
| HOST_NS=${HOST_NS} \ | ||
| HOST_OPERATOR_API=${HOST_OPERATOR_API} \ | ||
| SANDBOX_UI_NS=${SANDBOX_UI_NS} \ | ||
| SANDBOX_PLUGIN_IMAGE=${IMAGE_TO_PUSH_IN_QUAY} \ | ||
| RHDH=${RHDH} envsubst | oc apply -f - | ||
| HOST_OPERATOR_API=${HOST_OPERATOR_API} \ | ||
| SANDBOX_UI_NS=${SANDBOX_UI_NS} \ | ||
| SANDBOX_PLUGIN_IMAGE=${IMAGE_TO_PUSH_IN_QUAY} \ | ||
| RHDH=${RHDH} envsubst | oc apply -f - | ||
| $(MAKE) configure-oauth-idp | ||
| ifeq ($(ENVIRONMENT),ui-e2e-tests) | ||
| @echo "applying toolchainconfig changes" | ||
| @echo "HOST_NS: ${HOST_NS}" | ||
| @oc apply -f deploy/host-operator/ui-e2e-tests/toolchainconfig.yaml -n ${HOST_NS} | ||
| @echo "restarting registration-service to apply toolchainconfig changes" | ||
| @oc -n ${HOST_NS} rollout restart deploy/registration-service | ||
| else | ||
| @echo "skipping toolchainconfig changes - environment is not ui-e2e-tests" | ||
| endif | ||
| @oc -n ${SANDBOX_UI_NS} rollout status deploy/rhdh | ||
| @echo "Developer Sandbox UI running at ${RHDH}" | ||
|
|
||
|
|
||
| check-sso-credentials: | ||
| @echo "checking SSO credentials..." | ||
| @if [ -z "$$SSO_USERNAME" ] || [ -z "$$SSO_PASSWORD" ]; then \ | ||
| echo "SSO_USERNAME or SSO_PASSWORD not set"; \ | ||
| @if [ -z "$(SSO_USERNAME_READ)" ] || [ -z "$(SSO_PASSWORD_READ)" ]; then \ | ||
| if [ -n "$(CI)" ]; then \ | ||
| echo "SSO credential files not found or empty in CI environment"; \ | ||
| else \ | ||
| echo "SSO_USERNAME or SSO_PASSWORD environment variables not set"; \ | ||
| fi; \ | ||
| exit 1; \ | ||
| fi | ||
| @echo "Validating SSO credentials..." | ||
| @status=$$(curl -s -o /dev/null -w "%{http_code}" \ | ||
| -X POST "https://sso.devsandbox.dev/auth/realms/sandbox-dev/protocol/openid-connect/token" \ | ||
| -d "grant_type=password" \ | ||
| -d "client_id=sandbox-public" \ | ||
| -d "username=$$SSO_USERNAME" \ | ||
| -d "password=$$SSO_PASSWORD"); \ | ||
| -d "username=$(SSO_USERNAME_READ)" \ | ||
| -d "password=$(SSO_PASSWORD_READ)"); \ | ||
| if [ "$$status" != "200" ]; then \ | ||
| echo "failed trying to login to 'https://sso.devsandbox.dev/auth/realms/sandbox-dev' ($$status) — check your SSO credentials."; \ | ||
| exit 1; \ | ||
| fi | ||
| @echo "SSO credentials validated successfully" | ||
|
|
||
| configure-oauth-idp: | ||
| @echo "configuring DevSandbox identity provider" | ||
|
|
@@ -70,38 +104,73 @@ create-namespace: | |
|
|
||
| .PHONY: get-rhdh-plugins | ||
| get-rhdh-plugins: | ||
| ifeq ($(strip $(RHDH_PLUGINS_DIR)), $(TMPDIR)rhdh-plugins) | ||
| echo "using rhdh-plugins repo from master" | ||
| ifeq ($(strip $(RHDH_PLUGINS_TMP)), $(TMPDIR)rhdh-plugins) | ||
| ifeq ($(GITHUB_ACTIONS),true) | ||
| @echo "using author ${AUTHOR}" | ||
| $(eval AUTHOR_LINK = https://github.com/${AUTHOR}) | ||
| @echo "detected branch ${BRANCH_NAME}" | ||
| # check if a branch with the same ref exists in the user's fork of rhdh-plugins repo | ||
| @echo "branches of ${AUTHOR_LINK}/rhdh-plugins - checking if there is a branch ${BRANCH_NAME} we could pair with." | ||
| curl ${AUTHOR_LINK}/rhdh-plugins.git/info/refs?service=git-upload-pack --output - | ||
| $(eval REMOTE_RHDH_PLUGINS_BRANCH := $(shell curl ${AUTHOR_LINK}/rhdh-plugins.git/info/refs?service=git-upload-pack --output - 2>/dev/null | grep -a "refs/heads/${BRANCH_NAME}$$" | awk '{print $$2}')) | ||
|
Comment on lines
+114
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsafe curl output redirection may expose sensitive data. Line 118 uses - curl ${AUTHOR_LINK}/rhdh-plugins.git/info/refs?service=git-upload-pack --output -
- $(eval REMOTE_RHDH_PLUGINS_BRANCH := $(shell curl ${AUTHOR_LINK}/rhdh-plugins.git/info/refs?service=git-upload-pack --output - 2>/dev/null | grep -a "refs/heads/${BRANCH_NAME}$$" | awk '{print $$2}'))
+ @echo "Checking for branch ${BRANCH_NAME} in ${AUTHOR_LINK}/rhdh-plugins..."
+ $(eval REMOTE_RHDH_PLUGINS_BRANCH := $(shell curl -s ${AUTHOR_LINK}/rhdh-plugins.git/info/refs?service=git-upload-pack 2>/dev/null | grep -a "refs/heads/${BRANCH_NAME}$$" | awk '{print $$2}'))🤖 Prompt for AI Agents |
||
|
|
||
| # check if the branch with the same name exists, if so then merge it with master and use the merge branch, if not then use master | ||
| @echo "REMOTE_RHDH_PLUGINS_BRANCH: ${REMOTE_RHDH_PLUGINS_BRANCH}" | ||
| @$(MAKE) pair-if-needed REMOTE_RHDH_PLUGINS_BRANCH=${REMOTE_RHDH_PLUGINS_BRANCH} AUTHOR_LINK=${AUTHOR_LINK} | ||
| else | ||
| @echo "using rhdh-plugins repo from master" | ||
| @$(MAKE) clone-rhdh-plugins | ||
| endif | ||
| else | ||
| echo "using local rhdh-plugins repo: ${RHDH_PLUGINS_DIR}" | ||
| @echo "using local rhdh-plugins repo, no pairing needed: ${RHDH_PLUGINS_TMP}" | ||
| endif | ||
|
|
||
| pair-if-needed: | ||
| ifneq ($(strip $(REMOTE_RHDH_PLUGINS_BRANCH)),) | ||
| @echo "Branch ref of the user's fork to be used for pairing: \"${REMOTE_RHDH_PLUGINS_BRANCH}\"" | ||
| git config --global user.email "devsandbox@redhat.com" | ||
| git config --global user.name "KubeSaw" | ||
| # clone | ||
| rm -rf ${RHDH_PLUGINS_TMP} | ||
| git clone --depth=1 https://github.com/redhat-developer/rhdh-plugins.git ${RHDH_PLUGINS_TMP} | ||
| # add the user's fork as remote repo | ||
| git --git-dir=${RHDH_PLUGINS_TMP}/.git --work-tree=${RHDH_PLUGINS_TMP} remote add external ${AUTHOR_LINK}/rhdh-plugins.git | ||
| # fetch the branch | ||
| git --git-dir=${RHDH_PLUGINS_TMP}/.git --work-tree=${RHDH_PLUGINS_TMP} fetch external ${REMOTE_RHDH_PLUGINS_BRANCH} | ||
| # merge the branch with master | ||
| git --git-dir=${RHDH_PLUGINS_TMP}/.git --work-tree=${RHDH_PLUGINS_TMP} merge --ff-only FETCH_HEAD | ||
| else | ||
| @echo "no pairing needed, using rhdh-plugins repo from master" | ||
| @$(MAKE) clone-rhdh-plugins | ||
| endif | ||
|
|
||
| .PHONY: clone-rhdh-plugins | ||
| clone-rhdh-plugins: | ||
| rm -rf ${RHDH_PLUGINS_DIR}; \ | ||
| git clone https://github.com/redhat-developer/rhdh-plugins $(RHDH_PLUGINS_DIR) && \ | ||
| echo "cloned to $(RHDH_PLUGINS_DIR)" | ||
| rm -rf ${RHDH_PLUGINS_TMP}; \ | ||
| git clone --depth=1 https://github.com/redhat-developer/rhdh-plugins $(RHDH_PLUGINS_TMP) && \ | ||
| echo "cloned to $(RHDH_PLUGINS_TMP)" | ||
|
|
||
| .PHONY: push-sandbox-plugin | ||
| push-sandbox-plugin: | ||
| $(MAKE) get-rhdh-plugins | ||
| cd $(RHDH_PLUGINS_DIR)/workspaces/sandbox && \ | ||
| cd $(RHDH_PLUGINS_TMP)/workspaces/sandbox && \ | ||
| rm -rf plugins/sandbox/dist-dynamic && \ | ||
| rm -rf red-hat-developer-hub-backstage-plugin-sandbox && \ | ||
| yarn install && \ | ||
| npx @janus-idp/cli@3.3.1 package package-dynamic-plugins \ | ||
| --tag $(IMAGE_TO_PUSH_IN_QUAY) \ | ||
| --platform $(PLATFORM) && \ | ||
| podman push $(IMAGE_TO_PUSH_IN_QUAY) | ||
| --tag $(IMAGE_TO_PUSH_IN_QUAY) \ | ||
| --platform $(PLATFORM) && \ | ||
| podman push $(IMAGE_TO_PUSH_IN_QUAY) | ||
|
|
||
| .PHONY: clean-sandbox-ui | ||
| clean-sandbox-ui: HOST_NS=$(shell oc get projects -l app=host-operator --output=name -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | sort | tail -n 1) | ||
| clean-sandbox-ui: | ||
| @oc delete ns ${SANDBOX_UI_NS} | ||
| @oc delete secret ${OPENID_SECRET_NAME} -n openshift-config | ||
| @oc delete usersignup ${SSO_USERNAME} -n ${HOST_NS} | ||
|
|
||
| .PHONY: e2e-run-sandbox-ui | ||
| e2e-run-sandbox-ui: HOST_NS=$(shell oc get projects -l app=host-operator --output=name -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | sort | tail -n 1) | ||
| e2e-run-sandbox-ui: RHDH=https://rhdh-${SANDBOX_UI_NS}.$(shell oc get ingress.config.openshift.io/cluster -o jsonpath='{.spec.domain}') | ||
| e2e-run-sandbox-ui: | ||
| @echo "Installing Playwright..." | ||
|
|
@@ -112,24 +181,23 @@ e2e-run-sandbox-ui: | |
| $(GOPATH)/bin/playwright install firefox | ||
|
|
||
| @echo "Running Developer Sandbox UI setup e2e tests..." | ||
| SANDBOX_UI_NS=${SANDBOX_UI_NS} go test "./test/e2e/sandbox-ui/setup" -v -timeout=10m -failfast -count=1 | ||
| SANDBOX_UI_NS=${SANDBOX_UI_NS} go test "./test/e2e/sandbox-ui/setup" -v -timeout=10m -failfast | ||
|
|
||
| @echo "Running Developer Sandbox UI e2e tests in firefox..." | ||
| SSO_USERNAME=${SSO_USERNAME} SSO_PASSWORD=${SSO_PASSWORD} BASE_URL=${RHDH} BROWSER=firefox envsubst < deploy/sandbox-ui/ui-e2e-tests/.env > testsupport/sandbox-ui/.env | ||
| # NOTE: The "-count=1" is the idiomatic way of turning off the test result cache according to https://pkg.go.dev/cmd/go#hdr-Testing_flags. | ||
| go test "./test/e2e/sandbox-ui" -v -timeout=10m -failfast -count=1 | ||
| @oc delete usersignup ${SSO_USERNAME} -n ${HOST_NS} | ||
| @SSO_USERNAME=$(SSO_USERNAME_READ) SSO_PASSWORD=$(SSO_PASSWORD_READ) BASE_URL=${RHDH} BROWSER=firefox envsubst < deploy/sandbox-ui/ui-e2e-tests/.env > testsupport/sandbox-ui/.env | ||
| go test "./test/e2e/sandbox-ui" -v -timeout=10m -failfast | ||
| @oc delete usersignup $(SSO_USERNAME_READ) -n $(HOST_NS) | ||
|
|
||
| @echo "The Developer Sandbox UI e2e tests successfully finished" | ||
|
|
||
|
|
||
| .PHONY: test-ui-e2e | ||
| test-ui-e2e: | ||
| $(MAKE) prepare-and-deploy-e2e deploy-sandbox-ui e2e-run-sandbox-ui ENVIRONMENT=${UI_ENVIRONMENT} | ||
| $(MAKE) deploy-sandbox-ui e2e-run-sandbox-ui ENVIRONMENT=${UI_ENVIRONMENT} | ||
|
|
||
| .PHONY: test-ui-e2e-local | ||
| test-ui-e2e-local: | ||
| $(MAKE) prepare-and-deploy-e2e deploy-sandbox-ui e2e-run-sandbox-ui RHDH_PLUGINS_DIR=${PWD}/../rhdh-plugins ENVIRONMENT=${UI_ENVIRONMENT} | ||
| $(MAKE) deploy-sandbox-ui e2e-run-sandbox-ui RHDH_PLUGINS_TMP=${PWD}/../rhdh-plugins ENVIRONMENT=${UI_ENVIRONMENT} | ||
|
|
||
|
|
||
| UNIT_TEST_IMAGE_NAME=sandbox-ui-e2e-tests | ||
|
|
@@ -142,7 +210,7 @@ build-sandbox-ui-e2e-tests: | |
| podman build --platform $(PLATFORM) -t $(UNIT_TEST_IMAGE_NAME) -f $(UNIT_TEST_DOCKERFILE) . | ||
|
|
||
| # Run Developer Sandbox UI e2e tests image using podman | ||
| PHONY: test-sandbox-ui-in-container | ||
| .PHONY: test-sandbox-ui-in-container | ||
| test-sandbox-ui-in-container: build-sandbox-ui-e2e-tests | ||
| @echo "pushing Developer Sandbox UI image..." | ||
| $(MAKE) push-sandbox-plugin | ||
|
|
@@ -152,12 +220,11 @@ test-sandbox-ui-in-container: build-sandbox-ui-e2e-tests | |
| -e KUBECONFIG=/root/.kube/config \ | ||
| -v ${PWD}:/root/toolchain-e2e \ | ||
| -e E2E_REPO_PATH=/root/toolchain-e2e \ | ||
| -v $(RHDH_PLUGINS_DIR):/root/rhdh-plugins \ | ||
| -e RHDH_PLUGINS_DIR=/root/rhdh-plugins \ | ||
| -v $(RHDH_PLUGINS_TMP):/root/rhdh-plugins \ | ||
| -e RHDH_PLUGINS_TMP=/root/rhdh-plugins \ | ||
| -e SSO_USERNAME=$(SSO_USERNAME) \ | ||
| -e SSO_PASSWORD=$(SSO_PASSWORD) \ | ||
| -e QUAY_NAMESPACE=$(QUAY_NAMESPACE) \ | ||
| -e TMP=/tmp/ \ | ||
| -e PUSH_SANDBOX_IMAGE=false \ | ||
| -e RUNNING_IN_CONTAINER=true \ | ||
| $(UNIT_TEST_IMAGE_NAME) | ||
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.
Fix TMPDIR path join; current value can resolve to “/tmprhdh-plugins”.
Ensure a slash between TMPDIR and directory name and add a sane default for TMPDIR. Also update the equality check accordingly.
Also applies to: 112-113
🤖 Prompt for AI Agents