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

Update yaml to update slot deployment creds + add exponential backoff to intermittently failing integration tests #906

Merged
merged 4 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
- script: npm run test-staging && node helpers/integration-tests/index.js
displayName: 'Analyze staging with webhint'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- bash: |
az login --service-principal -u $AZURE_SERVICE_PRINCIPAL -p $AZURE_SERVICE_PRINCIPAL_PASSWORD --tenant $AZURE_TENANT
az webapp deployment slot swap -g webhint-web -n sonarwhal --slot staging
- task: AzureAppServiceManage@0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

displayName: 'Swap into production'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
AZURE_SERVICE_PRINCIPAL: $(AZURE_SERVICE_PRINCIPAL)
AZURE_SERVICE_PRINCIPAL_PASSWORD: $(AZURE_SERVICE_PRINCIPAL_PASSWORD)
AZURE_TENANT: $(AZURE_TENANT)
inputs:
azureSubscription: 'webhint-web'
Action: 'Swap Slots'
WebAppName: 'sonarwhal'
ResourceGroupName: 'webhint-web'
SourceSlot: 'staging'
- bash: |
curl https://www.google.com/ping?sitemap=https://webhint.io/sitemap.xml
curl https://www.bing.com/ping?sitemap=https://webhint.io/sitemap.xml
Expand Down
4 changes: 2 additions & 2 deletions helpers/integration-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const runIntegrationTests = async () => {

try {
for (const test of [runStaticTests, runScannerTest]) {
const errorFound = await test();
const success = await test();

if (errorFound) {
if (!success) {
error = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/integration-tests/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const runScannerTest = async () => {
}! => Status: ${response.status()}`
);

return response.status() !== 200;
return response.status() === 200;
} catch (error) {
console.error('🚨 Something went wrong while executing Puppeteer: ', error);
await browser.close();
Expand Down
23 changes: 18 additions & 5 deletions helpers/integration-tests/staticUrls.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ const staticURLsToVerify = [
'https://sonarwhal-staging.azurewebsites.net/docs/user-guide/hints/'
];

const backOffTime = 5000;
const maxRetries = 3;

const delay = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
};

const runPuppeteer = async (url) => {
const browser = await puppeteer.launch();

Expand All @@ -32,17 +39,23 @@ const runPuppeteer = async (url) => {
};

const runStaticTests = async () => {
let errorFound = false;
let success = true;
let retryCount = 0;
let resultStatus = null;

for (const url of staticURLsToVerify) {
const resultStatus = await runPuppeteer(url);
resultStatus = await runPuppeteer(url);

if (resultStatus !== 200) {
errorFound = true;
while(resultStatus !== 200 && retryCount < maxRetries) {
console.log('Test failed, retrying... Attempt #' + (++retryCount));
await delay(backOffTime * retryCount);
resultStatus = await runPuppeteer(url);
}

success = success && resultStatus === 200;
}

return errorFound;
return success;
};

module.exports = { runStaticTests };