Skip to content

Commit

Permalink
More WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyeats committed Oct 20, 2023
1 parent ba6e3a6 commit d3afe00
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 50 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Install Mage
uses: magefile/mage-action@v3
with:
install-only: true

- name: Install yarn dependencies
run: yarn install
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Build
run: go build -v ./...
- name: Build binaries
run: mage -v

- name: Build Frontend
- name: Build frontend
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Start Grafana
run: docker run --rm -d -p 3000:3000 --name=grafana --env GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-azure-data-explorer-datasource --volume "$PWD:/var/lib/grafana/plugins" grafana/grafana
run: docker run --rm -d -p 3000:3000 --name=grafana --env GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-azure-data-explorer-datasource --volume "$PWD/dist:/var/lib/grafana/plugins/grafana-azure-data-explorer-datasource" grafana/grafana; sleep 30

- name: Run E2E tests
run: yarn run e2e
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/k6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Use Node.js
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Install Mage
uses: magefile/mage-action@v3
with:
install-only: true

- name: Install yarn dependencies
run: yarn install
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Build
run: go build -v ./...
- name: Build binaries
run: mage -v

- name: Build Frontend
- name: Build frontend
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Install Mage
uses: magefile/mage-action@v3
with:
install-only: true

- name: Install yarn dependencies
run: yarn install
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Build
run: go build -v ./...
- name: Build binaries
run: mage -v

- name: Build Frontend
- name: Build frontend
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'
Expand All @@ -46,3 +51,10 @@ jobs:
name: playwright-report
path: playwright-report/
retention-days: 30

- uses: actions/upload-artifact@v3
if: always()
with:
name: screenshots
path: screenshots/
retention-days: 1
15 changes: 8 additions & 7 deletions cspell.config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"ignorePaths": [
".github/**",
"node_modules/**",
"dist/**",
"cypress/**",
"provisioning/**",
"src/dashboards/**",
"yarn.lock",
"dist/**",
"e2e/**",
"go.sum",
"mage_output_file.go",
"src/libs/**",
"node_modules/**",
"pkg/azuredx/models/testdata/**",
"pkg/azuredx/testdata/**",
"pkg/azuredx/models/testdata/**"
"provisioning/**",
"src/dashboards/**",
"src/libs/**",
"yarn.lock"
],
"words": [
"adxauth",
Expand Down
28 changes: 15 additions & 13 deletions e2e/k6/k6.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export async function login(page) {
}
}

/**
* @param {import('k6/experimental').Page} page
*/
export async function addDatasource(page) {
try {
await page.goto(`http://localhost:3000${selectors.pages.AddDataSource.url}`, {
Expand All @@ -77,24 +80,26 @@ export async function addDatasource(page) {

// name datasource
const dsName = page.locator(`input[aria-label="${selectors.pages.DataSource.name}"]`);
dsName.fill('');
dsName.type(`${DATASOURCE_NAME}`);

// fill in form inputs
await page.locator(`input[id="adx-cluster-url"]`).fill(__ENV.E2E_ADX_CLUSTER_URL);
await page.locator(`input[id="aad-tenant-id"]`).fill(__ENV.E2E_ADX_TENANT_ID);
await page.locator(`input[id="aad-client-id"]`).fill(__ENV.E2E_ADX_CLIENT_ID);
await page.locator(`input[id="aad-client-secret"]`).fill(__ENV.E2E_ADX_CLIENT_SECRET);
await page.locator(`input[id="adx-cluster-url"]`).type(__ENV.E2E_ADX_CLUSTER_URL);
await page.locator(`input[id="aad-tenant-id"]`).type(__ENV.E2E_ADX_TENANT_ID);
await page.locator(`input[id="aad-client-id"]`).type(__ENV.E2E_ADX_CLIENT_ID);
await page.locator(`input[id="aad-client-secret"]`).type(__ENV.E2E_ADX_CLIENT_SECRET);

// save and test
const saveBtn = page.locator(`button[data-testid="data-testid ${selectors.pages.DataSource.saveAndTest}"]`);
await saveBtn.click();

sleep(4);

const text = await page.locator('[aria-label="Data source settings page Alert"]').textContent();

console.log(1111111, text)

// checks the page for the data source is working message
check(page, {
'add datasource successful':
(await page.locator('div[data-testid="data-testid Alert success"]').textContent()) === 'Success',
});
check(page, { 'add datasource successful': text.includes('Success') === true });
} catch (e) {
fail(`add datasource failed: ${e}`);
}
Expand All @@ -114,7 +119,6 @@ export async function addDashboard(page) {

// name dashboard
const dashboardTitleInput = page.locator(`input[aria-label="${selectors.pages.SaveDashboardAsModal.newName}"]`);
dashboardTitleInput.fill('');
dashboardTitleInput.type(DASHBOARD_TITLE);

// save dashboard
Expand Down Expand Up @@ -150,11 +154,9 @@ export async function configurePanel(page) {
database.type('PerfTest');
page.keyboard.down('Enter');

sleep(1);

// select table
const table = page.locator(`[aria-label="Table"]`);
await table.click();
await table.click({ force: true });
table.type('PerfTest');
page.keyboard.down('Enter');

Expand Down
28 changes: 16 additions & 12 deletions e2e/playwright/playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ async function addDatasource(page: Page) {
const saveBtn = page.locator(`button[data-testid="data-testid ${selectors.pages.DataSource.saveAndTest}"]`);
await saveBtn.click();

await page.screenshot({ path: `screenshots/${DATASOURCE_NAME}.png` });

// checks the page for the data source is working message
await expect(page.locator(`[aria-label="Data source settings page Alert"]`)).toContainText(
'Success'
);
await expect(page.locator(`[aria-label="Data source settings page Alert"]`)).toContainText('Success');
}

async function addDashboard(page: Page) {
Expand Down Expand Up @@ -105,39 +105,43 @@ async function configurePanel(page: Page) {
await addPanelButton.click();

// select data source for panel
const dsPanel = page.locator('input[placeholder="Select data source"]')
const dsPanel = page.locator('input[placeholder="Search data source"]');
await dsPanel.fill(`${DATASOURCE_NAME}`);
await page.keyboard.down('Tab');
await page.keyboard.down('Enter');

// select database
const database = page.locator(`[aria-label="Database"]`);
await database.click();
await database.click({ force: true });
await database.fill('PerfTest');
await page.keyboard.down('Enter');

// select table
const table = page.locator(`[aria-label="Table"]`);
await table.click();
await table.click({ force: true });
await table.fill('PerfTest');
await page.keyboard.down('Enter');

// run query
const runQueryBtn = page.locator(`[data-testid="data-testid run-query"]`);
await runQueryBtn.click();
await runQueryBtn.click({ force: true });

// are there results?
const columns = page.locator(`[aria-label="Columns"]`);
await columns.click();
await columns.click({ force: true });

await page.waitForTimeout(6000);

const html = await page.locator('[aria-label="Select options menu"]').innerHTML();
await expect(html).toContain('_val1_');

// save panel
const savePanelBtn = page.locator(`button[title="Apply changes and save dashboard"]`);
await savePanelBtn.click();
await savePanelBtn.click({ force: true });

await page.screenshot({ path: `screenshots/${DASHBOARD_TITLE}.png` });

// save dashboard
const saveDashButton = page.locator('button[aria-label="Save dashboard button"]');
await saveDashButton.click();
await saveDashButton.click({ force: true });
}

export async function removeDashboard(page: Page) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@types/glob": "^8.0.0",
"@types/grafana": "github:CorpGlory/types-grafana.git",
"@types/jest": "^29.5.0",
"@types/k6": "^0.47.1",
"@types/lodash": "^4.14.194",
"@types/node": "^18.15.11",
"@types/prismjs": "1.26.1",
Expand Down
36 changes: 29 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4109,6 +4109,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==

"@types/k6@^0.47.1":
version "0.47.1"
resolved "https://registry.yarnpkg.com/@types/k6/-/k6-0.47.1.tgz#01e355d9f28f3be247c27c010cd71c5794f7f8f5"
integrity sha512-dQCSM3WT4f5MWCyyxmY/fO+BSYS217nvlvOhDvqg4lZGfzbAuS6pOG+UuwoH+3mLTChccEds+0Q0q7YWBbtgMQ==

"@types/lodash.memoize@^4.1.7":
version "4.1.7"
resolved "https://registry.yarnpkg.com/@types/lodash.memoize/-/lodash.memoize-4.1.7.tgz#aff94ab32813c557cbc1104e127030e3d60a3b27"
Expand Down Expand Up @@ -5657,11 +5662,6 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

crypt@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==

crypto-random-string@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-4.0.0.tgz#5a3cc53d7dd86183df5da0312816ceeeb5bb1fc2"
Expand Down Expand Up @@ -7473,7 +7473,7 @@ form-data@~2.3.2:
combined-stream "^1.0.6"
mime-types "^2.1.12"

fs-extra@^10.0.0, fs-extra@^10.1.0:
fs-extra@^10.0.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"
integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==
Expand Down Expand Up @@ -7502,11 +7502,16 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@2.3.2, fsevents@^2.3.2, fsevents@~2.3.2:
fsevents@2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
Expand Down Expand Up @@ -7714,6 +7719,16 @@ glob@^7.1.3, glob@^7.1.4:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^9.2.0:
version "9.3.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-9.3.5.tgz#ca2ed8ca452781a3009685607fdf025a899dfe21"
integrity sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==
dependencies:
fs.realpath "^1.0.0"
minimatch "^8.0.2"
minipass "^4.2.4"
path-scurry "^1.6.1"

global-dirs@^3.0.0, global-dirs@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-3.0.1.tgz#0c488971f066baceda21447aecb1a8b911d22485"
Expand Down Expand Up @@ -9504,6 +9519,13 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

minimatch@^8.0.2:
version "8.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-8.0.4.tgz#847c1b25c014d4e9a7f68aaf63dedd668a626229"
integrity sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==
dependencies:
brace-expansion "^2.0.1"

minimatch@^9.0.1:
version "9.0.3"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825"
Expand Down

0 comments on commit d3afe00

Please sign in to comment.