Skip to content

Commit ff808aa

Browse files
committed
[_502] test harness and container-based tests
A new test harness is introduced in which we construct a new container (using either Docker or podman) for each test program we run. This allows full customization of the container environment for the particular needs of each test. Accordingly, included with the Github workflows (in a separate commit) is a full run of the PRC test suite with the iRODS server and catalog DB server running in the same container as the client. In the process of putting old tests through new rigors, faults were found and corrected in some of those tests.
1 parent f59678c commit ff808aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1303
-221
lines changed

Dockerfile.prc_test.centos

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ RUN python${py_N} repo/docker_build/iinit.py \
2424
password rods
2525
SHELL ["/bin/bash","-c"]
2626
CMD echo "Waiting on iRODS server... " ; \
27-
python${PY_N} repo/docker_build/recv_oneshot -h irods-provider -p 8888 -t 360 && \
2827
sudo groupadd -o -g $(stat -c%g /irods_shared) irods && sudo usermod -aG irods user && \
2928
newgrp irods < repo/run_python_tests.sh

Dockerfile.prc_test.ubuntu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,5 @@ SHELL ["/bin/bash","-c"]
3131
# 3. run python tests as the new group
3232

3333
CMD echo "Waiting on iRODS server... " ; \
34-
python${PY_N} repo/docker_build/recv_oneshot -h irods-provider -p 8888 -t 360 && \
3534
sudo groupadd -o -g $(stat -c%g /irods_shared) irods && sudo usermod -aG irods user && \
3635
newgrp irods < repo/run_python_tests.sh

irods/message/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def ET(xml_type=(), server_version=None):
181181

182182
logger = logging.getLogger(__name__)
183183

184-
IRODS_VERSION = (5, 0, 1, "d")
184+
IRODS_VERSION = (5, 0, 2, "d")
185185

186186
UNICODE = str
187187

irods/test/access_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,7 @@ def test_iRODSAccess_cannot_be_constructed_using_unsupported_type__issue_558(sel
533533
# Before the fix in #558, this would have been allowed and only later would the type discrepancy be revealed,
534534
# leading to opaque error messages. Now, the types are checked on the way in to ensure clarity and correctness.
535535
# TODO(#480): We cannot use the unittest.assertRaises context manager as this was introduced in python 3.1.
536-
assertCall = getattr(self, "assertRaisesRegex", None)
537-
if assertCall is None:
538-
assertCall = self.assertRaisesRegexp
539-
540-
assertCall(
536+
self.assertRaisesRegex(
541537
TypeError,
542538
"'path' parameter must be of type 'str', 'irods.collection.iRODSCollection', "
543539
"'irods.data_object.iRODSDataObject', or 'irods.path.iRODSPath'.",

irods/test/exception_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def test_400(self):
4141
excep_repr = repr(exc)
4242
errno_object = irods.exception.Errno(errno.EACCES)
4343
errno_repr = repr(errno_object)
44-
self.assertRegexpMatches(errno_repr, r"\bErrno\b")
45-
self.assertRegexpMatches(
44+
self.assertRegex(errno_repr, r"\bErrno\b")
45+
self.assertRegex(
4646
errno_repr, """['"]{msg}['"]""".format(msg=os.strerror(errno.EACCES))
4747
)
4848
self.assertIn(errno_repr, excep_repr)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM ubuntu:22.04
2+
COPY install.sh /
3+
ARG irods_package_version
4+
ENV IRODS_PACKAGE_VERSION "$irods_package_version"
5+
RUN for phase in initialize install-essential-packages add-package-repo; do \
6+
bash /install.sh --w=$phase 0; \
7+
done
8+
RUN /install.sh 4
9+
COPY start_postgresql_and_irods.sh manage_irods5_procs /
10+
RUN apt install -y sudo
11+
RUN useradd -ms/bin/bash testuser
12+
RUN echo 'testuser ALL=(ALL) NOPASSWD: ALL' >>/etc/sudoers
13+
RUN apt install -y faketime
14+
CMD bash /start_postgresql_and_irods.sh
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM install-irods
2+
RUN apt update; apt install -y python3-pip bats
3+
RUN python3 -m pip install --upgrade pip
4+
RUN python3 -m pip install virtualenv
5+
RUN python3 -m virtualenv /py3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM bats-python3
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM ssl-and-pam
2+
RUN apt update
3+
RUN apt install -y wget build-essential
4+
RUN apt install -y libssl-dev zlib1g-dev libffi-dev libncurses-dev wget build-essential
5+
ARG python_version
6+
RUN wget https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tar.xz
7+
RUN touch /tmp/aaaaaaaaaa # dummmy change
8+
RUN tar xf Python-${python_version}.tar.xz
9+
WORKDIR /Python-${python_version}
10+
RUN ./configure --prefix /root/python --with-ensurepip=install
11+
RUN make -j
12+
RUN mkdir /root/python
13+
RUN make install
14+
WORKDIR /
15+
RUN /root/python/bin/python3 -m pip install virtualenv
16+
RUN chmod a+rx /root
17+
ENV PYTHON_VERSION=${python_version}

irods/test/harness/README.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
DOCKER POWERED TEST HARNESS
2+
3+
a. DESCRIPTION
4+
5+
A series of docker images which support running isolated test scripts (using BATS, bash, or Python).
6+
Once built, the images allow loading and customizing the Docker container environment for a given
7+
test script.
8+
9+
The general form for test invocation is: docker_container_driver.sh <path_to_script_on_host>
10+
11+
Within the container, a computed internal path to the same script is executed, whether directly or
12+
indirectly by a wrapper script. The wrapper for many of the PRC authentication-via-PAM tests is
13+
irods/test/login_auth_test.sh.
14+
15+
The test_script_parameters file, located in the irods/test/harness directory, contains customized
16+
settings for each test script run, including:
17+
18+
- Docker image name to be used.
19+
20+
- Wrapper to be invoked, if any. Wrappers shall perform common setup tasks up to and including
21+
invoking the test script itself.
22+
23+
- Which user is running the test. (Unless otherwise specified, this is the passwordless-sudo-
24+
enabled user 'testuser').
25+
26+
When done with a test, the docker_container_driver.sh exit code mirrors the return code from the
27+
run of the test script. The container itself is removed unless the -L ("leak") option is given.
28+
29+
b. SAMPLE RUNS
30+
31+
To build required images
32+
------------------------
33+
For our convenience in this doc, set a shell variable REPOROOT to ~/python-irodsclient (or
34+
similar) to specify the path to the top level of the local repository.
35+
36+
Sample command lines to build Docker images:
37+
38+
1) cd $REPO_ROOT/irods/test/harness
39+
./build_docker.sh
40+
41+
Builds docker images in proper sequence.
42+
43+
2) cd $REPO_ROOT/irods/test/harness;
44+
IRODS_PACKAGE_VERSION=4.3.4 PYTHON_VERSION=3.11 NO_CACHE=1 ./build-docker.sh [ Dockerfiles... ]
45+
46+
Builds (ignoring docker cache) images based on specific iRODS package version and desired
47+
Python Interpreter version, optionally with a restricted list of Docker files in need of rebulding.
48+
49+
Sample command lines to run a test script.
50+
51+
$REPO_ROOT/irods/test/harness/docker_container_driver.sh $REPO_ROOT/irods/test/scripts/run_local_suite
52+
53+
For both builder and driver script, the environment variable DOCKER may be set to "podman" to run
54+
the alternative container engine. It will otherwise default to a value of "docker".
55+
56+

0 commit comments

Comments
 (0)