From 425262a134dffdbc9e7cb1fec2512bbdc8e11cfd Mon Sep 17 00:00:00 2001 From: Carlo Minotti <50220438+minottic@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:37:15 +0100 Subject: [PATCH] Include v4 api:mocha tests in dev setup (#358) * Include v4 api:mocha tests in dev setup * Increase retries * Reuse credentials --- services/backend/services/v4/compose.dev.yaml | 6 ++ services/backend/services/v4/config/.dev.env | 11 +++ services/backend/services/v4/config/.env | 2 +- .../v4/config/functionalAccounts.dev.json | 93 +++++++++++++++++++ .../backend/services/v4/entrypoints/tests.sh | 7 ++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 services/backend/services/v4/config/.dev.env create mode 100644 services/backend/services/v4/config/functionalAccounts.dev.json diff --git a/services/backend/services/v4/compose.dev.yaml b/services/backend/services/v4/compose.dev.yaml index b5f44a94..f9242104 100644 --- a/services/backend/services/v4/compose.dev.yaml +++ b/services/backend/services/v4/compose.dev.yaml @@ -10,7 +10,13 @@ services: volumes: - v4_dev:/home/node/app - ${PWD}/entrypoints/setup_git.sh:/docker-entrypoints/2.sh + - ./config/functionalAccounts.dev.json:/home/node/app/functionalAccounts.json - ./entrypoints/tests.sh:/docker-entrypoints/3.sh + env_file: + - ./config/.dev.env + healthcheck: + retries: 20 + interval: 1m volumes: v4_dev: diff --git a/services/backend/services/v4/config/.dev.env b/services/backend/services/v4/config/.dev.env new file mode 100644 index 00000000..36ae3fd1 --- /dev/null +++ b/services/backend/services/v4/config/.dev.env @@ -0,0 +1,11 @@ +MONGODB_URI=mongodb://mongodb:27017/dev_be_next +ADMIN_GROUPS=admin,adminingestor +CREATE_DATASET_GROUPS=group1,group2,group3 +CREATE_DATASET_WITH_PID_GROUPS=group2 +CREATE_DATASET_PRIVILEGED_GROUPS=datasetIngestor,group3 +SAMPLE_PRIVILEGED_GROUPS=sampleingestor +SAMPLE_GROUPS=group1 +DATASET_CREATION_VALIDATION_ENABLED=true +DATASET_CREATION_VALIDATION_REGEX=^scicatlive_testing/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$ +PID_PREFIX=scicatlive_testing +SITE=PSI diff --git a/services/backend/services/v4/config/.env b/services/backend/services/v4/config/.env index d20f55cf..85f6656e 100644 --- a/services/backend/services/v4/config/.env +++ b/services/backend/services/v4/config/.env @@ -4,7 +4,7 @@ JWT_SECRET=secret EXPRESS_SESSION_SECRET=secret ADMIN_GROUPS=admin -DELETE_GROUPS=buggy +DELETE_GROUPS=archivemanager CREATE_DATASET_GROUPS=ingestor PROPOSAL_GROUPS=proposalingestor SAMPLE_GROUPS=ingestor diff --git a/services/backend/services/v4/config/functionalAccounts.dev.json b/services/backend/services/v4/config/functionalAccounts.dev.json new file mode 100644 index 00000000..9fb769d4 --- /dev/null +++ b/services/backend/services/v4/config/functionalAccounts.dev.json @@ -0,0 +1,93 @@ +[ + { + "username": "admin", + "email": "scicatadmin@your.site", + "password": "2jf70TPNZsS", + "role": "admin", + "global": true + }, + { + "username": "adminIngestor", + "email": "adminingestor@scicat.project", + "password": "13f4242dc691a3ee3bb5ca2006edcdf7", + "role": "adminingestor", + "global": false + }, + { + "username": "ingestor", + "password": "aman", + "email": "scicatingestor@your.site", + "role": "ingestor", + "global": false + }, + { + "username": "archiveManager", + "email": "scicatarchivemanager@your.site", + "password": "aman", + "role": "archivemanager", + "global": false + }, + { + "username": "datasetIngestor", + "email": "datasetingestor@scicat.project", + "password": "bc35db76848cf9fbb7f40b6661644e97", + "role": "datasetingestor", + "global": false + }, + { + "username": "proposalIngestor", + "email": "scicatproposalingestor@your.site", + "password": "aman", + "role": "proposalingestor", + "global": false + }, + { + "username": "sampleIngestor", + "email": "sampleingestor@scicat.project", + "password": "e4876cb39c7dc4fe957d7c4f6a34cdd8", + "role": "sampleingestor", + "global": false + }, + { + "username": "user1", + "email": "user1@your.site", + "password": "a609316768619f154ef58db4d847b75e", + "role": "group1", + "global": false + }, + { + "username": "user2", + "email": "user2@your.site", + "password": "f522d1d715970073a6413474ca0e0f63", + "role": "group2", + "global": false + }, + { + "username": "user3", + "email": "user3@your.site", + "password": "70dc489e8ee823ae815e18d664424df2", + "role": "group3", + "global": false + }, + { + "username": "user4", + "email": "user4@your.site", + "password": "0014890e7020f515b92b767227ef2dfa", + "role": "group4", + "global": false + }, + { + "username": "user5.1", + "email": "user5.1@your.site", + "password": "359a5fda99bfe5dbc42ee9b3ede77fb7", + "role": "group5", + "global": false + }, + { + "username": "user5.2", + "email": "user5.2@your.site", + "password": "f3ebd2e4def95db59ef95ee32ef45242", + "role": "group5", + "global": false + } +] diff --git a/services/backend/services/v4/entrypoints/tests.sh b/services/backend/services/v4/entrypoints/tests.sh index 811c4efb..a4758d2a 100755 --- a/services/backend/services/v4/entrypoints/tests.sh +++ b/services/backend/services/v4/entrypoints/tests.sh @@ -3,3 +3,10 @@ ## Setting the --runInBand makes the tests run sequentially, ## avoiding to fill the RAM which makes them freeze npm run test -- --runInBand + +npm start & +PID="${!}" +sleep 30 +npm run test:api:mocha + +kill "${PID}"