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

test(api): add force interrupting flag to perfomance test tool #484

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions tests/performance/shatal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ count: 100
# The flag to show debug level logs.
# Corresponds to the DEBUG environment variable.
debug: true
# The flag to enable force interrupting mode
eofff marked this conversation as resolved.
Show resolved Hide resolved
forceInterruption: false
drainer:
# The flag to enable node draining.
# Corresponds to the DRAINER_ENABLED environment variable.
Expand Down
1 change: 1 addition & 0 deletions tests/performance/shatal/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace: "default"
interval: "5s"
count: 100
debug: true
forceInterruption: false
drainer:
enabled: true
interval: "10s"
Expand Down
23 changes: 12 additions & 11 deletions tests/performance/shatal/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ import (
)

type Config struct {
Kubeconfig string `yaml:"kubeconfigBase64" env:"KUBECONFIG_BASE64" env-required:""`
ResourcesPrefix string `yaml:"resourcesPrefix" env:"RESOURCES_PREFIX" env-default:"performance"`
Namespace string `yaml:"namespace" env:"NAMESPACE" env-default:"default"`
Interval time.Duration `yaml:"interval" env:"INTERVAL" env-default:"5s"`
Count int `yaml:"count" env:"COUNT"`
Debug bool `yaml:"debug" env:"DEBUG" env-default:"false"`
Drainer DrainerFeature `yaml:"drainer"`
Creator CreatorFeature `yaml:"creator"`
Deleter DeleterFeature `yaml:"deleter"`
Modifier ModifierFeature `yaml:"modifier"`
Nothing NothingFeature `yaml:"nothing"`
Kubeconfig string `yaml:"kubeconfigBase64" env:"KUBECONFIG_BASE64" env-required:""`
ResourcesPrefix string `yaml:"resourcesPrefix" env:"RESOURCES_PREFIX" env-default:"performance"`
Namespace string `yaml:"namespace" env:"NAMESPACE" env-default:"default"`
Interval time.Duration `yaml:"interval" env:"INTERVAL" env-default:"5s"`
Count int `yaml:"count" env:"COUNT"`
Debug bool `yaml:"debug" env:"DEBUG" env-default:"false"`
Drainer DrainerFeature `yaml:"drainer"`
Creator CreatorFeature `yaml:"creator"`
Deleter DeleterFeature `yaml:"deleter"`
Modifier ModifierFeature `yaml:"modifier"`
Nothing NothingFeature `yaml:"nothing"`
ForceInterruption bool `yaml:"forceInterruption"`
}

type DrainerFeature struct {
Expand Down
18 changes: 14 additions & 4 deletions tests/performance/shatal/internal/shatal/shatal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package shatal
import (
"context"
"errors"
"fmt"
"log/slog"
"os"
"sync"

"github.com/deckhouse/virtualization/shatal/internal/api"
Expand All @@ -38,13 +40,16 @@ type Shatal struct {
logger *slog.Logger
exit chan struct{}
wg sync.WaitGroup

forceInterruption bool
}

func New(api *api.Client, conf config.Config, log *slog.Logger) (*Shatal, error) {
shatal := Shatal{
api: api,
logger: log,
exit: make(chan struct{}),
api: api,
logger: log,
exit: make(chan struct{}),
forceInterruption: conf.ForceInterruption,
}

nodes, err := api.GetNodes(context.Background(), conf.Drainer.LabelSelector)
Expand Down Expand Up @@ -131,7 +136,12 @@ func (s *Shatal) Run() {
select {
case <-s.exit:
s.logger.Info("Stop runners")
cancel()
if s.forceInterruption {
fmt.Println("Performing force interruption")
os.Exit(1)
} else {
cancel()
}
case <-ctx.Done():
}
}()
Expand Down
Loading