From e5fc6f202234c10ced2d9bb335a294f92c432796 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Thu, 25 Jun 2020 18:59:44 -0500 Subject: [PATCH] Runner Tweaks (#62) Co-authored-by: Steve Faulkner --- .github/workflows/runners.yml | 2 +- test/index.spec.js | 91 ++++++++++++++++++----------------- test/utils.js | 6 +++ 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/.github/workflows/runners.yml b/.github/workflows/runners.yml index 89747218c..9f9dc8924 100644 --- a/.github/workflows/runners.yml +++ b/.github/workflows/runners.yml @@ -1,7 +1,7 @@ name: Runners on: schedule: - - cron: "*/15 * * * *" + - cron: "*/10 * * * *" jobs: sqlcreatecollection: runs-on: ubuntu-latest diff --git a/test/index.spec.js b/test/index.spec.js index 4cf37d082..c46082b87 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -1,52 +1,57 @@ import "expect-puppeteer"; -import { trackEvent } from "./utils"; +import { trackEvent, trackException } from "./utils"; jest.setTimeout(300000); describe("Collection CRUD", () => { it("should complete collection crud", async () => { - // Login to Azure Portal - await page.goto("https://portal.azure.com"); - await page.waitFor("input[name=loginfmt]"); - await page.type("input[name=loginfmt]", process.env.PORTAL_RUNNER_USERNAME); - await page.click("input[type=submit]"); - await page.waitFor(3000); - await page.waitFor("input[name=loginfmt]"); - await page.type("input[name=passwd]", process.env.PORTAL_RUNNER_PASSWORD); - await page.click("input[type=submit]"); - await page.waitFor(3000); - await page.waitForNavigation(); - await page.goto( - `https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/${process.env.PORTAL_RUNNER_SUBSCRIPTION}/resourceGroups/${process.env.PORTAL_RUNNER_RESOURCE_GROUP}/providers/Microsoft.DocumentDb/databaseAccounts/${process.env.PORTAL_RUNNER_DATABASE_ACCOUNT}/dataExplorer` - ); - // Wait for page to settle - await page.waitFor(10000); - // Find Data Explorer iFrame - const frames = page.frames(); - const dataExplorer = frames.find(frame => frame.url().includes("cosmos.azure.com")); - // Click "New Container" - const newContainerButton = await dataExplorer.$('button[data-test="New Container"]'); - await newContainerButton.click(); - // Wait for side pane to appear - await dataExplorer.waitFor(".contextual-pane-in"); - // Fill out New Container form - const databaseIdInput = await dataExplorer.$("#databaseId"); - await databaseIdInput.type("foo"); - const collectionIdInput = await dataExplorer.$("#containerId"); - await collectionIdInput.type("foo"); - const partitionKeyInput = await dataExplorer.$('input[data-test="addCollection-partitionKeyValue"]'); - await partitionKeyInput.type("/partitionKey"); - trackEvent({ name: "ProductionRunnerSuccess" }); + try { + // Login to Azure Portal + await page.goto("https://portal.azure.com"); + await page.waitFor("input[name=loginfmt]"); + await page.type("input[name=loginfmt]", process.env.PORTAL_RUNNER_USERNAME); + await page.click("input[type=submit]"); + await page.waitFor(3000); + await page.waitFor("input[name=loginfmt]"); + await page.type("input[name=passwd]", process.env.PORTAL_RUNNER_PASSWORD); + await page.click("input[type=submit]"); + await page.waitFor(3000); + await page.waitForNavigation(); + await page.goto( + `https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/${process.env.PORTAL_RUNNER_SUBSCRIPTION}/resourceGroups/${process.env.PORTAL_RUNNER_RESOURCE_GROUP}/providers/Microsoft.DocumentDb/databaseAccounts/${process.env.PORTAL_RUNNER_DATABASE_ACCOUNT}/dataExplorer` + ); + // Wait for page to settle + await page.waitFor(10000); + // Find Data Explorer iFrame + const frames = page.frames(); + const dataExplorer = frames.find(frame => frame.url().includes("cosmos.azure.com")); + // Click "New Container" + const newContainerButton = await dataExplorer.$('button[data-test="New Container"]'); + await newContainerButton.click(); + // Wait for side pane to appear + await dataExplorer.waitFor(".contextual-pane-in"); + // Fill out New Container form + const databaseIdInput = await dataExplorer.$("#databaseId"); + await databaseIdInput.type("foo"); + const collectionIdInput = await dataExplorer.$("#containerId"); + await collectionIdInput.type("foo"); + const partitionKeyInput = await dataExplorer.$('input[data-test="addCollection-partitionKeyValue"]'); + await partitionKeyInput.type("/partitionKey"); + trackEvent({ name: "ProductionRunnerSuccess" }); - // TODO: Submit form and assert results - // cy.wrap($body) - // .find("#submitBtnAddCollection") - // .click(); - // cy.wait(10000); - // cy.wrap($body) - // .find('div[data-test="resourceTreeId"]') - // .should("exist") - // .find('div[class="treeComponent dataResourceTree"]') - // .should("contain", dbId); + // TODO: Submit form and assert results + // cy.wrap($body) + // .find("#submitBtnAddCollection") + // .click(); + // cy.wait(10000); + // cy.wrap($body) + // .find('div[data-test="resourceTreeId"]') + // .should("exist") + // .find('div[class="treeComponent dataResourceTree"]') + // .should("contain", dbId); + } catch (error) { + trackException(error); + throw error; + } }); }); diff --git a/test/utils.js b/test/utils.js index d35674f5d..acd8571af 100644 --- a/test/utils.js +++ b/test/utils.js @@ -13,3 +13,9 @@ module.exports.trackEvent = (...args) => { client.trackEvent(...args); } }; + +module.exports.trackException = exception => { + if (client) { + client.trackException({ exception }); + } +};