Skip to content

Commit

Permalink
more steps toward running run python suite
Browse files Browse the repository at this point in the history
  • Loading branch information
d-w-moore committed Feb 20, 2024
1 parent cf9e04b commit 23736d1
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 23 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/run-the-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,26 @@ jobs:

name: ${{ matrix.python }}
runs-on: ubuntu-latest
# container: ${{ matrix.os }}
defaults:
run:
working-directory: ./docker-testing
strategy:
matrix:
# python: ['2.7','3.4','3.6','3.7','3.8','3.9','3.10','3.11','3.12']
# python: ['2.7','3.4','3.6','3.7','3.8','3.9','3.10','3.11','3.12']
python: ['2.7','3.4']
# os: ['ubuntu:20.04','ubuntu:22.04']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Start containers
run: docker compose -f docker-testing/harness-docker-compose.yml up -d --build
run: ./start_containers.sh

- name: Get Python prerequisites
- name: run test
run: |
python -m pip install --upgrade pip
pip install python-irodsclient
- name: Run tests
run: python docker-testing/run_the_tests.py
client_container=$(docker ps --format "{{.Names}}"|grep python.client)
docker exec -it "$(client_container)" /repo/docker-testing/run_tests.sh
- name: Stop containers
if: always()
run: docker compose -f docker-testing/harness-docker-compose.yml down
run: docker-compose -f harness-docker-compose.yml down
11 changes: 11 additions & 0 deletions docker-testing/harness-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ services:
environment:
- POSTGRES_PASSWORD=testpassword

python-client:
args:
- python_version
- repo_external
build:
context: python_client
command:
tail -f /dev/null
volumes:
${repo_external}:/repo:ro

irods-catalog-provider:
build:
context: irods_catalog_provider
Expand Down
46 changes: 46 additions & 0 deletions docker-testing/iinit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python

from getpass import getpass
from irods.password_obfuscation import encode
import json
import os
import sys
from os import chmod
from os.path import expanduser,exists,join
from getopt import getopt


home_env_path = expanduser('~/.irods')
env_file_path = join(home_env_path,'irods_environment.json')
auth_file_path = join(home_env_path,'.irodsA')


def do_iinit(host, port, user, zone, password):
if not exists(home_env_path):
os.makedirs(home_env_path)
else:
raise RuntimeError('~/.irods already exists')

with open(env_file_path,'w') as env_file:
json.dump ( { "irods_host": host,
"irods_port": int(port),
"irods_user_name": user,
"irods_zone_name": zone }, env_file, indent=4)
with open(auth_file_path,'w') as auth_file:
auth_file.write(encode(password))
chmod (auth_file_path,0o600)


def get_kv_pairs_from_cmdline(*args):
arglist = list(args)
while arglist:
k = arglist.pop(0)
v = arglist.pop(0)
yield k,v


if __name__ == '__main__':
import sys
args = sys.argv[1:]
dct = {k:v for k,v in get_kv_pairs_from_cmdline(*args)}
do_iinit(**dct)
2 changes: 2 additions & 0 deletions docker-testing/irods_catalog_provider/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ RUN mv /setup-${irods_version}.input /irods_setup.input

WORKDIR /
COPY entrypoint.sh .
COPY send_oneshot .
RUN chmod u+x ./entrypoint.sh
RUN chmod u+x ./send_oneshot
ENTRYPOINT ["./entrypoint.sh"]
2 changes: 2 additions & 0 deletions docker-testing/irods_catalog_provider/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ echo "Starting server"

cd /usr/sbin
su irods -c 'bash -c "./irodsServer -u"'

env PORT=8888 command "$(dirname "$0")"/send_oneshot
6 changes: 6 additions & 0 deletions docker-testing/irods_catalog_provider/send_oneshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/gawk -f
BEGIN {
SERVER = "/inet/tcp/"ENVIRON["PORT"]"/0/0"
print ARGV[1] " - " strftime() |& SERVER
close(SERVER)
}
35 changes: 35 additions & 0 deletions docker-testing/recv_oneshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
from __future__ import print_function
import sys, os, time
from socket import *
import getopt

def try_connect(host,port):
try:
s=socket(AF_INET,SOCK_STREAM)
s.connect((host,port))
return s
except:
s.close()
return None

# Options:
#
# -t timeout
# -h host
# -p port

t = now = time.time()
opts = dict(getopt.getopt(sys.argv[1:],'t:h:p:')[0])

host = opts['-h']
port = int(opts['-p'])
timeout = float(opts['-t'])

while time.time() < now + timeout:
time.sleep(1)
s = try_connect(host, port)
if s:
print(s.recv(32767).decode('utf-8'),end='')
exit(0)
exit(1)
9 changes: 9 additions & 0 deletions docker-testing/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e
DIR=$(dirname "$0")
cd "$DIR"
./recv_oneshot -h irods-provider -p 8888 -t 360
REPO="$(realpath ./repo)"
python -m pip install "$REPO[tests]"
./iinit.py host irods-provider port 1247 user rods password rods zone tempZone
python $REPO/irods/test/runner.py
12 changes: 0 additions & 12 deletions docker-testing/run_the_tests.py

This file was deleted.

6 changes: 6 additions & 0 deletions docker-testing/start_containers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
DIR=$(dirname "$0")
cd "${DIR}"
echo "python_version=${1}" >.env
echo "repo_external=$(realpath "${DIR}/repo")" >>.env
docker-compose -f harness-docker-compose.yml up -d

0 comments on commit 23736d1

Please sign in to comment.