Skip to content

Commit

Permalink
Merge pull request #450 from jeremyandrews/decrease
Browse files Browse the repository at this point in the history
Support multiple and variable speed Decrease attack phases
  • Loading branch information
slashrsm authored Apr 27, 2022
2 parents cd07bd0 + 4ad8588 commit 909696f
Show file tree
Hide file tree
Showing 13 changed files with 437 additions and 266 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
o don't allow `--test-plan` together with `--users`, `--startup-time`, `--hatch-rate`, `--run-time`, `--no-reset-metrics`, `--manager` and `--worker`
o internal `AttackPhase`s renamed: `Starting` -> `Increase`, `Running` -> `Maintain`, `Stopping` -> `Decrease`
- [#449](https://github.com/tag1consulting/goose/pull/449) **API change**: rename `GooseTaskSet` -> `Scenario`, `GooseTask` -> `Transaction`, `GooseTaskResult` -> `TransationResult`, `GooseTaskEror` -> `TransactionError`, `WeightedGooseTasks` -> `WeightedTransactions`, `GooseTaskFunction` -> `TransactionFunction`, `test_start_task` -> `test_start_transaction`, `test_stop_task` -> `test_stop_transaction`, `register_task` -> `register_transaction`, `task!` -> `transaction!`, `--no-task-metrics` -> `--no-transaction-metrics`, `GooseTaskError` -> `TransactionError`
- [#450](https://github.com/tag1consulting/goose/pull/450) add support for variable speed and multiple decrease AttackPhases

## 0.15.2 December 13, 2021
- [#391](https://github.com/tag1consulting/goose/pull/391) properly sleep for configured `set_wait_time()` walking regularly to exit quickly if the load test ends
Expand Down
10 changes: 7 additions & 3 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ impl GooseAttack {
{
self.metrics.history.push(TestPlanHistory::step(
TestPlanStepAction::Decreasing,
self.metrics.users,
goose_attack_run_state.active_users,
));
self.set_attack_phase(
goose_attack_run_state,
Expand All @@ -1215,11 +1215,15 @@ impl GooseAttack {
// If load test is Idle, there are no metrics to display.
if self.attack_phase == AttackPhase::Idle {
self.metrics.display_metrics = false;
self.set_attack_phase(
goose_attack_run_state,
AttackPhase::Decrease,
);
} else {
self.cancel_attack(goose_attack_run_state).await?;
}
// Shutdown after stopping.
goose_attack_run_state.shutdown_after_stop = true;
// Properly stop any running GooseAttack first.
self.set_attack_phase(goose_attack_run_state, AttackPhase::Decrease);
// Confirm shut down to Controller.
self.reply_to_controller(
message,
Expand Down
4 changes: 2 additions & 2 deletions src/goose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2494,10 +2494,10 @@ impl<'a> GooseRequestBuilder<'a> {
/// ```rust
/// use goose::prelude::*;
///
/// let mut a_task = transaction!(task_function);
/// let mut a_transaction = transaction!(transaction_function);
///
/// // Make a named request.
/// async fn task_function(user: &mut GooseUser) -> TransactionResult {
/// async fn transaction_function(user: &mut GooseUser) -> TransactionResult {
/// // Manually create a GooseRequestBuilder object.
/// let goose_request = GooseRequest::builder()
/// // Set a relative path to request.
Expand Down
40 changes: 37 additions & 3 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl<'a, T: Clone + TimeSeriesValue<T, U>, U: Serialize + Copy + PartialEq + Par
));
}
// For decreasing show the new number of users from the current number of users.
TestPlanStepAction::Decreasing => {
TestPlanStepAction::Decreasing | TestPlanStepAction::Canceling => {
steps.push_str(&format!(
r#"[
{{
Expand Down Expand Up @@ -1659,6 +1659,32 @@ mod test {
xAxis: '{decreasing}',
itemStyle: {{ color: 'rgba(179, 65, 65, 0.05)' }},
}},
{{
xAxis: '{cancelling}'
}}
],
[
{{
xAxis: '{cancelling}',
itemStyle: {{ borderColor: 'rgba(179, 65, 65, 0.25)', borderWidth: 1 }},
}},
{{
xAxis: '{cancelling}'
}}
],[
{{
xAxis: '{cancelling}',
itemStyle: {{ borderColor: 'rgba(179, 65, 65, 0.25)', borderWidth: 1 }},
}},
{{
xAxis: '{cancelling}'
}}
],
[
{{
xAxis: '{cancelling}',
itemStyle: {{ color: 'rgba(179, 65, 65, 0.05)' }},
}},
{{
xAxis: '{finishing}'
}}
Expand Down Expand Up @@ -1690,9 +1716,12 @@ mod test {
decreasing = Local
.timestamp(Utc.ymd(2021, 11, 21).and_hms(21, 20, 33).timestamp(), 0)
.format("%Y-%m-%d %H:%M:%S"),
finishing = Local
cancelling = Local
.timestamp(Utc.ymd(2021, 11, 21).and_hms(21, 20, 34).timestamp(), 0)
.format("%Y-%m-%d %H:%M:%S"),
finishing = Local
.timestamp(Utc.ymd(2021, 11, 21).and_hms(21, 20, 35).timestamp(), 0)
.format("%Y-%m-%d %H:%M:%S"),
).as_str();

let steps = vec![
Expand All @@ -1707,10 +1736,15 @@ mod test {
users: 123,
},
TestPlanHistory {
action: TestPlanStepAction::Finished,
action: TestPlanStepAction::Canceling,
timestamp: Utc.ymd(2021, 11, 21).and_hms(21, 20, 34),
users: 123,
},
TestPlanHistory {
action: TestPlanStepAction::Finished,
timestamp: Utc.ymd(2021, 11, 21).and_hms(21, 20, 35),
users: 123,
},
];

assert_eq!(
Expand Down
Loading

0 comments on commit 909696f

Please sign in to comment.