Note: Setup for Windows would differ only in commands and keyboard shortcuts used
Find THIS document useful for the setup of OpenTest necessary in order to make this project work
Using TunnelBlick VPN, after receiving a response containing two files:
- Download both of them
- Remove
.txt
from<filename>.ovpn.txt
, so it's an.ovpn
extension file- Note: It was changed because of mail attachments policies
- Open TunnelBlick, go into
Configurations
tab and simply drag the.ovpn
configuration file into the box - Choose
Only Me
when asked- Note: Might be prompted to confirm the action using system credentials
- Press
⌘ + ,
(Command + comma) to step intoPreferences
window - Go to
Plugins
tab - Install
EnvFile
andPython
plugins- EnvFile - plugin that allows you to set env variables for run configurations from files
- Python - plugin allowing for having some PyCharm functionalities in IntelliJ
- Restart IntelliJ IDEA to make sure the plugins are installed properly
- Open cloned project from folder or clone using VCS
git clone https://github.com/nhsconnect/integration-adaptor-mhs.git
Install Python 3.7
:
brew install [email protected]
brew install pipenv
Note: If you have pyenv
already installed, pipenv
will get the global set Python version from it on installation
- Go into each of the directories in terminal (from the root directory of the project):
common
integration-tests/integration_tests
mhs/common
mhs/spineroutelookup
mhs/inbound
mhs/outbound
Install dependencies for Python 3.7
for each:
pipenv --python 3.7
For each module:
- Open shell using
pipenv shell
- Uninstall
setuptools
pip uninstall -y setuptools
- Install
setuptools 57.5.0
pip install -Iv setuptools==57.5.0
- Exit virtual environment shell with
exit
- Try installing dependencies again
pipenv install --dev
- Go to terminal window where you have
mhs/outbound
directory open - Install
openssl
andcurl-openssl
using
brew install openssl
brew install curl-openssl
- Open shell using
pipenv shell
(make sure you're still inmhs/outbound
directory) - Execute commands:
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS="-L/usr/local/opt/curl-openssl/lib"
export CPPFLAGS="-I/usr/local/opt/curl-openssl/include"
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" --install-option="--openssl-dir=/usr/local/opt/openssl" pycurl
exit
virtual environment shell
For each module:
- Check and copy the path to virtual enviroment
pipenv --venv
from terminal - In IntelliJ press
⌘ + ;
(Command + semicolon) to openProject Structure
window - Go to
SDKs
underPlatform Settings
- Click
+
sign on top of window or press⌘ + N
(Command + N) andAdd Python SDK...
- Make sure you're in
Virtualenv Enviroment
tab and click radioExisting enviroment
- In
Interpreter
, paste output copied from terminal adding/bin/python3
and clickOK
button- e.g.:
/Users/<username>/.local/share/virtualenvs/outbound-vfKgBI9O/bin/python3
- e.g.:
For each module:
- In IntelliJ press
⌘ + ;
(Command + semicolon) to openProject Structure
window - Go to
Modules
underProject Settings
- Click
+
sign on top of window or press⌘ + N
(Command + N) andImport Module
- Point to the module you want to import
- Note: Start with
mhs/common
first to avoid name clash of twocommon
- Note: Start with
- Make sure you're
creating module from existing sources
- Click
next
button all the way to the finish- Note: Rename
common
tomhs-common
if working on this module
- Note: Rename
- Select the corresponding
Module SDK
inDependencies
tab after clicking on newly imported module - Click
Apply
button
- MAKE SURE TO STORE THIS FILE SOMEWHERE OUTSIDE THE PROJECT TO AVOID IT BEING COMMITTED
- DO NOT SHARE THESE KEYS WITH OTHERS AS IT IS FOR YOUR PERSONAL USE ONLY
- Create a copy of MHS CONFIGURATION FILE
- Directory:
Root-folder-of-the-project/mhs-config.yaml
- Directory:
- Look for
User-specific env variables
, don't change anything else - Input
MHS_SECRET_PARTY_KEY
value from email's attached text file'sParty key
- NOTE FOR KEYS: Make sure to have two empty spaces on each line if the key has pasted differently
- Paste keys from new line leaving variable name with
|
, e.g.MHS_SECRET_CLIENT_CERT: |
- Paste keys from new line leaving variable name with
- Input
MHS_SECRET_CLIENT_CERT
value fromYour endpoint certificate
- Input
MHS_SECRET_CLIENT_KEY
value fromYour endpoint private key
- Input
MHS_SECRET_CA_CERTS
values- First from
Endpoint issuing subCA certificate
- Second from
Root CA certificate
- First from
- Find
main.py
files ofinbound
,outbound
andspineroutelookup
modules in project structure - For each of them:
- Right mouse click,
Modify Run Configuration...
(Should be underRun
andDebug
buttons) - In the
Edit Run Configuration
window:- Rename
main
to module name - Open
EnvFile
tab
- Rename
- EnvFile is disabled by default, so tick
Enable EnvFile
checkbox - Click
+
sign on top of the box below or press⌘ + N
(Command + N) andJSON/YAML file
- Specify path to the
.yaml
configuration file - Make sure it's enabled and click
Apply
and thenOk
- Right mouse click,
Note: If there are any problems with not found imports or errors in any module's main script:
- Consider invalidating caches (
File
->Invalidate Caches
and select all) and see if the problem dissapeared after the restart - If this didn't work, make sure your intelliJ and all plugins are up to date
- This might change modules structure after indexing, but it doesn't have any impact on them
- MAKE SURE TO STORE THIS FILE SOMEWHERE OUTSIDE THE PROJECT TO AVOID IT BEING COMMITTED
- DO NOT SHARE THESE KEYS WITH OTHERS AS IT IS FOR YOUR PERSONAL USE ONLY
- Create a copy of MHS INTEGRATION TESTS CONFIGURATION FILE
- Directory:
/integration-tests/integration_tests/integration-test-env-example.yaml
- Optionally you might want to rename the file to
integration-tests.yaml
- Directory:
- Fill the
INTEGRATION_TEST_ASID
's empty''
with a value ofASID
from e-mail's attached text file - Choose the proper
MHS_PERSISTENCE_ADAPTOR
andMHS_DB_ENDPOINT_URL
- In IntelliJ, click the Select
Run/Debug Configuration
dropdown menu on the top toolbar and clickEdit Configurations...
- Click
Edit Configuration Templates
- Find
Python tests
->Unittests
template and openEnvFile
tab - EnvFile is disabled by default, so tick
Enable EnvFile
checkbox - Click
+
sign on top of the box below or press⌘ + N
(Command + N) andJSON/YAML file
- Specify path to the
.yaml
integration-tests configuration file - Make sure it's enabled and click
Apply
and thenOk
- Click the Select
Run/Debug Configuration
dropdown menu on the top toolbar and clickEdit Configurations...
- Click
+
sign on top of window or press⌘ + N
(Command + N) to add a new configuration and clickCompound
- Rename the compound to
Run services
- Add
inbound
,outbound
andspineroutelookup
modules to theCompound
- Click
Apply
to save changes
- Click the Select
Run/Debug Configuration
dropdown menu on the top toolbar and clickEdit Configurations...
- For each module:
- Right click on module root folder name ->
Mark Directory As
->Test Sources Root
(The green one) - Right click on module root folder name ->
Modify Run Configuration...
- Go to
EnvFile
tab, addintegration-tests.yaml
configuration file (8 Attaching integration-tests configuration file to Run) - You can change name to
UnitTests in <modulename>
, clickApply
andOK
button to save - Right click on module root folder name ->
Mark Directory As
->Unmark As Test Sources Root
- Right click on module root folder name ->
- Click
+
sign on top of window or press⌘ + N
(Command + N) to add a new configuration and clickCompound
- Rename the compound to
Run Unit Tests
- Add all newly created
UnitTests in <modulename>
configurations to the compound
- Connect to the VPN you configured earlier
- Make sure Docker is running and from the root directory of the project, run:
./start-dependencies-docker-containers.sh
-
Run the
Run Services
compound you made earlier- If you skipped this stage:
- please refer to 8.1 Make running services easier section
- or start
inbound
,outbound
andspineroutelookup
modules to run parallelly
- If you skipped this stage:
-
When those services are running,
integration tests
should be passing -
Run the
Run Unit Tests
compound you made earlier- If you skipped this stage
- please refer to 8.2 Make running tests easier
- or run each Unit Test individually
- If you skipped this stage