From c67d021345f2a6065927490a6d3af6a093db1aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Tue, 23 Jul 2024 18:04:28 +0200 Subject: [PATCH] implement an initial artillery script --- .idea/workspace.xml | 26 +++++++++++++++++++++++++- artillery/non-reactive-stress.yml | 20 ++++++++++++++++++++ artillery/reactive-stress.yml | 20 ++++++++++++++++++++ playwright.config.ts | 3 +++ tests/non-reactive.spec.js | 6 ++++++ tests/non-reactive.spec.ts | 8 -------- tests/reactive.spec.js | 6 ++++++ tests/reactive.spec.ts | 8 -------- tests/test-helpers.js | 18 +++++++++++++++++- 9 files changed, 97 insertions(+), 18 deletions(-) create mode 100644 artillery/non-reactive-stress.yml create mode 100644 artillery/reactive-stress.yml create mode 100644 tests/non-reactive.spec.js delete mode 100644 tests/non-reactive.spec.ts create mode 100644 tests/reactive.spec.js delete mode 100644 tests/reactive.spec.ts diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0e0384f..3c48807 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,9 +1,33 @@ + + + + + + + + + + + + - + + + + \ No newline at end of file diff --git a/artillery/non-reactive-stress.yml b/artillery/non-reactive-stress.yml new file mode 100644 index 0000000..52c5053 --- /dev/null +++ b/artillery/non-reactive-stress.yml @@ -0,0 +1,20 @@ +config: + target: http://localhost:3000 + phases: + - duration: 60 + arrivalRate: 5 + rampTo: 10 + name: Warm up + ensure: + maxErrorRate: 1 + max: 500 + # Load the Playwright engine: + engines: + playwright: + launchOptions: + slowMo: 1000 + # Path to JavaScript file that defines Playwright test functions + processor: '../tests/test-helpers.js' +scenarios: + - engine: playwright + testFunction: 'nonReactiveAddAndRemoveTasks' diff --git a/artillery/reactive-stress.yml b/artillery/reactive-stress.yml new file mode 100644 index 0000000..af0e5df --- /dev/null +++ b/artillery/reactive-stress.yml @@ -0,0 +1,20 @@ +config: + target: http://localhost:3000 + phases: + - duration: 60 + arrivalRate: 5 + rampTo: 10 + name: Warm up + ensure: + maxErrorRate: 1 + max: 500 + # Load the Playwright engine: + engines: + playwright: + launchOptions: + slowMo: 100 + # Path to JavaScript file that defines Playwright test functions + processor: '../tests/test-helpers.js' +scenarios: + - engine: playwright + testFunction: 'reactiveAddAndRemoveTasks' diff --git a/playwright.config.ts b/playwright.config.ts index 82d56e9..11f9f41 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,6 +12,9 @@ import { defineConfig, devices } from '@playwright/test'; */ export default defineConfig({ timeout: 1260_000, + launchOptions: { + slowMo: 1_000, + }, testDir: './tests', /* Run tests in files in parallel */ fullyParallel: true, diff --git a/tests/non-reactive.spec.js b/tests/non-reactive.spec.js new file mode 100644 index 0000000..b7fbac0 --- /dev/null +++ b/tests/non-reactive.spec.js @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; +import { nonReactiveAddAndRemoveTasks } from './test-helpers'; + +test('non-reactive', async ({ page }) => { + await nonReactiveAddAndRemoveTasks(page); +}); diff --git a/tests/non-reactive.spec.ts b/tests/non-reactive.spec.ts deleted file mode 100644 index 740d3c1..0000000 --- a/tests/non-reactive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { test, expect } from '@playwright/test'; -import { addAndRemoveTasks } from './test-helpers'; - -const taskCount = parseFloat(process.env.TASK_COUNT || 1000); - -test('non-reactive', async ({ page }) => { - await addAndRemoveTasks({ page, reactive: false, taskCount}); -}); diff --git a/tests/reactive.spec.js b/tests/reactive.spec.js new file mode 100644 index 0000000..dea652b --- /dev/null +++ b/tests/reactive.spec.js @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; +import { reactiveAddAndRemoveTasks } from './test-helpers'; + +test('reactive', async ({ page }) => { + await reactiveAddAndRemoveTasks(page); +}); diff --git a/tests/reactive.spec.ts b/tests/reactive.spec.ts deleted file mode 100644 index 184ffd5..0000000 --- a/tests/reactive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { test, expect } from '@playwright/test'; -import { addAndRemoveTasks } from './test-helpers'; - -const taskCount = parseFloat(process.env.TASK_COUNT || 1000); - -test('reactive', async ({ page }) => { - await addAndRemoveTasks({ page, reactive: true, taskCount }); -}); diff --git a/tests/test-helpers.js b/tests/test-helpers.js index 59637b2..64837fb 100644 --- a/tests/test-helpers.js +++ b/tests/test-helpers.js @@ -1,4 +1,4 @@ -export const addAndRemoveTasks = async ({ page, reactive, taskCount }) => { +const addAndRemoveTasks = async ({ page, reactive, taskCount }) => { await page.goto('http://localhost:3000/'); await page.getByLabel(reactive ? 'Reactive' : 'No Reactive', { exact: true }).check(); @@ -24,3 +24,19 @@ export const addAndRemoveTasks = async ({ page, reactive, taskCount }) => { await page.getByRole('button', { name: 'Remove all tasks' }).click(); }; + +async function reactiveAddAndRemoveTasks(page) { + const taskCount = parseFloat(process.env.TASK_COUNT || 10); + await addAndRemoveTasks({ page, reactive: false, taskCount }); +} + +async function nonReactiveAddAndRemoveTasks(page) { + const taskCount = parseFloat(process.env.TASK_COUNT || 10); + await addAndRemoveTasks({ page, reactive: true, taskCount }); +} + +module.exports = { + reactiveAddAndRemoveTasks, + nonReactiveAddAndRemoveTasks, + addAndRemoveTasks, +}