Struct goose::GooseAttack [−][src]
pub struct GooseAttack { /* fields omitted */ }
Expand description
Global internal state for the load test.
Implementations
impl GooseAttack
[src]
impl GooseAttack
[src]Goose’s internal global state.
pub fn initialize() -> Result<GooseAttack, GooseError>
[src]
pub fn initialize() -> Result<GooseAttack, GooseError>
[src]Load configuration and initialize a GooseAttack
.
Example
use goose::prelude::*; let mut goose_attack = GooseAttack::initialize();
pub fn initialize_with_config(
configuration: GooseConfiguration
) -> Result<GooseAttack, GooseError>
[src]
pub fn initialize_with_config(
configuration: GooseConfiguration
) -> Result<GooseAttack, GooseError>
[src]Initialize a GooseAttack
with an already loaded
configuration. This should only be called by Worker instances.
Example
use goose::{GooseAttack, GooseConfiguration}; use gumdrop::Options; let configuration = GooseConfiguration::parse_args_default_or_exit(); let mut goose_attack = GooseAttack::initialize_with_config(configuration);
pub fn initialize_logger(&self)
[src]
pub fn initialize_logger(&self)
[src]Optionally initialize the logger which writes to standard out and/or to a configurable log file.
This method is invoked by
GooseAttack.execute()
.
pub fn set_scheduler(self, scheduler: GooseScheduler) -> Self
[src]
pub fn set_scheduler(self, scheduler: GooseScheduler) -> Self
[src]Define the order GooseTaskSet
s are
allocated to new GooseUser
s as they are
launched.
By default, GooseTaskSet
s are allocated
to new GooseUser
s in a round robin style.
For example, if TaskSet A has a weight of 5, TaskSet B has a weight of 3, and
you launch 20 users, they will be launched in the following order:
A, B, A, B, A, B, A, A, A, B, A, B, A, B, A, A, A, B, A, B
Note that the following pattern is repeated: A, B, A, B, A, B, A, A
If reconfigured to schedule serially, then they will instead be allocated in the following order: A, A, A, A, A, B, B, B, A, A, A, A, A, B, B, B, A, A, A, A
In the serial case, the following pattern is repeated: A, A, A, A, A, B, B, B
In the following example, GooseTaskSet
s
are allocated to launching GooseUser
s in a
random order. This means running the test multiple times can generate
different amounts of load, as depending on your weighting rules you may
have a different number of GooseUser
s
running each GooseTaskSet
each time.
Example
use goose::prelude::*; fn main() -> Result<(), GooseError> { GooseAttack::initialize()? .set_scheduler(GooseScheduler::Random) .register_taskset(taskset!("A Tasks") .set_weight(5)? .register_task(task!(a_task_1)) ) .register_taskset(taskset!("B Tasks") .set_weight(3)? .register_task(task!(b_task_1)) ); Ok(()) } async fn a_task_1(user: &GooseUser) -> GooseTaskResult { let _goose = user.get("/foo").await?; Ok(()) } async fn b_task_1(user: &GooseUser) -> GooseTaskResult { let _goose = user.get("/bar").await?; Ok(()) }
pub fn register_taskset(self, taskset: GooseTaskSet) -> Self
[src]
pub fn register_taskset(self, taskset: GooseTaskSet) -> Self
[src]A load test must contain one or more GooseTaskSet
s
be registered into Goose’s global state with this method for it to run.
Example
use goose::prelude::*; fn main() -> Result<(), GooseError> { GooseAttack::initialize()? .register_taskset(taskset!("ExampleTasks") .register_task(task!(example_task)) ) .register_taskset(taskset!("OtherTasks") .register_task(task!(other_task)) ); Ok(()) } async fn example_task(user: &GooseUser) -> GooseTaskResult { let _goose = user.get("/foo").await?; Ok(()) } async fn other_task(user: &GooseUser) -> GooseTaskResult { let _goose = user.get("/bar").await?; Ok(()) }
pub fn test_start(self, task: GooseTask) -> Self
[src]
pub fn test_start(self, task: GooseTask) -> Self
[src]Optionally define a task to run before users are started and all task sets start running. This is would generally be used to set up anything required for the load test.
The GooseUser
used to run the test_start
tasks is not preserved and does not otherwise affect the subsequent
GooseUser
s that run the rest of the load
test. For example, if the GooseUser
logs in during test_start
, subsequent GooseUser
do not retain this session and are therefor not already logged in.
When running in a distributed Gaggle, this task is only run one time by the Manager.
Example
use goose::prelude::*; fn main() -> Result<(), GooseError> { GooseAttack::initialize()? .test_start(task!(setup)); Ok(()) } async fn setup(user: &GooseUser) -> GooseTaskResult { // do stuff to set up load test ... Ok(()) }
pub fn test_stop(self, task: GooseTask) -> Self
[src]
pub fn test_stop(self, task: GooseTask) -> Self
[src]Optionally define a task to run after all users have finished running all defined task sets. This would generally be used to clean up anything that was specifically set up for the load test.
When running in a distributed Gaggle, this task is only run one time by the Manager.
Example
use goose::prelude::*; fn main() -> Result<(), GooseError> { GooseAttack::initialize()? .test_stop(task!(teardown)); Ok(()) } async fn teardown(user: &GooseUser) -> GooseTaskResult { // do stuff to tear down the load test ... Ok(()) }
pub fn execute(self) -> Result<GooseMetrics, GooseError>
[src]
pub fn execute(self) -> Result<GooseMetrics, GooseError>
[src]Execute the GooseAttack
load test.
Example
use goose::prelude::*; fn main() -> Result<(), GooseError> { let _goose_metrics = GooseAttack::initialize()? .register_taskset(taskset!("ExampleTasks") .register_task(task!(example_task).set_weight(2)?) .register_task(task!(another_example_task).set_weight(3)?) // Goose must run against a host, point to localhost so test starts. .set_host("http://localhost") ) // Exit after one second so test doesn't run forever. .set_default(GooseDefault::RunTime, 1)? .execute()?; Ok(()) } async fn example_task(user: &GooseUser) -> GooseTaskResult { let _goose = user.get("/foo").await?; Ok(()) } async fn another_example_task(user: &GooseUser) -> GooseTaskResult { let _goose = user.get("/bar").await?; Ok(()) }
pub fn record_error(&mut self, raw_request: &GooseRawRequest)
[src]
pub fn record_error(&mut self, raw_request: &GooseRawRequest)
[src]Update error metrics.
Trait Implementations
impl Clone for GooseAttack
[src]
impl Clone for GooseAttack
[src]fn clone(&self) -> GooseAttack
[src]
fn clone(&self) -> GooseAttack
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl GooseDefaultType<&'_ str> for GooseAttack
[src]
impl GooseDefaultType<&'_ str> for GooseAttack
[src]fn set_default(
self,
key: GooseDefault,
value: &str
) -> Result<Box<Self>, GooseError>
[src]
self,
key: GooseDefault,
value: &str
) -> Result<Box<Self>, GooseError>
impl GooseDefaultType<bool> for GooseAttack
[src]
impl GooseDefaultType<bool> for GooseAttack
[src]fn set_default(
self,
key: GooseDefault,
value: bool
) -> Result<Box<Self>, GooseError>
[src]
self,
key: GooseDefault,
value: bool
) -> Result<Box<Self>, GooseError>
impl GooseDefaultType<usize> for GooseAttack
[src]
impl GooseDefaultType<usize> for GooseAttack
[src]fn set_default(
self,
key: GooseDefault,
value: usize
) -> Result<Box<Self>, GooseError>
[src]
self,
key: GooseDefault,
value: usize
) -> Result<Box<Self>, GooseError>
Auto Trait Implementations
impl !RefUnwindSafe for GooseAttack
impl Send for GooseAttack
impl Sync for GooseAttack
impl Unpin for GooseAttack
impl !UnwindSafe for GooseAttack
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,