Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgriff committed Jan 31, 2025
1 parent 48222fb commit 81f5275
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 41 deletions.
3 changes: 2 additions & 1 deletion LoadTests/SET_UP_TEST_ENTITIES.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ DO $$

-- Delete users created using registration journey
DELETE FROM "UserStatus" WHERE "ByUserId" IN (SELECT "UserId" FROM "Users" WHERE "Users"."Firstname" = 'Test' AND "Users"."Lastname" = 'Example' AND "Users"."JobTitle" = 'Tester');
DELETE FROM "Users" WHERE "Users"."Firstname" = 'Test' AND "Users"."Lastname" = 'Example' AND "Users"."JobTitle" = 'Tester';

DELETE FROM "Users" WHERE "Users"."UserId" > STARTING_ID;
DELETE FROM "Organisations" WHERE "Organisations"."OrganisationId" > STARTING_ID;
Expand All @@ -32,7 +33,7 @@ DO $$
INSERT INTO "Users"
("UserId", "Firstname", "Lastname", "JobTitle", "StatusId", "StatusDate", "LoginAttempts", "LoginDate", "ResetAttempts", "VerifyAttempts", "Created", "Modified", "EmailAddress", "PasswordHash", "Salt", "HashingAlgorithm", "EmailVerifiedDate", "SendUpdates", "AllowContact")
VALUES
(STARTING_ID + INDEX, 'test', 'test', 'test', 3, '01/10/2021 12:26:44', 0, '01/10/2021 12:26:44', 0, 0, '01/10/2021 12:26:44', '01/10/2021 12:26:44', 'loadtest' || CAST(INDEX AS VARCHAR(16)) || '@example.com', 'EsbXTRJaMnDBhGEerRu1eqbMoInXkOz4P5rNZyq1VKU=','9jjDqTsUzGqk/+Rl8JeR4A==', 2, '01/10/2021 12:26:44', false, false);
(STARTING_ID + INDEX, 'test', 'test', 'test', 3, '01/10/2021 12:26:44', 0, '01/10/2021 12:26:44', 0, 0, '01/10/2021 12:26:44', '01/10/2021 12:26:44', 'loadtest' || CAST(INDEX AS VARCHAR(16)) || '@example.com', 'j2oZzqG9OQ4M8YUcv3zWFqgIO9+duNMFvMkxNCSgik0=','Xlatiovx5jcOsfU/opJxEw==', 2, '01/10/2021 12:26:44', false, false);

-- Create test organisations that are linked to test users
INSERT INTO "Organisations"
Expand Down
158 changes: 118 additions & 40 deletions load-tests/src/gender-pay-gap-service.gatling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default simulation((setUp) => {
const PAUSE_MIN_DURATION = 1; // seconds
const PAUSE_MAX_DURATION = 10; // seconds

const STARTING_ID = 3000000;

const MOST_RECENTLY_COMPLETED_REPORTING_YEAR = 2023;

const RUN_ID = 2;
Expand Down Expand Up @@ -59,6 +61,11 @@ export default simulation((setUp) => {
function alreadySetupEmailAddressFromUserId(userId: string): string {
return `loadtest${userId}@example.com`;
}
function organisationNameFromUserId(userId: string): string {
const userIdInt: int = parseInt(userId);
const organisationId = STARTING_ID + userIdInt;
return `test_${organisationId}`;
}

// const search = exec(
// http("Home").get("/"),
Expand Down Expand Up @@ -331,9 +338,9 @@ export default simulation((setUp) => {
.post("/login")
.headers(html_post_headers)
.formParam("EmailAddress", alreadySetupEmailAddressFromUserId("#{userId}"))
.formParam("Password", "Genderpaygap1")
.formParam("Password", "GenderPayGap123")
.formParam("ReturnUrl", "#{returnUrl}")
.formParam("__RequestVerificationToken", "${requestVerificationToken}")
.formParam("__RequestVerificationToken", "#{requestVerificationToken}")
.check(
status().is(200),
currentLocation().is(`${BASE_URL}/privacy-policy`),
Expand All @@ -344,55 +351,126 @@ export default simulation((setUp) => {
)
.pause(PAUSE_MIN_DURATION, PAUSE_MAX_DURATION),

acceptPrivacyPolicyPost:(): ChainBuilder =>
feed(usersFeeder)
.exec(http("Accept privacy policy")
.post("/privacy-policy")
.headers(html_post_headers)
.formParam("__RequestVerificationToken", "#{requestVerificationToken}")
.check(
status().is(200),
currentLocation().is(`${BASE_URL}/account/organisations`),
regex("Add or select an employer you're reporting for"),
css("input[name='__RequestVerificationToken']", "value").saveAs("requestVerificationToken")
)
.resources()
)
.pause(PAUSE_MIN_DURATION, PAUSE_MAX_DURATION),
}

const AddOrganisation = {
chooseEmployerTypeVisit: (): ChainBuilder =>
exec(http("Add Organisation: Choose Employer Type - visit")
.get(`/add-employer/choose-employer-type`)
.headers(html_get_headers)
.check(
status().is(200),
substring("What type of employer do you want to add?"),
)
.resources()
)
.pause(PAUSE_MIN_DURATION, PAUSE_MAX_DURATION),

chooseEmployerTypeAnswer: (): ChainBuilder =>
exec(http("Add Organisation: Choose Employer Type - answer")
.get(`/add-employer/choose-employer-type?Sector=Private&Validate=True`)
.headers(html_get_headers)
.check(
status().is(200),
currentLocation().is(`${BASE_URL}/add-employer/private/search`),
substring("Find your employer"),
)
.resources()
)
.pause(PAUSE_MIN_DURATION, PAUSE_MAX_DURATION),

searchByOrganisationName: (): ChainBuilder =>
exec(http("Add Organisation: Search for organiation by name")
.get(`/add-employer/private/search?query=${organisationNameFromUserId("#{userId}")}`)
.headers(html_get_headers)
.check(
status().is(200),
substring("Your search"),
substring("Can't find your employer?"),
)
.resources()
)
.pause(PAUSE_MIN_DURATION, PAUSE_MAX_DURATION),

manualEnterName: (): ChainBuilder =>
exec(http("Add Organisation: Manual: Employer name")
.get(`/add-employer/manual/name?Sector=Private&Query=${organisationNameFromUserId("#{userId}")}`)
.headers(html_get_headers)
.check(
status().is(200),
substring("Employer name"),
)
.resources()
)
.pause(PAUSE_MIN_DURATION, PAUSE_MAX_DURATION),

}

const userActions = exec(
// Journey: Search for an employer and view their reports
Homepage.visit(),
Homepage.suggestAutoComplete(),

SearchAndView.searchPage(),

SearchAndView.viewEmployer(),
SearchAndView.viewReportsForYear(2020),
SearchAndView.viewEmployer(),
SearchAndView.viewReportsForYear(2021),
SearchAndView.viewEmployer(),
SearchAndView.viewReportsForYear(2022),

// Journey: Compare employers
SearchAndView.searchPage(),
SearchAndView.viewEmployer(),
Compare.addToCompare(5816, 1),
SearchAndView.searchPage(),
SearchAndView.viewEmployer(),
Compare.addToCompare(491, 2),
SearchAndView.searchPage(),
SearchAndView.viewEmployer(),
Compare.addToCompare(234, 3),

Compare.comparePageDefault(),
Compare.comparePageForYear(2022),
Compare.comparePageForYear(2021),
Compare.comparePageForYear(2020),
SearchAndView.viewReportsForYear(2020),

// Journey: Create account
CreateAccount.alreadyCreatedAnAccountQuestion(),
CreateAccount.alreadyCreatedAnAccountAnswer(),
CreateAccount.createAccountGet(),
CreateAccount.createAccountPost(),
// Homepage.visit(),
// Homepage.suggestAutoComplete(),
//
// SearchAndView.searchPage(),
//
// SearchAndView.viewEmployer(),
// SearchAndView.viewReportsForYear(2020),
// SearchAndView.viewEmployer(),
// SearchAndView.viewReportsForYear(2021),
// SearchAndView.viewEmployer(),
// SearchAndView.viewReportsForYear(2022),
//
// // Journey: Compare employers
// SearchAndView.searchPage(),
// SearchAndView.viewEmployer(),
// Compare.addToCompare(5816, 1),
// SearchAndView.searchPage(),
// SearchAndView.viewEmployer(),
// Compare.addToCompare(491, 2),
// SearchAndView.searchPage(),
// SearchAndView.viewEmployer(),
// Compare.addToCompare(234, 3),
//
// Compare.comparePageDefault(),
// Compare.comparePageForYear(2022),
// Compare.comparePageForYear(2021),
// Compare.comparePageForYear(2020),
// SearchAndView.viewReportsForYear(2020),
//
// // Journey: Create account
// CreateAccount.alreadyCreatedAnAccountQuestion(),
// CreateAccount.alreadyCreatedAnAccountAnswer(),
// CreateAccount.createAccountGet(),
// CreateAccount.createAccountPost(),
//
// // Journey: Login
// Login.loginPageGet(),
// Login.loginPagePost(),
// Login.acceptPrivacyPolicyPost(),

// Journey: Login
Login.loginPageGet(),
Login.loginPagePost(),
// Journey: Add an organisation
);

const gpgScenario = scenario("Gender Pay Gap scenario").exec(userActions);

setUp(
gpgScenario.injectOpen(
rampUsers(10).during(10)
rampUsers(1).during(1)
)
).protocols(httpProtocol);
});

0 comments on commit 81f5275

Please sign in to comment.