> OctoPerf load testing - Strategy documentation page. How to configure the strategy of a User profile.

Source: https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/setup-teardown/

# Setup/Teardown

[Set Up](https://jmeter.apache.org/usermanual/component_reference.html#setUp_Thread_Group) and [Tear Down](https://jmeter.apache.org/usermanual/component_reference.html#tearDown_Thread_Group) are virtual users (or [threads](https://jmeter.apache.org/usermanual/component_reference.html#Thread_Group) in the JMeter language) that will execute before or after the main virtual user. They can be used to conduct preparation or cleaning actions that would be otherwise harder to schedule properly. 

A 10 minutes test using both would have an *Active users* curve like this:

![setup-teardown](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/setup-teardown.png "setup teardown example")

!!! warning
    As you can see **Set Up threads** add up to the overall duration of your tests. Make sure to leave room for them to execute otherwise the **Main threads** might be stopped earlier at the end of the planned duration. **Tear Down threads** on the other hand will execute at the end of the planned duration.

![Set Up](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/user-profile-set-up.png "Set Up")

Most of the settings on this screen are similar to what you can configure for the main virtual user, so we will only look at the ones specific to **Set Up/Tear Down** users. Please refer to the [load](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/user-load/) and [policies](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/policies/) pages for information on others.

!!! note
    The time spent in setup thread groups will be taken out of the total testing time, so make sure to take this into account when planning your tests. A good practice is to use the [lifetime](#virtual-user-lifetime) parameter to control how long it will last.

## Scope

You have two options for the scope:

- `Local` means every load generator during the test will execute a local **Set Up/Tear Down**
- `Global` means we will execute the **Set Up/Tear Down** on one load generator only, this is useful to conduct a unique action for the entire test.

## Number of concurrent users

Here again two options:

- `One` means only one virtual user will be run. (or one per load generator if the [scope](#scope) is `local`)
- `Same as main VU` means one **Set Up/Tear Down** per main virtual user (based on the maximum number specified in the [load section](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/user-load/)), this is useful if you need to create a unique value for each user of the main virtual user. This allows a Ramp-up period to be selected.

## Virtual user iteration behavior

- `Start from scratch` to get rid of cache and cookies every iteration,
- `Keep cache and cookies` to keep them when running several iterations. 

## Virtual user end

Choose to end after the planned `VU Duration` or after the `Max iterations` is reached

## Virtual user lifetime

This value define the minimum AND maximum duration of each **Set Up/Tear Down** user.

It is a very good tool to control how much time is allocated for those. Otherwise the main virtual user could be delayed indefinitely if one of the **Set Up/Tear Down** users times out.

For example for a **Set Up** user with a ramp up of `1 minute` and `2 minutes` of lifetime, you know the main virtual user will start after `2 + 1 = 3 minutes` have passed.  And that way **you can predict the time allocated to the main user** for this test.

A more detailed explanation is that:

- Since it is a minimum duration, each **Set Up/Tear Down** user that would finish before reaching that time will wait until `lifetime` duration has been reached,
- Since it is a maximum duration, each **Set Up/Tear Down** user that would not be done when `lifetime` duration has been reached will be forcefully shutdown.

## Think times

**Set Up/Tear Down** users keep the think times of their own Virtual User, even when the [think time of the user profile is overridden](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/policies/#think-time).

!!! warning
    A [Test Fragment](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/logic-actions/link-action/) used both by the main virtual user and by a **Set Up/Tear Down** user takes the overridden think time in both. To keep its own think times in the **Set Up/Tear Down** user, link a separate Test Fragment there.
