-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor new command and templates Signed-off-by: Daniel González Lopes <[email protected]> * Move Cloud to another command Signed-off-by: Daniel González Lopes <[email protected]> * Fix tests Signed-off-by: Daniel González Lopes <[email protected]> * Small changes to the templates Signed-off-by: Daniel González Lopes <[email protected]> * Move everything to one command based on feedback Signed-off-by: Daniel González Lopes <[email protected]> * Fix help text Signed-off-by: Daniel González Lopes <[email protected]> * Simplify cloud logic Signed-off-by: Daniel González Lopes <[email protected]> * Make linter happy Signed-off-by: Daniel González Lopes <[email protected]> * Fix package name and description Signed-off-by: Daniel González Lopes <[email protected]> * Use Authorization header instead of User-ID Signed-off-by: Daniel González Lopes <[email protected]> * Remove extra vus Signed-off-by: Daniel González Lopes <[email protected]> * Improve example text based on feedback Signed-off-by: Daniel González Lopes <[email protected]> * Add new lines in the browser template based on feedback Signed-off-by: Daniel González Lopes <[email protected]> * Add vus/iterations to the Browser example Signed-off-by: Daniel González Lopes <[email protected]> * Add catch + fail in the Browser template Signed-off-by: Daniel González Lopes <[email protected]> * Rename templates folder Signed-off-by: Daniel González Lopes <[email protected]> * Fix copy of force command Signed-off-by: Daniel González Lopes <[email protected]> * Remove the panic Signed-off-by: Daniel González Lopes <[email protected]> * Add constants for template types Signed-off-by: Daniel González Lopes <[email protected]> * Use exec.test.abort instead of throw Signed-off-by: Daniel González Lopes <[email protected]> * Make linter happy Signed-off-by: Daniel González Lopes <[email protected]> * Add package comment to templates.go --------- Signed-off-by: Daniel González Lopes <[email protected]>
- Loading branch information
Showing
6 changed files
with
294 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import http from "k6/http"; | ||
import exec from 'k6/execution'; | ||
import { browser } from "k6/browser"; | ||
import { sleep, check, fail } from 'k6'; | ||
|
||
const BASE_URL = __ENV.BASE_URL || "https://quickpizza.grafana.com"; | ||
|
||
export const options = { | ||
scenarios: { | ||
ui: { | ||
executor: "shared-iterations", | ||
vus: 1, | ||
iterations: 1, | ||
options: { | ||
browser: { | ||
type: "chromium", | ||
}, | ||
}, | ||
}, | ||
},{{ if .ProjectID }} | ||
cloud: { | ||
projectID: {{ .ProjectID }}, | ||
name: "{{ .ScriptName }}", | ||
},{{ end }} | ||
}; | ||
|
||
export function setup() { | ||
let res = http.get(BASE_URL); | ||
if (res.status !== 200) { | ||
exec.test.abort(`Got unexpected status code ${res.status} when trying to setup. Exiting.`); | ||
} | ||
} | ||
|
||
export default async function() { | ||
let checkData; | ||
const page = await browser.newPage(); | ||
|
||
try { | ||
await page.goto(BASE_URL); | ||
|
||
checkData = await page.locator("h1").textContent(); | ||
check(page, { | ||
header: checkData === "Looking to break out of your pizza routine?", | ||
}); | ||
|
||
await page.locator('//button[. = "Pizza, Please!"]').click(); | ||
await page.waitForTimeout(500); | ||
|
||
await page.screenshot({ path: "screenshot.png" }); | ||
|
||
checkData = await page.locator("div#recommendations").textContent(); | ||
check(page, { | ||
recommendation: checkData !== "", | ||
}); | ||
} catch (error) { | ||
fail(`Browser iteration failed: ${error.message}`); | ||
} finally { | ||
await page.close(); | ||
} | ||
|
||
sleep(1); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import http from 'k6/http'; | ||
import { sleep, check } from 'k6'; | ||
|
||
export const options = { | ||
vus: 10, | ||
duration: '30s',{{ if .ProjectID }} | ||
cloud: { | ||
projectID: {{ .ProjectID }}, | ||
name: "{{ .ScriptName }}", | ||
},{{ end }} | ||
}; | ||
|
||
export default function() { | ||
let res = http.get('https://quickpizza.grafana.com'); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
sleep(1); | ||
} |
Oops, something went wrong.