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

#400: Make sure that graphs are built if the load test is interrupted during startup. #406

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## 0.15.3-dev
- [#406](https://github.com/tag1consulting/goose/pull/406) make sure that the graphs are built correctly if the load test is interrupted during the starting phase

## 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
64 changes: 63 additions & 1 deletion src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3327,7 +3327,9 @@ impl GooseAttack {
data.iter()
.enumerate()
.filter(|(second, _)| {
if self.configuration.no_reset_metrics {
// If --no-reset-metrics is used or if the load test was stopped during the
// starting phase we display the data also for the staring phase.
if self.configuration.no_reset_metrics || self.metrics.started.is_none() {
true
} else {
*second as i64 + starting.timestamp() >= started.timestamp()
Expand Down Expand Up @@ -3966,4 +3968,64 @@ mod test {
);
}
}

#[test]
fn test_add_timestamp_to_html_graph_data() {
use gumdrop::Options;

let initial_config: Vec<&str> = Vec::new();
let mut attack = GooseAttack::initialize_with_config(
GooseConfiguration::parse_args_default(&initial_config).unwrap(),
)
.unwrap();
let data = vec![123, 234, 345, 456, 567];

attack.metrics.started = Some(Local.ymd(2021, 12, 14).and_hms(15, 12, 25));
attack.configuration.no_reset_metrics = false;
assert_eq!(
attack.add_timestamp_to_html_graph_data(
data.clone(),
&Local.ymd(2021, 12, 14).and_hms(15, 12, 23),
&Local.ymd(2021, 12, 14).and_hms(15, 12, 25),
),
vec![
("2021-12-14 15:12:25".to_string(), 345),
("2021-12-14 15:12:26".to_string(), 456),
("2021-12-14 15:12:27".to_string(), 567)
]
);

attack.configuration.no_reset_metrics = true;
assert_eq!(
attack.add_timestamp_to_html_graph_data(
data.clone(),
&Local.ymd(2021, 12, 14).and_hms(15, 12, 23),
&Local.ymd(2021, 12, 14).and_hms(15, 12, 25),
),
vec![
("2021-12-14 15:12:23".to_string(), 123),
("2021-12-14 15:12:24".to_string(), 234),
("2021-12-14 15:12:25".to_string(), 345),
("2021-12-14 15:12:26".to_string(), 456),
("2021-12-14 15:12:27".to_string(), 567)
]
);

attack.metrics.started = None;
attack.configuration.no_reset_metrics = false;
assert_eq!(
attack.add_timestamp_to_html_graph_data(
data,
&Local.ymd(2021, 12, 14).and_hms(15, 12, 23),
&Local.ymd(2021, 12, 14).and_hms(15, 12, 25),
),
vec![
("2021-12-14 15:12:23".to_string(), 123),
("2021-12-14 15:12:24".to_string(), 234),
("2021-12-14 15:12:25".to_string(), 345),
("2021-12-14 15:12:26".to_string(), 456),
("2021-12-14 15:12:27".to_string(), 567)
]
);
}
}