Skip to content

Commit

Permalink
move manager into thread; gaggle from controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyandrews committed Jul 17, 2022
1 parent 85d6490 commit 5a4cd10
Show file tree
Hide file tree
Showing 5 changed files with 420 additions and 66 deletions.
53 changes: 32 additions & 21 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ use crate::util;
use crate::{GooseAttack, GooseError};

/// Constant defining Goose's default port when running a Gaggle.
const DEFAULT_PORT: &str = "5115";
const DEFAULT_GAGGLE_PORT: &str = "5115";

/// Constant defining Goose's default manager_host when running a Gaggle.
const DEFAULT_GAGGLE_HOST: &str = "127.0.0.1";

/// Runtime options available when launching a Goose load test.
///
Expand Down Expand Up @@ -1846,7 +1849,30 @@ impl GooseConfiguration {
},
])
.unwrap_or(false);
}

pub(crate) fn configure_gaggle(&mut self, defaults: &GooseDefaults) {
// Re-configure `users`, in case the AttackMode was changed.
self.users = self.get_value(vec![
// Use --users if set and not on Worker.
GooseValue {
value: self.users,
filter: self.worker,
message: "--users",
},
// Otherwise use GooseDefault if set and not on Worker.
GooseValue {
value: defaults.users,
filter: defaults.users.is_none() || self.worker,
message: "default users",
},
// Otherwise use detected number of CPUs if not on Worker.
GooseValue {
value: Some(num_cpus::get()),
filter: self.worker || self.test_plan.is_some(),
message: "users defaulted to number of CPUs",
},
]);
// Configure `expect_workers`.
self.expect_workers = self.get_value(vec![
// Use --expect-workers if configured.
Expand Down Expand Up @@ -1920,9 +1946,9 @@ impl GooseConfiguration {
filter: defaults.manager_bind_port.is_none() || !self.manager,
message: "manager_bind_port",
},
// Otherwise default to DEFAULT_PORT if on Manager.
// Otherwise default to DEFAULT_GAGGLE_PORT if on Manager.
GooseValue {
value: Some(DEFAULT_PORT.to_string().parse().unwrap()),
value: Some(DEFAULT_GAGGLE_PORT.to_string().parse().unwrap()),
filter: !self.manager,
message: "manager_bind_port",
},
Expand All @@ -1946,7 +1972,7 @@ impl GooseConfiguration {
},
// Otherwise default to 127.0.0.1 if on Worker.
GooseValue {
value: Some("127.0.0.1".to_string()),
value: Some(DEFAULT_GAGGLE_HOST.to_string()),
filter: !self.worker,
message: "manager_host",
},
Expand All @@ -1968,9 +1994,9 @@ impl GooseConfiguration {
filter: defaults.manager_port.is_none() || !self.worker,
message: "manager_port",
},
// Otherwise default to DEFAULT_PORT if on Worker.
// Otherwise default to DEFAULT_GAGGLE_PORT if on Worker.
GooseValue {
value: Some(DEFAULT_PORT.to_string().parse().unwrap()),
value: Some(DEFAULT_GAGGLE_PORT.to_string().parse().unwrap()),
filter: !self.worker,
message: "manager_port",
},
Expand Down Expand Up @@ -2022,13 +2048,6 @@ impl GooseConfiguration {
detail: "`configuration.scenario_log` can not be set on the Manager."
.to_string(),
});
} else if self.no_autostart {
return Err(GooseError::InvalidOption {
option: "`configuration.no_autostart`".to_string(),
value: true.to_string(),
detail: "`configuration.no_autostart` can not be set on the Manager."
.to_string(),
});
} else if !self.report_file.is_empty() {
return Err(GooseError::InvalidOption {
option: "`configuration.report_file`".to_string(),
Expand Down Expand Up @@ -2206,14 +2225,6 @@ impl GooseConfiguration {
detail: "`configuration.no_status_codes` can not be set in Worker mode."
.to_string(),
});
// Can't set `no_autostart` on Worker.
} else if self.no_autostart {
return Err(GooseError::InvalidOption {
option: "`configuration.no_autostart`".to_string(),
value: true.to_string(),
detail: "`configuration.no_autostart` can not be set in Worker mode."
.to_string(),
});
// Can't set `no_gzip` on Worker.
} else if self.no_gzip {
return Err(GooseError::InvalidOption {
Expand Down
Loading

0 comments on commit 5a4cd10

Please sign in to comment.