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
.txtfrom<filename>.ovpn.txt, so it's an.ovpnextension file- Note: It was changed because of mail attachments policies
- Open TunnelBlick, go into
Configurationstab and simply drag the.ovpnconfiguration file into the box - Choose
Only Mewhen asked- Note: Might be prompted to confirm the action using system credentials
- Press
⌘ + ,(Command + comma) to step intoPreferenceswindow - Go to
Pluginstab - Install
EnvFileandPythonplugins- 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.11:
brew install python@3.11
brew install pipenvNote: 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):
commonintegration-tests/integration_testsmhs/commonmhs/spineroutelookupmhs/inboundmhs/outbound
Install dependencies for Python 3.11 for each:
pipenv --python 3.11- Go to terminal window where you have
mhs/outbounddirectory open - Install
opensslandcurl-opensslusing
brew install openssl
brew install curl-openssl- Open shell using
pipenv shell(make sure you're still inmhs/outbounddirectory) - 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 \
--config-settings="--build-option=--with-openssl" \
--config-settings="--build-option=--openssl-dir=/usr/local/opt/openssl" \
pycurl
exitvirtual environment shell
For each module:
- Check and copy the path to virtual enviroment
pipenv --venvfrom terminal - In IntelliJ press
⌘ + ;(Command + semicolon) to openProject Structurewindow - Go to
SDKsunderPlatform Settings - Click
+sign on top of window or press⌘ + N(Command + N) andAdd Python SDK... - Make sure you're in
Virtualenv Enviromenttab and click radioExisting enviroment - In
Interpreter, paste output copied from terminal adding/bin/python3and clickOKbutton- e.g.:
/Users/<username>/.local/share/virtualenvs/outbound-vfKgBI9O/bin/python3
- e.g.:
For each module:
- In IntelliJ press
⌘ + ;(Command + semicolon) to openProject Structurewindow - Go to
ModulesunderProject 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/commonfirst to avoid name clash of twocommon
- Note: Start with
- Make sure you're
creating module from existing sources - Click
nextbutton all the way to the finish- Note: Rename
commontomhs-commonif working on this module
- Note: Rename
- Select the corresponding
Module SDKinDependenciestab after clicking on newly imported module - Click
Applybutton
- 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_KEYvalue 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_CERTvalue fromYour endpoint certificate - Input
MHS_SECRET_CLIENT_KEYvalue fromYour endpoint private key - Input
MHS_SECRET_CA_CERTSvalues- First from
Endpoint issuing subCA certificate - Second from
Root CA certificate
- First from
- Find
main.pyfiles ofinbound,outboundandspineroutelookupmodules in project structure - For each of them:
- Right mouse click,
Modify Run Configuration...(Should be underRunandDebugbuttons) - In the
Edit Run Configurationwindow:- Rename
mainto module name - Open
EnvFiletab
- Rename
- EnvFile is disabled by default, so tick
Enable EnvFilecheckbox - Click
+sign on top of the box below or press⌘ + N(Command + N) andJSON/YAML file - Specify path to the
.yamlconfiguration file - Make sure it's enabled and click
Applyand 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 Cachesand 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 ofASIDfrom e-mail's attached text file - Choose the proper
MHS_PERSISTENCE_ADAPTORandMHS_DB_ENDPOINT_URL - In IntelliJ, click the Select
Run/Debug Configurationdropdown menu on the top toolbar and clickEdit Configurations... - Click
Edit Configuration Templates - Find
Python tests->Unitteststemplate and openEnvFiletab - EnvFile is disabled by default, so tick
Enable EnvFilecheckbox - Click
+sign on top of the box below or press⌘ + N(Command + N) andJSON/YAML file - Specify path to the
.yamlintegration-tests configuration file - Make sure it's enabled and click
Applyand thenOk
- Click the Select
Run/Debug Configurationdropdown 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,outboundandspineroutelookupmodules to theCompound - Click
Applyto save changes
- Click the Select
Run/Debug Configurationdropdown 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
EnvFiletab, addintegration-tests.yamlconfiguration file (8 Attaching integration-tests configuration file to Run) - You can change name to
UnitTests in <modulename>, clickApplyandOKbutton 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 Servicescompound you made earlier- If you skipped this stage:
- please refer to 8.1 Make running services easier section
- or start
inbound,outboundandspineroutelookupmodules to run parallelly
- If you skipped this stage:
-
When those services are running,
integration testsshould be passing -
Run the
Run Unit Testscompound 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