From 5bbad9114977b46a927d063359dc118f6c6fe42d Mon Sep 17 00:00:00 2001 From: marrobi Date: Tue, 17 Oct 2023 15:16:30 +0000 Subject: [PATCH 1/4] Extended e2e for all shared, workspaces, and workspace services Fixes #1921 --- .devcontainer/devcontainer.json | 16 ++++++++++++++++ .github/workflows/deploy_tre.yml | 2 +- .github/workflows/pr_comment_bot.yml | 2 +- api_app/_version.py | 2 +- api_app/api/routes/workspaces.py | 24 +++++++++++++++++++----- e2e_tests/resources/strings.py | 9 ++++++--- e2e_tests/test_workspace_services.py | 6 +++++- 7 files changed, 49 insertions(+), 12 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d73028ff90..c921d8fd71 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -135,6 +135,22 @@ "false" ] }, + { + "name": "E2E Workspace Services", + "type": "python", + "request": "launch", + "module": "pytest", + "justMyCode": true, + "cwd": "${workspaceFolder}/e2e_tests/", + "preLaunchTask": "Copy_env_file_for_e2e_debug", + "args": [ + "-n 5", + "-m", + "workspace_services", + "--verify", + "false" + ] + }, { "name": "E2E Performance", "type": "python", diff --git a/.github/workflows/deploy_tre.yml b/.github/workflows/deploy_tre.yml index 7c12cecd98..4bdfc0b606 100644 --- a/.github/workflows/deploy_tre.yml +++ b/.github/workflows/deploy_tre.yml @@ -32,7 +32,7 @@ jobs: ${{ (github.event_name == 'push' && 'extended or extended_aad') || 'extended or extended_aad or shared_services or airlock' }} environmentName: ${{ github.event.inputs.environment || 'CICD' }} - E2E_TESTS_NUMBER_PROCESSES: 1 + E2E_TESTS_NUMBER_PROCESSES: 5 DEVCONTAINER_TAG: 'latest' secrets: AAD_TENANT_ID: ${{ secrets.AAD_TENANT_ID }} diff --git a/.github/workflows/pr_comment_bot.yml b/.github/workflows/pr_comment_bot.yml index 99fe8e4ff1..fe8d43b25f 100644 --- a/.github/workflows/pr_comment_bot.yml +++ b/.github/workflows/pr_comment_bot.yml @@ -152,7 +152,7 @@ jobs: (needs.pr_comment.outputs.command == 'run-tests-shared-services' && 'shared_services') || (needs.pr_comment.outputs.command == 'run-tests' && '') }} environmentName: CICD - E2E_TESTS_NUMBER_PROCESSES: 1 + E2E_TESTS_NUMBER_PROCESSES: 5 DEVCONTAINER_TAG: ${{ needs.pr_comment.outputs.prRefId }} secrets: AAD_TENANT_ID: ${{ secrets.AAD_TENANT_ID }} diff --git a/api_app/_version.py b/api_app/_version.py index a99557a02f..fe051f14ca 100644 --- a/api_app/_version.py +++ b/api_app/_version.py @@ -1 +1 @@ -__version__ = "0.15.17" +__version__ = "0.15.18" diff --git a/api_app/api/routes/workspaces.py b/api_app/api/routes/workspaces.py index 8607e9fcf6..fcf38247e2 100644 --- a/api_app/api/routes/workspaces.py +++ b/api_app/api/routes/workspaces.py @@ -1,5 +1,6 @@ import asyncio import logging +import time from fastapi import APIRouter, Depends, HTTPException, Header, status, Request, Response @@ -256,12 +257,25 @@ async def create_workspace_service(response: Response, workspace_service_input: workspace_patch = ResourcePatch() workspace_patch.properties = {"address_spaces": workspace.properties["address_spaces"] + [workspace_service.properties["address_space"]]} # IP address allocation is managed by the API. Ideally this request would happen as a result of the workspace - # service deployment via the reosurce processor. there is no such functionality so the database is being + # service deployment via the resource processor. there is no such functionality so the database is being # updated directly, and an "update" on the workspace is called by the workspace service pipeline. - try: - await workspace_repo.patch_workspace(workspace, workspace_patch, workspace.etag, resource_template_repo, resource_history_repo, user, False) - except CosmosAccessConditionFailedError: - raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=strings.ETAG_CONFLICT) + MAX_RETRIES = 3 + RETRY_DELAY = 1 + + retries = 0 + while retries < MAX_RETRIES: + try: + await workspace_repo.patch_workspace(workspace, workspace_patch, workspace.etag, resource_template_repo, resource_history_repo, user, False) + break + except CosmosAccessConditionFailedError: + workspace = await workspace_repo.get_workspace(workspace.id) + workspace.etag = workspace.etag.strip('"') + workspace_patch = ResourcePatch() + workspace_patch.properties = {"address_spaces": workspace.properties["address_spaces"] + [workspace_service.properties["address_space"]]} + retries += 1 + if retries == MAX_RETRIES: + raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=strings.ETAG_CONFLICT) + time.sleep(RETRY_DELAY) operation = await save_and_deploy_resource( resource=workspace_service, diff --git a/e2e_tests/resources/strings.py b/e2e_tests/resources/strings.py index 833302a42f..a3c5584488 100644 --- a/e2e_tests/resources/strings.py +++ b/e2e_tests/resources/strings.py @@ -14,12 +14,15 @@ AIRLOCK_IMPORT_REVIEW_WORKSPACE = "tre-workspace-airlock-import-review" AZUREML_SERVICE = "tre-service-azureml" -INNEREYE_SERVICE = "tre-service-innereye" -GUACAMOLE_SERVICE = "tre-service-guacamole" +DATABRICKS_SERVICE = "tre-service-databricks" GITEA_SERVICE = "tre-workspace-service-gitea" +GUACAMOLE_SERVICE = "tre-service-guacamole" +INNEREYE_SERVICE = "tre-service-innereye" +HEALTH_SERVICE = "tre-workspace-service-health" MLFLOW_SERVICE = "tre-service-mlflow" MYSQL_SERVICE = "tre-workspace-service-mysql" -HEALTH_SERVICE = "tre-workspace-service-health" +OHDSI_SERVICE = "tre-workspace-service-ohdsi" + FIREWALL_SHARED_SERVICE = "tre-shared-service-firewall" GITEA_SHARED_SERVICE = "tre-shared-service-gitea" diff --git a/e2e_tests/test_workspace_services.py b/e2e_tests/test_workspace_services.py index df3f1d51d0..bffe33ee6e 100644 --- a/e2e_tests/test_workspace_services.py +++ b/e2e_tests/test_workspace_services.py @@ -9,8 +9,11 @@ workspace_services = [ strings.AZUREML_SERVICE, - # strings.INNEREYE_SERVICE, + strings.DATABRICKS_SERVICE, + strings.GUACAMOLE_SERVICE, strings.GITEA_SERVICE, + # strings.INNEREYE_SERVICE, + # strings.OHDSI_SERVICE, strings.MLFLOW_SERVICE, strings.MYSQL_SERVICE, strings.HEALTH_SERVICE, @@ -63,6 +66,7 @@ async def ping_guacamole_workspace_service(workspace_service_path, access_token, await check_aad_auth_redirect(endpoint, verify) +@pytest.mark.extended @pytest.mark.workspace_services @pytest.mark.timeout(45 * 60) @pytest.mark.parametrize("template_name", workspace_services) From e0039631f9fd13bade37a18b785516bb579ea794 Mon Sep 17 00:00:00 2001 From: Marcus Robinson Date: Mon, 11 Nov 2024 11:56:55 +0000 Subject: [PATCH 2/4] switch to aad worksapce. --- e2e_tests/test_workspace_services.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e_tests/test_workspace_services.py b/e2e_tests/test_workspace_services.py index de80c0a940..af09967c21 100644 --- a/e2e_tests/test_workspace_services.py +++ b/e2e_tests/test_workspace_services.py @@ -70,8 +70,8 @@ async def ping_guacamole_workspace_service(workspace_service_path, access_token, @pytest.mark.workspace_services @pytest.mark.timeout(45 * 60) @pytest.mark.parametrize("template_name", workspace_services) -async def test_install_workspace_service(template_name, verify, setup_test_workspace) -> None: - workspace_path, workspace_id = setup_test_workspace +async def test_install_workspace_service(template_name, verify, setup_test_aad_workspace) -> None: + workspace_path, workspace_id = setup_test_aad_workspace workspace_owner_token = await get_workspace_owner_token(workspace_id, verify) service_payload = { From c7b61c2022a985c193e57d6a4bc0872cb337d8a1 Mon Sep 17 00:00:00 2001 From: Marcus Robinson Date: Thu, 14 Nov 2024 17:05:08 +0000 Subject: [PATCH 3/4] Move to makefile --- .devcontainer/devcontainer.json | 16 ---------------- Makefile | 6 +++++- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 23ebdce709..9d49130458 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -138,22 +138,6 @@ "false" ] }, - { - "name": "E2E Workspace Services", - "type": "python", - "request": "launch", - "module": "pytest", - "justMyCode": true, - "cwd": "${workspaceFolder}/e2e_tests/", - "preLaunchTask": "Copy_env_file_for_e2e_debug", - "args": [ - "-n 5", - "-m", - "workspace_services", - "--verify", - "false" - ] - }, { "name": "E2E Performance", "type": "python", diff --git a/Makefile b/Makefile index 4c0b32bafa..59e79cd3b8 100644 --- a/Makefile +++ b/Makefile @@ -345,8 +345,12 @@ test-e2e-extended-aad: ## 🧪 Run E2E extended AAD tests $(call target_title, "Running E2E extended AAD tests") && \ $(MAKE) test-e2e-custom SELECTOR=extended_aad +test-e2e-workspace-services: ## 🧪 Run E2E workspace services tests + $(call target_title, "Running E2E workspace services tests") && \ + $(MAKE) test-e2e-custom SELECTOR=workspace_services + test-e2e-shared-services: ## 🧪 Run E2E shared service tests - $(call target_title, "Running E2E shared service tests") && \ + $(call target_title, "Running E2E shared services tests") && \ $(MAKE) test-e2e-custom SELECTOR=shared_services test-e2e-custom: ## 🧪 Run E2E tests with custom selector (SELECTOR=) From 1ce487608abd5c20cb795dc5516df4b872aa6157 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Fri, 29 Nov 2024 22:22:47 +0000 Subject: [PATCH 4/4] update to remove innereye and mlflow --- .github/workflows/deploy_tre.yml | 2 +- .github/workflows/pr_comment_bot.yml | 2 +- Makefile | 2 +- e2e_tests/resources/strings.py | 3 --- e2e_tests/test_workspace_services.py | 2 -- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy_tre.yml b/.github/workflows/deploy_tre.yml index f7c0b97420..a630c99905 100644 --- a/.github/workflows/deploy_tre.yml +++ b/.github/workflows/deploy_tre.yml @@ -36,7 +36,7 @@ jobs: ${{ (github.event_name == 'push' && 'extended or extended_aad') || 'extended or extended_aad or shared_services or airlock' }} environmentName: ${{ github.event.inputs.environment || 'CICD' }} - E2E_TESTS_NUMBER_PROCESSES: 5 + E2E_TESTS_NUMBER_PROCESSES: 3 DEVCONTAINER_TAG: 'latest' secrets: AAD_TENANT_ID: ${{ secrets.AAD_TENANT_ID }} diff --git a/.github/workflows/pr_comment_bot.yml b/.github/workflows/pr_comment_bot.yml index 1df3712124..6e0d034ae6 100644 --- a/.github/workflows/pr_comment_bot.yml +++ b/.github/workflows/pr_comment_bot.yml @@ -164,7 +164,7 @@ jobs: (needs.pr_comment.outputs.command == 'run-tests-shared-services' && 'shared_services') || (needs.pr_comment.outputs.command == 'run-tests' && '') }} environmentName: CICD - E2E_TESTS_NUMBER_PROCESSES: 5 + E2E_TESTS_NUMBER_PROCESSES: 3 DEVCONTAINER_TAG: ${{ needs.pr_comment.outputs.prRefId }} secrets: AAD_TENANT_ID: ${{ secrets.AAD_TENANT_ID }} diff --git a/Makefile b/Makefile index 59e79cd3b8..b890ff0fbb 100644 --- a/Makefile +++ b/Makefile @@ -349,7 +349,7 @@ test-e2e-workspace-services: ## 🧪 Run E2E workspace services tests $(call target_title, "Running E2E workspace services tests") && \ $(MAKE) test-e2e-custom SELECTOR=workspace_services -test-e2e-shared-services: ## 🧪 Run E2E shared service tests +test-e2e-shared-services: ## 🧪 Run E2E shared services tests $(call target_title, "Running E2E shared services tests") && \ $(MAKE) test-e2e-custom SELECTOR=shared_services diff --git a/e2e_tests/resources/strings.py b/e2e_tests/resources/strings.py index a35dc68f3f..724c69f3fd 100644 --- a/e2e_tests/resources/strings.py +++ b/e2e_tests/resources/strings.py @@ -18,12 +18,9 @@ GUACAMOLE_SERVICE = "tre-service-guacamole" GITEA_SERVICE = "tre-workspace-service-gitea" GUACAMOLE_SERVICE = "tre-service-guacamole" -INNEREYE_SERVICE = "tre-service-innereye" HEALTH_SERVICE = "tre-workspace-service-health" -MLFLOW_SERVICE = "tre-service-mlflow" MYSQL_SERVICE = "tre-workspace-service-mysql" OHDSI_SERVICE = "tre-workspace-service-ohdsi" - HEALTH_SERVICE = "tre-workspace-service-health" AZURESQL_SERVICE = "tre-workspace-service-azuresql" OPENAI_SERVICE = "tre-workspace-service-openai" diff --git a/e2e_tests/test_workspace_services.py b/e2e_tests/test_workspace_services.py index af09967c21..21ab0ed2b6 100644 --- a/e2e_tests/test_workspace_services.py +++ b/e2e_tests/test_workspace_services.py @@ -10,9 +10,7 @@ workspace_services = [ strings.AZUREML_SERVICE, strings.GITEA_SERVICE, - # strings.INNEREYE_SERVICE, # strings.OHDSI_SERVICE, - # strings.MLFLOW_SERVICE, strings.MYSQL_SERVICE, strings.HEALTH_SERVICE, strings.AZURESQL_SERVICE,