Skip to content

Commit 1c92fc6

Browse files
authored
[CI] Run tests from trustyai-tests (#279)
* Change Dockerfile to clone trustyai-tests * Add PYTEST_MARKERS env and remove TESTS_REGEX
1 parent 4458d0d commit 1c92fc6

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

tests/Dockerfile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
FROM registry.access.redhat.com/ubi8:8.10-1020
2-
32
ARG ORG=trustyai-explainability
43
ARG BRANCH=main
54
ARG ODS_CI_REPO=https://github.com/red-hat-data-services/ods-ci
6-
# This git reference should always reference a stable commit from ods-ci that supports ODH
7-
# This hash corresponds to a March 24th, 2023 commit
8-
ARG ODS_CI_GITREF=a8cf770b37caa4ef7ce6596acc8bdd6866cc7772
95
ARG OC_CLI_URL=https://mirror.openshift.com/pub/openshift-v4/amd64/clients/ocp/4.14.33/openshift-client-linux.tar.gz
106

117
ENV HOME /root
@@ -36,18 +32,19 @@ COPY Pipfile Pipfile.lock $HOME/peak/
3632
## Grab CI scripts from single-source-of-truth
3733
RUN mkdir -p $HOME/peak/operator-tests/trustyai-explainability/ &&\
3834
mkdir $HOME/kfdef/ &&\
39-
cp -r $HOME/src/trustyai-explainability/tests/resources/ $HOME/peak/operator-tests/trustyai-explainability/resources &&\
40-
cp $HOME/src/trustyai-explainability/tests/util $HOME/peak/operator-tests/trustyai-explainability &&\
41-
cp -r $HOME/src/trustyai-explainability/tests/basictests $HOME/peak/operator-tests/trustyai-explainability/basictests &&\
4235
cp -r $HOME/src/trustyai-explainability/tests/setup/odh-*.yaml $HOME/kfdef/ &&\
4336
cp -r $HOME/src/trustyai-explainability/tests/setup/*setup $HOME/peak/ &&\
4437
cp -r $HOME/src/trustyai-explainability/tests/scripts/installandtest.sh $HOME/peak/
4538

39+
# Install poetry to support the exeuction of trustyai-tests
40+
RUN curl -sSL https://install.python-poetry.org | python3 -
41+
ENV PATH="${PATH}:$HOME/.local/bin"
42+
RUN cd $HOME/peak && \
43+
git clone https://github.com/trustyai-explainability/trustyai-tests.git && \
44+
cd trustyai-tests && \
45+
poetry install
46+
4647
COPY scripts/install.sh $HOME/peak/
47-
#COPY resources $HOME/peak/operator-tests/trustyai-explainability/resources
48-
#COPY util $HOME/peak/operator-tests/trustyai-explainability
49-
#COPY setup/odh-core.yaml $HOME/kfdef/
50-
#COPY basictests $HOME/peak/operator-tests/trustyai-explainability/basictests
5148

5249
RUN chmod -R 777 $HOME/kfdef && \
5350
mkdir -p $HOME/.kube && \

tests/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ OPENSHIFT_TESTUSER_PASS=
1515
OPENSHIFT_TESTUSER_LOGIN_PROVIDER=
1616
# Setting SKIP_INSTALL will let you run the tests against an ODH instance that is already setup
1717
SKIP_INSTALL=
18-
# Setting TESTS_REGEX will allow you to change which tests are going to be run
19-
TESTS_REGEX=
18+
# Pytest markers to select the tests that will be executed
19+
PYTEST_MARKERS=
2020
# Location inside the container where CI system will retrieve files after a test run
2121
ARTIFACT_DIR=/tmp/artifacts
2222
LOCAL_ARTIFACT_DIR="${PWD}/artifacts"
@@ -25,17 +25,19 @@ BUILD_TOOL?=podman
2525
NO_CACHE?=false
2626
LOCAL?=false
2727
TEARDOWN?=false
28+
PLATFORM?=linux/amd64
29+
2830

2931
all: test
3032
test: build run clean
3133

3234
build:
33-
${BUILD_TOOL} build -t $(IMAGE) --build-arg ORG=$(GIT_ORG) --build-arg BRANCH=$(GIT_BRANCH) --build-arg ODS_CI_REPO=$(ODS_CI_REPO) --build-arg ODS_CI_GITREF=$(ODS_CI_GITREF) --build-arg OC_CLI_URL=$(OC_CLI_URL) .
35+
${BUILD_TOOL} build -t $(IMAGE) --build-arg ORG=$(GIT_ORG) --build-arg BRANCH=$(GIT_BRANCH) --build-arg ODS_CI_REPO=$(ODS_CI_REPO) --build-arg ODS_CI_GITREF=$(ODS_CI_GITREF) --build-arg OC_CLI_URL=$(OC_CLI_URL) --platform=$(PLATFORM) . --progress=plain
3436
run:
3537
# Confirm that we have a directory for storing any screenshots from selenium tests
3638
mkdir -p ${LOCAL_ARTIFACT_DIR}/screenshots
3739
oc config view --flatten --minify > /tmp/tests-kubeconfig
38-
${BUILD_TOOL} run -e SKIP_INSTALL=$(SKIP_INSTALL) -e TESTS_REGEX=$(TESTS_REGEX) -e SKIP_OPERATOR_INSTALL=$(SKIP_OPERATOR_INSTALL) \
40+
${BUILD_TOOL} run -e SKIP_INSTALL=$(SKIP_INSTALL) -e PYTEST_MARKERS=$(PYTEST_MARKERS) -e SKIP_OPERATOR_INSTALL=$(SKIP_OPERATOR_INSTALL) \
3941
-e SKIP_KFDEF_INSTALL=$(SKIP_KFDEF_INSTALL) -e ODHPROJECT=$(ODHPROJECT) \
4042
-e OPENSHIFT_TESTUSER_NAME="$(OPENSHIFT_TESTUSER_NAME)" -e OPENSHIFT_TESTUSER_PASS="$(OPENSHIFT_TESTUSER_PASS)" -e OPENSHIFT_TESTUSER_LOGIN_PROVIDER=$(OPENSHIFT_TESTUSER_LOGIN_PROVIDER) -e ARTIFACT_DIR=$(ARTIFACT_DIR) \
4143
-e LOCAL=$(LOCAL) -e TEARDOWN=$(TEARDOWN)\

tests/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ make clean # remove the artifacts of the test from the cluster (operator, ODH, p
2424
* `BUILD_TOOL=docker/podman`: set the tool used to build and run the testing container
2525
* `SKIP_INSTALL=true/false`: skip the install of the ODH operator, if you've already installed it manually or via a previous test
2626
* `SKIP_KFDEF_INSTALL=true/false`: skip the install of ODH via KFdef, if you've already installed it manually or via a previous test
27-
* `TESTS_REGEX=${REGEX}`: only run tests whose names match the regex
27+
* `PYTEST_MARKERS`: Used to select the tests that will be executed. [Available markers](https://github.com/trustyai-explainability/trustyai-tests/blob/main/pyproject.toml).
2828
* `LOCAL=true/false`: This flag makes the test suite stop and wait for user input between the end of a test script and cluster teardown. This prevents automatic teardown, which is useful for manual inspection of the cluster before teardown when running the tests locally.
2929
* `TEARDOWN=true/false`: This flag will just run the corresponding `teardown` functions within the various tests, useful for cleaning up stranded components from failed tests, without deleting the operator and ODH install. It's recommended to use this with a `make run`, as using `make test` will trigger a `make clean` that fully wipes the cluster.
3030

@@ -47,10 +47,6 @@ If you'd like to run the tests against an instance that already has a KfDef crea
4747
you set `SKIP_KFDEF_INSTALL=true` and that will cause the test run
4848
to skip the step of creating the default KfDef. example: `make run SKIP_KFDEF_INSTALL=true`
4949

50-
If you'd like to run a single test instead of all tests, you can
51-
set the TESTS_REGEX variable `TESTS_REGEX=<name of the test to run>`. That will
52-
only run the test that you specify instead of all of the tests. example: `make run TESTS_REGEX=grafana`
53-
5450
If you have a local instance already running the operator and you'd like to skip that part
5551
of the install process, you can set `SKIP_OPERATOR_INSTALL=true` and that will bypass installation
5652
of the operator, but will still install the authentication for any user tests.

0 commit comments

Comments
 (0)