Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve E2E Test Failure Handling and Reporting #1191

Merged
merged 21 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b24d254
Debug C8085776.
shammowla Sep 13, 2024
e8486e3
Remove edge browser.
shammowla Sep 13, 2024
a0aadca
Remove edge and add additional time before assertion.
shammowla Sep 13, 2024
3923878
Debug unit test dev workflow.
shammowla Sep 18, 2024
0388402
Debug unit test runner.
shammowla Sep 19, 2024
389e22e
Increase timeout for functional tests.
shammowla Sep 19, 2024
7549fb4
Remove debug logs from C8085776.
shammowla Sep 19, 2024
f0a425a
Update workflow to explicitly pass PACKAGE_VERSION to test environment
shammowla Sep 26, 2024
529aafc
Add debug info C2589 for getLibraryInfo firefox issue.
shammowla Sep 26, 2024
11e6df7
Run firefox test on Windows to debug library info bug.
shammowla Sep 26, 2024
0efdb92
Firefox get libraryinfo fixed, reenable chrome and safari tests.
shammowla Sep 26, 2024
c1f628d
Ensure that the mbox/json API request is being made.
shammowla Sep 26, 2024
1819b4f
Enable quarantineMode to debug safari error.
shammowla Sep 26, 2024
3b8fe47
Enable quarantineMode to debug safari error.
shammowla Sep 26, 2024
42077ee
Safari failure fixed, removing quarantineMode.
shammowla Sep 27, 2024
89b0983
Enable 3 attemps with failure logs.
shammowla Sep 27, 2024
9b44fee
Remove quarantineMode from the browser configs.
shammowla Sep 27, 2024
02b369c
Enable quarantineMode for safari.
shammowla Sep 27, 2024
cc42837
Update config for Chrome to debug intermittent failures.
shammowla Sep 30, 2024
a14c204
Set smartRetry on failed tests.
shammowla Sep 30, 2024
e633772
Create a github issue when a test fails.
shammowla Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/scripts/handle-test-failures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = async ({ github, context, browser }) => {
const fs = require('fs');
const path = require('path');

// Read the test results
const testResultsDir = './test-results';
const files = fs.readdirSync(testResultsDir);

for (const file of files) {
const content = fs.readFileSync(path.join(testResultsDir, file), 'utf8');
let result;
try {
result = JSON.parse(content);
} catch (error) {
console.error(`Error parsing JSON from ${file}: ${error}`);
continue;
}

if (result.status === 'failed') {
const testName = result.name;
const sauceLabsLink = `https://app.saucelabs.com/tests/${result.id}`;

// Search for an existing issue
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: ['test-failure', browser]
});

const existingIssue = issues.data.find(issue => issue.title.includes(testName));

if (existingIssue) {
// Update existing issue
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `Test failed again in the latest run.\nBrowser: ${browser}\nRun: ${context.runId}\n[View on SauceLabs](${sauceLabsLink})`
});
} else {
// Create new issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Test Failure: ${testName} (${browser})`,
body: `The test "${testName}" failed in the ${browser} browser.\n\nRun: ${context.runId}\n[View on SauceLabs](${sauceLabsLink})`,
labels: ['test-failure', browser]
});
}
}
}
};
1 change: 1 addition & 0 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
SAUCE_CAPABILITIES_OVERRIDES_PATH: "sauceLabsCapabilities.json"
EDGE_BASE_PATH: ee-pre-prd
ALLOY_ENV: int
SAUCE_TUNNEL_ID: github-action-tunnel

jobs:
linting:
Expand Down
60 changes: 18 additions & 42 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,14 @@ jobs:
echo "TEST_RESULTS=No test results found in ./test-results/" >> $GITHUB_ENV
fi

- name: Notify Slack on Failure
- name: Handle Test Failures
if: failure()
uses: 8398a7/action-slack@v3
uses: actions/github-script@v7
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow
text: |
Alloy Prod Firefox Tests Failed
Job ID: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').id }}
Build: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').build }}
Status: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').status }}
Error: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').error }}
Full Results: https://app.saucelabs.com/tests/${{ fromJson(steps.saucelabs-results.outputs.results || '{}').id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const handleTestFailures = require('./.github/scripts/handle-test-failures.js');
await handleTestFailures({ github, context, browser: 'safari' });

alloy-prod-e2e-firefox:
name: Firefox
Expand Down Expand Up @@ -244,22 +236,14 @@ jobs:
echo "TEST_RESULTS=No test results found in ./test-results/" >> $GITHUB_ENV
fi

- name: Notify Slack on Failure
- name: Handle Test Failures
if: failure()
uses: 8398a7/action-slack@v3
uses: actions/github-script@v7
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow
text: |
Alloy Prod Firefox Tests Failed
Job ID: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').id }}
Build: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').build }}
Status: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').status }}
Error: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').error }}
Full Results: https://app.saucelabs.com/tests/${{ fromJson(steps.saucelabs-results.outputs.results || '{}').id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const handleTestFailures = require('./.github/scripts/handle-test-failures.js');
await handleTestFailures({ github, context, browser: 'firefox' });

alloy-prod-e2e-chrome:
name: Chrome
Expand Down Expand Up @@ -328,19 +312,11 @@ jobs:
ALLOY_ENV=prod
config-file: ./.sauce/prod-chrome.yml

- name: Notify Slack on Failure
- name: Handle Test Failures
if: failure()
uses: 8398a7/action-slack@v3
uses: actions/github-script@v7
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow
text: |
Alloy Prod Firefox Tests Failed
Job ID: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').id }}
Build: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').build }}
Status: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').status }}
Error: ${{ fromJson(steps.saucelabs-results.outputs.results || '{}').error }}
Full Results: https://app.saucelabs.com/tests/${{ fromJson(steps.saucelabs-results.outputs.results || '{}').id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const handleTestFailures = require('./.github/scripts/handle-test-failures.js');
await handleTestFailures({ github, context, browser: 'chrome' });
16 changes: 1 addition & 15 deletions .sauce/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ testcafe:
version: 3.6.0
nodeVersion: "22"
speed: 1
pageLoadTimeout: 3000
pageLoadTimeout: 5000
disablePageCaching: true
timeZone: New_York
npm:
Expand All @@ -26,22 +26,8 @@ npm:
- "@adobe/reactor-cookie"
- "@adobe/reactor-query-string"
suites:
- name: "Edge"
browserName: "microsoftedge"
headless: true
browserVersion: "119"
src:
- "test/functional/specs/**/*.js"
platformName: "Windows 11"
excludedTestFiles:
[
"test/functional/specs/Personalization/C782718.js",
"test/functional/specs/Privacy/C5594870.js",
"test/functional/specs/Personalization/C8631577.js",
]
- name: "Safari"
browserName: "safari"
headless: true
browserVersion: "latest"
src:
- "test/functional/specs/**/*.js"
Expand Down
10 changes: 7 additions & 3 deletions .sauce/prod-chrome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ apiVersion: v1alpha
kind: testcafe
sauce:
region: us-west-1
retries: 3
metadata:
name: Alloy Prod
rootDir: ./
env:
ALLOY_ENV: prod
ALLOY_PROD_VERSION: $ALLOY_PROD_VERSION
NPM_PACKAGE_VERSION: $NPM_PACKAGE_VERSION
PACKAGE_VERSION: $PACKAGE_VERSION
testcafe:
version: "package.json"
nodeVersion: "$NODE_VERSION"
speed: 1
pageLoadTimeout: 3000
disablePageCaching: true
speed: 0.5
pageLoadTimeout: 8000
disablePageCaching: false
timeZone: New_York
npm:
dependencies:
Expand All @@ -31,6 +33,8 @@ npm:
- "@adobe/reactor-object-assign"
suites:
- name: "Chrome"
smartRetry:
failedOnly: true
browserName: "chrome"
browserVersion: "latest"
src:
Expand Down
15 changes: 9 additions & 6 deletions .sauce/prod-firefox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ apiVersion: v1alpha
kind: testcafe
sauce:
region: us-west-1
retries: 3
metadata:
name: Alloy Prod
rootDir: ./
env:
ALLOY_ENV: prod
ALLOY_PROD_VERSION: $ALLOY_PROD_VERSION
NPM_PACKAGE_VERSION: $NPM_PACKAGE_VERSION
PACKAGE_VERSION: $PACKAGE_VERSION
testcafe:
version: 3.6.0
nodeVersion: "22"
speed: 1
pageLoadTimeout: 3000
version: "package.json"
nodeVersion: "$NODE_VERSION"
speed: 0.5
pageLoadTimeout: 8000
disablePageCaching: true
timeZone: New_York
timeout: 3600
npm:
dependencies:
- node-fetch
Expand All @@ -32,11 +33,13 @@ npm:
- "@adobe/reactor-object-assign"
suites:
- name: "Firefox"
smartRetry:
failedOnly: true
browserName: "firefox"
browserVersion: "latest"
src:
- "test/functional/specs/**/*.js"
platformName: "macOS 13"
platformName: "Windows 11"
excludedTestFiles:
[
"test/functional/specs/Data Collector/C81182.js",
Expand Down
10 changes: 7 additions & 3 deletions .sauce/prod-safari.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ apiVersion: v1alpha
kind: testcafe
sauce:
region: us-west-1
retries: 3
metadata:
name: Alloy Prod
rootDir: ./
env:
ALLOY_ENV: prod
ALLOY_PROD_VERSION: $ALLOY_PROD_VERSION
NPM_PACKAGE_VERSION: $NPM_PACKAGE_VERSION
PACKAGE_VERSION: $PACKAGE_VERSION
testcafe:
version: "package.json"
nodeVersion: "$NODE_VERSION"
speed: 1
pageLoadTimeout: 3000
disablePageCaching: true
speed: 0.5
pageLoadTimeout: 8000
disablePageCaching: false
timeZone: New_York
npm:
dependencies:
Expand All @@ -31,6 +33,8 @@ npm:
- "@adobe/reactor-object-assign"
suites:
- name: "Safari"
smartRetry:
failedOnly: true
browserName: "safari"
browserVersion: "latest"
src:
Expand Down
30 changes: 18 additions & 12 deletions karma.saucelabs.conf.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,32 @@ module.exports = (config) => {
base: "SauceLabs",
browserName: "chrome",
browserVersion: "latest",
platform: "Windows 11",
platformName: "Windows 11",
"sauce:options": {
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
headless: true,
},
},
sl_safariW3C: {
base: "SauceLabs",
browserName: "safari",
browserVersion: "latest",
platform: "macOS 13",
platformName: "macOS 13",
"sauce:options": {
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
headless: true,
},
},
sl_firefoxW3C: {
base: "SauceLabs",
browserName: "firefox",
platformName: "Windows 11",
browserVersion: "latest",
platformName: "Windows 11",
"sauce:options": {
geckodriverVersion: "0.34.0",
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
headless: true,
},
},
sl_edgeW3C: {
base: "SauceLabs",
browserName: "microsoftedge",
browserVersion: "latest",
platform: "Windows 11",
},
};

config.set({
Expand All @@ -50,9 +53,12 @@ module.exports = (config) => {
concurrency: 10,
colors: true,
sauceLabs: {
screenResolution: "800x600",
testName: "Alloy Unit Tests",
build: `GH #${process.env.BUILD_NUMBER} (${process.env.BUILD_ID})`,
tunnelIdentifier: process.env.JOB_NUMBER,
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
screenResolution: "1280x1024",
recordVideo: false,
recordScreenshots: false,
},
plugins: [
"karma-jasmine",
Expand Down
Loading