-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chris Ahl <cahl@redhat.com>
- Loading branch information
Showing
5 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM registry.ci.openshift.org/stolostron/builder:go1.17-linux AS builder | ||
|
||
# FROM cypress/included:8.4.1 as production | ||
# The below is just a copy of the above retagged and pushed to quay.io for easier pulling | ||
#FROM quay.io/kcormier/cypress-included:latest as production | ||
FROM quay.io/chrisahl/cypress-included:latest as production | ||
|
||
USER root | ||
|
||
RUN mkdir -p /idp-mgmt-operator-ui-tests/cypress_cache | ||
ENV CYPRESS_CACHE_FOLDER=/idp-mgmt-operator-ui-tests/cypress_cache | ||
WORKDIR /idp-mgmt-operator-ui-tests | ||
COPY test/e2e ./test | ||
WORKDIR /idp-mgmt-operator-ui-tests/test | ||
|
||
#RUN npm ci | ||
RUN ./download-clis.sh | ||
# Make the directory writable by non-root users | ||
RUN chmod -R go+w /idp-mgmt-operator-ui-tests | ||
|
||
ENTRYPOINT ["./start-cypress-tests.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Red Hat | ||
|
||
# Install OpenShift CLI. | ||
echo "Installing oc and kubectl clis..." | ||
curl -kLo oc.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.8.24/openshift-client-linux-4.8.24.tar.gz | ||
mkdir oc-unpacked | ||
tar -xzf oc.tar.gz -C oc-unpacked | ||
chmod 755 ./oc-unpacked/oc | ||
chmod 755 ./oc-unpacked/kubectl | ||
mv ./oc-unpacked/oc /usr/local/bin/oc | ||
mv ./oc-unpacked/kubectl /usr/local/bin/kubectl | ||
rm -rf ./oc-unpacked ./oc.tar.gz | ||
|
||
|
||
|
||
# Install jq to parse json within bash scripts | ||
curl -o /usr/local/bin/jq http://stedolan.github.io/jq/download/linux64/jq | ||
chmod +x /usr/local/bin/jq | ||
|
||
|
||
echo 'set up complete' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
# Copyright Red Hat | ||
|
||
set -e | ||
|
||
############################################################################### | ||
# Test Setup | ||
############################################################################### | ||
|
||
echo $SHARED_DIR | ||
|
||
BROWSER=chrome | ||
BUILD_WEB_URL=https://prow.ci.openshift.org/view/gs/origin-ci-test/${JOB_NAME}/${BUILD_ID} | ||
GIT_PULL_NUMBER=$PULL_NUMBER | ||
GIT_REPO_SLUG=${REPO_OWNER}/${REPO_NAME} | ||
HUB_CREDS=$(cat "${SHARED_DIR}/hub-1.json") | ||
OCM_NAMESPACE=open-cluster-management | ||
OCM_ROUTE=multicloud-console | ||
# Hub cluster | ||
export KUBECONFIG="${SHARED_DIR}/hub-1.kc" | ||
|
||
OCM_ADDRESS=https://`oc -n $OCM_NAMESPACE get route $OCM_ROUTE -o json | jq -r '.spec.host'` | ||
export CYPRESS_BASE_URL=$OCM_ADDRESS | ||
export CYPRESS_OC_CLUSTER_URL=$(echo $HUB_CREDS | jq -r '.api_url') | ||
export CYPRESS_OC_CLUSTER_USER=$(echo $HUB_CREDS | jq -r '.username') | ||
export CYPRESS_OC_CLUSTER_PASS=$(echo $HUB_CREDS | jq -r '.password') | ||
|
||
# Cypress env variables | ||
#export ANSIBLE_URL=$(cat "/etc/e2e-secrets/ansible-url") | ||
#export ANSIBLE_TOKEN=$(cat "/etc/e2e-secrets/ansible-token") | ||
export BROWSER=$BROWSER | ||
export BUILD_WEB_URL=$BUILD_WEB_URL | ||
export CYPRESS_JOB_ID=$PROW_JOB_ID | ||
export CYPRESS_RBAC_TEST=$(cat "/etc/e2e-secrets/cypress-rbac-test") | ||
export CYPRESS_TEST_MODE=BVT | ||
#export GITHUB_PRIVATE_URL=$(cat "/etc/e2e-secrets/github-private-url") | ||
#export GITHUB_USER=$(cat "/etc/e2e-secrets/github-user") | ||
#export GITHUB_TOKEN=$(cat "/etc/e2e-secrets/github-token") | ||
export GIT_PULL_NUMBER=$PULL_NUMBER | ||
export GIT_REPO_SLUG=$GIT_REPO_SLUG | ||
#export HELM_PRIVATE_URL=$(cat "/etc/e2e-secrets/helm-private-url") | ||
#export HELM_USERNAME=$(cat "/etc/e2e-secrets/github-user") | ||
#export HELM_PASSWORD=$(cat "/etc/e2e-secrets/github-token") | ||
#export HELM_CHART_NAME=$(cat "/etc/e2e-secrets/helm-chart-name") | ||
#export OBJECTSTORE_PRIVATE_URL=$(cat "/etc/e2e-secrets/objectstore-private-url") | ||
#export OBJECTSTORE_ACCESS_KEY=$(cat "/etc/e2e-secrets/objectstore-access-key") | ||
#export OBJECTSTORE_SECRET_KEY=$(cat "/etc/e2e-secrets/objectstore-secret-key") | ||
#export SLACK_TOKEN=$(cat "/etc/e2e-secrets/slack-token") | ||
|
||
# Workaround for "error: x509: certificate signed by unknown authority" problem with oc login | ||
mkdir -p ${HOME}/certificates | ||
OAUTH_POD=$(oc -n openshift-authentication get pods -o jsonpath='{.items[0].metadata.name}') | ||
export CYPRESS_OC_CLUSTER_INGRESS_CA=/certificates/ingress-ca.crt | ||
oc rsh -n openshift-authentication $OAUTH_POD cat /run/secrets/kubernetes.io/serviceaccount/ca.crt > ${HOME}${CYPRESS_OC_CLUSTER_INGRESS_CA} | ||
|
||
# managed cluster | ||
MANAGED_CREDS=$(cat "${SHARED_DIR}/managed-1.json") | ||
export CYPRESS_MANAGED_OCP_URL=$(echo $MANAGED_CREDS | jq -r '.api_url') | ||
export CYPRESS_MANAGED_OCP_USER=$(echo $MANAGED_CREDS | jq -r '.username') | ||
export CYPRESS_MANAGED_OCP_PASS=$(echo $MANAGED_CREDS | jq -r '.password') | ||
export CYPRESS_PROW="true" | ||
|
||
echo `Running ${CYPRESS_TEST_MODE} tests` | ||
./start-cypress-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Red Hat | ||
|
||
echo "Initiating tests..." | ||
|
||
if [ -z "$CYPRESS_TEST_MODE" ]; then | ||
echo "CYPRESS_TEST_MODE not exported; setting to 'e2e' mode" | ||
export CYPRESS_TEST_MODE='e2e' | ||
fi | ||
|
||
if [ -z "$BROWSER" ]; then | ||
export BROWSER="chrome" | ||
fi | ||
|
||
if [[ -z $CYPRESS_MANAGED_OCP_URL || -z $CYPRESS_MANAGED_OCP_USER || -z $CYPRESS_MANAGED_OCP_PASS ]]; then | ||
echo 'One or more variables are undefined. Copying kubeconfigs...' | ||
cp -r ~/resources/extra-import-kubeconfigs/* ./cypress/config/import-kubeconfig | ||
else | ||
echo "Logging into the managed cluster using credentials and generating the kubeconfig..." | ||
mkdir -p ./import-kubeconfig && touch ./import-kubeconfig/kubeconfig | ||
export KUBECONFIG=$(pwd)/import-kubeconfig/kubeconfig | ||
oc login --server=$CYPRESS_MANAGED_OCP_URL -u $CYPRESS_MANAGED_OCP_USER -p $CYPRESS_MANAGED_OCP_PASS --insecure-skip-tls-verify | ||
unset KUBECONFIG | ||
echo "Copying managed cluster kubeconfig to ./cypress/config/import-kubeconfig ..." | ||
cp ./import-kubeconfig/* ./cypress/config/import-kubeconfig | ||
fi | ||
|
||
echo "Logging into Kube API server..." | ||
oc login --server=$CYPRESS_OC_CLUSTER_URL -u $CYPRESS_OC_CLUSTER_USER -p $CYPRESS_OC_CLUSTER_PASS --insecure-skip-tls-verify | ||
|
||
echo "Show nodes..." | ||
oc get nodes | ||
|
||
|
||
if [[ "$CLEAN_UP" == "true" ]]; then | ||
echo "Cleaning up test resources. Tests will not run." | ||
|
||
|
||
echo "Clean up done. Exiting." | ||
exit 0 | ||
fi | ||
|
||
|
||
#echo "Running tests on $CYPRESS_BASE_URL in $CYPRESS_TEST_MODE mode..." | ||
testCode=0 | ||
#npx cypress run --config-file "./cypress.json" --browser $BROWSER | ||
#testCode=$? | ||
|
||
#testDirectory="/results" | ||
|
||
if [ -d "$testDirectory" ]; then | ||
# move test results if $testDirectory exists. | ||
echo "Copying Mocha JSON and XML output to /results..." | ||
cp -r ./test-output/cypress/json/* /results | ||
cp -r ./test-output/cypress/xml/* /results | ||
|
||
echo "Copying outputed screenshots and videos to /results..." | ||
cp -r ./cypress/screenshots /results/screenshots | ||
cp -r ./cypress/videos /results/videos | ||
fi | ||
|
||
if [[ ! -z "$SLACK_TOKEN" ]]; then | ||
echo "Slack integration is configured; processing..." | ||
npm run test:slack | ||
fi | ||
|
||
exit $testCode |