Skip to content

Commit c602ce2

Browse files
committed
[_502] experimental test harness using containers
1 parent fd1ed6f commit c602ce2

29 files changed

Lines changed: 887 additions & 108 deletions

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: 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 /
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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 tar xf Python-${python_version}.tar.xz
8+
workdir /Python-${python_version}
9+
run ./configure --prefix /root/python --with-ensurepip=install
10+
run make -j
11+
run mkdir /root/python
12+
run make install
13+
workdir /
14+
run /root/python/bin/python3 -m pip install python-irodsclient
15+
run chmod a+rx /root

irods/test/harness/README.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 NO_CACHE='1' ./build-docker.sh [ ... optional in-directory dockerfiles in sequence ... ]
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+
For both scripts, the environment variable DOCKER may be set to "podman" to run the alternative virtualizer.
32+
33+
Demo / Demo hook / args
34+
------------------------
35+
36+
$ ~/python-irodsclient/irods/test/harness$ ./docker_container_driver.sh ../demo.sh
37+
ORIGINAL_SCRIPT_RELATIVE_TO_ROOT=[irods/test/demo.sh]
38+
image=[ssl-and-pam]
39+
.......-- HOOK RUNNING --
40+
/prc/irods/test/demo.sh running
41+
args:
42+
1: [arg1]
43+
2: [arg2]
44+
Killed: 1358fbff6eadac24f0915ffb414f0367deedc84b0c3e4de69a23bd3a8726298f
45+
daniel@prec3431:~/python-irodsclient/irods/test/harness$ echo $?
46+
118
47+

irods/test/harness/build-docker.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# environment variables for build
4+
# IRODS_PACKAGE_VERSION if defined is like "4.3.4" or "5.0.1".
5+
# (but contains no '~' suffix for irods versions <= 4.2.10)
6+
# PYTHON_VERSION is usually two dot-separated numbers: example "3.13", but could also have zero, one or three version numbers.
7+
# (Do not specify the triple form, X.Y.Z, if that release is not known to exist - not counting alphas and release candidates)
8+
9+
BASE=$(basename "$0")
10+
DIR=$(realpath "$(dirname "$0")")
11+
cd "$DIR"
12+
: ${DOCKER:=docker}
13+
if [ $# -gt 0 ]; then
14+
ARGS=("$@")
15+
else
16+
ARGS=([0-9]*.Dockerfile)
17+
fi
18+
for dockerfile in "${ARGS[@]}"; do
19+
image_name=${dockerfile#[0-9]*_}
20+
image_name=${image_name%.Dockerfile}
21+
irods_package_version_option=""
22+
python_version_option=""
23+
if [ "$image_name" = "install-irods" ]; then
24+
irods_package_version_option=${IRODS_PACKAGE_VERSION:+"--build-arg=irods_package_version=$IRODS_PACKAGE_VERSION"}
25+
elif [ "$image_name" = "compile-specific-python" ]; then
26+
temp=$(./most_recent_python.sh $PYTHON_VERSION)
27+
if [ -n "$temp" ]; then
28+
PYTHON_VERSION="$temp"
29+
fi
30+
python_version_option=${PYTHON_VERSION:+"--build-arg=python_version=$PYTHON_VERSION"}
31+
else
32+
package_version_option=""
33+
fi
34+
$DOCKER build -f $dockerfile -t $image_name . $irods_package_version_option $python_version_option \
35+
${NO_CACHE+"--no-cache"} ||
36+
{ STATUS=$?; echo "*** Failure while building [$image_name]"; exit $STATUS; }
37+
done

0 commit comments

Comments
 (0)