Skip to content

feat: Playwright scenario + load test for SF2.0#3004

Merged
thecristen merged 8 commits intomainfrom
cbj/sf2.0/load-testing
Mar 12, 2026
Merged

feat: Playwright scenario + load test for SF2.0#3004
thecristen merged 8 commits intomainfrom
cbj/sf2.0/load-testing

Conversation

@thecristen
Copy link
Collaborator

Scope

Asana Ticket: Add basic integration test for SF2.0 and Add and run load tests for SF2.0

Implementation

We're re-using our existing test setups to add tests for our new departures!

  1. integration/scenarios/ gets a new Playwright test -- view-departures.js. This is a brief test which loads a randomly selected departure page, checking for a successful response and some expected text and links. As part of scenarios/ it'll also get run by our monitor, which runs and reports on all scenarios many times per day.
  2. load_tests/departures.yml specifies a new load test using Artillery and its Playwright engine, which lets us write the test code with Playwright. Via departures.js, it references the new scenarios/view-departures.js, expanding upon it with additional actions and checks - opening an upcoming departure, changing the selected schedule, etc. The YAML config can be changed ad-hoc to change the rate/amount of visits in the load test.
  3. integration/e2e_tests/ gets a new Playwright test -- visit-departures.spec.js. This mostly just runs the aforementioned load test code, but using the Playwright test runner.
  4. These refer to schedule_finder_visits.csv, which I extracted from a Splunk query tabulating visits to our existing Schedule Finder on Tuesday, March 3rd by distinct route, direction, and stop. I also wrote some code which parses this and can return a /departures URL, randomly generated but weighted by actual visits in the CSV.

It was a bit insane trying to get interdependent scripting bits to play nice together across the CommonJS/ES module systems (seems like either Playwright and/or Artillery each had stringent expectations). This setup was the best I could come up with which still worked without my duplicating test code between the two systems.

Screenshots

Testing looks something like that:

image image

How to test

If you haven't already, run npm install --ignore-scripts from the root folder.

These run against localhost if you don't specify a --target or HOST.

The briefer Playwright scenario:

npx playwright test all-scenarios --grep @view_departures

The more elaborate Playwright test. I attempted to make it flexible enough such that it shouldn't break on a route/direction/stop which doesn't happen to be in service at the tested moment.

npx playwright test visit-departures
HOST=dev-green.mbtace.com npx playwright test visit-departures

I recommend learning the CLI. Can run these with --ui to run the test from a fun interface, with --repeat-each=50 to run it many times, etc.

(Running the Playwright tests against another server may have varied results, since this branch has a few HTML fixes on which the test cases depend.)

The load tests

npx artillery run ./integration/load_tests/departures.yml
npx artillery run ./integration/load_tests/departures.yml --target dev-green.mbtace.com

@thecristen thecristen requested a review from a team as a code owner March 10, 2026 18:35
@thecristen thecristen requested a review from lvachon1 March 10, 2026 18:35
Copy link
Contributor

@lvachon1 lvachon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests all run and seem to work well, however I think the chooseURL function isn't randomizing it's choices

@thecristen thecristen force-pushed the cbj/sf2.0/load-testing branch from fb67bf9 to 3b9cb2d Compare March 12, 2026 17:12
@thecristen thecristen enabled auto-merge (squash) March 12, 2026 17:13
@thecristen thecristen merged commit d26b0cf into main Mar 12, 2026
17 checks passed
@thecristen thecristen deleted the cbj/sf2.0/load-testing branch March 12, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants