diff --git a/pipelines/e2e/Dockerfile.setup b/pipelines/e2e/Dockerfile.setup index 5fd0be7b8c..c877f0c35e 100644 --- a/pipelines/e2e/Dockerfile.setup +++ b/pipelines/e2e/Dockerfile.setup @@ -25,7 +25,7 @@ RUN wget -q https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_V wget -q "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" && \ mv yq_linux_amd64 /usr/local/bin/yq && \ chmod +x /usr/local/bin/yq && \ - apk add openssl openssh-client ca-certificates git rsync bash curl jq python3 py3-pip gcc python3-dev libc-dev py3-virtualenv && \ + apk add openssl openssh-client ca-certificates git rsync bash curl jq python3 py3-pip gcc python3-dev libc-dev py3-virtualenv docker && \ ssh-keygen -t rsa -b 4096 -N "" -f ~/.ssh/id_rsa && \ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && \ chmod 700 get_helm.sh && \ diff --git a/pipelines/e2e/Jenkinsfile b/pipelines/e2e/Jenkinsfile index 9335197801..051696b8c0 100644 --- a/pipelines/e2e/Jenkinsfile +++ b/pipelines/e2e/Jenkinsfile @@ -114,6 +114,9 @@ node { --env TF_VAR_registration_code=${REGISTRATION_CODE} \ --env TF_VAR_cis_hardening=${CIS_HARDENING} \ --env TF_VAR_resources_owner=longhorn-long-running \ + --env IMAGE_NAME=${imageName} \ + -v /var/run/docker.sock:/var/run/docker.sock \ + --mount source="vol-${imageName}",target=/tmp \ ${imageName} """ } @@ -170,6 +173,7 @@ node { sh "docker stop ${JOB_BASE_NAME}-${BUILD_NUMBER}" sh "docker rm -v ${JOB_BASE_NAME}-${BUILD_NUMBER}" sh "docker rmi ${imageName}" + sh "docker volume rm vol-${imageName}" } if (summary) { diff --git a/pipelines/e2e/scripts/longhorn-setup.sh b/pipelines/e2e/scripts/longhorn-setup.sh index bc0066b5a8..5be47957d3 100755 --- a/pipelines/e2e/scripts/longhorn-setup.sh +++ b/pipelines/e2e/scripts/longhorn-setup.sh @@ -53,11 +53,7 @@ main(){ setup_longhorn_ui_nodeport export_longhorn_ui_url - if [[ -n "${LONGHORN_TESTS_CUSTOM_IMAGE}" ]]; then - run_longhorn_e2e_test - else - run_longhorn_e2e_test_out_of_cluster - fi + run_longhorn_e2e_test_out_of_cluster } main diff --git a/pipelines/utilities/run_longhorn_e2e_test.sh b/pipelines/utilities/run_longhorn_e2e_test.sh index bc26e8168f..acc9dde371 100755 --- a/pipelines/utilities/run_longhorn_e2e_test.sh +++ b/pipelines/utilities/run_longhorn_e2e_test.sh @@ -65,14 +65,30 @@ run_longhorn_e2e_test(){ } run_longhorn_e2e_test_out_of_cluster(){ - cd e2e - python3 -m venv . - source bin/activate - pip install -r requirements.txt eval "ROBOT_COMMAND_ARGS=($PYTEST_CUSTOM_OPTIONS)" - ./run.sh "${ROBOT_COMMAND_ARGS[@]}" + if [[ -n ${LONGHORN_TESTS_CUSTOM_IMAGE} ]]; then + cat /tmp/instance_mapping + cp "${KUBECONFIG}" /tmp/kubeconfig + CONTAINER_NAME="e2e-container-${IMAGE_NAME}" + docker run --name "${CONTAINER_NAME}" \ + -e AWS_ACCESS_KEY_ID="${TF_VAR_lh_aws_access_key}" \ + -e AWS_SECRET_ACCESS_KEY="${TF_VAR_lh_aws_secret_key}" \ + -e AWS_DEFAULT_REGION="${TF_VAR_aws_region}" \ + -e LONGHORN_CLIENT_URL="${LONGHORN_CLIENT_URL}" \ + -e KUBECONFIG="/tmp/kubeconfig" \ + --mount source="vol-${IMAGE_NAME}",target=/tmp \ + "${LONGHORN_TESTS_CUSTOM_IMAGE}" "${ROBOT_COMMAND_ARGS[@]}" + docker stop "${CONTAINER_NAME}" + docker rm "${CONTAINER_NAME}" + else + cd e2e + python3 -m venv . + source bin/activate + pip install -r requirements.txt + ./run.sh "${ROBOT_COMMAND_ARGS[@]}" + fi cp /tmp/test-report/log.html "${WORKSPACE}/log.html" cp /tmp/test-report/output.xml "${WORKSPACE}/output.xml"