From e53ac1350cbbd711e9c45e38060291d843db44f6 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 10:12:10 +0100 Subject: [PATCH 01/34] Add make file compatible with Mac and fix tests that filed on re-runs. --- Makefile | 112 ++++++++++++++++++ tests/tests_deployment/test_jupyterhub_api.py | 12 +- 2 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..ff3ff4c21f --- /dev/null +++ b/Makefile @@ -0,0 +1,112 @@ +all: init deploy test +build: init deploy + +TARGET := local-deployment/nebari-config.yaml +HOST := local-deployment.nebari.dev +TEST_USERNAME := "test-user" +TEST_PASSWORD := "P@sswo3d" +NEBARI_CONFIG_PATH = `realpath ./local-deployment/nebari-config.yaml` + +clean: + nebari destroy -c local-deployment/nebari-config.yaml --disable-prompt + rm $(TARGET) + kind delete clusters test-cluster + rm -rf local-deployment/stages + +pre-init-checks: + @echo Checking prerequsits + @ping $(HOST) | head -1 | grep '172.18.1.100' + kind --version + docker --version + brew services info chipmk/tap/docker-mac-net-connect + @echo "Check $(HOST) resolves" + +install: + pip install .[dev] + playwright install + @echo "Initialize Nebari Cloud." + +init: pre-init-checks install + @echo "Initializing deployment." + mkdir -p local-deployment + rm -rf loca-deployment/* + cd local-deployment && nebari init local --project=thisisatest --domain $(HOST) --auth-provider=password + #sed -i -E 's/(cpu_guarantee):\s+[0-9\.]+/\1: 0.25/g' "nebari-config.yaml" + #sed -i -E 's/(mem_guarantee):\s+[A-Za-z0-9\.]+/\1: 0.25G/g' "nebari-config.yaml" + @echo "Change default JupyterLab theme." + @echo "jupyterlab:" >> $(TARGET) + @echo " default_settings:" >> $(TARGET) + @echo ' "@jupyterlab/apputils-extension:themes":' >> $(TARGET) + @echo " theme: JupyterLab Dark" >> $(TARGET) + @echo "monitoring:" >> $(TARGET) + @echo " enabled: true" >> $(TARGET) + @echo " overrides:" >> $(TARGET) + @echo " minio:" >> $(TARGET) + @echo " persistence:" >> $(TARGET) + @echo " size: 1Gi" >> $(TARGET) + # @echo "default_images:" >> $(TARGET) + # @echo " jupyterhub: quay.io/nebari/nebari-jupyterhub:m1-image" >> $(TARGET) + # @echo " jupyterlab: quay.io/nebari/nebari-jupyterlab:m1-image" >> $(TARGET) + # @echo " dask_worker: quay.io/nebari/nebari-dask-worker:m1-image" >> $(TARGET) + # @echo "jhub_apps:" >> $(TARGET) + # @echo " enabled: true" >> $(TARGET) + # @echo "argo_workflows:" >> $(TARGET) + # @echo " enabled: false" >> $(TARGET) + @echo "conda_store:" >> $(TARGET) + @echo " image: quay.io/aktech/conda-store-server" >> $(TARGET) + @echo " image_tag: sha-558beb8" >> $(TARGET) + @awk -v n=13 -v s=' overrides:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + @awk -v n=14 -v s=' image:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + @awk -v n=15 -v s=' repository: quay.io/aktech/keycloak' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + # @awk -v n=16 -v s=' tag: 15.0.2' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + # @echo "certificate:" >> $(TARGET) + # @echo " type: lets-encrypt" >> $(TARGET) + # @echo " acme_email: priwari@quansight.com" >> $(TARGET) + # @echo "dns:" >> $(TARGET) + # @echo " provider: cloudflare" >> $(TARGET) + cat local-deployment/nebari-config.yaml + + + +deploy: + cd local-deployment && nebari deploy -c nebari-config.yaml + @echo "Create example-user" + ./scripts/create_test_user.sh $(TEST_USERNAME) $(TEST_PASSWORD) $(NEBARI_CONFIG_PATH) + @echo "Basic kubectl checks after deployment" + kubectl get all,cm,secret,pv,pvc,ing -A + @echo "Curl jupyterhub login page" + curl -k "https://$(HOST)/hub/home" -i + @echo "Get nebari-config.yaml full path" + @echo "NEBARI_CONFIG_PATH = $(NEBARI_CONFIG_PATH)" + + +test-cypress-run: + @echo "CYPRESS_EXAMPLE_USER_NAME=$(TEST_USERNAME) CYPRESS_EXAMPLE_USER_PASSWORD=$(TEST_PASSWORD) CYPRESS_BASE_URL=https://$(HOST)/" + cd tests/tests_e2e/ && \ + npm install && \ + CYPRESS_EXAMPLE_USER_NAME=$(TEST_USERNAME) \ + CYPRESS_EXAMPLE_USER_PASSWORD=$(TEST_PASSWORD) \ + CYPRESS_BASE_URL=https://$(HOST) \ + NEBARI_CONFIG_PATH=/Users/prashant/work/nebari/local-deployment/nebari-config.yaml \ + npx cypress run # --headed + +playwright-tests: + @echo "Run playwright pytest tests in headed mode with the chromium browser" + cd tests/tests_e2e/playwright && envsubst < .env.tpl > .env + cd tests/tests_e2e/playwright && \ + KEYCLOAK_USERNAME=${TEST_USERNAME} \ + KEYCLOAK_PASSWORD=${TEST_PASSWORD} \ + NEBARI_FULL_URL=https://$(HOST) \ + pytest --browser chromium --headed + +pytest: + KEYCLOAK_USERNAME=${TEST_USERNAME} \ + KEYCLOAK_PASSWORD=${TEST_PASSWORD} \ + NEBARI_HOSTNAME=${HOST} \ + NEBARI_CONFIG_PATH=/Users/prashant/work/nebari/local-deployment/nebari-config.yaml \ + pytest tests/tests_deployment/test_jupyterhub_ssh.py -v -s + + + +test: playwright-tests pytest # SKIPPED test-cypress-run + diff --git a/tests/tests_deployment/test_jupyterhub_api.py b/tests/tests_deployment/test_jupyterhub_api.py index 5e1a54562b..9d4f4d7572 100644 --- a/tests/tests_deployment/test_jupyterhub_api.py +++ b/tests/tests_deployment/test_jupyterhub_api.py @@ -1,4 +1,5 @@ import pytest +from requests.cookies import CookieConflictError from tests.tests_deployment import constants from tests.tests_deployment.keycloak_utils import ( @@ -11,7 +12,11 @@ @pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning") def test_jupyterhub_loads_roles_from_keycloak(): session = get_jupyterhub_session() - xsrf_token = session.cookies.get("_xsrf") + try: + xsrf_token = session.cookies.get("_xsrf") + except CookieConflictError as cce: + xsrf_token = session.cookies.get("_xsrf", path='/hub/') + response = session.get( f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}", headers={"X-XSRFToken": xsrf_token}, @@ -84,7 +89,10 @@ def test_keycloak_roles_attributes_parsed_as_jhub_scopes( @pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning") def test_jupyterhub_loads_groups_from_keycloak(): session = get_jupyterhub_session() - xsrf_token = session.cookies.get("_xsrf") + try: + xsrf_token = session.cookies.get("_xsrf") + except CookieConflictError as cce: + xsrf_token = session.cookies.get("_xsrf", path='/hub/') response = session.get( f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}", headers={"X-XSRFToken": xsrf_token}, From d7a18f4a3a99e21d8d459aba27ac64692bd9be89 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 09:13:44 +0000 Subject: [PATCH 02/34] [pre-commit.ci] Apply automatic pre-commit fixes --- Makefile | 3 +-- tests/tests_deployment/test_jupyterhub_api.py | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index ff3ff4c21f..93acc28acb 100644 --- a/Makefile +++ b/Makefile @@ -108,5 +108,4 @@ pytest: -test: playwright-tests pytest # SKIPPED test-cypress-run - +test: playwright-tests pytest # SKIPPED test-cypress-run diff --git a/tests/tests_deployment/test_jupyterhub_api.py b/tests/tests_deployment/test_jupyterhub_api.py index 9d4f4d7572..4c1122871f 100644 --- a/tests/tests_deployment/test_jupyterhub_api.py +++ b/tests/tests_deployment/test_jupyterhub_api.py @@ -14,9 +14,9 @@ def test_jupyterhub_loads_roles_from_keycloak(): session = get_jupyterhub_session() try: xsrf_token = session.cookies.get("_xsrf") - except CookieConflictError as cce: - xsrf_token = session.cookies.get("_xsrf", path='/hub/') - + except CookieConflictError: + xsrf_token = session.cookies.get("_xsrf", path="/hub/") + response = session.get( f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}", headers={"X-XSRFToken": xsrf_token}, @@ -91,8 +91,8 @@ def test_jupyterhub_loads_groups_from_keycloak(): session = get_jupyterhub_session() try: xsrf_token = session.cookies.get("_xsrf") - except CookieConflictError as cce: - xsrf_token = session.cookies.get("_xsrf", path='/hub/') + except CookieConflictError: + xsrf_token = session.cookies.get("_xsrf", path="/hub/") response = session.get( f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}", headers={"X-XSRFToken": xsrf_token}, From dc997f09233e64f316c4740cbf41d865fc498c94 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 10:14:28 +0100 Subject: [PATCH 03/34] Fix for pytests. --- tests/tests_deployment/utils.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/tests_deployment/utils.py b/tests/tests_deployment/utils.py index b0965dd1ae..71d51a8d76 100644 --- a/tests/tests_deployment/utils.py +++ b/tests/tests_deployment/utils.py @@ -28,17 +28,33 @@ def get_jupyterhub_session(): def create_jupyterhub_token(note): session = get_jupyterhub_session() - xsrf_token = session.cookies.get("_xsrf") + try: + xsrf_token = session.cookies.get("_xsrf") + except requests.cookies.CookieConflictError as cce: + xsrf_token = session.cookies.get("_xsrf", path='/hub/') + headers = {"Referer": f"https://{constants.NEBARI_HOSTNAME}/hub/token"} if xsrf_token: headers["X-XSRFToken"] = xsrf_token + print(f"xsrf_token: {xsrf_token}") data = {"note": note, "expires_in": None} - return session.post( + response = session.post( f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}/tokens", headers=headers, json=data, verify=False, ) + if response.status_code == 403: + xsrf_token = response.cookies.get("_xsrf") + headers["X-XSRFToken"] = xsrf_token + response = session.post( + f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}/tokens", + headers=headers, + json=data, + verify=False, + ) + + return response def get_jupyterhub_token(note="jupyterhub-tests-deployment"): From bc19a4c35d2ebea8b7c0e4a473f6f909c79f5847 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 09:15:39 +0000 Subject: [PATCH 04/34] [pre-commit.ci] Apply automatic pre-commit fixes --- tests/tests_deployment/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests_deployment/utils.py b/tests/tests_deployment/utils.py index 71d51a8d76..f81dca554e 100644 --- a/tests/tests_deployment/utils.py +++ b/tests/tests_deployment/utils.py @@ -30,9 +30,9 @@ def create_jupyterhub_token(note): session = get_jupyterhub_session() try: xsrf_token = session.cookies.get("_xsrf") - except requests.cookies.CookieConflictError as cce: - xsrf_token = session.cookies.get("_xsrf", path='/hub/') - + except requests.cookies.CookieConflictError: + xsrf_token = session.cookies.get("_xsrf", path="/hub/") + headers = {"Referer": f"https://{constants.NEBARI_HOSTNAME}/hub/token"} if xsrf_token: headers["X-XSRFToken"] = xsrf_token @@ -53,7 +53,7 @@ def create_jupyterhub_token(note): json=data, verify=False, ) - + return response From 8efa3fb5acd90c5b728ea45ecad46fd97cc7eaeb Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 10:32:19 +0100 Subject: [PATCH 05/34] Check for OS before running brew command. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 93acc28acb..f9d141a665 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ pre-init-checks: @ping $(HOST) | head -1 | grep '172.18.1.100' kind --version docker --version - brew services info chipmk/tap/docker-mac-net-connect + if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; fi @echo "Check $(HOST) resolves" install: From fbeaa7054e2feb6f4467c8b2670781c8828e504e Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 10:39:43 +0100 Subject: [PATCH 06/34] If not mac setup docker on unix. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f9d141a665..8b16764974 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ pre-init-checks: @ping $(HOST) | head -1 | grep '172.18.1.100' kind --version docker --version - if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; fi + if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; else sudo usermod -aG docker $USER && newgrp docker; fi @echo "Check $(HOST) resolves" install: From eff9f98675c77e18d1f36ff175f6d5cefcf342cf Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 10:49:50 +0100 Subject: [PATCH 07/34] Update local integration test workflow in CI to use Makefile. --- .github/workflows/test_local_integration.yaml | 99 ++----------------- 1 file changed, 6 insertions(+), 93 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 6d605787a6..b3adfec856 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -71,125 +71,38 @@ jobs: python-version: "3.11" miniconda-version: "latest" - - name: Install Nebari and playwright + - name: Install Nebari and playwright and initialize Nebari run: | - pip install .[dev] - playwright install + make init - uses: azure/setup-kubectl@v4.0.0 with: version: v1.19.16 - - name: Enable docker permissions for user - run: | - sudo docker ps - sudo usermod -aG docker $USER && newgrp docker - - docker info - docker ps - - - name: Get routing table for docker pods - run: | - ip route - - - name: Initialize Nebari Cloud - run: | - mkdir -p local-deployment - cd local-deployment - nebari init local --project=thisisatest --domain github-actions.nebari.dev --auth-provider=password - - # Need smaller profiles on Local Kind - sed -i -E 's/(cpu_guarantee):\s+[0-9\.]+/\1: 0.25/g' "nebari-config.yaml" - sed -i -E 's/(mem_guarantee):\s+[A-Za-z0-9\.]+/\1: 0.25G/g' "nebari-config.yaml" - - # Change default JupyterLab theme - cat >> nebari-config.yaml <<- EOM - jupyterlab: - default_settings: - "@jupyterlab/apputils-extension:themes": - theme: JupyterLab Dark - EOM - - # Change default value for minio persistence size - cat >> nebari-config.yaml <<- EOM - monitoring: - enabled: true - overrides: - minio: - persistence: - size: 1Gi - EOM - - cat nebari-config.yaml - name: Deploy Nebari working-directory: local-deployment run: | - nebari deploy --config nebari-config.yaml --disable-prompt - - - name: Basic kubectl checks after deployment - if: always() - run: | - kubectl get all,cm,secret,pv,pvc,ing -A - - - name: Check github-actions.nebari.dev resolves - run: | - nslookup github-actions.nebari.dev - - - name: Curl jupyterhub login page - run: | - curl -k https://github-actions.nebari.dev/hub/home -i - - - name: Create example-user - working-directory: local-deployment - run: | - nebari keycloak adduser --user "${TEST_USERNAME}" "${TEST_PASSWORD}" --config nebari-config.yaml - nebari keycloak listusers --config nebari-config.yaml + make deploy - uses: actions/setup-node@v4 with: node-version: 20 - - name: Get nebari-config.yaml full path - run: echo "NEBARI_CONFIG_PATH=`realpath ./local-deployment/nebari-config.yaml`" >> "$GITHUB_ENV" - - - name: Cypress run - uses: cypress-io/github-action@v6 - env: - CYPRESS_EXAMPLE_USER_NAME: ${{ env.TEST_USERNAME }} - CYPRESS_EXAMPLE_USER_PASSWORD: ${{ env.TEST_PASSWORD }} - CYPRESS_BASE_URL: https://github-actions.nebari.dev/ - with: - working-directory: tests/tests_e2e - - name: Playwright Tests env: KEYCLOAK_USERNAME: ${{ env.TEST_USERNAME }} KEYCLOAK_PASSWORD: ${{ env.TEST_PASSWORD }} NEBARI_FULL_URL: https://github-actions.nebari.dev/ - working-directory: tests/tests_e2e/playwright run: | - # create environment file - envsubst < .env.tpl > .env - # run playwright pytest tests in headed mode with the chromium browser - xvfb-run pytest --browser chromium - - - name: Save Cypress screenshots and videos - if: always() - uses: actions/upload-artifact@v4.3.1 - with: - name: e2e-cypress - path: | - ./tests/tests_e2e/cypress/screenshots/ - ./tests/tests_e2e/cypress/videos/ - ./tests/tests_e2e/playwright/videos/ + make playwright-test - name: Deployment Pytests env: KEYCLOAK_USERNAME: ${{ env.TEST_USERNAME }} KEYCLOAK_PASSWORD: ${{ env.TEST_PASSWORD }} run: | - pytest tests/tests_deployment/ -v -s + make pytest ### CLEANUP AFTER TESTS - name: Cleanup nebari deployment @@ -199,4 +112,4 @@ jobs: if: github.ref_name == 'develop' || github.event_name == 'workflow_dispatch' working-directory: local-deployment run: | - nebari destroy --config nebari-config.yaml --disable-prompt + make clean From f9d6e366304ecdf8b78bf087cd7b1b5c1b01f372 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 11:05:57 +0100 Subject: [PATCH 08/34] Set host for CI. --- .github/workflows/test_local_integration.yaml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index b3adfec856..005e371006 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -73,7 +73,7 @@ jobs: - name: Install Nebari and playwright and initialize Nebari run: | - make init + make init HOST=github-actions.nebari.dev - uses: azure/setup-kubectl@v4.0.0 with: @@ -81,28 +81,20 @@ jobs: - name: Deploy Nebari - working-directory: local-deployment run: | - make deploy + make deploy HOST=github-actions.nebari.dev - uses: actions/setup-node@v4 with: node-version: 20 - name: Playwright Tests - env: - KEYCLOAK_USERNAME: ${{ env.TEST_USERNAME }} - KEYCLOAK_PASSWORD: ${{ env.TEST_PASSWORD }} - NEBARI_FULL_URL: https://github-actions.nebari.dev/ run: | - make playwright-test + make playwright-test HOST=github-actions.nebari.dev - name: Deployment Pytests - env: - KEYCLOAK_USERNAME: ${{ env.TEST_USERNAME }} - KEYCLOAK_PASSWORD: ${{ env.TEST_PASSWORD }} run: | - make pytest + make pytest HOST=github-actions.nebari.dev ### CLEANUP AFTER TESTS - name: Cleanup nebari deployment @@ -110,6 +102,5 @@ jobs: # in the CI, it makes sense to only run on merge to main or workflow_dispatch to speed # up feedback cycle if: github.ref_name == 'develop' || github.event_name == 'workflow_dispatch' - working-directory: local-deployment run: | - make clean + make clean HOST=github-actions.nebari.dev From 3f9215aa934eac0ff304492dd43b36d6e8604757 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 20:10:47 +0100 Subject: [PATCH 09/34] Fix pre-init-checks. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8b16764974..608cdfd7f1 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ clean: pre-init-checks: @echo Checking prerequsits - @ping $(HOST) | head -1 | grep '172.18.1.100' + # @ping $(HOST) | head -1 | grep '172.18.1.100' kind --version docker --version if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; else sudo usermod -aG docker $USER && newgrp docker; fi From 4c1de2c0038429d3da6c608e1daceba6b9ff1a06 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 20:21:37 +0100 Subject: [PATCH 10/34] Setup tmate for testing. --- .github/workflows/test_local_integration.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 005e371006..50af7705b3 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -71,6 +71,9 @@ jobs: python-version: "3.11" miniconda-version: "latest" + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + - name: Install Nebari and playwright and initialize Nebari run: | make init HOST=github-actions.nebari.dev From 0dcbbef1bf34d7408cb4904feaf826dbeed0efbc Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 20:21:57 +0100 Subject: [PATCH 11/34] Run kind only on mac. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 608cdfd7f1..614d0441ec 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,9 @@ clean: pre-init-checks: @echo Checking prerequsits # @ping $(HOST) | head -1 | grep '172.18.1.100' - kind --version + docker --version - if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; else sudo usermod -aG docker $USER && newgrp docker; fi + if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; kind --version; else sudo usermod -aG docker $USER && newgrp docker; fi @echo "Check $(HOST) resolves" install: From 2b2c4b3871c31dd4bc8593f2bb6ec7cfcfadfc0f Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Wed, 3 Jul 2024 20:48:09 +0100 Subject: [PATCH 12/34] Remove mac specific steps. --- .github/workflows/test_local_integration.yaml | 2 -- Makefile | 4 ++-- tests/tests_deployment/test_jupyterhub_api.py | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 50af7705b3..767b603621 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -71,8 +71,6 @@ jobs: python-version: "3.11" miniconda-version: "latest" - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - name: Install Nebari and playwright and initialize Nebari run: | diff --git a/Makefile b/Makefile index 614d0441ec..af6eb42842 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ pre-init-checks: # @ping $(HOST) | head -1 | grep '172.18.1.100' docker --version - if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; kind --version; else sudo usermod -aG docker $USER && newgrp docker; fi + #if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; kind --version; else sudo usermod -aG docker $USER && newgrp docker; fi @echo "Check $(HOST) resolves" install: @@ -104,7 +104,7 @@ pytest: KEYCLOAK_PASSWORD=${TEST_PASSWORD} \ NEBARI_HOSTNAME=${HOST} \ NEBARI_CONFIG_PATH=/Users/prashant/work/nebari/local-deployment/nebari-config.yaml \ - pytest tests/tests_deployment/test_jupyterhub_ssh.py -v -s + pytest tests/tests_deployment/ -v -s diff --git a/tests/tests_deployment/test_jupyterhub_api.py b/tests/tests_deployment/test_jupyterhub_api.py index 4c1122871f..2cafdfea64 100644 --- a/tests/tests_deployment/test_jupyterhub_api.py +++ b/tests/tests_deployment/test_jupyterhub_api.py @@ -10,6 +10,7 @@ @pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning") +@pytest.mark.filterwarnings("ignore::ResourceWarning") def test_jupyterhub_loads_roles_from_keycloak(): session = get_jupyterhub_session() try: From fd1720cf1f2f014a2e4e36230260d8d61dd34ad6 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 16:16:43 +0100 Subject: [PATCH 13/34] Fix make file for mac again. --- Makefile | 58 ++++++++++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index af6eb42842..28fabb69a4 100644 --- a/Makefile +++ b/Makefile @@ -6,20 +6,31 @@ HOST := local-deployment.nebari.dev TEST_USERNAME := "test-user" TEST_PASSWORD := "P@sswo3d" NEBARI_CONFIG_PATH = `realpath ./local-deployment/nebari-config.yaml` +UNAME_S := $(shell uname -s) -clean: +ifeq ($(UNAME_S),Darwin) + IS_MAC := true +else + IS_MAC := false +endif + +clean: nebari-destroy delete-cluster + +nebari-destroy: nebari destroy -c local-deployment/nebari-config.yaml --disable-prompt rm $(TARGET) - kind delete clusters test-cluster + +delete-cluster: + @$(IS_MAC) && kind delete clusters test-cluster rm -rf local-deployment/stages pre-init-checks: @echo Checking prerequsits - # @ping $(HOST) | head -1 | grep '172.18.1.100' - - docker --version - #if [ "$(uname -s)" = "Darwin" ]; then brew services info chipmk/tap/docker-mac-net-connect; kind --version; else sudo usermod -aG docker $USER && newgrp docker; fi - @echo "Check $(HOST) resolves" + @docker --version + @$(IS_MAC) && ping $(HOST) | head -1 | grep '172.18.1.100' + @$(IS_MAC) && brew services info chipmk/tap/docker-mac-net-connect + @$(IS_MAC) && kind --version + @$(IS_MAC) || sudo usermod -aG docker $USER newgrp docker install: pip install .[dev] @@ -44,29 +55,13 @@ init: pre-init-checks install @echo " minio:" >> $(TARGET) @echo " persistence:" >> $(TARGET) @echo " size: 1Gi" >> $(TARGET) - # @echo "default_images:" >> $(TARGET) - # @echo " jupyterhub: quay.io/nebari/nebari-jupyterhub:m1-image" >> $(TARGET) - # @echo " jupyterlab: quay.io/nebari/nebari-jupyterlab:m1-image" >> $(TARGET) - # @echo " dask_worker: quay.io/nebari/nebari-dask-worker:m1-image" >> $(TARGET) - # @echo "jhub_apps:" >> $(TARGET) - # @echo " enabled: true" >> $(TARGET) - # @echo "argo_workflows:" >> $(TARGET) - # @echo " enabled: false" >> $(TARGET) - @echo "conda_store:" >> $(TARGET) - @echo " image: quay.io/aktech/conda-store-server" >> $(TARGET) - @echo " image_tag: sha-558beb8" >> $(TARGET) - @awk -v n=13 -v s=' overrides:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) - @awk -v n=14 -v s=' image:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) - @awk -v n=15 -v s=' repository: quay.io/aktech/keycloak' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) - # @awk -v n=16 -v s=' tag: 15.0.2' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) - # @echo "certificate:" >> $(TARGET) - # @echo " type: lets-encrypt" >> $(TARGET) - # @echo " acme_email: priwari@quansight.com" >> $(TARGET) - # @echo "dns:" >> $(TARGET) - # @echo " provider: cloudflare" >> $(TARGET) - cat local-deployment/nebari-config.yaml - - + @$(IS_MAC) && echo "conda_store:" >> $(TARGET) + @$(IS_MAC) && echo " image: quay.io/aktech/conda-store-server" >> $(TARGET) + @$(IS_MAC) && echo " image_tag: sha-558beb8" >> $(TARGET) + @$(IS_MAC) && awk -v n=13 -v s=' overrides:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + @$(IS_MAC) && awk -v n=14 -v s=' image:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + @$(IS_MAC) && awk -v n=15 -v s=' repository: quay.io/aktech/keycloak' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + @cat local-deployment/nebari-config.yaml deploy: cd local-deployment && nebari deploy -c nebari-config.yaml @@ -79,7 +74,6 @@ deploy: @echo "Get nebari-config.yaml full path" @echo "NEBARI_CONFIG_PATH = $(NEBARI_CONFIG_PATH)" - test-cypress-run: @echo "CYPRESS_EXAMPLE_USER_NAME=$(TEST_USERNAME) CYPRESS_EXAMPLE_USER_PASSWORD=$(TEST_PASSWORD) CYPRESS_BASE_URL=https://$(HOST)/" cd tests/tests_e2e/ && \ @@ -106,6 +100,4 @@ pytest: NEBARI_CONFIG_PATH=/Users/prashant/work/nebari/local-deployment/nebari-config.yaml \ pytest tests/tests_deployment/ -v -s - - test: playwright-tests pytest # SKIPPED test-cypress-run From 6d3d851e34f7c6d0d54f523e4feaa02b318fcb29 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 16:40:59 +0100 Subject: [PATCH 14/34] Add debugging. --- .github/workflows/test_local_integration.yaml | 4 ++++ Makefile | 1 + 2 files changed, 5 insertions(+) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 767b603621..3e24ab7ee9 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -76,6 +76,10 @@ jobs: run: | make init HOST=github-actions.nebari.dev + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + - uses: azure/setup-kubectl@v4.0.0 with: version: v1.19.16 diff --git a/Makefile b/Makefile index 28fabb69a4..ae5bd6268c 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ pre-init-checks: @$(IS_MAC) && ping $(HOST) | head -1 | grep '172.18.1.100' @$(IS_MAC) && brew services info chipmk/tap/docker-mac-net-connect @$(IS_MAC) && kind --version + @echo $(SHELL) @$(IS_MAC) || sudo usermod -aG docker $USER newgrp docker install: From c97782d19f29e121047ecf905c62962a2c287092 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 17:04:48 +0100 Subject: [PATCH 15/34] Ignore errors on mac filters. --- Makefile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index ae5bd6268c..f56f218ce1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ all: init deploy test build: init deploy +SHELL = /bin/bash TARGET := local-deployment/nebari-config.yaml HOST := local-deployment.nebari.dev TEST_USERNAME := "test-user" @@ -21,17 +22,17 @@ nebari-destroy: rm $(TARGET) delete-cluster: - @$(IS_MAC) && kind delete clusters test-cluster + -@$(IS_MAC) && kind delete clusters test-cluster rm -rf local-deployment/stages pre-init-checks: @echo Checking prerequsits @docker --version - @$(IS_MAC) && ping $(HOST) | head -1 | grep '172.18.1.100' - @$(IS_MAC) && brew services info chipmk/tap/docker-mac-net-connect - @$(IS_MAC) && kind --version - @echo $(SHELL) - @$(IS_MAC) || sudo usermod -aG docker $USER newgrp docker + -@$(IS_MAC) && ping $(HOST) | head -1 | grep '172.18.1.100' + -@$(IS_MAC) && brew services info chipmk/tap/docker-mac-net-connect + -@$(IS_MAC) && kind --version + -@echo $(SHELL) + -@$(IS_MAC) || sudo usermod -aG docker $USER newgrp docker install: pip install .[dev] @@ -56,12 +57,12 @@ init: pre-init-checks install @echo " minio:" >> $(TARGET) @echo " persistence:" >> $(TARGET) @echo " size: 1Gi" >> $(TARGET) - @$(IS_MAC) && echo "conda_store:" >> $(TARGET) - @$(IS_MAC) && echo " image: quay.io/aktech/conda-store-server" >> $(TARGET) - @$(IS_MAC) && echo " image_tag: sha-558beb8" >> $(TARGET) - @$(IS_MAC) && awk -v n=13 -v s=' overrides:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) - @$(IS_MAC) && awk -v n=14 -v s=' image:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) - @$(IS_MAC) && awk -v n=15 -v s=' repository: quay.io/aktech/keycloak' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + -@$(IS_MAC) && echo "conda_store:" >> $(TARGET) + -@$(IS_MAC) && echo " image: quay.io/aktech/conda-store-server" >> $(TARGET) + -@$(IS_MAC) && echo " image_tag: sha-558beb8" >> $(TARGET) + -@$(IS_MAC) && awk -v n=13 -v s=' overrides:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + -@$(IS_MAC) && awk -v n=14 -v s=' image:' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) + -@$(IS_MAC) && awk -v n=15 -v s=' repository: quay.io/aktech/keycloak' 'NR == n {print s} {print}' $(TARGET) > tmp && mv tmp $(TARGET) @cat local-deployment/nebari-config.yaml deploy: From a715cd994ca9643cbc8126b031fe3a44a5360763 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 17:05:29 +0100 Subject: [PATCH 16/34] Remove tmate. --- .github/workflows/test_local_integration.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 3e24ab7ee9..0939e33c10 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -76,9 +76,9 @@ jobs: run: | make init HOST=github-actions.nebari.dev - - name: Setup tmate session - if: ${{ failure() }} - uses: mxschmitt/action-tmate@v3 + # - name: Setup tmate session + # if: ${{ failure() }} + # uses: mxschmitt/action-tmate@v3 - uses: azure/setup-kubectl@v4.0.0 with: From 97ced6c39242053560338351ed25d34e025196c0 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 17:29:23 +0100 Subject: [PATCH 17/34] Add debugging and tmate. --- .github/workflows/test_local_integration.yaml | 11 +++++------ Makefile | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 0939e33c10..366904005a 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -76,19 +76,18 @@ jobs: run: | make init HOST=github-actions.nebari.dev - # - name: Setup tmate session - # if: ${{ failure() }} - # uses: mxschmitt/action-tmate@v3 - - uses: azure/setup-kubectl@v4.0.0 with: version: v1.19.16 - - - name: Deploy Nebari + - name: Deploy Nebari and create user run: | make deploy HOST=github-actions.nebari.dev + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + - uses: actions/setup-node@v4 with: node-version: 20 diff --git a/Makefile b/Makefile index f56f218ce1..be316868a0 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,8 @@ init: pre-init-checks install deploy: cd local-deployment && nebari deploy -c nebari-config.yaml @echo "Create example-user" + @pwd + @ls ./scripts/create_test_user.sh $(TEST_USERNAME) $(TEST_PASSWORD) $(NEBARI_CONFIG_PATH) @echo "Basic kubectl checks after deployment" kubectl get all,cm,secret,pv,pvc,ing -A From e40f2da25da8f235afe0066c73558cb283b0241d Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 17:50:59 +0100 Subject: [PATCH 18/34] Add ./scripts/create_test_user.sh. --- scripts/create_test_user.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 scripts/create_test_user.sh diff --git a/scripts/create_test_user.sh b/scripts/create_test_user.sh new file mode 100755 index 0000000000..b4e779c54d --- /dev/null +++ b/scripts/create_test_user.sh @@ -0,0 +1,16 @@ +#!/bin/bash +TEST_USERNAME=$1 +TEST_PASSWORD=$2 +NEBARI_CONFIG_PATH=$3 +count="$(nebari keycloak listusers --config "$NEBARI_CONFIG_PATH" | grep test-user | wc -l | tr -d '[:blank:]')" +echo "TEST_USERNAME: $TEST_USERNAME, TEST_PASSWORD: ${TEST_PASSWORD}" +cd +if [[ $count == "0" ]]; then + nebari keycloak adduser \ + --user "${TEST_USERNAME}" "${TEST_PASSWORD}" \ + --config "$NEBARI_CONFIG_PATH" +else + echo 'Nebari users already created.' + echo `pwd` + nebari keycloak listusers --config "$NEBARI_CONFIG_PATH" +fi From b6325ba32514384e6847ef1b777a4cd7db3e006c Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 18:18:58 +0100 Subject: [PATCH 19/34] Fix playwright tests target name. --- .github/workflows/test_local_integration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 366904005a..889fbb299d 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -94,7 +94,7 @@ jobs: - name: Playwright Tests run: | - make playwright-test HOST=github-actions.nebari.dev + make playwright-tests HOST=github-actions.nebari.dev - name: Deployment Pytests run: | From f93bf1c39112243f9eed5b08967dfbd7948b1133 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 20:38:43 +0100 Subject: [PATCH 20/34] Headless playwright-tests. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index be316868a0..adfc26f55d 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,7 @@ playwright-tests: KEYCLOAK_USERNAME=${TEST_USERNAME} \ KEYCLOAK_PASSWORD=${TEST_PASSWORD} \ NEBARI_FULL_URL=https://$(HOST) \ - pytest --browser chromium --headed + pytest --browser chromium # --headed pytest: KEYCLOAK_USERNAME=${TEST_USERNAME} \ From 0a0fe8d69ec5fd6a81280b6aeca8ad9779f50d21 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 20:40:47 +0100 Subject: [PATCH 21/34] Save playwright test video artifact. --- .github/workflows/test_local_integration.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 889fbb299d..23ea67014f 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -96,6 +96,14 @@ jobs: run: | make playwright-tests HOST=github-actions.nebari.dev + - name: Save playwright videos + if: always() + uses: actions/upload-artifact@v4.3.1 + with: + name: playwright-cypress + path: | + ./tests/tests_e2e/playwright/videos/ + - name: Deployment Pytests run: | make pytest HOST=github-actions.nebari.dev From 1e6d46b37e8bb15da91a905e63db13029691d094 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 20:53:32 +0100 Subject: [PATCH 22/34] Remove tmate. --- .github/workflows/test_local_integration.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 23ea67014f..500687815c 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -84,10 +84,6 @@ jobs: run: | make deploy HOST=github-actions.nebari.dev - - name: Setup tmate session - if: ${{ failure() }} - uses: mxschmitt/action-tmate@v3 - - uses: actions/setup-node@v4 with: node-version: 20 From d3a1982b6737330f41afe9a0b985adce3fc0c22e Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 21:16:42 +0100 Subject: [PATCH 23/34] Fix NEBARI_CONFIG_PATH. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index adfc26f55d..4fc46beb36 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ test-cypress-run: CYPRESS_EXAMPLE_USER_NAME=$(TEST_USERNAME) \ CYPRESS_EXAMPLE_USER_PASSWORD=$(TEST_PASSWORD) \ CYPRESS_BASE_URL=https://$(HOST) \ - NEBARI_CONFIG_PATH=/Users/prashant/work/nebari/local-deployment/nebari-config.yaml \ + NEBARI_CONFIG_PATH=$(NEBARI_CONFIG_PATH) \ npx cypress run # --headed playwright-tests: @@ -101,7 +101,7 @@ pytest: KEYCLOAK_USERNAME=${TEST_USERNAME} \ KEYCLOAK_PASSWORD=${TEST_PASSWORD} \ NEBARI_HOSTNAME=${HOST} \ - NEBARI_CONFIG_PATH=/Users/prashant/work/nebari/local-deployment/nebari-config.yaml \ + NEBARI_CONFIG_PATH=$(NEBARI_CONFIG_PATH) \ pytest tests/tests_deployment/ -v -s test: playwright-tests pytest # SKIPPED test-cypress-run From d8115d763da2a57d342ce84bffafe2f731662c41 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 21:27:19 +0100 Subject: [PATCH 24/34] CI refactor and re-enable cypress. --- .github/workflows/test_local_integration.yaml | 16 ++++++++++------ Makefile | 7 ++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 500687815c..e537be8ea1 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -74,7 +74,7 @@ jobs: - name: Install Nebari and playwright and initialize Nebari run: | - make init HOST=github-actions.nebari.dev + make init - uses: azure/setup-kubectl@v4.0.0 with: @@ -82,27 +82,31 @@ jobs: - name: Deploy Nebari and create user run: | - make deploy HOST=github-actions.nebari.dev + make deploy - uses: actions/setup-node@v4 with: node-version: 20 + - name: Cypress run + run: | + make cypress-run + - name: Playwright Tests run: | - make playwright-tests HOST=github-actions.nebari.dev + make playwright-tests - name: Save playwright videos if: always() uses: actions/upload-artifact@v4.3.1 with: - name: playwright-cypress + name: e2e-playwright path: | ./tests/tests_e2e/playwright/videos/ - name: Deployment Pytests run: | - make pytest HOST=github-actions.nebari.dev + make pytest ### CLEANUP AFTER TESTS - name: Cleanup nebari deployment @@ -111,4 +115,4 @@ jobs: # up feedback cycle if: github.ref_name == 'develop' || github.event_name == 'workflow_dispatch' run: | - make clean HOST=github-actions.nebari.dev + make clean diff --git a/Makefile b/Makefile index 4fc46beb36..681aa1a5bb 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ build: init deploy SHELL = /bin/bash TARGET := local-deployment/nebari-config.yaml -HOST := local-deployment.nebari.dev TEST_USERNAME := "test-user" TEST_PASSWORD := "P@sswo3d" NEBARI_CONFIG_PATH = `realpath ./local-deployment/nebari-config.yaml` @@ -11,8 +10,10 @@ UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) IS_MAC := true + HOST := local-deployment.nebari.dev else IS_MAC := false + HOST := github-actions.nebari.dev endif clean: nebari-destroy delete-cluster @@ -78,7 +79,7 @@ deploy: @echo "Get nebari-config.yaml full path" @echo "NEBARI_CONFIG_PATH = $(NEBARI_CONFIG_PATH)" -test-cypress-run: +cypress-run: @echo "CYPRESS_EXAMPLE_USER_NAME=$(TEST_USERNAME) CYPRESS_EXAMPLE_USER_PASSWORD=$(TEST_PASSWORD) CYPRESS_BASE_URL=https://$(HOST)/" cd tests/tests_e2e/ && \ npm install && \ @@ -104,4 +105,4 @@ pytest: NEBARI_CONFIG_PATH=$(NEBARI_CONFIG_PATH) \ pytest tests/tests_deployment/ -v -s -test: playwright-tests pytest # SKIPPED test-cypress-run +test: playwright-tests pytest # SKIPPED cypress-run From d9c20edf34bdcfc1c3c29552642150beedc5679f Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 21:39:32 +0100 Subject: [PATCH 25/34] Enable cypress tests. --- .github/workflows/test_local_integration.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index e537be8ea1..9ffe3d6d52 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -96,12 +96,14 @@ jobs: run: | make playwright-tests - - name: Save playwright videos + - name: Save playwright and cypress videos and screenshots. if: always() uses: actions/upload-artifact@v4.3.1 with: name: e2e-playwright path: | + ./tests/tests_e2e/cypress/screenshots/ + ./tests/tests_e2e/cypress/videos/ ./tests/tests_e2e/playwright/videos/ - name: Deployment Pytests From 8901f6dd5c9e1811c84f252bc2b3b3441b94ec45 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 22:00:43 +0100 Subject: [PATCH 26/34] Remove Cypress tests. --- .github/workflows/test_local_integration.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 9ffe3d6d52..14110e06ce 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -88,22 +88,16 @@ jobs: with: node-version: 20 - - name: Cypress run - run: | - make cypress-run - - name: Playwright Tests run: | make playwright-tests - - name: Save playwright and cypress videos and screenshots. + - name: Save playwright videos. if: always() uses: actions/upload-artifact@v4.3.1 with: name: e2e-playwright path: | - ./tests/tests_e2e/cypress/screenshots/ - ./tests/tests_e2e/cypress/videos/ ./tests/tests_e2e/playwright/videos/ - name: Deployment Pytests From 47648861ecef35f6e21decccbb7adfea36d58a2e Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Thu, 4 Jul 2024 23:04:15 +0100 Subject: [PATCH 27/34] Run pytest before playwrite tests. --- .github/workflows/test_local_integration.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 14110e06ce..c60d290cf8 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -88,6 +88,10 @@ jobs: with: node-version: 20 + - name: Deployment Pytests + run: | + make pytest + - name: Playwright Tests run: | make playwright-tests @@ -100,10 +104,6 @@ jobs: path: | ./tests/tests_e2e/playwright/videos/ - - name: Deployment Pytests - run: | - make pytest - ### CLEANUP AFTER TESTS - name: Cleanup nebari deployment # Since this is not critical for most pull requests and takes more than half of the time From b5d2cd9c8a1ba58f5eabdaf6cedce300acd4c895 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Fri, 5 Jul 2024 18:07:17 +0100 Subject: [PATCH 28/34] Fix playwright tets. --- tests/common/navigator.py | 17 +++++++++++++---- tests/common/playwright_fixtures.py | 3 ++- tests/common/run_notebook.py | 7 ++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/common/navigator.py b/tests/common/navigator.py index f846d9a545..9c401e8047 100644 --- a/tests/common/navigator.py +++ b/tests/common/navigator.py @@ -189,7 +189,11 @@ def start_server(self) -> None: """ # wait for the page to load logout_button = self.page.get_by_text("Logout", exact=True) - logout_button.wait_for(state="attached", timeout=90000) + logger.info("waiting for logout button.") + file_menu = self.page.get_by_text("File", exact=True) + if file_menu.is_visible(): + logger.info("Server is already up!") + return # if the server is already running start_locator = self.page.get_by_role("button", name="My Server", exact=True) @@ -255,7 +259,10 @@ def reset_workspace(self): if popup: self._set_environment_via_popup(kernel=None) - # go to Kernel menu + logger.info(">>> go to Kernel menu") + dialog = self.page.get_by_role("dialog") + if dialog.is_visible(): + dialog.get_by_role("button", name="No Kernel").click() kernel_menuitem = self.page.get_by_role("menuitem", name="Kernel", exact=True) kernel_menuitem.click() # shut down multiple running kernels @@ -283,9 +290,11 @@ def reset_workspace(self): # close all tabs self.page.get_by_role("menuitem", name="Close All Tabs", exact=True).click() - # there may be a popup to save your work, don't save + logger.info("there may be a popup to save your work, don't save") + time.sleep(2) if self.page.get_by_text("Save your work", exact=True).is_visible(): - self.page.get_by_role("button", name="Discard", exact=True).click() + logger.info("popup to save your work found. Discarding change ...") + self.page.get_by_role("button", name="Discard changes to file", exact=True).click() # wait to ensure that the Launcher is showing self.page.get_by_text("VS Code [↗]", exact=True).wait_for( diff --git a/tests/common/playwright_fixtures.py b/tests/common/playwright_fixtures.py index 03e17a5065..bdc0577643 100644 --- a/tests/common/playwright_fixtures.py +++ b/tests/common/playwright_fixtures.py @@ -52,7 +52,8 @@ def _navigator_session(request, browser_name, pytestconfig): nav.stop_server() except Exception as e: logger.debug(e) - nav.teardown() + finally: + nav.teardown() @pytest.fixture(scope="function") diff --git a/tests/common/run_notebook.py b/tests/common/run_notebook.py index 019fd26710..978c0c215f 100644 --- a/tests/common/run_notebook.py +++ b/tests/common/run_notebook.py @@ -66,7 +66,12 @@ def run( # navigate to specific notebook self.open_notebook(path) - # make sure the focus is on the dashboard tab we want to run + + logger.info(f">>> make sure the focus is on the dashboard tab we want to run") + time.sleep(retry_wait_time) + dialog = self.nav.page.get_by_role("dialog") + if dialog.is_visible(): + dialog.get_by_role("button", name="No Kernel").click() self.nav.page.get_by_role("tab", name=filename).get_by_text(filename).click() self.nav.set_environment(kernel=conda_env) From ffc4e94f2d1fbba8d0507492c1624e50c8150c31 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:51:49 +0000 Subject: [PATCH 29/34] [pre-commit.ci] Apply automatic pre-commit fixes --- tests/common/navigator.py | 4 +++- tests/common/run_notebook.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/common/navigator.py b/tests/common/navigator.py index 9c401e8047..ce4433cf57 100644 --- a/tests/common/navigator.py +++ b/tests/common/navigator.py @@ -294,7 +294,9 @@ def reset_workspace(self): time.sleep(2) if self.page.get_by_text("Save your work", exact=True).is_visible(): logger.info("popup to save your work found. Discarding change ...") - self.page.get_by_role("button", name="Discard changes to file", exact=True).click() + self.page.get_by_role( + "button", name="Discard changes to file", exact=True + ).click() # wait to ensure that the Launcher is showing self.page.get_by_text("VS Code [↗]", exact=True).wait_for( diff --git a/tests/common/run_notebook.py b/tests/common/run_notebook.py index 978c0c215f..a8bfe0baa0 100644 --- a/tests/common/run_notebook.py +++ b/tests/common/run_notebook.py @@ -67,7 +67,7 @@ def run( # navigate to specific notebook self.open_notebook(path) - logger.info(f">>> make sure the focus is on the dashboard tab we want to run") + logger.info(">>> make sure the focus is on the dashboard tab we want to run") time.sleep(retry_wait_time) dialog = self.nav.page.get_by_role("dialog") if dialog.is_visible(): From 6754ff9da3f620a7319a7f94f070dc205d1797af Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Fri, 5 Jul 2024 19:29:44 +0100 Subject: [PATCH 30/34] Add debug logs. --- tests/common/navigator.py | 44 ++++++++++++++++++++++-------------- tests/common/run_notebook.py | 11 +++++---- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/tests/common/navigator.py b/tests/common/navigator.py index ce4433cf57..a63abcc551 100644 --- a/tests/common/navigator.py +++ b/tests/common/navigator.py @@ -67,6 +67,7 @@ def __init__( instance_name="small-instance", video_dir=None, ): + logger.info(">>> Navigator init") self.nebari_url = nebari_url self.username = username self.password = password @@ -84,16 +85,19 @@ def __init__( slow_mo=self.slow_mo, ) self.wait_for_server_spinup = 300_000 # 5 * 60 * 1_000 # 5 minutes in ms + logger.info(">>> Navigator initialized.") @property def initialize(self): """Ensure that the Navigator is setup and ready for testing.""" + logger.info(">>> Ensure that the Navigator is setup and ready for testing.") if not self.initialized: self.setup( browser=self.browser, headless=self.headless, slow_mo=self.slow_mo, ) + logger.info(">>> Navigator is setup and ready for testing.") def setup(self, browser, headless, slow_mo): """Initial setup for running playwright. Starts playwright, creates @@ -111,7 +115,7 @@ def setup(self, browser, headless, slow_mo): creating the effect of running the tests in slow motion so they are easier for humans to follow. """ - logger.debug(">>> Setting up browser for Playwright") + logger.info(">>> Setting up browser for Playwright") self.playwright = sync_playwright().start() try: @@ -133,10 +137,11 @@ def teardown(self) -> None: self.context.close() self.browser.close() # Make sure to close, so that videos are saved. self.playwright.stop() - logger.debug(">>> Teardown complete.") + logger.info(">>> Teardown complete.") def login(self) -> None: """Login to nebari deployment using the auth method on the class.""" + logger.info("Login to nebari deployment using the auth method on the class.") try: return { "google": self.login_google, @@ -147,7 +152,7 @@ def login(self) -> None: def login_google(self) -> None: """Go to a nebari deployment, login via Google""" - logger.debug(">>> Sign in via Google and start the server") + logger.info(">>> Sign in via Google and start the server") self.page.goto(self.nebari_url) expect(self.page).to_have_url(re.compile(f"{self.nebari_url}*")) @@ -167,7 +172,7 @@ def login_password(self) -> None: """Go to a nebari deployment, login via Username/Password, and start a new server. """ - logger.debug(">>> Sign in via Username/Password") + logger.info(">>> Sign in via Username/Password") self.page.goto(self.nebari_url) expect(self.page).to_have_url(re.compile(f"{self.nebari_url}*")) @@ -178,6 +183,8 @@ def login_password(self) -> None: self.page.get_by_role("button", name="Sign In").click() # let the page load + logger.info(">>> let the page load") + logger.info(">>> wait_for_load_state") self.page.wait_for_load_state("networkidle") def start_server(self) -> None: @@ -187,7 +194,7 @@ def start_server(self) -> None: we look for html elements that exist when no server is running, if they aren't visible, we check for an existing server start option. """ - # wait for the page to load + logger.info("wait for the page to load") logout_button = self.page.get_by_text("Logout", exact=True) logger.info("waiting for logout button.") file_menu = self.page.get_by_text("File", exact=True) @@ -200,7 +207,7 @@ def start_server(self) -> None: if start_locator.is_visible(): start_locator.click() - # if server is not yet running + logger.info("if server is not yet running") start_locator = self.page.get_by_role("button", name="Start My Server") if start_locator.is_visible(): start_locator.click() @@ -212,7 +219,7 @@ def start_server(self) -> None: self.page.locator(f"#profile-item-{self.instance_name}").click() self.page.get_by_role("button", name="Start").click() - # wait for server spinup + logger.info("wait for server spinup") self.page.wait_for_url( urllib.parse.urljoin(self.nebari_url, f"user/{self.username}/*"), wait_until="networkidle", @@ -222,13 +229,14 @@ def start_server(self) -> None: # the jupyter page loads independent of network activity so here # we wait for the File menu to be available on the page, a proxy for # the jupyterlab page being loaded. + logger.info(">>> the jupyterlab page being loaded.") file_locator = self.page.get_by_text("File", exact=True) file_locator.wait_for( timeout=self.wait_for_server_spinup, state="attached", ) - logger.debug(">>> Sign in complete.") + logger.info(">>> Sign in complete.") def _check_for_kernel_popup(self): """Is the kernel popup currently open? @@ -255,7 +263,7 @@ def reset_workspace(self): # server is already running and there is no popup popup = self._check_for_kernel_popup() - # server is on running and there is a popup + logger.info(">>> server is on running and there is a popup") if popup: self._set_environment_via_popup(kernel=None) @@ -265,7 +273,7 @@ def reset_workspace(self): dialog.get_by_role("button", name="No Kernel").click() kernel_menuitem = self.page.get_by_role("menuitem", name="Kernel", exact=True) kernel_menuitem.click() - # shut down multiple running kernels + logger.info(">>> shut down multiple running kernels") with contextlib.suppress(Exception): shut_down_all = self.page.get_by_text( "Shut Down All Kernels...", exact=True @@ -273,21 +281,22 @@ def reset_workspace(self): shut_down_all.wait_for(timeout=300, state="attached") shut_down_all.click() - # shut down kernel if only one notebook is running + logger.info(">>> shut down kernel if only one notebook is running") kernel_menuitem.click() with contextlib.suppress(Exception): shut_down_current = self.page.get_by_text("Shut Down Kernel", exact=True) shut_down_current.wait_for(timeout=300, state="attached") shut_down_current.click() - # go back to root folder + logger.info(">>> go back to root folder") self.page.get_by_title(f"/home/{self.username}", exact=True).locator( "path" ).click() - # go to File menu + + logger.info("go to File menu") self.page.get_by_text("File", exact=True).click() - # close all tabs + logger.info("close all tabs") self.page.get_by_role("menuitem", name="Close All Tabs", exact=True).click() logger.info("there may be a popup to save your work, don't save") @@ -298,10 +307,11 @@ def reset_workspace(self): "button", name="Discard changes to file", exact=True ).click() - # wait to ensure that the Launcher is showing + logger.info("wait to ensure that the Launcher is showing") self.page.get_by_text("VS Code [↗]", exact=True).wait_for( timeout=3000, state="attached" ) + logger.info("Launcher is showing") def _set_environment_via_popup(self, kernel=None): """Set the environment kernel on a jupyter notebook via the popup @@ -419,13 +429,13 @@ def write_file(self, filepath, content): text to write to that file. """ start = dt.datetime.now() - logger.debug(f"Writing notebook to {filepath}") + logger.info(f"Writing notebook to {filepath}") self.open_terminal() self.run_terminal_command(f"cat <{filepath}") self.run_terminal_command(content) self.run_terminal_command("EOF") self.run_terminal_command(f"ls {filepath}") - logger.debug(f"time to complete {dt.datetime.now() - start}") + logger.info(f"time to complete {dt.datetime.now() - start}") time.sleep(2) def stop_server(self) -> None: diff --git a/tests/common/run_notebook.py b/tests/common/run_notebook.py index a8bfe0baa0..c7e90840ba 100644 --- a/tests/common/run_notebook.py +++ b/tests/common/run_notebook.py @@ -61,10 +61,10 @@ def run( expected output must be a substring of the actual output. default: True """ - logger.debug(f">>> Running notebook: {path}") + logger.info(f">>> Running notebook: {path}") filename = Path(path).name - # navigate to specific notebook + logger.info(f">>> navigate to specific notebook") self.open_notebook(path) logger.info(">>> make sure the focus is on the dashboard tab we want to run") @@ -73,10 +73,12 @@ def run( if dialog.is_visible(): dialog.get_by_role("button", name="No Kernel").click() self.nav.page.get_by_role("tab", name=filename).get_by_text(filename).click() + logger.info(f">>> set_environment") self.nav.set_environment(kernel=conda_env) - # make sure that this notebook is one currently selected + logger.info(f">>> make sure that this notebook is one currently selected") self.nav.page.get_by_role("tab", name=filename).get_by_text(filename).click() + logger.info(f">>> Ensure restart") for _ in range(retry): self._restart_run_all() @@ -85,6 +87,7 @@ def run( self._wait_for_commands_completion(timeout, complition_wait_time) all_outputs = self._get_outputs() assert_match_all_outputs(expected_outputs, all_outputs, exact_match) + logger.info(f">>> run over.") def create_notebook(self, conda_env=None): file_locator = self.nav.page.get_by_text("File", exact=True) @@ -123,7 +126,7 @@ def open_notebook(self, path): "Could not find path:", exact=False, ).is_visible(): - logger.debug("Path to notebook is invalid") + logger.info("Path to notebook is invalid") raise RuntimeError("Path to notebook is invalid") def assert_code_output( From af5ae293db1f64a24283af509e2284749feadccb Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Fri, 5 Jul 2024 19:32:33 +0100 Subject: [PATCH 31/34] Fix ruff error. --- tests/common/navigator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common/navigator.py b/tests/common/navigator.py index a63abcc551..807020eff5 100644 --- a/tests/common/navigator.py +++ b/tests/common/navigator.py @@ -195,7 +195,7 @@ def start_server(self) -> None: they aren't visible, we check for an existing server start option. """ logger.info("wait for the page to load") - logout_button = self.page.get_by_text("Logout", exact=True) + self.page.get_by_text("Logout", exact=True) logger.info("waiting for logout button.") file_menu = self.page.get_by_text("File", exact=True) if file_menu.is_visible(): From 8b834d5ea5a7cbbf60da0f514523ae254561b2f5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:34:51 +0000 Subject: [PATCH 32/34] [pre-commit.ci] Apply automatic pre-commit fixes --- tests/common/navigator.py | 1 - tests/common/run_notebook.py | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/common/navigator.py b/tests/common/navigator.py index 807020eff5..a3112deb2a 100644 --- a/tests/common/navigator.py +++ b/tests/common/navigator.py @@ -293,7 +293,6 @@ def reset_workspace(self): "path" ).click() - logger.info("go to File menu") self.page.get_by_text("File", exact=True).click() logger.info("close all tabs") diff --git a/tests/common/run_notebook.py b/tests/common/run_notebook.py index c7e90840ba..fb5d8a9455 100644 --- a/tests/common/run_notebook.py +++ b/tests/common/run_notebook.py @@ -64,7 +64,7 @@ def run( logger.info(f">>> Running notebook: {path}") filename = Path(path).name - logger.info(f">>> navigate to specific notebook") + logger.info(">>> navigate to specific notebook") self.open_notebook(path) logger.info(">>> make sure the focus is on the dashboard tab we want to run") @@ -73,12 +73,12 @@ def run( if dialog.is_visible(): dialog.get_by_role("button", name="No Kernel").click() self.nav.page.get_by_role("tab", name=filename).get_by_text(filename).click() - logger.info(f">>> set_environment") + logger.info(">>> set_environment") self.nav.set_environment(kernel=conda_env) - logger.info(f">>> make sure that this notebook is one currently selected") + logger.info(">>> make sure that this notebook is one currently selected") self.nav.page.get_by_role("tab", name=filename).get_by_text(filename).click() - logger.info(f">>> Ensure restart") + logger.info(">>> Ensure restart") for _ in range(retry): self._restart_run_all() @@ -87,7 +87,7 @@ def run( self._wait_for_commands_completion(timeout, complition_wait_time) all_outputs = self._get_outputs() assert_match_all_outputs(expected_outputs, all_outputs, exact_match) - logger.info(f">>> run over.") + logger.info(">>> run over.") def create_notebook(self, conda_env=None): file_locator = self.nav.page.get_by_text("File", exact=True) From c0270895cfd6ff241100db4b04aebe133263c6fa Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Mon, 8 Jul 2024 14:26:49 +0100 Subject: [PATCH 33/34] Remove logging changes in tests. --- tests/common/navigator.py | 49 ++++++++++++++------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/tests/common/navigator.py b/tests/common/navigator.py index a3112deb2a..bc569f0072 100644 --- a/tests/common/navigator.py +++ b/tests/common/navigator.py @@ -67,7 +67,6 @@ def __init__( instance_name="small-instance", video_dir=None, ): - logger.info(">>> Navigator init") self.nebari_url = nebari_url self.username = username self.password = password @@ -85,19 +84,16 @@ def __init__( slow_mo=self.slow_mo, ) self.wait_for_server_spinup = 300_000 # 5 * 60 * 1_000 # 5 minutes in ms - logger.info(">>> Navigator initialized.") @property def initialize(self): """Ensure that the Navigator is setup and ready for testing.""" - logger.info(">>> Ensure that the Navigator is setup and ready for testing.") if not self.initialized: self.setup( browser=self.browser, headless=self.headless, slow_mo=self.slow_mo, ) - logger.info(">>> Navigator is setup and ready for testing.") def setup(self, browser, headless, slow_mo): """Initial setup for running playwright. Starts playwright, creates @@ -115,7 +111,7 @@ def setup(self, browser, headless, slow_mo): creating the effect of running the tests in slow motion so they are easier for humans to follow. """ - logger.info(">>> Setting up browser for Playwright") + logger.debug(">>> Setting up browser for Playwright") self.playwright = sync_playwright().start() try: @@ -137,11 +133,10 @@ def teardown(self) -> None: self.context.close() self.browser.close() # Make sure to close, so that videos are saved. self.playwright.stop() - logger.info(">>> Teardown complete.") + logger.debug(">>> Teardown complete.") def login(self) -> None: """Login to nebari deployment using the auth method on the class.""" - logger.info("Login to nebari deployment using the auth method on the class.") try: return { "google": self.login_google, @@ -152,7 +147,7 @@ def login(self) -> None: def login_google(self) -> None: """Go to a nebari deployment, login via Google""" - logger.info(">>> Sign in via Google and start the server") + logger.debug(">>> Sign in via Google and start the server") self.page.goto(self.nebari_url) expect(self.page).to_have_url(re.compile(f"{self.nebari_url}*")) @@ -172,7 +167,7 @@ def login_password(self) -> None: """Go to a nebari deployment, login via Username/Password, and start a new server. """ - logger.info(">>> Sign in via Username/Password") + logger.debug(">>> Sign in via Username/Password") self.page.goto(self.nebari_url) expect(self.page).to_have_url(re.compile(f"{self.nebari_url}*")) @@ -183,8 +178,6 @@ def login_password(self) -> None: self.page.get_by_role("button", name="Sign In").click() # let the page load - logger.info(">>> let the page load") - logger.info(">>> wait_for_load_state") self.page.wait_for_load_state("networkidle") def start_server(self) -> None: @@ -194,12 +187,10 @@ def start_server(self) -> None: we look for html elements that exist when no server is running, if they aren't visible, we check for an existing server start option. """ - logger.info("wait for the page to load") self.page.get_by_text("Logout", exact=True) - logger.info("waiting for logout button.") file_menu = self.page.get_by_text("File", exact=True) if file_menu.is_visible(): - logger.info("Server is already up!") + logger.debug("Server is already up!") return # if the server is already running @@ -207,7 +198,7 @@ def start_server(self) -> None: if start_locator.is_visible(): start_locator.click() - logger.info("if server is not yet running") + # if server is not yet running start_locator = self.page.get_by_role("button", name="Start My Server") if start_locator.is_visible(): start_locator.click() @@ -219,7 +210,7 @@ def start_server(self) -> None: self.page.locator(f"#profile-item-{self.instance_name}").click() self.page.get_by_role("button", name="Start").click() - logger.info("wait for server spinup") + # wait for server spinup self.page.wait_for_url( urllib.parse.urljoin(self.nebari_url, f"user/{self.username}/*"), wait_until="networkidle", @@ -229,14 +220,13 @@ def start_server(self) -> None: # the jupyter page loads independent of network activity so here # we wait for the File menu to be available on the page, a proxy for # the jupyterlab page being loaded. - logger.info(">>> the jupyterlab page being loaded.") file_locator = self.page.get_by_text("File", exact=True) file_locator.wait_for( timeout=self.wait_for_server_spinup, state="attached", ) - logger.info(">>> Sign in complete.") + logger.debug(">>> Sign in complete.") def _check_for_kernel_popup(self): """Is the kernel popup currently open? @@ -263,17 +253,16 @@ def reset_workspace(self): # server is already running and there is no popup popup = self._check_for_kernel_popup() - logger.info(">>> server is on running and there is a popup") + # server is on running and there is a popup if popup: self._set_environment_via_popup(kernel=None) - logger.info(">>> go to Kernel menu") dialog = self.page.get_by_role("dialog") if dialog.is_visible(): dialog.get_by_role("button", name="No Kernel").click() kernel_menuitem = self.page.get_by_role("menuitem", name="Kernel", exact=True) kernel_menuitem.click() - logger.info(">>> shut down multiple running kernels") + # shut down multiple running kernels with contextlib.suppress(Exception): shut_down_all = self.page.get_by_text( "Shut Down All Kernels...", exact=True @@ -281,36 +270,34 @@ def reset_workspace(self): shut_down_all.wait_for(timeout=300, state="attached") shut_down_all.click() - logger.info(">>> shut down kernel if only one notebook is running") + # shut down kernel if only one notebook is running kernel_menuitem.click() with contextlib.suppress(Exception): shut_down_current = self.page.get_by_text("Shut Down Kernel", exact=True) shut_down_current.wait_for(timeout=300, state="attached") shut_down_current.click() - logger.info(">>> go back to root folder") + # go back to root folder self.page.get_by_title(f"/home/{self.username}", exact=True).locator( "path" ).click() - logger.info("go to File menu") + # go to File menu self.page.get_by_text("File", exact=True).click() - logger.info("close all tabs") + # close all tabs self.page.get_by_role("menuitem", name="Close All Tabs", exact=True).click() - logger.info("there may be a popup to save your work, don't save") + # there may be a popup to save your work, don't save time.sleep(2) if self.page.get_by_text("Save your work", exact=True).is_visible(): - logger.info("popup to save your work found. Discarding change ...") self.page.get_by_role( "button", name="Discard changes to file", exact=True ).click() - logger.info("wait to ensure that the Launcher is showing") + # wait to ensure that the Launcher is showing self.page.get_by_text("VS Code [↗]", exact=True).wait_for( timeout=3000, state="attached" ) - logger.info("Launcher is showing") def _set_environment_via_popup(self, kernel=None): """Set the environment kernel on a jupyter notebook via the popup @@ -428,13 +415,13 @@ def write_file(self, filepath, content): text to write to that file. """ start = dt.datetime.now() - logger.info(f"Writing notebook to {filepath}") + logger.debug(f"Writing notebook to {filepath}") self.open_terminal() self.run_terminal_command(f"cat <{filepath}") self.run_terminal_command(content) self.run_terminal_command("EOF") self.run_terminal_command(f"ls {filepath}") - logger.info(f"time to complete {dt.datetime.now() - start}") + logger.debug(f"time to complete {dt.datetime.now() - start}") time.sleep(2) def stop_server(self) -> None: From f6dac5a5066452393d8d566da0947270ade8b29b Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Mon, 8 Jul 2024 14:29:37 +0100 Subject: [PATCH 34/34] Remove logging changes in tests. --- tests/common/run_notebook.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/common/run_notebook.py b/tests/common/run_notebook.py index fb5d8a9455..c525cddabf 100644 --- a/tests/common/run_notebook.py +++ b/tests/common/run_notebook.py @@ -61,24 +61,21 @@ def run( expected output must be a substring of the actual output. default: True """ - logger.info(f">>> Running notebook: {path}") + logger.debug(f">>> Running notebook: {path}") filename = Path(path).name - logger.info(">>> navigate to specific notebook") + # navigate to specific notebook self.open_notebook(path) - - logger.info(">>> make sure the focus is on the dashboard tab we want to run") + # make sure the focus is on the dashboard tab we want to run time.sleep(retry_wait_time) dialog = self.nav.page.get_by_role("dialog") if dialog.is_visible(): dialog.get_by_role("button", name="No Kernel").click() self.nav.page.get_by_role("tab", name=filename).get_by_text(filename).click() - logger.info(">>> set_environment") self.nav.set_environment(kernel=conda_env) - logger.info(">>> make sure that this notebook is one currently selected") + # make sure that this notebook is one currently selected self.nav.page.get_by_role("tab", name=filename).get_by_text(filename).click() - logger.info(">>> Ensure restart") for _ in range(retry): self._restart_run_all() @@ -87,7 +84,6 @@ def run( self._wait_for_commands_completion(timeout, complition_wait_time) all_outputs = self._get_outputs() assert_match_all_outputs(expected_outputs, all_outputs, exact_match) - logger.info(">>> run over.") def create_notebook(self, conda_env=None): file_locator = self.nav.page.get_by_text("File", exact=True) @@ -126,7 +122,7 @@ def open_notebook(self, path): "Could not find path:", exact=False, ).is_visible(): - logger.info("Path to notebook is invalid") + logger.debug("Path to notebook is invalid") raise RuntimeError("Path to notebook is invalid") def assert_code_output(