Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch integration tests to launch irida via gradle #27

Merged
merged 3 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to irida-galaxy-importer will be documeted in this file.

## 2.0.1
* Switched from travisCI tests to Github Actions
* Switched integration tests to launch irida via gradle

## 2.0.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ If you wish to make additions to the code, the below instructions can be used to
The script `run-tests.sh` can be used to run the tests. This should check for some of the dependencies and let you know which is missing. However, you will have to have the following dependencies installed:

* Java 11
* Maven
* Gradle
* MySQL/MariaDB (Server and Client)
* PostgreSQL (Server and Client)
* Git
Expand All @@ -256,7 +256,7 @@ The script `run-tests.sh` can be used to run the tests. This should check for so
On Ubuntu, you can install these with:

```bash
sudo apt-get install openjdk-11-jdk maven mariadb-client mariadb-server postgresql git chromium-chromedriver xvfb
sudo apt-get install openjdk-11-jdk gradle mariadb-client mariadb-server postgresql git chromium-chromedriver xvfb
```

MySQL must be configured to grant all privileges to the user `test` with password `test` for the databases `irida_test`. MySQL must also be configured to disable `ONLY_FULL_GROUP_BY` mode.
Expand Down
8 changes: 1 addition & 7 deletions irida_import/tests/integration/bash_scripts/install_irida.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# This file creates a repos directory and pulls the irida branch with the name in $1

pushd /tmp/repos

Expand All @@ -8,12 +9,5 @@ then
echo >&2 "Failed to clone"
exit 1
else
pushd irida
echo "Preparing IRIDA for first excecution..."

pushd lib
./install-libs.sh
popd
popd
echo "IRIDA has been installed"
fi
23 changes: 13 additions & 10 deletions irida_import/tests/integration/irida_data_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def __init__(self, base_url, user, password, branch, db_host, db_port, repo_dir)
self.DB_NAME + ' < {}'.format(sql_file)

self.IRIDA_CMD = \
'mvn clean compile spring-boot:start -DskipTests --quiet ' +\
'-Dspring-boot.run.arguments=\"' +\
'./gradlew -q clean bootRun -x check ' +\
'--args=\"' +\
'--spring.datasource.url={} '.format(self.DB_JDBC_URL) +\
'--spring.datasource.username={} '.format(self.DB_USERNAME) +\
'--spring.datasource.password={} '.format(self.DB_PASSWORD) +\
Expand All @@ -73,8 +73,6 @@ def __init__(self, base_url, user, password, branch, db_host, db_port, repo_dir)
'--logging.pattern.console=' +\
'\"'

self.IRIDA_STOP = 'mvn spring-boot:stop'

self.PATH_TO_MODULE = path.dirname(__file__)
if len(self.PATH_TO_MODULE) == 0:
self.PATH_TO_MODULE = "."
Expand All @@ -86,6 +84,9 @@ def __init__(self, base_url, user, password, branch, db_host, db_port, repo_dir)
self.REPO_PATH = repo_dir
self.IRIDA_PATH = path.join(self.REPO_PATH, "irida")

# Handles the irida subprocess
self.irida_subprocess = None

def install_irida(self):
"""
Installs IRIDA
Expand Down Expand Up @@ -127,8 +128,11 @@ def run_irida(self):
Waits until IRIDA is up to return
:return:
"""
subprocess.Popen(
self.IRIDA_CMD, cwd=self.IRIDA_PATH, shell=True)
self.irida_subprocess = subprocess.Popen(
"exec " + self.IRIDA_CMD, # assign new process image
stdout=subprocess.PIPE, # makes subprocess.Popen return pid of command, and not shell (default behaviour)
cwd=self.IRIDA_PATH,
shell=True)
self._wait_until_up()

def _wait_until_up(self):
Expand All @@ -153,10 +157,9 @@ def _wait_until_up(self):

def stop_irida(self):
"""
Stops the IRIDA mvn process
Kill the IRIDA gradlew process
This will sometimes dump errors into the log, but it is harmless
:return:
"""
stopper = subprocess.Popen(
self.IRIDA_STOP, cwd=self.IRIDA_PATH, shell=True)
stopper.wait()
self.irida_subprocess.kill()
self.irida_subprocess = None
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def readme():
"pytest-mock",
"mock",
"subprocess32",
"selenium",
"selenium==4.2.0",
"rauth",
"argparse",
"webdriver-manager",
Expand Down