mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add cleanup strategy to loadtest (#4991)
This commit is contained in:
+3
-2
@@ -135,8 +135,9 @@ func loadtest() *cobra.Command {
|
||||
client.PropagateTracing = tracePropagate
|
||||
|
||||
// Prepare the test.
|
||||
strategy := config.Strategy.ExecutionStrategy()
|
||||
th := harness.NewTestHarness(strategy)
|
||||
runStrategy := config.Strategy.ExecutionStrategy()
|
||||
cleanupStrategy := config.CleanupStrategy.ExecutionStrategy()
|
||||
th := harness.NewTestHarness(runStrategy, cleanupStrategy)
|
||||
|
||||
for i, t := range config.Tests {
|
||||
name := fmt.Sprintf("%s-%d", t.Type, i)
|
||||
|
||||
@@ -38,6 +38,9 @@ func TestLoadTest(t *testing.T) {
|
||||
Strategy: cli.LoadTestStrategy{
|
||||
Type: cli.LoadTestStrategyTypeLinear,
|
||||
},
|
||||
CleanupStrategy: cli.LoadTestStrategy{
|
||||
Type: cli.LoadTestStrategyTypeLinear,
|
||||
},
|
||||
Tests: []cli.LoadTest{
|
||||
{
|
||||
Type: cli.LoadTestTypePlacebo,
|
||||
@@ -89,6 +92,10 @@ func TestLoadTest(t *testing.T) {
|
||||
Type: cli.LoadTestStrategyTypeConcurrent,
|
||||
ConcurrencyLimit: 2,
|
||||
},
|
||||
CleanupStrategy: cli.LoadTestStrategy{
|
||||
Type: cli.LoadTestStrategyTypeConcurrent,
|
||||
ConcurrencyLimit: 2,
|
||||
},
|
||||
Tests: []cli.LoadTest{
|
||||
{
|
||||
Type: cli.LoadTestTypeWorkspaceBuild,
|
||||
@@ -210,6 +217,9 @@ func TestLoadTest(t *testing.T) {
|
||||
Strategy: cli.LoadTestStrategy{
|
||||
Type: cli.LoadTestStrategyTypeLinear,
|
||||
},
|
||||
CleanupStrategy: cli.LoadTestStrategy{
|
||||
Type: cli.LoadTestStrategyTypeLinear,
|
||||
},
|
||||
Tests: []cli.LoadTest{
|
||||
{
|
||||
Type: cli.LoadTestTypePlacebo,
|
||||
|
||||
@@ -15,8 +15,9 @@ import (
|
||||
|
||||
// LoadTestConfig is the overall configuration for a call to `coder loadtest`.
|
||||
type LoadTestConfig struct {
|
||||
Strategy LoadTestStrategy `json:"strategy"`
|
||||
Tests []LoadTest `json:"tests"`
|
||||
Strategy LoadTestStrategy `json:"strategy"`
|
||||
CleanupStrategy LoadTestStrategy `json:"cleanup_strategy"`
|
||||
Tests []LoadTest `json:"tests"`
|
||||
// Timeout sets a timeout for the entire test run, to control the timeout
|
||||
// for each individual run use strategy.timeout.
|
||||
Timeout httpapi.Duration `json:"timeout"`
|
||||
@@ -134,6 +135,10 @@ func (c *LoadTestConfig) Validate() error {
|
||||
if err != nil {
|
||||
return xerrors.Errorf("validate strategy: %w", err)
|
||||
}
|
||||
err = c.CleanupStrategy.Validate()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("validate cleanup_strategy: %w", err)
|
||||
}
|
||||
|
||||
for i, test := range c.Tests {
|
||||
err := test.Validate()
|
||||
|
||||
Reference in New Issue
Block a user