Skip to content

Commit d5de89b

Browse files
d-w-moorealanking
authored andcommitted
[#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, also included with the Github workflows 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 c1266a5 commit d5de89b

Some content is hidden

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

42 files changed

+1532
-235
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Run a set of tests, each in its own container and with a potentially customized setup.
2+
3+
# To this end, each test is launched via docker_container_driver.sh, part of the single-node
4+
# test harness machinery whose implementation and documentation is to be found in the
5+
# `irods/test/harness` directory.
6+
7+
# A test may be written as a Bash or BATS script, but the only real requirement is that it be
8+
# executable.
9+
10+
name: run-test-programs-single-node
11+
12+
on: [push, pull_request]
13+
14+
jobs:
15+
tests:
16+
name: Python ${{ matrix.python }}, iRODS ${{ matrix.irods_server }}
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: ./test_harness/single_node
21+
strategy:
22+
matrix:
23+
python: ['3.9','3.13']
24+
irods_server: ['4.3.4','5.0.2']
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Build images
31+
run: ./create_docker_images.sh "${{ matrix.irods_server }}" "${{ matrix.python }}"
32+
33+
- name: run tests
34+
run: |
35+
for script in \
36+
../../irods/test/scripts/test[0-9]* \
37+
../../irods/test/login_auth_test_*.py
38+
do
39+
./docker_container_driver.sh -V $script
40+
done
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Run the client test suite in a Docker container, targeting a locally running instance of the iRODS server.
2+
# (Documentation and implementation for the test harness may be found in `irods/test/harness`.)
3+
4+
name: run-test-suite-single-node
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
tests:
10+
name: Python ${{ matrix.python }}, iRODS ${{ matrix.irods_server }}
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
working-directory: ./test_harness/single_node
15+
strategy:
16+
matrix:
17+
python: ['3.9','3.13']
18+
irods_server: ['4.3.4','5.0.2']
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Build images
25+
run: ./create_docker_images.sh "${{ matrix.irods_server }}" "${{ matrix.python }}"
26+
27+
- name: run tests
28+
run: |
29+
./docker_container_driver.sh -V ../../irods/test/scripts/run_suite_locally.sh

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)

irods/test/login_auth_test.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
. "$(dirname "$0")/scripts/test_support_functions"
3+
. "$(dirname "$0")/scripts/update_json_for_test"
4+
5+
IRODS_SERVER_CONFIG=/etc/irods/server_config.json
6+
IRODS_SERVICE_ACCOUNT_ENV_FILE=~irods/.irods/irods_environment.json
7+
LOCAL_ACCOUNT_ENV_FILE=~/.irods/irods_environment.json
8+
9+
cannot_iinit=''
10+
tries=8
11+
while true; do
12+
iinit_as_rods >/dev/null 2>&1 && break
13+
[ $((--tries)) -le 0 ] && {
14+
cannot_iinit=1
15+
break
16+
}
17+
sleep 5
18+
done
19+
[ -n "$cannot_iinit" ] && {
20+
echo >&2 "Could not iinit as rods."
21+
exit 2
22+
}
23+
24+
setup_preconnect_preference DONT_CARE
25+
26+
add_irods_to_system_pam_configuration
27+
28+
# set up /etc/irods/ssl directory and files
29+
set_up_ssl sudo
30+
31+
sudo useradd -ms/bin/bash alissa
32+
sudo chpasswd <<<"alissa:test123"
33+
34+
update_json_file $IRODS_SERVICE_ACCOUNT_ENV_FILE \
35+
"$(newcontent $IRODS_SERVICE_ACCOUNT_ENV_FILE ssl_keys)"
36+
37+
# This is mostly so we can call python3 as just "python"
38+
activate_virtual_env_with_prc_installed >/dev/null 2>&1 || {
39+
echo >&2 "couldn't set up virtual environment"
40+
exit 1
41+
}
42+
43+
server_hup=
44+
if irods_server_version ge 5.0.0; then
45+
server_hup="y"
46+
update_json_file $IRODS_SERVER_CONFIG \
47+
"$(newcontent $IRODS_SERVER_CONFIG tls_server_items tls_client_items)"
48+
49+
sudo su - irods -c "$IRODS_CONTROL_PATH/manage_irods5_procs rescan-config"
50+
fi
51+
52+
# Configure clients with admin user + TLS
53+
54+
update_json_file $LOCAL_ACCOUNT_ENV_FILE \
55+
"$(newcontent $LOCAL_ACCOUNT_ENV_FILE ssl_keys encrypt_keys)"
56+
57+
update_time=0
58+
# We won't time out, however we will warn for each minute the server
59+
# has not returned to readiness.
60+
if [ "$server_hup" = "y" ]; then
61+
# wait for server to be ready after configuration reload
62+
while true; do
63+
sleep 2
64+
if ils >/dev/null 2>&1; then
65+
break
66+
else
67+
now=$(date +%s)
68+
if [ $now -ge $((update_time + 60)) ]; then
69+
echo >&2 "At [$(date)] ... still waiting on server reload"
70+
update_time=$now
71+
fi
72+
fi
73+
done
74+
fi
75+
76+
if [ -n "$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT" ]; then
77+
original_script="/prc/$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT"
78+
79+
# Run tests.
80+
if [ -x "$original_script" ]; then
81+
command "$original_script" $*
82+
elif [[ $original_script =~ \.py$ ]]; then
83+
python "$original_script" $*
84+
elif [[ $original_script =~ \.bats$ ]]; then
85+
bats "$original_script"
86+
else
87+
echo >&2 "I don't know how to run this: original_script=[$original_script]"
88+
fi
89+
90+
fi

irods/test/login_auth_test_1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
login_auth_test_must_run_manually.py

irods/test/login_auth_test_2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
login_auth_test_must_run_manually.py

0 commit comments

Comments
 (0)