From 54829ec2570d8dd649f032ffa2d1503e12c8267c Mon Sep 17 00:00:00 2001 From: Iain Sproat <68657+iainsproat@users.noreply.github.com> Date: Thu, 13 Jul 2023 13:02:03 +0100 Subject: [PATCH] fix(helm test): works with frontend2 (#1693) --- .../templates/tests/deployment.yml | 6 ++++ utils/test-deployment/run_tests.py | 28 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/utils/helm/speckle-server/templates/tests/deployment.yml b/utils/helm/speckle-server/templates/tests/deployment.yml index 976d7edd2..d6691fb32 100644 --- a/utils/helm/speckle-server/templates/tests/deployment.yml +++ b/utils/helm/speckle-server/templates/tests/deployment.yml @@ -25,6 +25,12 @@ spec: value: https://{{ .Values.domain }} - name: SERVER_VERSION value: {{ .Values.docker_image_tag }} + - name: FRONTEND_VERSION + {{- if .Values.frontend_2.enabled }} + value: 2 + {{- else }} + value: 1 + {{- end }} resources: requests: cpu: {{ .Values.test.requests.cpu }} diff --git a/utils/test-deployment/run_tests.py b/utils/test-deployment/run_tests.py index 6b7f884f2..143889390 100755 --- a/utils/test-deployment/run_tests.py +++ b/utils/test-deployment/run_tests.py @@ -23,6 +23,13 @@ if not SPECKLE_SERVER: ) exit(1) +FRONTEND_VERSION = os.getenv("FRONTEND_VERSION", "") +if not FRONTEND_VERSION: + print( + "Error: No frontend version specified. Use FRONTEND_VERSION environment variable." + ) + exit(1) + if not SPECKLE_SERVER.startswith("http://") and not SPECKLE_SERVER.startswith( "https://" ): @@ -31,12 +38,21 @@ if not SPECKLE_SERVER.startswith("http://") and not SPECKLE_SERVER.startswith( print(f"Using Speckle server '{SPECKLE_SERVER}'") # Test if frontend is accessible -frontend_response = requests.get(urllib.parse.urljoin(SPECKLE_SERVER, "logo.svg")) -# don't check for status code, the frontend app will server the 404 page with a status code 200 -# even if the rote doesn't exist -assert frontend_response.headers.get("Content-Type", "").startswith( - "image/" -), "Frontend logo Content-Type is not an image" +if FRONTEND_VERSION == "1": + frontend_response = requests.get(urllib.parse.urljoin(SPECKLE_SERVER, "logo.svg")) + # don't check for status code, the frontend app will server the 404 page with a status code 200 + # even if the rote doesn't exist + assert frontend_response.headers.get("Content-Type", "").startswith( + "image/" + ), "Frontend logo Content-Type is not an image" +elif FRONTEND_VERSION == "2": + frontend_response = requests.get(SPECKLE_SERVER) + assert ( + frontend_response.status_code == 200 + ), "Frontend did not return a 200 status code" +else: + print(f"Unknown frontend version '{FRONTEND_VERSION}'") + exit(1) print("Frontend accessible") # Test basic unauthenticated operation using specklepy