Skip to content

Commit

Permalink
Workflow and playwright test updates
Browse files Browse the repository at this point in the history
Signed-off-by: ytimocin <[email protected]>
  • Loading branch information
ytimocin committed Apr 25, 2024
1 parent 6949da2 commit 2cd9ac3
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 206 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/test-aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,12 @@ jobs:
- name: Deploy app
if: steps.gen-id.outputs.RUN_TEST == 'true'
id: deploy-app
run: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }} -e ${{ matrix.env }}
- name: Wait for all pods to be ready
if: steps.gen-id.outputs.RUN_TEST == 'true'
id: wait-for-pods
run: |
namespace="${{ matrix.env }}-${{ matrix.app }}"
label="radapp.io/application=${{ matrix.app }}"
kubectl rollout status deployment -l $label -n $namespace --timeout=90s
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
max_attempts: 3
retry_wait_seconds: 30
command: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }} -e ${{ matrix.env }}
- name: Run Playwright Test
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.uiTestFile != ''
id: run-playwright-test
Expand All @@ -316,6 +314,14 @@ jobs:
path: playwright/playwright-report/
retention-days: 30
if-no-files-found: error
- name: Upload Playwright Videos
uses: actions/upload-artifact@v4
if: always() && steps.run-playwright-test.outcome == 'failure'
with:
name: playwright-report-${{ matrix.name }}
path: playwright/test-results/
retention-days: 30
if-no-files-found: error
# Handle failures
- name: Get Pod logs for failed tests
id: get-pod-logs
Expand Down
58 changes: 30 additions & 28 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
enableDapr: false
- name: eshop-azure
os: ubuntu-latest-m
runOnPullRequest: false
runOnPullRequest: true
app: eshop
env: azure
path: ./samples/eshop/eshop.bicep
Expand All @@ -85,7 +85,7 @@ jobs:
enableDapr: false
- name: eshop-aws
os: ubuntu-latest-m
runOnPullRequest: false
runOnPullRequest: true
app: eshop
env: aws
path: ./samples/eshop/eshop.bicep
Expand Down Expand Up @@ -256,39 +256,33 @@ jobs:
fi
rad env switch ${{ matrix.env }}
# Deploy application and run tests
# Retry the deployment step in case of transient failures
- name: Deploy app
if: steps.gen-id.outputs.RUN_TEST == 'true'
id: deploy-app
run: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }}
- name: Wait for all pods to be ready
if: steps.gen-id.outputs.RUN_TEST == 'true'
id: wait-for-pods
run: |
namespace="${{ matrix.env }}-${{ matrix.app }}"
label="radapp.io/application=${{ matrix.app }}"
kubectl rollout status deployment -l $label -n $namespace --timeout=90s
- name: Run Playwright Test
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.uiTestFile != ''
id: run-playwright-test
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
timeout_minutes: 30
max_attempts: 3
retry_wait_seconds: 30
command: |
if [[ "${{ matrix.container }}" != "" ]]; then
rad resource expose containers ${{ matrix.container }} ${{ matrix.exposeArgs }} --port ${{ matrix.port }} &
echo "Endpoint: http://localhost:${{ matrix.port }}"
export ENDPOINT="http://localhost:${{ matrix.port }}"
else
endpoint="$(rad app status -a ${{ matrix.app }} | sed 's/ /\n/g' | grep http)"
echo "Endpoint: $endpoint"
export ENDPOINT=$endpoint
fi
cd playwright/
npm ci
npx playwright install --with-deps
npx playwright test ${{ matrix.uiTestFile }} --retries 3
command: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }}
- name: Run Playwright Test
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.uiTestFile != ''
id: run-playwright-test
run: |
if [[ "${{ matrix.container }}" != "" ]]; then
rad resource expose containers ${{ matrix.container }} ${{ matrix.exposeArgs }} --port ${{ matrix.port }} &
export ENDPOINT="http://localhost:3000/"
else
endpoint="$(rad app status -a ${{ matrix.app }} | sed 's/ /\n/g' | grep http)"
echo "Endpoint: $endpoint"
export ENDPOINT=$endpoint
fi
cd playwright/
npm ci
npx playwright install --with-deps
npx playwright test ${{ matrix.uiTestFile }} --retries 3
- name: Upload Playwright Results
uses: actions/upload-artifact@v4
if: always() && ( steps.run-playwright-test.outcome == 'success' || steps.run-playwright-test.outcome == 'failure' )
Expand All @@ -297,6 +291,14 @@ jobs:
path: playwright/playwright-report/
retention-days: 30
if-no-files-found: error
- name: Upload Playwright Videos
uses: actions/upload-artifact@v4
if: always() && steps.run-playwright-test.outcome == 'failure'
with:
name: playwright-report-${{ matrix.name }}
path: playwright/test-results/
retention-days: 30
if-no-files-found: error
# Handle failures
- name: Get Pod logs for failed tests
id: get-pod-logs
Expand Down
111 changes: 20 additions & 91 deletions playwright/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.43.0",
"@types/node": "^20.12.6",
"@playwright/test": "^1.43.1",
"@types/node": "^20.12.7",
"@types/uuid": "^9.0.8",
"typescript": "^5.4.4"
"typescript": "^5.4.5"
},
"dependencies": {
"uuid": "^9.0.1"
}
}
}
3 changes: 2 additions & 1 deletion playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default defineConfig({

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
video: "retain-on-failure",
},
/* Configure projects for major browsers */
projects: [
Expand All @@ -46,7 +47,7 @@ export default defineConfig({
use: { ...devices["Desktop Safari"] },
},
],
timeout: 1 * 60 * 1000,
timeout: 5 * 60 * 1000,
expect: {
timeout: 30 * 1000,
},
Expand Down
2 changes: 2 additions & 0 deletions playwright/tests/eshop/eshop.app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ test("eShop on Containers App Basic UI and Functionality Checks", async ({
numberOfItemsAdded++;

// Go to the cart
console.log("Going to the cart");
const cartLink = page.getByRole("link", { name: `${numberOfItemsAdded}` });
await expect(cartLink).toBeVisible();
await cartLink.click();
console.log("Cart page loaded");

// Expect page to have proper URL
await expect(page).toHaveURL(new RegExp(`${endpoint}/basket.*`));
Expand Down
6 changes: 3 additions & 3 deletions samples/eshop-dapr/services/webshopping-agg.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ resource webshoppingAgg 'Applications.Core/containers@2023-10-01-preview' = {
IdentityUrl: 'http://identity-api:80'
IdentityUrlExternal: '${gateway.properties.url}/identity/'
SeqServerUrl: 'http://seq:5340'
BasketUrlHC: 'http://localhost:3500/v1.0/invoke/basket-api/method/hc'
CatalogUrlHC: 'http://localhost:3500/v1.0/invoke/catalog-api/method/hc'
IdentityUrlHC: 'http://localhost:3500/v1.0/invoke/identity-api/method/hc'
BasketUrlHC: 'http://localhost:3500/v1.0/invoke/basket-api/method/liveness'
CatalogUrlHC: 'http://localhost:3500/v1.0/invoke/catalog-api/method/liveness'
IdentityUrlHC: 'http://localhost:3500/v1.0/invoke/identity-api/method/liveness'
}
ports: {
http: {
Expand Down
14 changes: 7 additions & 7 deletions samples/eshop-dapr/services/webstatus.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ resource webstatus 'Applications.Core/containers@2023-10-01-preview' = {
ASPNETCORE_URLS: 'http://0.0.0.0:80'
PATH_BASE: '/health'
HealthChecksUI__HealthChecks__0__Name: 'Blazor UI Host'
HealthChecksUI__HealthChecks__0__Uri: 'http://blazor-client:80/hc'
HealthChecksUI__HealthChecks__0__Uri: 'http://blazor-client:80/liveness'
HealthChecksUI__HealthChecks__1__Name: 'Identity API'
HealthChecksUI__HealthChecks__1__Uri: 'http://localhost:3500/v1.0/invoke/identity-api/method/hc'
HealthChecksUI__HealthChecks__1__Uri: 'http://localhost:3500/v1.0/invoke/identity-api/method/liveness'
HealthChecksUI__HealthChecks__2__Name: 'Basket API'
HealthChecksUI__HealthChecks__2__Uri: 'http://localhost:3500/v1.0/invoke/basket-api/method/hc'
HealthChecksUI__HealthChecks__2__Uri: 'http://localhost:3500/v1.0/invoke/basket-api/method/liveness'
HealthChecksUI__HealthChecks__3__Name: 'Catalog API'
HealthChecksUI__HealthChecks__3__Uri: 'http://localhost:3500/v1.0/invoke/catalog-api/method/hc'
HealthChecksUI__HealthChecks__3__Uri: 'http://localhost:3500/v1.0/invoke/catalog-api/method/liveness'
HealthChecksUI__HealthChecks__4__Name: 'Ordering API'
HealthChecksUI__HealthChecks__4__Uri: 'http://localhost:3500/v1.0/invoke/ordering-api/method/hc'
HealthChecksUI__HealthChecks__4__Uri: 'http://localhost:3500/v1.0/invoke/ordering-api/method/liveness'
HealthChecksUI__HealthChecks__5__Name: 'Payment API'
HealthChecksUI__HealthChecks__5__Uri: 'http://localhost:3500/v1.0/invoke/payment-api/method/hc'
HealthChecksUI__HealthChecks__5__Uri: 'http://localhost:3500/v1.0/invoke/payment-api/method/liveness'
HealthChecksUI__HealthChecks__6__Name: 'Web Shopping Aggregator'
HealthChecksUI__HealthChecks__6__Uri: 'http://localhost:3500/v1.0/invoke/webshoppingagg/method/hc'
HealthChecksUI__HealthChecks__6__Uri: 'http://localhost:3500/v1.0/invoke/webshoppingagg/method/liveness'
}
ports: {
http: {
Expand Down
Loading

0 comments on commit 2cd9ac3

Please sign in to comment.