Skip to content

Commit a9c2d75

Browse files
committed
[_502] experimental test harness using containers
setupssl chgs -q [_502] fixes/enhancements to test harness (inclusive misc__ commits) misc__ pre: make irods install simpler, independent of other repos run the test script using exec (The docker run command initiates an iRODS startup process via CMD). now able to define the irods version to be installed. fix relative paths; sample BATS test setupssl changes pam and ssl setup funcs build target version of Python (will parameterize version later) refactor of test containers experiment.sh -- call setupssl.py in container tighter checking in driver/test-runner corrections enable ageing out pam pw (postgresql only) misc__: add/refine options - workdir etc options include dummy_script called from experiment.sh move to test-script-parameters more utility funcs directory name change misc__ post: update json files for test restore correction to update json funcs chmod +x login_auth_test.py failing/script-to-script call demo implement wrapping virtual env provide path to original script; allow args (testnames) delete script not used include overlooked ssl-and-pam Dockerfile wrap/args demo get rid of troublesome recursive symlink abspath for orig script; -t better for early docker versions username is now param for setting up pam with iinit setup conditions properly for tests adjustments to keys. arglist is now affected by symlink basename of argument if any. changes to login_auth test changes for login_auth_test nr 2 allow different irods versions include symlink change to test script params only separate container run for env-modifying test test001 working include the other symlink In testing don't depend on strong primes for DH param generation. 362-test-harness setupssl-q-nr2
1 parent c238d9b commit a9c2d75

28 files changed

+768
-109
lines changed

irods/test/demo.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
echo "$0 running"
4+
echo args:
5+
for arg in $*; do
6+
echo $((++x)): "[$arg]"
7+
done
8+
9+
exit 118

irods/test/demo_A.sh

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

irods/test/demo_B.sh

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

irods/test/demo_hook.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo "-- HOOK RUNNING --"
3+
command "/prc/$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT" $*
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ubuntu:18.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 /
10+
RUN useradd -ms/bin/bash user
11+
RUN apt install -y faketime
12+
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM bats-python3
2+
RUN apt install -y sudo
3+
RUN useradd -ms/bin/bash testuser
4+
RUN echo 'testuser ALL=(ALL) NOPASSWD: ALL' >>/etc/sudoers
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from install-irods
2+
run apt update
3+
run apt install -y wget build-essential libssl-dev zlib1g-dev
4+
run apt install wget build-essential
5+
run wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz
6+
run tar xf Python-3.12.2.tar.xz
7+
workdir /Python-3.12.2
8+
run ./configure --prefix /root/python --with-ensurepip=install
9+
run make -j
10+
run mkdir /root/python
11+
run make install
12+
workdir /
13+
run /root/python/bin/python3 -m pip install python-irodsclient
14+
run chmod a+rx /root

irods/test/harness/README.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
SAMPLE RUNS
2+
3+
To build required images
4+
------------------------
5+
Examples
6+
7+
1) ./build-docker.sh
8+
DEFAULT: build single-node system based on latest iRODS release
9+
10+
2) IRODS_PACKAGE_VERSION="4.2.12-1~bionic" NO_CACHE='1' ./build-docker.sh
11+
Build (ignoring docker cache) single-node system based on specified package version string.
12+
13+
simple examples
14+
---------------
15+
./docker_container_driver.sh tests/test_1.sh
16+
./docker_container_driver.sh tests/test_2.sh
17+
18+
Any script in a subdirectory of the repo (mounted at /prc within the container) can be
19+
executed and will be able to find other scripts and source include files within the tree.
20+
[See "experiment.sh" example below.]
21+
22+
Examples of options in driver script
23+
------------------------------------
24+
25+
1. To start container and run test script:
26+
C=$( ./docker_container_driver.sh -c -L -u testuser ../scripts/experiment.sh )
27+
28+
2. To manually examine results afterward:
29+
docker exec -it $C bash
30+
31+
32+
Demo / Demo hook / args
33+
------------------------
34+
35+
$ ~/python-irodsclient/irods/test/harness$ ./docker_container_driver.sh ../demo.sh
36+
ORIGINAL_SCRIPT_RELATIVE_TO_ROOT=[irods/test/demo.sh]
37+
image=[ssl-and-pam]
38+
.......-- HOOK RUNNING --
39+
/prc/irods/test/demo.sh running
40+
args:
41+
1: [arg1]
42+
2: [arg2]
43+
Killed: 1358fbff6eadac24f0915ffb414f0367deedc84b0c3e4de69a23bd3a8726298f
44+
daniel@prec3431:~/python-irodsclient/irods/test/harness$ echo $?
45+
118
46+

irods/test/harness/build-docker.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
# IRODS_PACKAGE_VERSION if defined is like "4.3.1-0~bionic"
4+
# (but contains no '~' suffix for irods versions <= 4.2.10)
5+
6+
BASE=$(basename "$0")
7+
DIR=$(realpath "$(dirname "$0")")
8+
cd "$DIR"
9+
DOCKER=docker
10+
for dockerfile in [0-9]*.Dockerfile; do
11+
image_name=${dockerfile#[0-9]*_}
12+
image_name=${image_name%.Dockerfile}
13+
if [ "$image_name" = "install-irods" ];then
14+
package_version_option=${IRODS_PACKAGE_VERSION:+"--build-arg=irods_package_version=$IRODS_PACKAGE_VERSION"}
15+
else
16+
package_version_option=""
17+
fi
18+
$DOCKER build -f $dockerfile -t $image_name . $package_version_option \
19+
${NO_CACHE+"--no-cache"} ||
20+
{ STATUS=$?; echo "*** Failure while building [$image_name]"; exit $STATUS; }
21+
done

0 commit comments

Comments
 (0)