Skip to content

Commit

Permalink
feat: target acceptation for load testing
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu <[email protected]>
  • Loading branch information
mtlmatt committed Jul 17, 2024
1 parent edf3fc2 commit e0a4258
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 57 deletions.
5 changes: 4 additions & 1 deletion le-taxi-api-tests/config/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export class Configs {
runWithTaxiExpiration: this.cache.get<number>(
"loadTesting.snapshots.runWithTaxiExpiration"
),
numberOfOperators: this.cache.get<number>(
"loadTesting.snapshots.numberOfOperators"
),
},
};
}
Expand Down Expand Up @@ -152,7 +155,7 @@ export let configs: Configs = Configs.instance;

export function getAbsoluteUrl(relative: string): string {
if (configs.environment.isDev) {
return `https://taximtldev.accept.ville.montreal.qc.ca${relative}`;
return `https://taximtl.accept.ville.montreal.qc.ca${relative}`;
}

// Default value in LOCAL
Expand Down
1 change: 1 addition & 0 deletions le-taxi-api-tests/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ caching:
loadTesting:
snapshots:
runWithTaxiExpiration: false
numberOfOperators: 50

#==========================================
# Routing Service OSRM
Expand Down
5 changes: 2 additions & 3 deletions le-taxi-api-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
"all-tests-localhost": "tsc && env NODE_ENV=localhost npm run launch-all-tests",
"all-tests-dev": "tsc && env NODE_ENV=development npm run launch-all-tests",
"launch-all-tests": "mocha \"src/all.apiTestSuite.js\" --require source-map-support/register --reporter \"src/shared/specWithCompleteErrorsReporter/specWithCompleteErrors.js\" --no-timeouts --exit",
"load-test-position-snapshots-generate-shared-state": "tsc && node -r source-map-support/register src/taxiPositionSnapShots/loadTests/generateTaxis.sharedState.js",
"load-test-position-snapshots": "tsc && node node_modules/artillery/bin/artillery run -o test-position-snapshots.report.json src/taxiPositionSnapShots/loadTests/test-position-snapshots-with-50-operators-200-taxis.yaml && node node_modules/artillery/bin/artillery report -o test-position-snapshots.report.html test-position-snapshots.report.json",
"load-test-generate-shared-state": "env NODE_ENV=development npm run launch-load-test-generate-shared-state",
"load-test-realtime-booking": "tsc && node node_modules/artillery/bin/artillery run -o test-realtime-booking.report.json src/taxis/loadTests/test-realtime-booking.yaml && node node_modules/artillery/bin/artillery report -o test-realtime-booking.report.html test-realtime-booking.report.json",
"load-test-optional-realtime-booking-no-destination": "tsc && node node_modules/artillery/bin/artillery run -o test-optional-realtime-booking-no-destination.report.json src/taxis/loadTests/test-realtime-booking-no-destination.yaml && node node_modules/artillery/bin/artillery report -o test-optional-realtime-booking-no-destination.report.html test-optional-realtime-booking-no-destination.report.json",
"load-test-optional-trigger-many-bad-requests-alert": "tsc && node node_modules/artillery/bin/artillery run src/taxis/loadTests/test-trigger-many-bad-requests-alert.yaml",
"load-test-optional-trigger-many-errors-alert": "tsc && node node_modules/artillery/bin/artillery run src/taxis/loadTests/test-trigger-many-errors-alert.yaml",
"load-test-taxi-position-snapshot-data-dump": "tsc && node node_modules/artillery/bin/artillery run -o test-taxi-position-snapshot-data-dump.report.json src/taxiPositionSnapshotDataDumps/loadTests/test-taxi-position-snapshot-data-dump.yaml && node node_modules/artillery/bin/artillery report -o test-taxi-position-snapshot-data-dump.report.html test-taxi-position-snapshot-data-dump.report.json",
"load-test-taxi-grid": "tsc && node node_modules/artillery/bin/artillery run -o test-taxi-grid.report.json src/taxis/loadTests/test-taxi-grid.yaml && node node_modules/artillery/bin/artillery report -o test-taxi-grid.report.html test-taxi-grid.report.json",
"generate-load-test-shared-state": "env NODE_ENV=development npm run launch-generate-load-test-shared-state",
"generate-integration-tests-shared-state": "env NODE_ENV=development npm run launch-generate-integration-tests-shared-state",
"clean": "rimraf src/**/*.js src/**/*.js.map",
"watch": "npm run clean && tsc --watch --pretty",
Expand All @@ -28,7 +27,7 @@
"tsc": "tsc",
"osrm-random-montreal-car-route-5rps": "tsc && node node_modules/artillery/bin/artillery run -o osrm-random-montreal-car-route-5rps.report.json src/osrm/osrm-random-montreal-car-route-5rps.yaml && node node_modules/artillery/bin/artillery report -o osrm-random-montreal-car-route-5rps.report.html osrm-random-montreal-car-route-5rps.report.json",
"osrm-random-montreal-car-route-20rps": "tsc && node node_modules/artillery/bin/artillery run -o osrm-random-montreal-car-route-20rps.report.json src/osrm/osrm-random-montreal-car-route-20rps.yaml && node node_modules/artillery/bin/artillery report -o osrm-random-montreal-car-route-20rps.report.html osrm-random-montreal-car-route-20rps.report.json",
"launch-load-test-generate-shared-state": "tsc && node -r source-map-support/register src/taxis/loadTests/generateMotor.sharedState.js",
"launch-generate-load-test-shared-state": "tsc && node -r source-map-support/register src/taxis/loadTests/generateMotor.sharedState.js && node -r source-map-support/register src/taxiPositionSnapShots/loadTests/generateTaxis.sharedState.js",
"launch-generate-integration-tests-shared-state": "tsc && node -r source-map-support/register src/apiIntegrationTests/generateApiIntegration.sharedState.js",
"launch-load-tests": "node node_modules/artillery/bin/artillery run -o load-tests-results.json artillery.yaml"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { generatePointsForLoadTest } from "../../shared/commonLoadTests/specialR
import { getCurrentUnixTime } from "../../shared/commonTests/testUtil";
import { copyTaxiPositionSnapShotItemTemplate } from "../taxiPositionSnapShotsDto.template";

const numberOfOperatorsForTesting = 20;

// tslint:disable-next-line: no-console
console.log(
"WARNING: ALL LOAD TESTS MUST BE EXECUTED WITH A SINGLE REPLICA PER DEPLOYMENT!"
Expand Down Expand Up @@ -45,7 +43,10 @@ export function beforeRequestForTests(
ee: any,
next: any
) {
const sliced = sharedStateForTests.slice(0, numberOfOperatorsForTesting);
const sliced = sharedStateForTests.slice(
0,
configs.loadTesting.snapshots.numberOfOperators
);
return beforeRequest(sliced, requestParams, context, ee, next);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
config:
target: 'https://taximtldev.accept.ville.montreal.qc.ca'
processor: './generateSnapshotsFor50Operators.js'
target: "https://taximtl.accept.ville.montreal.qc.ca"
processor: "./generateSnapshotsFor50Operators.js"
http:
pool: 20
timeout: 5
phases:
- name: '3 000 POST taxi-position-snapshots - 50 operators x 200 taxis'
- name: "3 000 POST taxi-position-snapshots - 50 operators x 200 taxis"
# Each virtual user per second will send 1 snapshot / 200 positions.
# Using 10 virtual users per second will have a total of 10 snapshots / 2,000 positions sent every second.
# Therefore, we'll be sending a total of 3000 snapshots / 600,000 positions in 5 minutes.
Expand All @@ -14,19 +14,19 @@ config:
before:
flow:
- loop:
- post:
url: '/api/taxi-position-snapshots'
beforeRequest: 'beforeRequestForInitialization'
json: '{{snapshots}}'
headers:
X-API-KEY: '{{operatorApikey}}'
- post:
url: "/api/taxi-position-snapshots"
beforeRequest: "beforeRequestForInitialization"
json: "{{snapshots}}"
headers:
X-API-KEY: "{{operatorApikey}}"
count: 50
scenarios:
- name: 'sending snapshots'
- name: "sending snapshots"
flow:
- post:
url: '/api/taxi-position-snapshots'
beforeRequest: 'beforeRequestForTests'
json: '{{snapshots}}'
url: "/api/taxi-position-snapshots"
beforeRequest: "beforeRequestForTests"
json: "{{snapshots}}"
headers:
X-API-KEY: '{{operatorApikey}}'
X-API-KEY: "{{operatorApikey}}"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config:
target: "https://taximtldev.accept.ville.montreal.qc.ca"
target: "https://taximtl.accept.ville.montreal.qc.ca"
processor: "./test-taxi-position-snapshot-data-dump.js"
http:
pool: 30
Expand All @@ -18,7 +18,7 @@ scenarios:
# npm run load-test-position-snapshots-with-25-operators-200-taxis
# at an hour that fits in a 10 minutes windows. Ex: xx:00, xx:10, xx:20, xx:30, xx:40, xx:50,
# and ajusting the snapshot id (date each 10 minutes) in the url below
url: "/api/data-dumps/taxi-positions/2023-11-13T19:50:00.000Z"
url: "/api/data-dumps/taxi-positions/2024-06-21T17:00:00.000Z"
headers:
Accept-Encoding: "gzip"
X-API-KEY: "{{apikey}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config:
target: "https://taximtldev.accept.ville.montreal.qc.ca"
target: "https://taximtl.accept.ville.montreal.qc.ca"
processor: "./generateQueryParams.js"
http:
pool: 20
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
config:
target: "https://taximtldev.accept.ville.montreal.qc.ca"
target: "https://taximtl.accept.ville.montreal.qc.ca"
processor: "./generateQueryParams.js"
http:
pool: 30
pool: 100
timeout: 35
phases:
- name: "1 800 inquiries"
arrivalRate: 30
arrivalRate: 100
duration: 300
scenarios:
- name: "GOFS realtime_booking"
Expand Down
14 changes: 7 additions & 7 deletions le-taxi-api-tests/src/taxis/loadTests/test-taxi-grid.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
config:
target: 'https://taximtldev.accept.ville.montreal.qc.ca'
processor: './test-taxi-grid.js'
target: "https://taximtl.accept.ville.montreal.qc.ca"
processor: "./test-taxi-grid.js"
http:
pool: 30
phases:
- name: '300 GET taxis/grid - used by UI'
- name: "300 GET taxis/grid - used by UI"
arrivalRate: 1
duration: 300
scenarios:
- name: 'taxi grid'
- name: "taxi grid"
flow:
- function: 'beforeFlow'
- function: "beforeFlow"
- get:
url: '/api/legacy-web/taxis/grid?page=0&pagesize=10'
url: "/api/legacy-web/taxis/grid?page=0&pagesize=10"
headers:
X-API-KEY: '{{apikey}}'
X-API-KEY: "{{apikey}}"
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
config:
target: 'https://taximtldev.accept.ville.montreal.qc.ca'
processor: './generatePayload.js'
target: "https://taximtl.accept.ville.montreal.qc.ca"
processor: "./generatePayload.js"
http:
pool: 20
timeout: 5
phases:
- name: 'trigger many bad requests (4xx)'
- name: "trigger many bad requests (4xx)"
arrivalRate: 50
duration: 300
before:
flow:
- log: 'WARNING: to trigger alerts you need to make sure they are available on DEV. Check kubernetes-installed-apps repository first.'
- log: "WARNING: to trigger alerts you need to make sure they are available on DEV. Check kubernetes-installed-apps repository first."
scenarios:
- name: 'error 400'
- name: "error 400"
flow:
- get:
url: '/api/fakes/fake-error-400'
url: "/api/fakes/fake-error-400"
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
config:
target: 'https://taximtldev.accept.ville.montreal.qc.ca'
processor: './generatePayload.js'
target: "https://taximtl.accept.ville.montreal.qc.ca"
processor: "./generatePayload.js"
http:
pool: 20
timeout: 5
phases:
- name: 'trigger many errors (5xx)'
- name: "trigger many errors (5xx)"
arrivalRate: 50
duration: 300
before:
flow:
- log: 'WARNING: to trigger alerts you need to make sure they are available on DEV. Check kubernetes-installed-apps repository first.'
- log: "WARNING: to trigger alerts you need to make sure they are available on DEV. Check kubernetes-installed-apps repository first."
scenarios:
- name: 'error 500'
- name: "error 500"
flow:
- get:
url: '/api/fakes/fake-error-500'
url: "/api/fakes/fake-error-500"
51 changes: 40 additions & 11 deletions le-taxi-api-tests/src/teardown.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
truncate table driver, public."ADS", vehicle, vehicle_description, taxi

delete from roles_users
where user_id in (
select id
from public.user
where email like 'zApiTest%'
)
);

delete from customer
where added_by in (
select id
from public.user
where email like 'zApiTest%'
)

);

-- truncate if you don't want to keep existing data otherwise use the deletes
-- truncate table driver, public."ADS", vehicle, vehicle_description, taxi

-- start of deletes
delete
from public."taxi" t
using public.user u
where u.id = t.added_by
and u.email like 'zApiTest%';

delete
from public."vehicle_description" vd
using public.user u
where u.id = vd.added_by
and u.email like 'zApiTest%';

delete
from public."vehicle" v
using public.user u
where u.id = v.added_by_user
and u.email like 'zApiTest%';

delete
from public."driver" d
using public.user u
where u.id = d.added_by
and u.email like 'zApiTest%';

delete
from public."ADS" ads
using public.user u
where u.id = ads.added_by
and u.email like 'zApiTest%';
-- end of deletes

-- then delete the tests users
delete from public.user
where email like 'zApiTest%'





where email like 'zApiTest%';

0 comments on commit e0a4258

Please sign in to comment.