diff --git a/Makefile b/Makefile index 01d3b0db68..e88380d51e 100644 --- a/Makefile +++ b/Makefile @@ -319,6 +319,11 @@ shared_service_bundle = $(MAKE) bundle-build DIR=./templates/shared_services/$(1 && $(MAKE) bundle-publish DIR=./templates/shared_services/$(1)/ \ && $(MAKE) bundle-register DIR="./templates/shared_services/$(1)" BUNDLE_TYPE=shared_service +user_resource_bundle = $(MAKE) bundle-build DIR=./templates/workspace_services/$(1)/user_resources/$(2)/ \ + && $(MAKE) bundle-publish DIR=./templates/workspace_services/$(1)/user_resources/$(2) \ + && $(MAKE) bundle-register DIR="./templates/workspace_services/$(1)/user_resources/$(2)" BUNDLE_TYPE=user_resource WORKSPACE_SERVICE_NAME=tre-service-$(1) + + deploy-shared-service: @# NOTE: ACR_NAME below comes from the env files, so needs the double '$$'. Others are set on command execution and don't $(call target_title, "Deploying ${DIR} shared service") \ @@ -352,7 +357,8 @@ prepare-for-e2e: && $(call workspace_service_bundle,gitea) \ && $(call workspace_service_bundle,innereye) \ && $(call shared_service_bundle,sonatype-nexus) \ - && $(call shared_service_bundle,gitea) + && $(call shared_service_bundle,gitea) \ + && $(call user_resource_bundle,guacamole,guacamole-dev-vm) test-e2e-smoke: $(call target_title, "Running E2E smoke tests") && \ diff --git a/e2e_tests/test_performance.py b/e2e_tests/test_performance.py index 3eca1dfbb1..a9bc36d0a5 100644 --- a/e2e_tests/test_performance.py +++ b/e2e_tests/test_performance.py @@ -1,8 +1,7 @@ import asyncio import pytest - import config -from helpers import disable_and_delete_resource, post_resource +from helpers import disable_and_delete_resource, get_workspace_owner_token, post_resource from resources import strings pytestmark = pytest.mark.asyncio @@ -10,7 +9,7 @@ @pytest.mark.performance @pytest.mark.timeout(3000) -async def test_parallel_resource_creations(admin_token, workspace_owner_token, verify) -> None: +async def test_parallel_resource_creations(admin_token, verify) -> None: """Creates N workspaces in parallel, and creates a workspace service in each, in parallel""" number_workspaces = 2 @@ -28,23 +27,24 @@ async def test_parallel_resource_creations(admin_token, workspace_owner_token, v } } - task = asyncio.create_task(post_resource(payload, strings.API_WORKSPACES, 'workspace', workspace_owner_token, admin_token, verify)) + task = asyncio.create_task(post_resource(payload=payload, endpoint=strings.API_WORKSPACES, access_token=admin_token, verify=verify)) tasks.append(task) resource_paths = await asyncio.gather(*tasks) # Now disable + delete them all in parallel tasks = [] - for ws, _ in resource_paths: - task = asyncio.create_task(disable_and_delete_resource(f'/api{ws}', 'workspace', workspace_owner_token, admin_token, verify)) + for workspace_path, _ in resource_paths: + task = asyncio.create_task(disable_and_delete_resource(f'/api{workspace_path}', admin_token, verify)) tasks.append(task) await asyncio.gather(*tasks) +@pytest.mark.skip @pytest.mark.performance @pytest.mark.timeout(3000) -async def test_bulk_updates_to_ensure_each_resource_updated_in_series(admin_token, workspace_owner_token, verify) -> None: +async def test_bulk_updates_to_ensure_each_resource_updated_in_series(admin_token, verify) -> None: """Optionally creates a workspace and workspace service, then creates N number of VMs in parallel, patches each, and deletes them""" @@ -53,7 +53,9 @@ async def test_bulk_updates_to_ensure_each_resource_updated_in_series(admin_toke # To avoid creating + deleting a workspace + service in this test, set the vars for existing ones in ./templates/core/.env # PERF_TEST_WORKSPACE_ID | PERF_TEST_WORKSPACE_SERVICE_ID - if config.PERF_TEST_WORKSPACE_ID == "": + workspace_id = config.PERF_TEST_WORKSPACE_ID + + if workspace_id == "": # create the workspace to use payload = { "templateName": "tre-workspace-base", @@ -65,10 +67,12 @@ async def test_bulk_updates_to_ensure_each_resource_updated_in_series(admin_toke } } - workspace_path, _ = await post_resource(payload, strings.API_WORKSPACES, 'workspace', workspace_owner_token, admin_token, verify) + workspace_path, workspace_id = await post_resource(payload, strings.API_WORKSPACES, admin_token, verify) else: workspace_path = f"/workspaces/{config.PERF_TEST_WORKSPACE_ID}" + workspace_owner_token = await get_workspace_owner_token(admin_token=admin_token, workspace_id=workspace_id, verify=verify) + if config.PERF_TEST_WORKSPACE_SERVICE_ID == "": # create a guac service service_payload = { @@ -81,7 +85,11 @@ async def test_bulk_updates_to_ensure_each_resource_updated_in_series(admin_toke } } - workspace_service_path, _ = await post_resource(service_payload, f'/api{workspace_path}/{strings.API_WORKSPACE_SERVICES}', 'workspace_service', workspace_owner_token, None, verify) + workspace_service_path, _ = await post_resource( + payload=service_payload, + endpoint=f'/api{workspace_path}/{strings.API_WORKSPACE_SERVICES}', + access_token=workspace_owner_token, + verify=verify) else: workspace_service_path = f"{workspace_path}/{strings.API_WORKSPACE_SERVICES}/{config.PERF_TEST_WORKSPACE_SERVICE_ID}" @@ -97,7 +105,11 @@ async def test_bulk_updates_to_ensure_each_resource_updated_in_series(admin_toke tasks = [] for i in range(number_vms): - task = asyncio.create_task(post_resource(user_resource_payload, f'/api{workspace_service_path}/{strings.API_USER_RESOURCES}', 'user_resource', workspace_owner_token, None, verify)) + task = asyncio.create_task(post_resource( + payload=user_resource_payload, + endpoint=f'/api{workspace_service_path}/{strings.API_USER_RESOURCES}', + access_token=workspace_owner_token, + verify=verify)) tasks.append(task) resource_paths = await asyncio.gather(*tasks) @@ -113,17 +125,23 @@ async def test_bulk_updates_to_ensure_each_resource_updated_in_series(admin_toke "display_name": f'Perf test VM update {i}', } } - await post_resource(patch_payload, f'/api{resource_path}', 'user_resource', workspace_owner_token, None, verify, method="PATCH", wait=False) + await post_resource( + payload=patch_payload, + endpoint=f'/api{resource_path}', + access_token=workspace_owner_token, + verify=verify, + method="PATCH", + wait=False) # clear up all the VMs in parallel # NOTE: Due to bug https://github.com/microsoft/AzureTRE/issues/1163 - this VM delete step currently fails - task = asyncio.create_task(disable_and_delete_resource(f'/api{resource_path}', 'user_resource', workspace_owner_token, None, verify)) + task = asyncio.create_task(disable_and_delete_resource(f'/api{resource_path}', workspace_owner_token, verify)) tasks.append(task) await asyncio.gather(*tasks) # clear up workspace + service (if we created them) if config.PERF_TEST_WORKSPACE_SERVICE_ID == "": - await disable_and_delete_resource(f'/api{workspace_service_path}', 'workspace_service', workspace_owner_token, None, verify) + await disable_and_delete_resource(f'/api{workspace_service_path}', workspace_owner_token, verify) if config.PERF_TEST_WORKSPACE_ID == "": - await disable_and_delete_resource(f'/api{workspace_path}', 'workspace', workspace_owner_token, admin_token, verify) + await disable_and_delete_resource(f'/api{workspace_path}', admin_token, verify) diff --git a/e2e_tests/test_shared_services.py b/e2e_tests/test_shared_services.py index 71e950f0d4..bbca3e6809 100644 --- a/e2e_tests/test_shared_services.py +++ b/e2e_tests/test_shared_services.py @@ -79,12 +79,10 @@ async def test_patch_firewall(admin_token, verify): shared_service_path = f'/shared-services/{shared_service_firewall["id"]}' await post_resource( - patch_payload, - f"/api{shared_service_path}", - "shared_service", - admin_token, - None, - verify, + payload=patch_payload, + endpoint=f"/api{shared_service_path}", + access_token=admin_token, + verify=verify, method="PATCH", ) @@ -109,7 +107,7 @@ async def test_create_shared_service(template_name, admin_token, verify) -> None f"Shared service {template_name} already exists (id {id}), deleting it first..." ) await disable_and_delete_resource( - f"/api/shared-services/{id}", "shared_service", admin_token, None, verify + f"/api/shared-services/{id}", admin_token, verify ) post_payload = { @@ -121,14 +119,12 @@ async def test_create_shared_service(template_name, admin_token, verify) -> None } shared_service_path, _ = await post_resource( - post_payload, - "/api/shared-services", - "shared_service", - admin_token, - None, - verify, + payload=post_payload, + endpoint="/api/shared-services", + access_token=admin_token, + verify=verify, ) await disable_and_delete_resource( - f"/api{shared_service_path}", "shared_service", admin_token, None, verify + f"/api{shared_service_path}", admin_token, verify ) diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/porter.yaml b/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/porter.yaml index 4e1cd2fd25..1f455a82d5 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/porter.yaml +++ b/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/porter.yaml @@ -1,6 +1,6 @@ --- name: tre-service-dev-vm -version: 0.3.0 +version: 0.3.1 description: "An Azure TRE User Resource Template for a Dev VM" registry: azuretre dockerfile: Dockerfile.tmpl diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/template_schema.json b/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/template_schema.json index 535bcb14b3..e2eedfe1db 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/template_schema.json +++ b/templates/workspace_services/guacamole/user_resources/guacamole-dev-vm/template_schema.json @@ -37,7 +37,7 @@ "stepId": "6d2d7eb7-984e-4330-bd3c-c7ec98658402", "stepTitle": "Update the firewall the first time", "resourceTemplateName": "tre-shared-service-firewall", - "resourceType": "shared_service", + "resourceType": "shared-service", "resourceAction": "upgrade", "properties": [ { @@ -53,7 +53,7 @@ "stepId": "2fe8a6a7-2c27-4c49-8773-127df8a48b4e", "stepTitle": "Update the firewall the second time", "resourceTemplateName": "tre-shared-service-firewall", - "resourceType": "shared_service", + "resourceType": "shared-service", "resourceAction": "upgrade", "properties": [ { diff --git a/templates/workspaces/base/porter.yaml b/templates/workspaces/base/porter.yaml index e47a87d707..7f8d072678 100644 --- a/templates/workspaces/base/porter.yaml +++ b/templates/workspaces/base/porter.yaml @@ -1,6 +1,6 @@ --- name: tre-workspace-base -version: 0.3.0 +version: 0.3.1 description: "A base Azure TRE workspace" registry: azuretre