Skip to content

Commit

Permalink
Add 'docker/' from commit '1866be264483901ef1d372732ad95af787cdcd19'
Browse files Browse the repository at this point in the history
git-subtree-dir: docker
git-subtree-mainline: b24e487
git-subtree-split: 1866be2
  • Loading branch information
dometto committed May 21, 2024
2 parents b24e487 + 1866be2 commit 23e19f8
Show file tree
Hide file tree
Showing 32 changed files with 1,353 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docker/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# source: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
# Set the default behavior, in case people don't have core.autocrlf set.
# * binary

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
#*.c text
#*.h text

# Declare files that will always have CRLF line endings on checkout.
#*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
#*.png binary
#*.jpg binary
52 changes: 52 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# iBridges-Integration-tests
Dockerised integration tests of iBridges with iRODS

## Docker images
- iCAT database
- iRODS server, version 4.3.0
- Client: icommands, python-irodsclient and intgration tests

## Usage
1. Clone iBridges

```sh
git clone --branch develop https://github.com/UtrechtUniversity/iBridges.git
```

Execute the following commands in the root ibridges directory:

2. `docker-compose build`
3. `docker-compose up`

To recreate the images:

1. `docker-compose rm -f`
2. `docker-compose up --force-recreate --build --no-deps`

Clean up

1. `docker image prune`
2. `docker container prune`

Enter the irods-client
1. Bring the images up
2. `docker ps`
3. `docker exec -it <IMAGE> /bin/bash`

## Example output:

```
irods-client-1 | ============================= test session starts ==============================
irods-client-1 | platform linux -- Python 3.10.12, pytest-8.0.0, pluggy-1.4.0
irods-client-1 | rootdir: /ibridges/integration_test
irods-client-1 | collected 14 items
irods-client-1 |
irods-client-1 | test_meta.py .. [ 28%]
irods-client-1 | test_permissions.py .. [ 42%]
irods-client-1 | test_resources.py . [ 50%]
irods-client-1 | test_rules.py . [ 57%]
irods-client-1 | test_session.py .x [ 71%]
irods-client-1 | test_ticket.py .... [100%]
irods-client-1 |
irods-client-1 | ======================== 13 passed, 1 xfailed in 3.22s =========================
```
3 changes: 3 additions & 0 deletions docker/irods_catalog/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM postgres:10

COPY init-user-db.sh /docker-entrypoint-initdb.d/init-user-db.sh
11 changes: 11 additions & 0 deletions docker/irods_catalog/init-user-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Adapted from "Initialization script" in documentation for official Postgres dockerhub:
# https://hub.docker.com/_/postgres/
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE DATABASE "ICAT";
CREATE USER irods WITH PASSWORD 'testpassword';
GRANT ALL PRIVILEGES ON DATABASE "ICAT" to irods;
EOSQL
39 changes: 39 additions & 0 deletions docker/irods_catalog_provider/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:22.04
ARG os_name=jammy

ENV DEBIAN_FRONTEND=noninteractive
ARG ubuntu_name=focal

RUN apt-get update
RUN apt-get install -y lsb-release gnupg wget sudo
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*

# IRODS SERVER PACKAGES
RUN wget -qO - https://packages.irods.org/irods-signing-key.asc | sudo apt-key add -
RUN sudo rm -rf /etc/apt/sources.list.d/renci-irods.list
RUN sudo echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" |sudo tee /etc/apt/sources.list.d/renci-irods.list

RUN apt-get update
RUN apt-get install -y python3 unixodbc
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*

ARG irods_version=4.3.2
ARG irods_package_version_suffix=-0~${os_name}
ARG irods_package_version=${irods_version}${irods_package_version_suffix}
#ARG irods_resource_plugin_version=${irods_version}.0${irods_package_version_suffix}

RUN apt-get update && \
apt-get install -y irods-database-plugin-postgres=$irods_package_version
RUN apt-get install irods-server=$irods_package_version
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*

COPY setup-${irods_version}.input /
RUN mv /setup-${irods_version}.input /irods_setup.input

WORKDIR /
COPY entrypoint.sh .
RUN chmod u+x ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
39 changes: 39 additions & 0 deletions docker/irods_catalog_provider/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#! /bin/bash -e

catalog_db_hostname=irods-catalog

echo "Waiting for iRODS catalog database to be ready"

until pg_isready -h ${catalog_db_hostname} -d ICAT -U irods -q
do
sleep 1
done

echo "iRODS catalog database is ready"

setup_input_file=/irods_setup.input

if [ -e "${setup_input_file}" ]; then
echo "Running iRODS setup"
python3 /var/lib/irods/scripts/setup_irods.py < "${setup_input_file}"
rm /irods_setup.input
fi

mkdir /var/lib/irods/Vault1
chown irods:irods /var/lib/irods/Vault1

#echo "Starting server"
#su irods -c 'bash -c ./irodsctl start'
#su irods -c 'iadmin mkresc resc2 unixfilesystem `hostname`:/var/lib/irods/Vault1'
#echo "Stop server"
#su irods -c 'bash -c ./irodsctl stop'

echo "Creating resource"
cd /var/lib/irods
su irods -c 'bash -c "./irodsctl start"'
su irods -c 'iadmin mkresc resc2 unixfilesystem `hostname`:/var/lib/irods/Vault1'
su irods -c 'bash -c "./irodsctl stop"'

echo "Starting server"
cd /usr/sbin
su irods -c 'bash -c "./irodsServer -u"'
28 changes: 28 additions & 0 deletions docker/irods_catalog_provider/setup-4.3.1.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@




irods-catalog
5432
ICAT
irods
y
testpassword

y
demoResc

tempZone
1247
20000
20199
1248

rods
y
TEMPORARY_ZONE_KEY
32_byte_server_negotiation_key__
32_byte_server_control_plane_key
rods


28 changes: 28 additions & 0 deletions docker/irods_catalog_provider/setup-4.3.2.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@




irods-catalog
5432
ICAT
irods
y
testpassword

y
demoResc

tempZone
1247
20000
20199
1248

rods
y
TEMPORARY_ZONE_KEY
32_byte_server_negotiation_key__
32_byte_server_control_plane_key
rods


60 changes: 60 additions & 0 deletions docker/irods_client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
apt-transport-https \
gnupg \
wget \
lsb-release \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*

RUN wget -qO - https://packages.irods.org/irods-signing-key.asc | apt-key add - && \
echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/renci-irods.list

# ARG icommands_version=4.3.0
# ARG icommands_package_version_suffix=-1~focal
# ARG icommands_package_version=${icommands_version}${icommands_package_version_suffix}

RUN apt-get update && \
apt-get install -y \
netcat \
irods-runtime \
irods-icommands \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*

RUN mkdir -p /root/.irods
COPY docker/irods_client/environments/plain-irods/irods_environment.json /root/.irods
COPY docker/irods_client/environments/plain-irods/irods_environment_testuser.json /root/.irods

RUN mkdir -p /tmp
ADD docker/irods_client/testdata /tmp/testdata/

# install python 3
RUN apt-get update && \
apt-get upgrade -y
RUN apt-get install -y python3 git
# python3-pip \
# git

# Work around for a bug in Ubuntu 22.04: https://github.com/pypa/setuptools/issues/3269#ref-issue-1217398136
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3 get-pip.py
RUN mkdir -p /ibridges/integration_test
ADD ibridges /ibridges/ibridges
ADD docker/irods_client/tests ibridges/integration_test
ADD docker/irods_client/environments/plain-irods ibridges/integration_test/environment
ADD .git /ibridges/.git
COPY pyproject.toml /ibridges
RUN /usr/local/bin/pip3 install /ibridges
RUN /usr/local/bin/pip3 install pytest tomli

WORKDIR /
COPY docker/irods_client/entrypoint.sh .
RUN chmod u+x ./entrypoint.sh
ENTRYPOINT bash -c "./entrypoint.sh"
50 changes: 50 additions & 0 deletions docker/irods_client/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /bin/bash -e

echo "waiting for iRODS to be ready"

irods_catalog_provider_hostname=irods-catalog-provider
until nc -z ${irods_catalog_provider_hostname} 1247
do
sleep 10
done

# After setting up iRODS, the server will respond on port 1247. However, the server process is
# stopped after some preliminary tests are completed. The irods-catalog-provider service will
# start the server manually again, but this will take a few seconds. Sleep here to ensure that
# next time the server responds is not the temporary uptime provided during setup.
sleep 3

until nc -z ${irods_catalog_provider_hostname} 1247
do
sleep 1
done

echo "iRODS is ready"

# pre-authenticate the user so the iCommands are ready to use
echo 'rods' | iinit
echo 'Authenticated as rods'

# wait until second resource is created
ilsresc | grep 'resc2' &> /dev/null
while [ $? != 0 ];
do
echo "Sleep"
sleep 1
done

# create second user
iadmin mkuser testuser rodsuser
iadmin moduser testuser password testuser
echo 'testuser created'
echo $(iadmin lu testuser)

cd /ibridges/integration_test
pytest .

result=$?
if [[ -z "$CI" ]]; then
/bin/bash
else
exit $result
fi
11 changes: 11 additions & 0 deletions docker/irods_client/environments/plain-irods/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
password = "rods"
server_version = "4.3.2"
can_write_pam_pass = false
has_cached_pw = true
resources = ["demoResc", "resc2"]
free_resources = [false, false, false]
env_path = "/root/.irods/irods_environment.json"
test_user = "testuser"
test_user_pw = "testuser"
test_user_env_path = "/root/.irods/irods_environment_testuser.json"
ticket_date_only = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"irods_host": "irods-catalog-provider",
"irods_port": 1247,
"irods_user_name": "rods",
"irods_default_resource": "demoResc",
"irods_home": "/tempZone/home/rods",
"irods_zone_name": "tempZone"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"irods_host": "irods-catalog-provider",
"irods_port": 1247,
"irods_user_name": "testuser",
"irods_default_resource": "demoResc",
"irods_home": "/tempZone/home/testuser",
"irods_zone_name": "tempZone"
}
9 changes: 9 additions & 0 deletions docker/irods_client/environments/yoda/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
password = "test"
server_version = "4.2.12"
can_write_pam_pass = false
create_session_from_cached_pw = false
resources = ["demoResc", "dev001", "dev001_1", "dev001_2", "dev001_p1", "dev001_p2", "dev002", "dev002_1", "dev002_p1", "dev003", "dev003_1", "dev003_p1", "irodsResc", "irodsRescRepl", "irodsRescReplS3"]
free_resources = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
test_user = "researcher"
test_user_pw = "test"
ticket_date_only = true
18 changes: 18 additions & 0 deletions docker/irods_client/environments/yoda/irods_environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"irods_host": "provider.yoda",
"irods_port": 8247,
"irods_user_name": "technicaladmin",
"irods_password": "test",
"irods_home": "/tempZone/home/rods",
"irods_cwd": "/tempZone/home/rods",
"irods_zone_name": "tempZone",
"irods_client_server_negotiation": "request_server_negotiation",
"irods_client_server_policy": "CS_NEG_REQUIRE",
"irods_default_hash_scheme": "SHA256",
"irods_default_resource": "irodsResc",
"irods_encryption_algorithm": "AES-256-CBC",
"irods_encryption_key_size": 32,
"irods_encryption_num_hash_rounds": 16,
"irods_encryption_salt_size": 8,
"irods_ssl_verify_server": "none"
}
Loading

0 comments on commit 23e19f8

Please sign in to comment.