Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Revamp "Writing realistic tests" page #62

Merged
merged 47 commits into from
Mar 21, 2025

Conversation

alhusseinsamy
Copy link
Contributor

No description provided.

@alhusseinsamy alhusseinsamy changed the title FEAT: replace SUT in "Writing realistic Gatling tests" page FEAT: Replace SUT in "Writing realistic Gatling tests" page Feb 24, 2025
Copy link
Contributor

@stb13579 stb13579 left a comment

Choose a reason for hiding this comment

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

A few small suggestions, I realize you aren't quite finished with updating the code examples.

Questions: Is this the best format for teaching these concepts? Is it easy enough to find this tutorial if you want to learn about these topics? Possible alternatives:

  • divide up into more than 1 tutorial/guide
  • rename to make the topic(s) clearer

Just food for thought

@@ -25,9 +25,10 @@ This way, you'll be able to easily reuse some parts and build complex behaviors

In our scenario we have three separated processes:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In our scenario we have three separated processes:
In our scenario, we have four separated processes:

1. First we create a Feeder from a csv file with the following columns: *searchCriterion*, *searchComputerName*.
2. As the default Feeder strategy is *queue*, we will use the *random* strategy for this test to avoid feeder starvation.
1. First we create a Feeder from a csv file with the following columns: _searchCriterion_, _searchProductName_.
2. As the default Feeder strategy is _queue_, we will use the _random_ strategy for this test to avoid feeder starvation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
2. As the default Feeder strategy is _queue_, we will use the _random_ strategy for this test to avoid feeder starvation.
2. As the default Feeder strategy is `queue`, we will use the `random` strategy for this test to avoid feeder starvation.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, I think using the code ticks is more consistent with the rest of the docs. I didn't try to fix this everywhere.

@alhusseinsamy alhusseinsamy force-pushed the feat/change-sut-realistic-tests branch from e8c3989 to 1b3e7e8 Compare March 4, 2025 13:50
Copy link
Member

@karimatwa karimatwa left a comment

Choose a reason for hiding this comment

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

  • Extra Indentations need to be rechecked and removed if needed.
  • Parent classes need to be removed from snippets in order to reduce noise and align all code snippets.
  • Missing reference links from Kotlin snippets.

@alhusseinsamy alhusseinsamy requested a review from karimatwa March 14, 2025 17:02
Comment on lines 164 to 195
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
static final ScenarioBuilder scn1 = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
static final ScenarioBuilder scn1 = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed();
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
static final ScenarioBuilder scn1 = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed();

Comment on lines 199 to 226
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
static final ScenarioBuilder scn2 = scenario("Scenario 2")
.exitBlockOnFail()
.on(
uniformRandomSwitch()
.on(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
static final ScenarioBuilder scn2 = scenario("Scenario 2")
.exitBlockOnFail()
.on(
uniformRandomSwitch()
.on(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed();
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
static final ScenarioBuilder scn2 = scenario("Scenario 2")
.exitBlockOnFail()
.on(
uniformRandomSwitch()
.on(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed();

Comment on lines 164 to 195
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
static final ScenarioBuilder scn1 = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
static final ScenarioBuilder scn1 = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed();
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
static final ScenarioBuilder scn1 = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed();

Comment on lines 136 to 167
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
val scn1: ScenarioBuilder = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70.0)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30.0)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
val scn1: ScenarioBuilder = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70.0)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30.0)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed()
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
val scn1: ScenarioBuilder = scenario("Scenario 1")
.exitBlockOnFail()
.on(
randomSwitch()
.on(
percent(70.0)
.then(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)),
percent(30.0)
.then(
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy))))
.exitHereIfFailed()

Comment on lines 171 to 198
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
val scn2: ScenarioBuilder = scenario("Scenario 2")
.exitBlockOnFail()
.on(
uniformRandomSwitch()
.on(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
val scn2: ScenarioBuilder = scenario("Scenario 2")
.exitBlockOnFail()
.on(
uniformRandomSwitch()
.on(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed()
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
val scn2: ScenarioBuilder = scenario("Scenario 2")
.exitBlockOnFail()
.on(
uniformRandomSwitch()
.on(
group("fr")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")
.on(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed()

Comment on lines 149 to 172
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
private val scn1: ScenarioBuilder = scenario("Scenario 1")
.exitBlockOnFail(
randomSwitch(
70.0 -> group("fr")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
30.0 -> group("us")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
private val scn1: ScenarioBuilder = scenario("Scenario 1")
.exitBlockOnFail(
randomSwitch(
70.0 -> group("fr")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
30.0 -> group("us")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed
// Define scenario 1 with a random traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#randomswitch
private val scn1: ScenarioBuilder = scenario("Scenario 1")
.exitBlockOnFail(
randomSwitch(
70.0 -> group("fr")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
30.0 -> group("us")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed

Comment on lines 176 to 199
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
private val scn2: ScenarioBuilder = scenario("Scenario 2")
.exitBlockOnFail(
uniformRandomSwitch(
group("fr")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
private val scn2: ScenarioBuilder = scenario("Scenario 2")
.exitBlockOnFail(
uniformRandomSwitch(
group("fr")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed
// Define scenario 2 with a uniform traffic distribution
// Reference: https://docs.gatling.io/reference/script/core/scenario/#uniformrandomswitch
private val scn2: ScenarioBuilder = scenario("Scenario 2")
.exitBlockOnFail(
uniformRandomSwitch(
group("fr")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy),
group("us")(
homeAnonymous,
pause(5, 15),
authenticate,
homeAuthenticated,
pause(5, 15),
addToCart,
pause(5, 15),
buy)))
.exitHereIfFailed

Copy link
Member

@slandelle slandelle left a comment

Choose a reason for hiding this comment

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

Wouldn't it better to have the page url match its content and title? Doesn't it have an impact on SEO?
Should we keep "advanced" or rename the folder and files? cc @stb13579

@stb13579
Copy link
Contributor

Wouldn't it better to have the page url match its content and title? Doesn't it have an impact on SEO? Should we keep "advanced" or rename the folder and files? cc @stb13579
⚠️ @alhusseinsamy : I just pushed a commit to rename and add the redirects

@alhusseinsamy alhusseinsamy requested a review from slandelle March 21, 2025 08:59
Copy link
Contributor

@stb13579 stb13579 left a comment

Choose a reason for hiding this comment

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

lgtm

@alhusseinsamy alhusseinsamy merged commit fb5bcb8 into main Mar 21, 2025
1 check passed
@alhusseinsamy alhusseinsamy deleted the feat/change-sut-realistic-tests branch March 21, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

4 participants