Skip to content

Commit c745356

Browse files
dbasunagclaude
andauthored
fix: create a script to make the make target cleaner (#1711)
* fix: create a script to make the make target cleaner Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com> Co-Authored-By: Claude <noreply@anthropic.com> * fix: address review comments Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com> * fix: mismatch in naming the make targets Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com> --------- Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent e382102 commit c745356

3 files changed

Lines changed: 58 additions & 22 deletions

File tree

Dockerfile.testops

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,25 @@ RUN ARCH="${TARGETARCH:-amd64}" && \
3131
echo "$(<kubectl.sha256) kubectl" | sha256sum -c - && \
3232
install -m 0755 kubectl /usr/local/bin/ && rm -f kubectl kubectl.sha256
3333

34-
# Install poetry and pytest
35-
RUN pip install --no-cache-dir poetry pytest
36-
3734
# Give write permissions to all copied folders and change ownership to odh user
3835
RUN chown -R odh:odh /home/odh && \
3936
chmod -R 755 api/ manifests/ scripts/
37+
# Install poetry and pytest (as root, into the app-root virtualenv)
38+
RUN pip install --no-cache-dir poetry pytest
39+
4040
RUN chown -R odh:odh /opt/app-root/src/
41+
42+
# Disable the base image's auto-activation of /opt/app-root virtualenv so
43+
# Poetry creates its own in-project .venv instead of installing into root-owned dirs
44+
ENV VIRTUAL_ENV="" \
45+
BASH_ENV="" \
46+
ENV="" \
47+
PROMPT_COMMAND="" \
48+
POETRY_VIRTUALENVS_IN_PROJECT=true
49+
4150
# Switch to odh user
4251
USER odh
4352

44-
# Add user's pip bin to PATH
4553
ENV PATH="/home/odh/.local/bin:$PATH"
4654

4755
# Set entrypoint to make command

jobs/async-upload/odh_rules.mk

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,24 @@ deploy-mr-odh:
66
undeploy-mr-odh:
77
cd ../../ && ./scripts/undeploy_on_odh.sh
88

9-
.PHONY: test-e2e-odh
10-
test-e2e-odh: deploy-mr-odh deploy-local-registry deploy-test-minio
11-
@echo "Running e2e tests..."
12-
@set -a; . ../../scripts/manifests/minio/.env; set +a; \
9+
.PHONY: test-e2e-odh-async-jobs
10+
test-e2e-odh-async-jobs: deploy-mr-odh deploy-local-registry deploy-test-minio
11+
@echo "Running Async Jobs e2e tests..."
12+
@( \
13+
trap 'rm -f ../../scripts/manifests/minio/.env' EXIT; \
14+
set -a; . ../../scripts/manifests/minio/.env; set +a; \
1315
mkdir -p ../../results; \
14-
export AUTH_TOKEN=$$(kubectl config view --raw -o jsonpath="{.users[?(@.name==\"$$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"$$(kubectl config current-context)\")].context.user}")\")].user.token}") && \
15-
export VERIFY_SSL=False && \
16-
export MR_NAMESPACE=$$(kubectl get datasciencecluster default-dsc -o jsonpath='{.spec.components.modelregistry.registriesNamespace}') && \
17-
export MR_HOST_URL="https://$$(kubectl get service -n "$$MR_NAMESPACE" model-registry -o jsonpath='{.metadata.annotations.routing\.opendatahub\.io\/external-address-rest}')" && \
18-
export MR_ENDPOINT=$$(kubectl get service -n "$$MR_NAMESPACE" model-registry -o jsonpath='{.metadata.annotations.routing\.opendatahub\.io\/external-address-rest}' | cut -d: -f1) && \
19-
export MODEL_SYNC_REGISTRY_SERVER_ADDRESS="https://$$MR_ENDPOINT" && \
20-
export MODEL_SYNC_REGISTRY_PORT="443" && \
21-
export MODEL_SYNC_REGISTRY_IS_SECURE="false" && \
22-
export MODEL_SYNC_REGISTRY_USER_TOKEN="$$AUTH_TOKEN" && \
23-
export CONTAINER_IMAGE_URI=$$(../../scripts/get_async_upload_image.sh) && \
24-
poetry install --all-extras --with integration && poetry run pytest --e2e tests/integration/ -svvv -rA --html=../../results/report.html --junit-xml=../../results/xunit_report.xml --self-contained-html -o junit_suite_name=odh-async-upload && \
25-
rm -f ../../scripts/manifests/minio/.env
16+
. ../../scripts/odh_env.sh && \
17+
poetry install --all-extras --with integration && \
18+
poetry run pytest --e2e tests/integration/ -svvv -rA \
19+
--html=../../results/report.html \
20+
--junit-xml=../../results/xunit_report.xml \
21+
--self-contained-html \
22+
-o junit_suite_name=odh-async-upload \
23+
)
2624

27-
.PHONY: test-e2e-port-cleanup
28-
test-e2e-odh-cleanup: undeploy-mr-odh undeploy-minio undeploy-local-kind-registry
25+
.PHONY: test-e2e-odh-async-jobs-cleanup
26+
test-e2e-odh-async-jobs-cleanup: undeploy-mr-odh undeploy-minio undeploy-local-kind-registry
2927
@echo "Cleaning up port-forward processes..."
3028
@if [ -f .port-forwards.pid ]; then \
3129
kill $$(cat .port-forwards.pid) || true; \

scripts/odh_env.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Common ODH environment variables for test targets.
2+
# Usage: . scripts/odh_env.sh
3+
#
4+
# Exported variables:
5+
# AUTH_TOKEN, VERIFY_SSL, MR_NAMESPACE, MR_HOST_URL, MR_ENDPOINT,
6+
# MODEL_SYNC_REGISTRY_SERVER_ADDRESS, MODEL_SYNC_REGISTRY_PORT,
7+
# MODEL_SYNC_REGISTRY_IS_SECURE, MODEL_SYNC_REGISTRY_USER_TOKEN,
8+
# CONTAINER_IMAGE_URI
9+
10+
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
11+
12+
AUTH_TOKEN=$(kubectl config view --raw -o jsonpath="{.users[?(@.name==\"$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"$(kubectl config current-context)\")].context.user}")\")].user.token}")
13+
export AUTH_TOKEN
14+
15+
export VERIFY_SSL=False
16+
17+
MR_NAMESPACE=$(kubectl get datasciencecluster default-dsc -o jsonpath='{.spec.components.modelregistry.registriesNamespace}')
18+
export MR_NAMESPACE
19+
20+
MR_ENDPOINT=$(kubectl get service -n "${MR_NAMESPACE}" model-registry -o jsonpath='{.metadata.annotations.routing\.opendatahub\.io\/external-address-rest}')
21+
export MR_HOST_URL="https://${MR_ENDPOINT}"
22+
MR_ENDPOINT="${MR_ENDPOINT%%:*}"
23+
export MR_ENDPOINT
24+
25+
export MODEL_SYNC_REGISTRY_SERVER_ADDRESS="https://${MR_ENDPOINT}"
26+
export MODEL_SYNC_REGISTRY_PORT="443"
27+
export MODEL_SYNC_REGISTRY_IS_SECURE="false"
28+
export MODEL_SYNC_REGISTRY_USER_TOKEN="${AUTH_TOKEN}"
29+
CONTAINER_IMAGE_URI=$("${SCRIPT_DIR}/get_async_upload_image.sh")
30+
export CONTAINER_IMAGE_URI

0 commit comments

Comments
 (0)