Skip to content

Commit b4f6592

Browse files
committed
[_502] experimental test harness using containers
testuser universal for all containers login_auth*.py adjustments [__502] scriptdir [__502] patch for consistency in starting document SKIP_IINIT_FOR_PASSWORD "funcs" include file renamed to "test_support_functions" remove fail.sh to scripts dir
1 parent 4818f65 commit b4f6592

27 files changed

+779
-108
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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 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: 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)