Skip to content

Commit

Permalink
implement an initial artillery script
Browse files Browse the repository at this point in the history
  • Loading branch information
nachocodoner committed Jul 23, 2024
1 parent bd1ecc0 commit c67d021
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 18 deletions.
26 changes: 25 additions & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions artillery/non-reactive-stress.yml
Original file line number Diff line number Diff line change
@@ -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'
20 changes: 20 additions & 0 deletions artillery/reactive-stress.yml
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 3 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/non-reactive.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test, expect } from '@playwright/test';
import { nonReactiveAddAndRemoveTasks } from './test-helpers';

test('non-reactive', async ({ page }) => {
await nonReactiveAddAndRemoveTasks(page);
});
8 changes: 0 additions & 8 deletions tests/non-reactive.spec.ts

This file was deleted.

6 changes: 6 additions & 0 deletions tests/reactive.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test, expect } from '@playwright/test';
import { reactiveAddAndRemoveTasks } from './test-helpers';

test('reactive', async ({ page }) => {
await reactiveAddAndRemoveTasks(page);
});
8 changes: 0 additions & 8 deletions tests/reactive.spec.ts

This file was deleted.

18 changes: 17 additions & 1 deletion tests/test-helpers.js
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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,
}

0 comments on commit c67d021

Please sign in to comment.