Skip to content

Commit

Permalink
test (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximemulder authored Sep 20, 2024
1 parent d2ced7d commit 182ae25
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 349 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Integration tests

on:
pull_request:
push:
branches:
- 'main'
- '*-release'

jobs:
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Check out LORIS-MRI
uses: actions/checkout@v4

- name: Clone the LORIS core repository
run: git clone https://github.com/aces/Loris.git /tmp/Loris

- name: Import database files
run: |
mkdir -p ./test/database
mkdir -p ./test/database/SQL
mkdir -p ./test/database/raisinbread/RB_files
mkdir -p ./test/database/raisinbread/instruments/instrument_sql
mkdir -p ./test/database/test/test_instrument
cp -r /tmp/Loris/SQL/* ./test/database/SQL
cp -r ./test/RB_SQL/* ./test/database/raisinbread/RB_files
cp -r -n /tmp/Loris/raisinbread/RB_files/* ./test/database/raisinbread/RB_files
cp -r /tmp/Loris/raisinbread/instruments/instrument_sql/* ./test/database/raisinbread/instruments/instrument_sql
cp -r /tmp/Loris/test/test_instrument/testtest.sql ./test/database/test/test_instrument/testtest.sql
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker database image
uses: docker/build-push-action@v6
with:
context: .
file: ./test/db.Dockerfile
build-args: |
BASE_DIR=/app/
tags: loris-db
load: true
cache-from: type=gha,scope=loris-db
cache-to: type=gha,scope=loris-db

- name: Build Docker MRI image
uses: docker/build-push-action@v6
with:
context: .
file: ./test/mri.Dockerfile
tags: loris-mri
load: true
cache-from: type=gha,scope=loris-mri
cache-to: type=gha,scope=loris-mri

- name: Run integration tests
run: docker compose --file ./test/docker-compose.yml run mri pytest python/tests/integration
100 changes: 0 additions & 100 deletions .github/workflows/loristest.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:

jobs:
stale:

runs-on: ubuntu-latest

permissions:
issues: write
pull-requests: write
Expand All @@ -24,6 +24,6 @@ jobs:
stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 3 months.'
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 20 days.'
days-before-issue-stale: 365 # ~1 year
days-before-issue-close: 90 # ~3 months
days-before-issue-close: 90 # ~3 months
days-before-pr-stale: 90 # ~3 months
days-before-pr-close: 45 # ~1.5 month
11 changes: 2 additions & 9 deletions install/imaging_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,5 @@ fi
###### Update the Database table, Config, with the user values #######
######################################################################
echo "Populating database configuration entries for the Imaging Pipeline and LORIS-MRI code and images Path:"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='dataDirBasepath')"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='imagePath')"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='$PROJ' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='prefix')"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='$email' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='mail_user')"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/opt/$PROJ/bin/mri/dicom-archive/get_dicom_info.pl' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='get_dicom_info')"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/data/$PROJ/data/tarchive/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='tarchiveLibraryDir')"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='/opt/$PROJ/bin/mri/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='MRICodePath')"
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e "UPDATE Config SET Value='$MINC_TOOLKIT_DIR' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='MINCToolsPath')"
echo
mysql $mysqldb -h$mysqlhost --user=$mysqluser --password="$mysqlpass" -A -e \
"SET @email := '$email'; SET @project := '$PROJ'; SET @minc_dir := '$MINC_TOOLKIT_DIR'; SOURCE install_database.sql"
25 changes: 25 additions & 0 deletions install/install_database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- This file contains a few statements to adapt a core LORIS database to LORIS-MRI.
-- This file is ran by the installation or the database dockerfile, it usually
-- should not be ran as a standalone.

-- The script arguments must be set as SQL variables when calling the script.
-- @email -- User email address
-- @project -- Project name
-- @minc_dir -- MINC Toolkit directory

UPDATE Config SET Value = @email
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'mail_user');
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/')
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'dataDirBasepath');
UPDATE Config SET Value = CONCAT('/data/', @project, '/data/')
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'imagePath');
UPDATE Config SET Value = CONCAT('/data/', @project, '/data/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');
UPDATE Config SET Value = CONCAT('/opt/', @project, '/bin/mri/')
WHERE ConfigID = (SELECT ID FROM ConfigSettings WHERE Name = 'MRICodePath');
6 changes: 4 additions & 2 deletions test/test_example.py → python/tests/integration/test_poc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# tests/test_example.py
# Proof-of-concept integration tests. TODO: Replace with real tests


def test_addition():
assert 1 + 1 == 2


def test_subtraction():
assert 2 - 1 == 1

66 changes: 0 additions & 66 deletions test/Dockerfile.test.php8

This file was deleted.

22 changes: 0 additions & 22 deletions test/Dockerfile.test.python

This file was deleted.

41 changes: 41 additions & 0 deletions test/db.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM mariadb:latest

ARG BASE_DIR

COPY test/database/SQL/0000-00-00-schema.sql /0000-00-00-schema.sql
COPY test/database/SQL/0000-00-01-Modules.sql /0000-00-01-Modules.sql
COPY test/database/SQL/0000-00-02-Permission.sql /0000-00-02-Permission.sql
COPY test/database/SQL/0000-00-03-ConfigTables.sql /0000-00-03-ConfigTables.sql
COPY test/database/SQL/0000-00-04-Help.sql /0000-00-04-Help.sql
COPY test/database/SQL/0000-00-05-ElectrophysiologyTables.sql /0000-00-05-ElectrophysiologyTables.sql
COPY test/database/raisinbread/RB_files/*.sql /RB_files/
COPY test/database/raisinbread/instruments/instrument_sql/aosi.sql /aosi.sql
COPY test/database/raisinbread/instruments/instrument_sql/bmi.sql /bmi.sql
COPY test/database/raisinbread/instruments/instrument_sql/medical_history.sql /medical_history.sql
COPY test/database/raisinbread/instruments/instrument_sql/mri_parameter_form.sql /mri_parameter_form.sql
COPY test/database/raisinbread/instruments/instrument_sql/radiology_review.sql /radiology_review.sql
COPY test/database/test/test_instrument/testtest.sql /test_instrument.sql

RUN echo "Use LorisTest;" | cat - \
0000-00-00-schema.sql \
0000-00-01-Modules.sql \
0000-00-02-Permission.sql \
0000-00-03-ConfigTables.sql \
0000-00-04-Help.sql \
0000-00-05-ElectrophysiologyTables.sql \
aosi.sql \
bmi.sql \
medical_history.sql \
mri_parameter_form.sql \
radiology_review.sql \
test_instrument.sql \
RB_files/*.sql > /docker-entrypoint-initdb.d/0000-compiled.sql

RUN echo "Use LorisTest;" >> /docker-entrypoint-initdb.d/0001-paths.sql
RUN echo "UPDATE Config SET Value='${BASE_DIR}/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='base');" >> /docker-entrypoint-initdb.d/0001-paths.sql
RUN echo "GRANT UPDATE,INSERT,SELECT,DELETE,DROP,CREATE TEMPORARY TABLES ON LorisTest.* TO 'SQLTestUser'@'%' IDENTIFIED BY 'TestPassword' WITH GRANT OPTION;" >> /docker-entrypoint-initdb.d/0004-sql-user.sql

# Run the LORIS-MRI database installation script
COPY install/install_database.sql /tmp/install_database.sql
RUN echo "SET @email := 'root@localhost'; SET @project := 'loris'; SET @minc_dir = '/opt/minc/1.9.18';" >> 0001-paths.sql
RUN cat /tmp/install_database.sql >> /docker-entrypoint-initdb.d/0001-paths.sql
Loading

0 comments on commit 182ae25

Please sign in to comment.