Skip to content

Commit b1756d7

Browse files
committed
[_502] experimental test harness using containers
1 parent 41a86ca commit b1756d7

9 files changed

Lines changed: 92 additions & 0 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ARG linux_vsn="ubuntu:18.04"
2+
FROM ${linux_vsn}
3+
ARG irods_vsn="4.3.1-0~bionic"
4+
5+
ARG createdb=""
6+
ENV ICAT_DEFERRED_CREATEDB /tmp/icat_deferred_createdb
7+
8+
RUN apt update
9+
RUN apt install -y sudo git
10+
WORKDIR /root
11+
RUN git clone http://github.com/d-w-moore/ubuntu_irods_installer
12+
RUN if [ -n "${createdb}" ]; then \
13+
/root/ubuntu_irods_installer/install.sh --w="config-essentials create-db" 0 ;\
14+
else \
15+
/root/ubuntu_irods_installer/install.sh --w="config-essentials" 0 ;\
16+
touch "${ICAT_DEFERRED_CREATEDB}" ;\
17+
fi
18+
RUN /root/ubuntu_irods_installer/install.sh --w="add-package-repo" 0
19+
RUN /root/ubuntu_irods_installer/install.sh --i=${irods_vsn} -r 4
20+
# --- set up script for command line iRODS install ---
21+
22+
COPY start_postgresql_and_irods.sh /
23+
RUN chmod +x /start_postgresql_and_irods.sh
24+
RUN apt update && apt install vim iputils-ping -y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from install-irods
2+
run apt update; apt install -y python3 bats

irods/test/harness/README.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
./build-docker.sh
2+
./docker_container_driver.sh tests/test_1.sh
3+
./docker_container_driver.sh tests/test_2.sh

irods/test/harness/build-docker.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
#IRODS_VERSION="4.3.1-0~bionic"
4+
5+
BASE=$(basename "$0")
6+
DIR=$(realpath "$(dirname "$0")")
7+
cd "$DIR"
8+
DOCKER=docker
9+
for dockerfile in [0-9]*.Dockerfile; do
10+
image_name=${dockerfile#[0-9]*_}
11+
image_name=${image_name%.Dockerfile}
12+
$DOCKER build -f $dockerfile -t $image_name . || exit
13+
done
14+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
DIR=$(dirname $0)
3+
cd $DIR
4+
testscript=${1}
5+
declare -A images=(
6+
[test_1.sh]=install-irods
7+
[test_2.sh]=bats-python3
8+
)
9+
image=${images[$(basename $testscript)]}
10+
reporoot=$(realpath ./tests/repo)
11+
#--------------
12+
INNER_MOUNT=/prc
13+
docker run \
14+
-v $reporoot:$INNER_MOUNT:ro \
15+
--rm \
16+
$image \
17+
$INNER_MOUNT/$(realpath --relative-to $reporoot $testscript)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
service postgresql start
3+
x=${DB_WAIT_SEC:-20}
4+
while [ $x -ge 0 ] && { ! $SUDO su - postgres -c "psql -c '\l' >/dev/null 2>&1" || x=""; }
5+
do
6+
[ -z "$x" ] && break
7+
echo >&2 "$((x--)) secs til database timeout"; sleep 1
8+
done
9+
[ -z "$x" ] || { echo >&2 "Error -- database didn't start" ; exit 1; }
10+
if ! id -u irods >/dev/null 2>&1 ; then
11+
if [ -f "${ICAT_DEFERRED_CREATEDB}" ] ; then
12+
~/ubuntu_irods_installer/install.sh --w=create-db 0
13+
rm -f "${ICAT_DEFERRED_CREATEDB}"
14+
fi
15+
VERSION_file=$(ls /var/lib/irods/{VERSION,version}.json.dist 2>/dev/null)
16+
IRODS_VSN=$(jq -r '.irods_version' $VERSION_file) ~/ubuntu_irods_installer/install.sh 5
17+
else
18+
su - irods -c '~/irodsctl start'
19+
fi

irods/test/harness/tests/repo

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

irods/test/harness/tests/test_1.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
run() {
3+
echo dir of this = $(realpath "$(dirname "${BASH_SOURCE[0]}")/repo")
4+
}
5+
6+
echo hello_there

irods/test/harness/tests/test_2.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
run() {
3+
echo dir of this = $(realpath "$(dirname "${BASH_SOURCE[0]}")/repo")
4+
}
5+
6+
echo later_alligator

0 commit comments

Comments
 (0)