Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
maximemulder committed Oct 31, 2024
1 parent eb802b7 commit 09b9572
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 27 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
DATABASE_PASSWORD: TestPassword
BUCKET_URL: https://ace-minio-1.loris.ca:9000
BUCKET_NAME: loris-rb-data
BUCKET_ACCESS_KEY: lorisadmin
BUCKET_ACCESS_KEY: lorisadmin-ro
BUCKET_SECRET_KEY: Tn=qP3LupmXnMuc

jobs:
Expand Down Expand Up @@ -76,6 +76,7 @@ jobs:
chmod 600 .passwd-s3fs
echo ${{ env.BUCKET_ACCESS_KEY }}:${{ env.BUCKET_SECRET_KEY }} > .passwd-s3fs
sudo s3fs ${{ env.BUCKET_NAME }} /data-imaging -o passwd_file=.passwd-s3fs -o url=${{ env.BUCKET_URL }} -o use_path_request_style -o allow_other
ls /data-imaging
- name: Run integration tests
run: docker compose --file ./test/docker-compose.yml run mri pytest python/tests/integration
run: docker compose --file ./test/docker-compose.yml run mri pytest -s python/tests/integration
18 changes: 9 additions & 9 deletions dicom-archive/database_config_template.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python

import re

from lib.config_file import CreateVisitInfo, DatabaseConfig, SubjectInfo
from lib.database import Database
from lib.imaging import Imaging
from lib.config_file import CreateVisitInfo, DatabaseConfig, S3Config, SubjectInfo


mysql: DatabaseConfig = DatabaseConfig(
host = 'DBHOST',
Expand All @@ -14,13 +14,13 @@
port = 3306,
)

# This statement can be omitted if the project does not use AWS S3.
s3: S3Config = S3Config(
aws_access_key_id = 'AWS_ACCESS_KEY_ID',
aws_secret_access_key = 'AWS_SECRET_ACCESS_KEY',
aws_s3_endpoint_url = 'AWS_S3_ENDPOINT',
aws_s3_bucket_name = 'AWS_S3_BUCKET_NAME',
)
# Uncomment this statement if your project uses AWS S3.
# s3: S3Config = S3Config(
# aws_access_key_id = 'AWS_ACCESS_KEY_ID',
# aws_secret_access_key = 'AWS_SECRET_ACCESS_KEY',
# aws_s3_endpoint_url = 'AWS_S3_ENDPOINT',
# aws_s3_bucket_name = 'AWS_S3_BUCKET_NAME',
# )


def get_subject_info(db: Database, subject_name: str, scanner_id: int | None = None) -> SubjectInfo | None:
Expand Down
6 changes: 3 additions & 3 deletions install/install_database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ UPDATE Config SET Value = @project
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'prefix');
UPDATE Config SET Value = @minc_dir
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'MINCToolsPath');
UPDATE Config SET Value = CONCAT('/data/', @project, '/data/')
UPDATE Config SET Value = CONCAT('/data/', @project, '/')
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'dataDirBasepath');
UPDATE Config SET Value = CONCAT('/data/', @project, '/data/')
UPDATE Config SET Value = CONCAT('/data/', @project, '/')
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'imagePath');
UPDATE Config SET Value = CONCAT('/data/', @project, '/data/tarchive/')
UPDATE Config SET Value = CONCAT('/data/', @project, '/tarchive/')
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'tarchiveLibraryDir');
UPDATE Config SET Value = CONCAT('/opt/', @project, '/bin/mri/dicom-archive/get_dicom_info.pl')
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'get_dicom_info');
Expand Down
18 changes: 18 additions & 0 deletions python/tests/integration/scripts/test_run_dicom_archive_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import subprocess


def test():
process = subprocess.run([
'run_dicom_archive_loader.py',
'--profile', 'database_config.py',
'--tarchive_path', '/data/loris/tarchive/DCM_2015-07-07_ImagingUpload-14-30-FoTt1K.tar',
# Only one of the DICOM archive path or the upload ID should be specified
# '--upload_id', '126',
], capture_output=True)

print(process.stdout)
print(process.stderr)
print(process.returncode)

assert process.returncode == 0
assert process.stderr == b''
2 changes: 1 addition & 1 deletion test/RB_SQL/RB_tarchive.sql

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions test/imaging_install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ mridir="/opt/loris/bin/mri"
#############################Create directories########################################
#######################################################################################
echo "Creating the data directories"
sudo -S su $USER -c "mkdir -m 2770 -p /data/$PROJ/data/"
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/trashbin" #holds mincs that didn't match protocol
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/tarchive" #holds tared dicom-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/hrrtarchive" #holds tared hrrt-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/pic" #holds jpegs generated for the MRI-browser
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/logs" #holds logs from pipeline script
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/assembly" #holds the MINC files
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/assembly_bids" #holds the BIDS files derived from DICOMs
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/batch_output" #contains the result of the SGE (queue)
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/bids_imports" #contains imported BIDS studies
sudo -S su $USER -c "mkdir -m 2770 -p /data/$PROJ/"
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/trashbin" #holds mincs that didn't match protocol
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/tarchive" #holds tared dicom-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/hrrtarchive" #holds tared hrrt-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/pic" #holds jpegs generated for the MRI-browser
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/logs" #holds logs from pipeline script
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/assembly" #holds the MINC files
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/assembly_bids" #holds the BIDS files derived from DICOMs
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/batch_output" #contains the result of the SGE (queue)
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/bids_imports" #contains imported BIDS studies
sudo -S su $USER -c "mkdir -m 770 -p $mridir/dicom-archive/.loris_mri"
echo

Expand Down Expand Up @@ -71,8 +71,8 @@ sudo usermod -a -G $group $USER
sudo chgrp $group -R /opt/$PROJ/
sudo chgrp $group -R /data/$PROJ/

#Setting group ID for all files/dirs under /data/$PROJ/data
sudo chmod -R g+s /data/$PROJ/data/
#Setting group ID for all files/dirs under /data/$PROJ/
sudo chmod -R g+s /data/$PROJ/

# Setting group permissions and group ID for all files/dirs under /data/incoming
# If the directory was not created earlier, then instructions to do so manually are provided.
Expand Down
2 changes: 2 additions & 0 deletions test/mri.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ ENV LORIS_MRI=/opt/${PROJECT}/bin/mri
ENV PYTHONPATH=$PYTHONPATH:/opt/${PROJECT}/bin/mri/python:/opt/${PROJECT}/bin/mri/python/react-series-data-viewer

Check warning on line 115 in test/mri.Dockerfile

View workflow job for this annotation

GitHub Actions / Docker

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PYTHONPATH' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
ENV BEASTLIB=${MINC_TOOLKIT_DIR}/../share/beast-library-1.1
ENV MNI_MODELS=${MINC_TOOLKIT_DIR}/../share/icbm152_model_09c

ENTRYPOINT sh -c "replicate_raisinbread_for_mcin_dev_vm.pl /data-imaging /data/loris && $@"

Check warning on line 119 in test/mri.Dockerfile

View workflow job for this annotation

GitHub Actions / Docker

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

0 comments on commit 09b9572

Please sign in to comment.