From 4b39d5ffe927e157de7a09fcd04f8bb17f1efef7 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 15 Sep 2023 10:12:01 -0400 Subject: [PATCH 01/45] Re-enable E2E GitHub action jobs This changeset re-enables the GitHub action jobs we had to disable to make it possible to deploy recent changes. Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 99ef30c3b..880427912 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -44,29 +44,29 @@ jobs: run: npm test - name: Run py tests with coverage run: poetry run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/ - # - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - # env: - # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + - name: Run E2E tests + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - # - name: Health check - # run: | - # response=$(curl -url ${{secrets.NOTIFY_E2E_TEST_URI}}_status) - # if grep -q "ok" <<< "$response"; then - # echo "Health check passed" - # else - # echo "Health check failed" - # exit 1 - # fi - # env: - # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + - name: Health check + run: | + response=$(curl -url ${{secrets.NOTIFY_E2E_TEST_URI}}_status) + if grep -q "ok" <<< "$response"; then + echo "Health check passed" + else + echo "Health check failed" + exit 1 + fi + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} validate-new-relic-config: runs-on: ubuntu-latest From d25f0869e017733e75bd0f3e805e79ca492fcf90 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:14:06 -0500 Subject: [PATCH 02/45] First attempt at getting the API to run for E2E tests Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 71 +++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 880427912..a29937511 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -44,6 +44,62 @@ jobs: run: npm test - name: Run py tests with coverage run: poetry run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/ + - name: Check coverage threshold + run: poetry run coverage report --fail-under=90 + + end-to-end-tests: + permissions: + checks: write + pull-requests: write + contents: write + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-project + - uses: jwalton/gh-find-current-pr@v1 + id: findPr + - uses: ArtiomTr/jest-coverage-report-action@v2 + with: + test-script: npm test + output: report-markdown + annotations: failed-tests + prnumber: ${{ steps.findPr.outputs.number }} + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: './notifications-api' + - name: Install API dependencies + with: + path: './notifications-api' + run: make bootstrap + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run API server + with: + path: './notifications-api' + run: make run-procfile & + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: @@ -51,22 +107,9 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + API_HOST_NAME: http://localhost:6011 - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - - name: Health check - run: | - response=$(curl -url ${{secrets.NOTIFY_E2E_TEST_URI}}_status) - if grep -q "ok" <<< "$response"; then - echo "Health check passed" - else - echo "Health check failed" - exit 1 - fi - env: - NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} validate-new-relic-config: runs-on: ubuntu-latest From 89b6e13afb25cf826e068060accd64b272caedcf Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:34:12 -0500 Subject: [PATCH 03/45] Just trying to get the workflow to run Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 126 +++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a29937511..736323589 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,69 +47,69 @@ jobs: - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - end-to-end-tests: - permissions: - checks: write - pull-requests: write - contents: write - runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 5432 on service container to the host - - 5432:5432 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-project - - uses: jwalton/gh-find-current-pr@v1 - id: findPr - - uses: ArtiomTr/jest-coverage-report-action@v2 - with: - test-script: npm test - output: report-markdown - annotations: failed-tests - prnumber: ${{ steps.findPr.outputs.number }} - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: './notifications-api' - - name: Install API dependencies - with: - path: './notifications-api' - run: make bootstrap - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - - name: Run API server - with: - path: './notifications-api' - run: make run-procfile & - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - - name: Run E2E tests - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - env: - NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - API_HOST_NAME: http://localhost:6011 - - name: Check coverage threshold - run: poetry run coverage report --fail-under=90 + # end-to-end-tests: + # permissions: + # checks: write + # pull-requests: write + # contents: write + # runs-on: ubuntu-latest + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_USER: user + # POSTGRES_PASSWORD: password + # POSTGRES_DB: test_notification_api + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 5432 on service container to the host + # - 5432:5432 + # steps: + # - uses: actions/checkout@v3 + # - uses: ./.github/actions/setup-project + # - uses: jwalton/gh-find-current-pr@v1 + # id: findPr + # - uses: ArtiomTr/jest-coverage-report-action@v2 + # with: + # test-script: npm test + # output: report-markdown + # annotations: failed-tests + # prnumber: ${{ steps.findPr.outputs.number }} + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: './notifications-api' + # - name: Install API dependencies + # with: + # path: './notifications-api' + # run: make bootstrap + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Run API server + # with: + # path: './notifications-api' + # run: make run-procfile & + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Run E2E tests + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # env: + # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + # API_HOST_NAME: http://localhost:6011 + # - name: Check coverage threshold + # run: poetry run coverage report --fail-under=90 validate-new-relic-config: runs-on: ubuntu-latest From 891cec530035f135920aea0a1c8d23e7a2b5feb1 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:42:55 -0500 Subject: [PATCH 04/45] Uncommenting E2E test job Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 126 +++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 736323589..a29937511 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,69 +47,69 @@ jobs: - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - # end-to-end-tests: - # permissions: - # checks: write - # pull-requests: write - # contents: write - # runs-on: ubuntu-latest - # services: - # postgres: - # image: postgres - # env: - # POSTGRES_USER: user - # POSTGRES_PASSWORD: password - # POSTGRES_DB: test_notification_api - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 5432 on service container to the host - # - 5432:5432 - # steps: - # - uses: actions/checkout@v3 - # - uses: ./.github/actions/setup-project - # - uses: jwalton/gh-find-current-pr@v1 - # id: findPr - # - uses: ArtiomTr/jest-coverage-report-action@v2 - # with: - # test-script: npm test - # output: report-markdown - # annotations: failed-tests - # prnumber: ${{ steps.findPr.outputs.number }} - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: './notifications-api' - # - name: Install API dependencies - # with: - # path: './notifications-api' - # run: make bootstrap - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # - name: Run API server - # with: - # path: './notifications-api' - # run: make run-procfile & - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - # env: - # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - # API_HOST_NAME: http://localhost:6011 - # - name: Check coverage threshold - # run: poetry run coverage report --fail-under=90 + end-to-end-tests: + permissions: + checks: write + pull-requests: write + contents: write + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-project + - uses: jwalton/gh-find-current-pr@v1 + id: findPr + - uses: ArtiomTr/jest-coverage-report-action@v2 + with: + test-script: npm test + output: report-markdown + annotations: failed-tests + prnumber: ${{ steps.findPr.outputs.number }} + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: './notifications-api' + - name: Install API dependencies + with: + path: './notifications-api' + run: make bootstrap + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run API server + with: + path: './notifications-api' + run: make run-procfile & + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run E2E tests + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + API_HOST_NAME: http://localhost:6011 + - name: Check coverage threshold + run: poetry run coverage report --fail-under=90 validate-new-relic-config: runs-on: ubuntu-latest From 5a39165644795358bcd16a8798122d9fd79e342a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:45:19 -0500 Subject: [PATCH 05/45] Just trying to get the new job to run Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 50 ++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a29937511..a57d3615c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -73,33 +73,27 @@ jobs: - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - - uses: ArtiomTr/jest-coverage-report-action@v2 - with: - test-script: npm test - output: report-markdown - annotations: failed-tests - prnumber: ${{ steps.findPr.outputs.number }} - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: './notifications-api' - - name: Install API dependencies - with: - path: './notifications-api' - run: make bootstrap - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - - name: Run API server - with: - path: './notifications-api' - run: make run-procfile & - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: './notifications-api' + # - name: Install API dependencies + # with: + # path: './notifications-api' + # run: make bootstrap + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Run API server + # with: + # path: './notifications-api' + # run: make run-procfile & + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: @@ -107,7 +101,7 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - API_HOST_NAME: http://localhost:6011 + # API_HOST_NAME: http://localhost:6011 - name: Check coverage threshold run: poetry run coverage report --fail-under=90 From 3003f822235f9e7496d54dded9a6e4c3360c3314 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:56:38 -0500 Subject: [PATCH 06/45] Attempting to get the API cloned at least Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a57d3615c..f638f5e65 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -73,11 +73,11 @@ jobs: - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: './notifications-api' + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: './notifications-api' # - name: Install API dependencies # with: # path: './notifications-api' @@ -102,8 +102,6 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} # API_HOST_NAME: http://localhost:6011 - - name: Check coverage threshold - run: poetry run coverage report --fail-under=90 validate-new-relic-config: runs-on: ubuntu-latest From f8c48f77119be8083524dd81cd8d4cebf77d85ed Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 15:11:02 -0500 Subject: [PATCH 07/45] Now trying to install API dependencies... Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f638f5e65..dde423fd9 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -78,14 +78,14 @@ jobs: with: repository: GSA/notifications-api path: './notifications-api' - # - name: Install API dependencies - # with: - # path: './notifications-api' - # run: make bootstrap - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Install API dependencies + with: + path: './notifications-api' + run: make bootstrap + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} # - name: Run API server # with: # path: './notifications-api' From bb242dc7d71cb124fb1022ce896f6f7f70b7b374 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 15:29:03 -0500 Subject: [PATCH 08/45] Adjusted API clone and working directory Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dde423fd9..5cfc170d5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -77,10 +77,9 @@ jobs: uses: actions/checkout@v3 with: repository: GSA/notifications-api - path: './notifications-api' + path: 'notifications-api' - name: Install API dependencies - with: - path: './notifications-api' + working-directory: 'notifications-api' run: make bootstrap env: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api From b8b330f55be27eac1adb03cd3d82af5c429cb84c Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 15:52:55 -0500 Subject: [PATCH 09/45] Attempting to get API up and running Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5cfc170d5..61b2c0696 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -13,6 +13,9 @@ env: WERKZEUG_DEBUG_PIN: off REDIS_ENABLED: 0 NODE_VERSION: 16.15.1 + AWS_US_TOLL_FREE_NUMBER: "+18556438890" + ADMIN_BASE_URL: http://localhost:6012 + API_HOST_NAME: http://localhost:6011 jobs: build: @@ -85,14 +88,13 @@ jobs: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # - name: Run API server - # with: - # path: './notifications-api' - # run: make run-procfile & - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run API server + working-directory: 'notifications-api' + run: make run-flask & + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: @@ -100,7 +102,6 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - # API_HOST_NAME: http://localhost:6011 validate-new-relic-config: runs-on: ubuntu-latest From d544d7c8f854409dbd03b3840321affb0216818a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:00:37 -0500 Subject: [PATCH 10/45] Now trying to run the Admin server with PR code... Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 61b2c0696..f547d367b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -95,13 +95,16 @@ jobs: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run Admin server + run: make run-flask & - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + # Run the E2E tests against the code found in this PR. + NOTIFY_E2E_TEST_URI: http://localhost:6012 validate-new-relic-config: runs-on: ubuntu-latest From 5e7319cbac434e53b54a3df155bee2310ad7be0a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:17:01 -0500 Subject: [PATCH 11/45] Testing to see if we can connect to the local server. Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f547d367b..dd0b6baaa 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -98,7 +98,10 @@ jobs: - name: Run Admin server run: make run-flask & - name: Run E2E tests - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: | + curl --request GET --url "http://localhost:6012" + curl --request GET --url "http://127.0.0.1:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 92b33834e86b715775583585c5bade2dc8840a8c Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:38:26 -0500 Subject: [PATCH 12/45] Trying to discern if there is a difference in local URLs Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dd0b6baaa..0e8876e17 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,10 +97,19 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server run: make run-flask & - - name: Run E2E tests + - name: Run E2E tests 1 # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - run: | + run: curl --request GET --url "http://localhost:6012" + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # Run the E2E tests against the code found in this PR. + NOTIFY_E2E_TEST_URI: http://localhost:6012 + - name: Run E2E tests 2 + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: curl --request GET --url "http://127.0.0.1:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} From b60dc00f0e435ced7db44d10389e6ee34cb1b51a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:42:53 -0500 Subject: [PATCH 13/45] A bit of cleanup and debugging comment to resume after holidays! Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0e8876e17..c7e7cb9e5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,20 +97,10 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server run: make run-flask & - - name: Run E2E tests 1 + - name: Run E2E tests # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - run: - curl --request GET --url "http://localhost:6012" - env: - NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # Run the E2E tests against the code found in this PR. - NOTIFY_E2E_TEST_URI: http://localhost:6012 - - name: Run E2E tests 2 - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - run: - curl --request GET --url "http://127.0.0.1:6012" + # Debugging for now to troubleshoot a connectivity issue to the local servers + run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 9c32fa2d4e7d085ff330409cd32094e23d9ddefa Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 11:47:20 -0500 Subject: [PATCH 14/45] Adding in missing DATABASE_URL environment variable Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c7e7cb9e5..ab1ee085e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -85,6 +85,7 @@ jobs: working-directory: 'notifications-api' run: make bootstrap env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} @@ -92,6 +93,7 @@ jobs: working-directory: 'notifications-api' run: make run-flask & env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 91527f32f29ced3de2a7e4fc6c5fedb25df76285 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 11:54:46 -0500 Subject: [PATCH 15/45] Changing DB name to match Makefile bootstrap command Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ab1ee085e..943e11efc 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -62,7 +62,7 @@ jobs: env: POSTGRES_USER: user POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api + POSTGRES_DB: notification_api options: >- --health-cmd pg_isready --health-interval 10s @@ -85,16 +85,16 @@ jobs: working-directory: 'notifications-api' run: make bootstrap env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run API server working-directory: 'notifications-api' run: make run-flask & env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server From 6b98cf7c35f115df636f697aced454d240211869 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 12:01:20 -0500 Subject: [PATCH 16/45] Reverting previous change of the DB name Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 943e11efc..ab1ee085e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -62,7 +62,7 @@ jobs: env: POSTGRES_USER: user POSTGRES_PASSWORD: password - POSTGRES_DB: notification_api + POSTGRES_DB: test_notification_api options: >- --health-cmd pg_isready --health-interval 10s @@ -85,16 +85,16 @@ jobs: working-directory: 'notifications-api' run: make bootstrap env: - DATABASE_URL: postgresql://user:password@localhost:5432/notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run API server working-directory: 'notifications-api' run: make run-flask & env: - DATABASE_URL: postgresql://user:password@localhost:5432/notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server From 57cd123f4e5ef3793422350ecb08651745e4a08b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 12:37:34 -0500 Subject: [PATCH 17/45] Adding Redis for running the API Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ab1ee085e..8d981cb27 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -71,6 +71,16 @@ jobs: ports: # Maps tcp port 5432 on service container to the host - 5432:5432 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 6379 on service container to the host + - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project @@ -87,14 +97,16 @@ jobs: env: DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run API server working-directory: 'notifications-api' - run: make run-flask & + run: make run-procfile & env: DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server From 3ba9a858457e4ed4f4ea9ac4036b4457da00407e Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 13:17:49 -0500 Subject: [PATCH 18/45] Adjusting API environment to development Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8d981cb27..e6c123a2f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -100,6 +100,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development - name: Run API server working-directory: 'notifications-api' run: make run-procfile & @@ -109,6 +110,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & - name: Run E2E tests From 558296684c84dc79f980fcfa09eacaeb96f971c5 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 15:43:26 -0500 Subject: [PATCH 19/45] Attempting to run actual E2E tests again to see real errors Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e6c123a2f..1ec912f6a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -114,9 +114,9 @@ jobs: - name: Run Admin server run: make run-flask & - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers - run: curl --request GET --url "http://localhost:6012" + # run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From b9a7e48e780a2b43ed83423a5c6a0f12a8aecf0d Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:29:10 -0500 Subject: [PATCH 20/45] Attempting to work against staging API Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 107 ++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1ec912f6a..30b492a7a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,8 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - API_HOST_NAME: http://localhost:6011 + #API_HOST_NAME: http://localhost:6011 + API_HOST_NAME: https://notify-api-staging.app.cloud.gov jobs: build: @@ -56,67 +57,67 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 5432 on service container to the host - - 5432:5432 - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 6379 on service container to the host - - 6379:6379 + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_USER: user + # POSTGRES_PASSWORD: password + # POSTGRES_DB: test_notification_api + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 5432 on service container to the host + # - 5432:5432 + # redis: + # image: redis + # options: >- + # --health-cmd "redis-cli ping" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 6379 on service container to the host + # - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: 'notifications-api' - - name: Install API dependencies - working-directory: 'notifications-api' - run: make bootstrap - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development - - name: Run API server - working-directory: 'notifications-api' - run: make run-procfile & - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: 'notifications-api' + # - name: Install API dependencies + # working-directory: 'notifications-api' + # run: make bootstrap + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development + # - name: Run API server + # working-directory: 'notifications-api' + # run: make run-procfile & + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & - name: Run E2E tests - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers - # run: curl --request GET --url "http://localhost:6012" + run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 84559e05741ff0ac88ebddfe413f535a85c41ad5 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:34:46 -0500 Subject: [PATCH 21/45] Switch Admin site environment to development Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 30b492a7a..4a5be3670 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -114,6 +114,8 @@ jobs: # NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & + env: + NOTIFY_ENVIRONMENT: development - name: Run E2E tests # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers From 2201c16a2b89b3c3cf7739972b3d82dda2682756 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:39:12 -0500 Subject: [PATCH 22/45] Now try to run the E2E tests! Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4a5be3670..9dfd779d4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -117,9 +117,9 @@ jobs: env: NOTIFY_ENVIRONMENT: development - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers - run: curl --request GET --url "http://localhost:6012" + # run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 46be3cd7b3b6e8bbc18281adc5ffcff0a59898e8 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:44:49 -0500 Subject: [PATCH 23/45] Add a missing slash in the test URI Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9dfd779d4..fd9372e17 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -125,7 +125,7 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} # Run the E2E tests against the code found in this PR. - NOTIFY_E2E_TEST_URI: http://localhost:6012 + NOTIFY_E2E_TEST_URI: http://localhost:6012/ validate-new-relic-config: runs-on: ubuntu-latest From c652c176177cf1eccb0e38fd6303c61b6bb722b4 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:30:47 -0500 Subject: [PATCH 24/45] Clean up and fix the E2E tests so that they run Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- tests/conftest.py | 14 ++++++----- tests/end_to_end/test_accounts_page.py | 23 +++++-------------- .../test_landing_and_sign_in_pages.py | 9 +++++--- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fd9372e17..9dfd779d4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -125,7 +125,7 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} # Run the E2E tests against the code found in this PR. - NOTIFY_E2E_TEST_URI: http://localhost:6012/ + NOTIFY_E2E_TEST_URI: http://localhost:6012 validate-new-relic-config: runs-on: ubuntu-latest diff --git a/tests/conftest.py b/tests/conftest.py index 122b76826..48ea3c5fa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,6 +36,8 @@ from . import ( load_dotenv() +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + class ElementNotFound(Exception): pass @@ -529,7 +531,7 @@ def mock_update_service(mocker): "sms_sender", "permissions", ] - } + }, ) return {"data": service} @@ -2353,7 +2355,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _test_page_title=True, _test_for_elements_without_class=True, _optional_args="", - **endpoint_kwargs + **endpoint_kwargs, ): return ClientRequest.get_url( url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args, @@ -2372,7 +2374,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _expected_redirect=None, _test_page_title=True, _test_for_elements_without_class=True, - **endpoint_kwargs + **endpoint_kwargs, ): resp = logged_in_client.get( url, @@ -2414,7 +2416,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _follow_redirects=False, _expected_redirect=None, _content_type=None, - **endpoint_kwargs + **endpoint_kwargs, ): return ClientRequest.post_url( url_for(endpoint, **(endpoint_kwargs or {})), @@ -2473,7 +2475,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _expected_status=302, _optional_args="", _content_type=None, - **endpoint_kwargs + **endpoint_kwargs, ): return ClientRequest.post_response_from_url( url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args, @@ -3523,7 +3525,7 @@ def login_for_end_to_end_testing(browser): # Open a new page and go to the staging site. context = browser.new_context() page = context.new_page() - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") sign_in_button = page.get_by_role("link", name="Sign in") diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index c8c8d5a6a..070e5d08d 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -4,12 +4,14 @@ import re from playwright.sync_api import expect +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + def _bypass_sign_in(end_to_end_context): # Open a new page and go to the staging site. page = end_to_end_context.new_page() - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") sign_in_button = page.get_by_role("link", name="Sign in") @@ -24,7 +26,7 @@ def _bypass_sign_in(end_to_end_context): def test_add_new_service_workflow(end_to_end_context): # page = end_to_end_context.new_page() page = _bypass_sign_in(end_to_end_context) - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") # sign_in_button = page.get_by_role("link", name="Sign in") # @@ -41,9 +43,7 @@ def test_add_new_service_workflow(end_to_end_context): browser_type=end_to_end_context.browser.browser_type.name, ) - accounts_uri = "{}accounts".format(os.getenv("NOTIFY_E2E_TEST_URI")) - - page.goto(accounts_uri) + page.goto(f"{E2E_TEST_URI}/accounts") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -82,24 +82,13 @@ def test_add_new_service_workflow(end_to_end_context): # Retrieve some prominent elements on the page for testing. service_name_input = page.locator('xpath=//input[@name="name"]') - federal_radio_button = page.locator('xpath=//input[@value="federal"]') - state_radio_button = page.locator('xpath=//input[@value="state"]') - other_radio_button = page.locator('xpath=//input[@value="other"]') add_service_button = page.get_by_role("button", name=re.compile("Add service")) expect(service_name_input).to_be_visible() - expect(federal_radio_button).to_be_visible() - expect(state_radio_button).to_be_visible() - expect(other_radio_button).to_be_visible() expect(add_service_button).to_be_visible() # Fill in the form. service_name_input.fill(new_service_name) - expect(federal_radio_button).to_be_enabled() - # Trying to click directly on the radio button resulted in a "not in viewport error" and this is the - # suggested workaround. Googling, the reason seems to be that there might be some (invisible?) css positioned - # above the radio button itself. - page.click("text='Federal government'") # Click on add service. add_service_button.click() @@ -108,7 +97,7 @@ def test_add_new_service_workflow(end_to_end_context): page.wait_for_load_state("domcontentloaded") # Check for the service name title and heading. - service_heading = page.get_by_text(new_service_name) + service_heading = page.get_by_text(new_service_name, exact=True) expect(service_heading).to_be_visible() expect(page).to_have_title(re.compile(new_service_name)) diff --git a/tests/end_to_end/test_landing_and_sign_in_pages.py b/tests/end_to_end/test_landing_and_sign_in_pages.py index 895b3851f..dd6a70beb 100644 --- a/tests/end_to_end/test_landing_and_sign_in_pages.py +++ b/tests/end_to_end/test_landing_and_sign_in_pages.py @@ -3,11 +3,13 @@ import re from playwright.sync_api import expect +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + def test_landing_page(end_to_end_context): # Open a new page and go to the staging site. page = end_to_end_context.browser.new_page() - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -17,7 +19,8 @@ def test_landing_page(end_to_end_context): # Retrieve some prominent elements on the page for testing. main_header = page.get_by_role( - "heading", name="Send text messages to your participants" + "heading", + name="Reach people where they are with government-powered text messages", ) sign_in_button = page.get_by_role("link", name="Sign in") benefits_studio_email = page.get_by_role("link", name="tts-benefits-studio@gsa.gov") @@ -51,7 +54,7 @@ def test_landing_page(end_to_end_context): # def test_sign_in_and_mfa_pages(end_to_end_context): # # Open a new page and go to the staging site. # page = end_to_end_context.new_page() -# page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) +# page.goto(f"{E2E_TEST_URI}/") # print(f"test_sign_in_and_mfa_pages initial {page}") # # sign_in_button = page.get_by_role("link", name="Sign in") From 997aa8e72f0d93f7a0c81c4241f9d8e3a04928df Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:42:54 -0500 Subject: [PATCH 25/45] Added missing environment variables for the server process Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 3 +++ tests/conftest.py | 11 +++++------ tests/end_to_end/test_accounts_page.py | 5 ----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9dfd779d4..498a9f273 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -116,6 +116,9 @@ jobs: run: make run-flask & env: NOTIFY_ENVIRONMENT: development + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers diff --git a/tests/conftest.py b/tests/conftest.py index 48ea3c5fa..269bf5282 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3576,12 +3576,11 @@ def login_for_end_to_end_testing(browser): # page.wait_for_load_state('domcontentloaded') - # # Save storage state into the file. - # auth_state_path = os.path.join( - # os.getenv('NOTIFY_E2E_AUTH_STATE_PATH'), - # 'state.json' - # ) - # context.storage_state(path=auth_state_path) + # Save storage state into the file. + auth_state_path = os.path.join( + os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" + ) + context.storage_state(path=auth_state_path) @pytest.fixture(scope="session") diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 070e5d08d..498242743 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -28,11 +28,6 @@ def test_add_new_service_workflow(end_to_end_context): page = _bypass_sign_in(end_to_end_context) page.goto(f"{E2E_TEST_URI}/") - # sign_in_button = page.get_by_role("link", name="Sign in") - # - # Test trying to sign in. Because we are loading the email and password - # sign_in_button.click() - # # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") From e8e23e3ac0de177f74f9f22b9886f5f0d9a89957 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:55:19 -0500 Subject: [PATCH 26/45] A little more cleanup Signed-off-by: Carlo Costino --- tests/end_to_end/test_accounts_page.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 498242743..6df6ec5be 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -24,7 +24,6 @@ def _bypass_sign_in(end_to_end_context): def test_add_new_service_workflow(end_to_end_context): - # page = end_to_end_context.new_page() page = _bypass_sign_in(end_to_end_context) page.goto(f"{E2E_TEST_URI}/") From 9987946f9296672e86c99c68385ddd3be5a18d5b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:58:56 -0500 Subject: [PATCH 27/45] Trying one more environment variable for auth Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 498a9f273..389e373b3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -119,6 +119,7 @@ jobs: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: http://localhost:6012 - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers From 87ca03f6d8e84055b769b12d593173ce933c321f Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 09:36:06 -0500 Subject: [PATCH 28/45] Switch back to using the API locally in the CI/CD job Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 103 +++++++++++++++++------------------ 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 389e373b3..d9ad358fe 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,8 +15,7 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - #API_HOST_NAME: http://localhost:6011 - API_HOST_NAME: https://notify-api-staging.app.cloud.gov + API_HOST_NAME: http://localhost:6011 jobs: build: @@ -57,61 +56,61 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - # services: - # postgres: - # image: postgres - # env: - # POSTGRES_USER: user - # POSTGRES_PASSWORD: password - # POSTGRES_DB: test_notification_api - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 5432 on service container to the host - # - 5432:5432 - # redis: - # image: redis - # options: >- - # --health-cmd "redis-cli ping" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 6379 on service container to the host - # - 6379:6379 + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 6379 on service container to the host + - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: 'notifications-api' - # - name: Install API dependencies - # working-directory: 'notifications-api' - # run: make bootstrap - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development - # - name: Run API server - # working-directory: 'notifications-api' - # run: make run-procfile & - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: 'notifications-api' + - name: Install API dependencies + working-directory: 'notifications-api' + run: make bootstrap + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development + - name: Run API server + working-directory: 'notifications-api' + run: make run-procfile & + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & env: From 95bdd335ebb0552dcdfe35d7329291ab1ebd4837 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 10:29:02 -0500 Subject: [PATCH 29/45] Changing back to staging API; trying to get E2E auth working Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 104 +++++++++++++++++------------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d9ad358fe..d99e54b9c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,7 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - API_HOST_NAME: http://localhost:6011 + API_HOST_NAME: https://notify-api-staging.app.cloud.gov jobs: build: @@ -56,61 +56,61 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 5432 on service container to the host - - 5432:5432 - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 6379 on service container to the host - - 6379:6379 + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_USER: user + # POSTGRES_PASSWORD: password + # POSTGRES_DB: test_notification_api + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 5432 on service container to the host + # - 5432:5432 + # redis: + # image: redis + # options: >- + # --health-cmd "redis-cli ping" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 6379 on service container to the host + # - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: 'notifications-api' - - name: Install API dependencies - working-directory: 'notifications-api' - run: make bootstrap - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development - - name: Run API server - working-directory: 'notifications-api' - run: make run-procfile & - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: 'notifications-api' + # - name: Install API dependencies + # working-directory: 'notifications-api' + # run: make bootstrap + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development + # - name: Run API server + # working-directory: 'notifications-api' + # run: make run-procfile & + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & env: @@ -120,6 +120,7 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: http://localhost:6012 - name: Run E2E tests + # Run the E2E tests against the code found in this PR. run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" @@ -127,7 +128,6 @@ jobs: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # Run the E2E tests against the code found in this PR. NOTIFY_E2E_TEST_URI: http://localhost:6012 validate-new-relic-config: From aec20b5e731a18ab659858694010760a65aa7f4b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 17:17:40 -0500 Subject: [PATCH 30/45] Add API access to Admin server Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d99e54b9c..15c820b8d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -114,6 +114,8 @@ jobs: - name: Run Admin server run: make run-flask & env: + ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} + ADMIN_CLIENT_USERNAME: ${{ secrets.ADMIN_CLIENT_USERNAME }} NOTIFY_ENVIRONMENT: development NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 136403a263ef504a4a73f48aa5a59578e976abf1 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 17:22:21 -0500 Subject: [PATCH 31/45] Adding a couple more missing env vars for the admin server Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 15c820b8d..3c1845c63 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -116,6 +116,8 @@ jobs: env: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: ${{ secrets.ADMIN_CLIENT_USERNAME }} + DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} NOTIFY_ENVIRONMENT: development NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From c2e7b4897de34a31b408ce3534fc8e0c10fa9a05 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 17:28:00 -0500 Subject: [PATCH 32/45] Adjusting a couple of other environment variables Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3c1845c63..3a1e41728 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -115,10 +115,10 @@ jobs: run: make run-flask & env: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} - ADMIN_CLIENT_USERNAME: ${{ secrets.ADMIN_CLIENT_USERNAME }} + ADMIN_CLIENT_USERNAME: notify-admin DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} SECRET_KEY: ${{ secrets.SECRET_KEY }} - NOTIFY_ENVIRONMENT: development + NOTIFY_ENVIRONMENT: staging NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 5aacdcbc356c785c0262bde7272d603c2f044096 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Tue, 9 Jan 2024 10:55:37 -0500 Subject: [PATCH 33/45] Slight adjustments to make sure no typos are present Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3a1e41728..befe91c71 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,6 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - API_HOST_NAME: https://notify-api-staging.app.cloud.gov jobs: build: @@ -114,10 +113,11 @@ jobs: - name: Run Admin server run: make run-flask & env: - ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} - ADMIN_CLIENT_USERNAME: notify-admin + API_HOST_NAME: https://notify-api-staging.app.cloud.gov DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} SECRET_KEY: ${{ secrets.SECRET_KEY }} + ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} + ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: staging NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 29c20a0ee9d03aec676b2770e3932c966984c29c Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Tue, 9 Jan 2024 11:57:58 -0500 Subject: [PATCH 34/45] Trying to see if New Relic needs to be in place Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index befe91c71..b57a516e4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -119,6 +119,8 @@ jobs: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: staging + NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} + NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 1b6446e213c95be211bcd3f9c34cf6fe98d67ee4 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 13:00:39 -0500 Subject: [PATCH 35/45] Added a new E2ETest config and adjusted a couple of things Signed-off-by: Carlo Costino --- app/config.py | 23 +++++++++++++++++++++-- tests/conftest.py | 2 +- tests/end_to_end/test_accounts_page.py | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/config.py b/app/config.py index f424076fa..c46ddf725 100644 --- a/app/config.py +++ b/app/config.py @@ -81,8 +81,7 @@ class Config(object): "IBAN": "GB33BUKB20201555555555", "swift": "ABCDEF12", "notify_billing_email_addresses": [ - "generic@digital.cabinet-office.gov.uk", - "first.last@digital.cabinet-office.gov.uk", + "tts-benefits-studio@gsa.gov", ], } @@ -152,6 +151,25 @@ class Staging(Production): HEADER_COLOUR = "#00ff00" # $green +class E2ETest(Staging): + """ + An environment config that is intended to operate as if it were in the + staging environment but with the configuration of the development and test + environments so the E2E tests work. + """ + + # Borrowed from development environment + SESSION_COOKIE_SECURE = False + SESSION_PROTECTION = None + HTTP_PROTOCOL = "http" + ASSET_DOMAIN = "" + ASSET_PATH = "/static/" + + # Borrowed from test environment + TESTING = True + WTF_CSRF_ENABLED = False + + class Demo(Staging): HEADER_COLOUR = "#6F72AF" # $mauve @@ -173,6 +191,7 @@ class Scanning(Production): configs = { "development": Development, "test": Test, + "e2etest": E2ETest, "scanning": Scanning, "staging": Staging, "demo": Demo, diff --git a/tests/conftest.py b/tests/conftest.py index 269bf5282..4a397b7ec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3593,7 +3593,7 @@ def end_to_end_context(browser): def end_to_end_authenticated_context(browser): # Create and load a previously authenticated context for Playwright E2E # tests. - login_for_end_to_end_testing(browser) + # login_for_end_to_end_testing(browser) auth_state_path = os.path.join( os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 6df6ec5be..8484e58b0 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -15,7 +15,7 @@ def _bypass_sign_in(end_to_end_context): sign_in_button = page.get_by_role("link", name="Sign in") - # Test trying to sign in. Because we are loading the email and password + # Sign in to the site - E2E test accounts are set to flow through. sign_in_button.click() # Wait for the next page to fully load. From 719ecfe8f6de1b3128bc861d3eec0616db293106 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 13:06:21 -0500 Subject: [PATCH 36/45] Modified E2E test job environment Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b57a516e4..12d39def8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -118,7 +118,7 @@ jobs: SECRET_KEY: ${{ secrets.SECRET_KEY }} ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: notify-admin - NOTIFY_ENVIRONMENT: staging + NOTIFY_ENVIRONMENT: e2etest NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} From c790d8b84439c8a578738d16f727b92127b00939 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 13:23:19 -0500 Subject: [PATCH 37/45] Added some additional environment variables to E2E command Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 12d39def8..fb67bfd5a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -131,6 +131,11 @@ jobs: # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: + DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} + ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} + ADMIN_CLIENT_USERNAME: notify-admin + NOTIFY_ENVIRONMENT: e2etest NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 534daa2d82e4ed29f51efe46f9d54eed181462f8 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:22:19 -0500 Subject: [PATCH 38/45] Attempting to match local E2E config with CI/CD Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 9 +-------- app/config.py | 8 ++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fb67bfd5a..22b3b8ae7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,8 +7,6 @@ permissions: env: NOTIFY_ENVIRONMENT: test - NEW_RELIC_CONFIG_FILE: newrelic.ini - NEW_RELIC_ENVIRONMENT: test FLASK_APP: application.py WERKZEUG_DEBUG_PIN: off REDIS_ENABLED: 0 @@ -119,8 +117,6 @@ jobs: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: e2etest - NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} - NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} @@ -131,10 +127,6 @@ jobs: # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: - DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} - SECRET_KEY: ${{ secrets.SECRET_KEY }} - ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} - ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: e2etest NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} @@ -149,6 +141,7 @@ jobs: - uses: ./.github/actions/setup-project - name: Validate NewRelic config env: + NEW_RELIC_CONFIG_FILE: newrelic.ini NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} # Need to set a NEW_RELIC_ENVIRONMENT with monitor_mode: true NEW_RELIC_ENVIRONMENT: staging diff --git a/app/config.py b/app/config.py index c46ddf725..091dd35fd 100644 --- a/app/config.py +++ b/app/config.py @@ -169,6 +169,14 @@ class E2ETest(Staging): TESTING = True WTF_CSRF_ENABLED = False + # buckets - mirror staging + CSV_UPLOAD_BUCKET = cloud_config.s3_credentials( + "notify-api-csv-upload-bucket-staging" + ) + LOGO_UPLOAD_BUCKET = cloud_config.s3_credentials( + "notify-admin-logo-upload-bucket-staging" + ) + class Demo(Staging): HEADER_COLOUR = "#6F72AF" # $mauve From bd41dfc1c2bcb48e90397f18b471ac5369abf411 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:31:59 -0500 Subject: [PATCH 39/45] Attempting to get E2E work with local API Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 103 ++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 22b3b8ae7..d68df41ad 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -53,65 +53,66 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - # services: - # postgres: - # image: postgres - # env: - # POSTGRES_USER: user - # POSTGRES_PASSWORD: password - # POSTGRES_DB: test_notification_api - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 5432 on service container to the host - # - 5432:5432 - # redis: - # image: redis - # options: >- - # --health-cmd "redis-cli ping" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 6379 on service container to the host - # - 6379:6379 + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 6379 on service container to the host + - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: 'notifications-api' - # - name: Install API dependencies - # working-directory: 'notifications-api' - # run: make bootstrap - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development - # - name: Run API server - # working-directory: 'notifications-api' - # run: make run-procfile & - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: 'notifications-api' + - name: Install API dependencies + working-directory: 'notifications-api' + run: make bootstrap + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: staging + - name: Run API server + working-directory: 'notifications-api' + run: make run-procfile & + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: staging - name: Run Admin server run: make run-flask & env: - API_HOST_NAME: https://notify-api-staging.app.cloud.gov + # API_HOST_NAME: https://notify-api-staging.app.cloud.gov + API_HOST_NAME: http://localhost:6011 DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} SECRET_KEY: ${{ secrets.SECRET_KEY }} ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} From 3a6eeb229277a10c096d8664c3330e4a6f2e330e Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:37:22 -0500 Subject: [PATCH 40/45] Swapping API back to development environment Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d68df41ad..f5d614280 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,7 +97,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: staging + NOTIFY_ENVIRONMENT: development - name: Run API server working-directory: 'notifications-api' run: make run-procfile & @@ -107,7 +107,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: staging + NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & env: From fd5cd36959e59d324c240c7b7521ec5fcef9199a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:52:32 -0500 Subject: [PATCH 41/45] Remove webkit testing for now Signed-off-by: Carlo Costino --- Makefile | 4 ++-- app/config.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8f950dbf6..aa9b404af 100644 --- a/Makefile +++ b/Makefile @@ -80,8 +80,8 @@ dead-code: .PHONY: e2e-test e2e-test: export NEW_RELIC_ENVIRONMENT=test -e2e-test: ## Run end-to-end integration tests - poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end +e2e-test: ## Run end-to-end integration tests; note that --browser webkit isn't currently working + poetry run pytest -v --browser chromium --browser firefox tests/end_to_end .PHONY: js-lint js-lint: ## Run javascript linting scanners diff --git a/app/config.py b/app/config.py index 091dd35fd..58623f426 100644 --- a/app/config.py +++ b/app/config.py @@ -159,6 +159,7 @@ class E2ETest(Staging): """ # Borrowed from development environment + DEBUG = True SESSION_COOKIE_SECURE = False SESSION_PROTECTION = None HTTP_PROTOCOL = "http" From 7259d617eebedfafcbc8c8523709b3382867ac66 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 18:04:07 -0500 Subject: [PATCH 42/45] Actually disable webkit in CI/CD E2E tests Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f5d614280..179615e89 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -124,7 +124,9 @@ jobs: NOTIFY_E2E_TEST_URI: http://localhost:6012 - name: Run E2E tests # Run the E2E tests against the code found in this PR. - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # --browser webkit doesn't work at this time. + run: poetry run pytest -v --browser chromium --browser firefox tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: From 9c392bca78cfda193694a0dab0bd4d7c4cb3225b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 26 Jan 2024 09:26:23 -0500 Subject: [PATCH 43/45] Switch E2E test command to use Makefile Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 179615e89..53af0de2d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -126,7 +126,7 @@ jobs: # Run the E2E tests against the code found in this PR. # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # --browser webkit doesn't work at this time. - run: poetry run pytest -v --browser chromium --browser firefox tests/end_to_end + run: make e2e-test # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: From 4180dca164540c7ec5653e2bed7c56c3b1fbc5ac Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 11:24:03 -0500 Subject: [PATCH 44/45] Last bits of cleanup with pytest configuration for E2E tests Signed-off-by: Carlo Costino --- tests/conftest.py | 85 -------------------- tests/end_to_end/__init__.py | 0 tests/end_to_end/conftest.py | 105 +++++++++++++++++++++++++ tests/end_to_end/test_accounts_page.py | 20 +---- 4 files changed, 107 insertions(+), 103 deletions(-) create mode 100644 tests/end_to_end/__init__.py create mode 100644 tests/end_to_end/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py index 4a397b7ec..6c4f94b4f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ import copy import json import os -import re from contextlib import contextmanager from datetime import date, datetime, timedelta from unittest.mock import Mock, PropertyMock @@ -36,8 +35,6 @@ from . import ( load_dotenv() -E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") - class ElementNotFound(Exception): pass @@ -3521,88 +3518,6 @@ def mock_get_invited_org_user_by_id(mocker, sample_org_invite): ) -def login_for_end_to_end_testing(browser): - # Open a new page and go to the staging site. - context = browser.new_context() - page = context.new_page() - page.goto(f"{E2E_TEST_URI}/") - - sign_in_button = page.get_by_role("link", name="Sign in") - - # Test trying to sign in. - sign_in_button.click() - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") - - # Check for the sign in form elements. - # NOTE: Playwright cannot find input elements by role and recommends using - # get_by_label() instead; however, hidden form elements do not have - # labels associated with them, hence the XPath! - # See https://playwright.dev/python/docs/api/class-page#page-get-by-label - # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath - # for more information. - email_address_input = page.get_by_label("Email address") - password_input = page.get_by_label("Password") - continue_button = page.get_by_role("button", name=re.compile("Continue")) - - # Sign in to the site. - email_address_input.fill(os.getenv("NOTIFY_E2E_TEST_EMAIL")) - password_input.fill(os.getenv("NOTIFY_E2E_TEST_PASSWORD")) - continue_button.click() - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") - - # Check for the sign in form elements. - # NOTE: Playwright cannot find input elements by role and recommends using - # get_by_label() instead; however, hidden form elements do not have - # labels associated with them, hence the XPath! - # See https://playwright.dev/python/docs/api/class-page#page-get-by-label - # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath - # for more information. - # mfa_input = page.get_by_label('Text message code') - # continue_button = page.get_by_role('button', name=re.compile('Continue')) - - # # Enter MFA code and continue. - # TODO: Revisit this at a later point in time. - # totp = pyotp.TOTP( - # os.getenv('MFA_TOTP_SECRET'), - # digits=int(os.getenv('MFA_TOTP_LENGTH')) - # ) - - # mfa_input.fill(totp.now()) - # continue_button.click() - - # page.wait_for_load_state('domcontentloaded') - - # Save storage state into the file. - auth_state_path = os.path.join( - os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" - ) - context.storage_state(path=auth_state_path) - - -@pytest.fixture(scope="session") -def end_to_end_context(browser): - context = browser.new_context() - return context - - -@pytest.fixture(scope="session") -def end_to_end_authenticated_context(browser): - # Create and load a previously authenticated context for Playwright E2E - # tests. - # login_for_end_to_end_testing(browser) - - auth_state_path = os.path.join( - os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" - ) - context = browser.new_context(storage_state=auth_state_path) - - return context - - @pytest.fixture() def fake_markdown_file(): input = "#Test" diff --git a/tests/end_to_end/__init__.py b/tests/end_to_end/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py new file mode 100644 index 000000000..6abd2e231 --- /dev/null +++ b/tests/end_to_end/conftest.py @@ -0,0 +1,105 @@ +import os +import re + +import pytest + +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + + +def login_for_end_to_end_testing(browser): + # Open a new page and go to the staging site. + context = browser.new_context() + page = context.new_page() + page.goto(f"{E2E_TEST_URI}/") + + sign_in_button = page.get_by_role("link", name="Sign in") + + # Test trying to sign in. + sign_in_button.click() + + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") + + # Check for the sign in form elements. + # NOTE: Playwright cannot find input elements by role and recommends using + # get_by_label() instead; however, hidden form elements do not have + # labels associated with them, hence the XPath! + # See https://playwright.dev/python/docs/api/class-page#page-get-by-label + # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath + # for more information. + email_address_input = page.get_by_label("Email address") + password_input = page.get_by_label("Password") + continue_button = page.get_by_role("button", name=re.compile("Continue")) + + # Sign in to the site. + email_address_input.fill(os.getenv("NOTIFY_E2E_TEST_EMAIL")) + password_input.fill(os.getenv("NOTIFY_E2E_TEST_PASSWORD")) + continue_button.click() + + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") + + # Check for the sign in form elements. + # NOTE: Playwright cannot find input elements by role and recommends using + # get_by_label() instead; however, hidden form elements do not have + # labels associated with them, hence the XPath! + # See https://playwright.dev/python/docs/api/class-page#page-get-by-label + # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath + # for more information. + # mfa_input = page.get_by_label('Text message code') + # continue_button = page.get_by_role('button', name=re.compile('Continue')) + + # # Enter MFA code and continue. + # TODO: Revisit this at a later point in time. + # totp = pyotp.TOTP( + # os.getenv('MFA_TOTP_SECRET'), + # digits=int(os.getenv('MFA_TOTP_LENGTH')) + # ) + + # mfa_input.fill(totp.now()) + # continue_button.click() + + # page.wait_for_load_state('domcontentloaded') + + # Save storage state into the file. + auth_state_path = os.path.join( + os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" + ) + context.storage_state(path=auth_state_path) + + +@pytest.fixture(scope="session") +def end_to_end_context(browser): + context = browser.new_context() + return context + + +@pytest.fixture(scope="session") +def end_to_end_authenticated_context(browser): + # Create and load a previously authenticated context for Playwright E2E + # tests. + # login_for_end_to_end_testing(browser) + + auth_state_path = os.path.join( + os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" + ) + context = browser.new_context(storage_state=auth_state_path) + + return context + + +@pytest.fixture(scope="session") +def bypass_sign_in(end_to_end_context): + # Open a new page and go to the staging site. + page = end_to_end_context.new_page() + + page.goto(f"{E2E_TEST_URI}/") + + sign_in_button = page.get_by_role("link", name="Sign in") + + # Sign in to the site - E2E test accounts are set to flow through. + sign_in_button.click() + + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") + return page diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 8484e58b0..89357c7ed 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -7,24 +7,8 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def _bypass_sign_in(end_to_end_context): - # Open a new page and go to the staging site. - page = end_to_end_context.new_page() - - page.goto(f"{E2E_TEST_URI}/") - - sign_in_button = page.get_by_role("link", name="Sign in") - - # Sign in to the site - E2E test accounts are set to flow through. - sign_in_button.click() - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") - return page - - -def test_add_new_service_workflow(end_to_end_context): - page = _bypass_sign_in(end_to_end_context) +def test_add_new_service_workflow(bypass_sign_in, end_to_end_context): + page = bypass_sign_in(end_to_end_context) page.goto(f"{E2E_TEST_URI}/") # Wait for the next page to fully load. From 4741b381c2545bff5857ff1cd835c8bf1fd23e2e Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 11:39:14 -0500 Subject: [PATCH 45/45] Adjusting authenticated page fixture Signed-off-by: Carlo Costino --- tests/end_to_end/conftest.py | 2 +- tests/end_to_end/test_accounts_page.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 6abd2e231..48d1bcd35 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -89,7 +89,7 @@ def end_to_end_authenticated_context(browser): @pytest.fixture(scope="session") -def bypass_sign_in(end_to_end_context): +def authenticated_page(end_to_end_context): # Open a new page and go to the staging site. page = end_to_end_context.new_page() diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 89357c7ed..411728e33 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -7,8 +7,8 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def test_add_new_service_workflow(bypass_sign_in, end_to_end_context): - page = bypass_sign_in(end_to_end_context) +def test_add_new_service_workflow(authenticated_page, end_to_end_context): + page = authenticated_page page.goto(f"{E2E_TEST_URI}/") # Wait for the next page to fully load.