Skip to content

Commit

Permalink
Merge pull request #1150 from k1LoW/fix-loadt
Browse files Browse the repository at this point in the history
Fix loadt stucked
  • Loading branch information
k1LoW authored Jan 11, 2025
2 parents 1c4bb3c + 697ab13 commit 7782232
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ test-integration: cert
chmod 600 testdata/sshd/id_rsa
go test ./... -tags=integration -count=1

test-all: cert
test-all: cert test-loadt
chmod 600 testdata/sshd/id_rsa
go test ./... -tags=integration -coverprofile=coverage.out -covermode=count

benchmark: cert
go test -bench . -benchmem -run Benchmark | octocov-go-test-bench --tee > custom_metrics_benchmark.json

test-loadt:
go run ./cmd/runn/main.go loadt testdata/book/always_success.yml --duration 1s --warm-up 0s

lint:
golangci-lint run ./...
govulncheck ./...
Expand Down
27 changes: 19 additions & 8 deletions cmd/loadt.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/k1LoW/donegroup"
"github.com/k1LoW/duration"
"github.com/k1LoW/runn"
"github.com/mattn/go-isatty"
"github.com/ryo-yamaoka/otchkiss"
"github.com/ryo-yamaoka/otchkiss/setting"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -90,15 +91,25 @@ var loadtCmd = &cobra.Command{
if err != nil {
return err
}
p := tea.NewProgram(newSpinnerModel())
go func() {
_, _ = p.Run()
}()
if err := ot.Start(ctx); err != nil {
return err

if isatty.IsTerminal(os.Stdout.Fd()) {
// With tty
p := tea.NewProgram(newSpinnerModel(), tea.WithContext(ctx))
go func() {
if _, errr := p.Run(); errr != nil {
err = errr
}
}()
if err := ot.Start(ctx); err != nil {
return err
}
p.Quit()
p.Wait()
} else {
if err := ot.Start(ctx); err != nil {
return err
}
}
p.Quit()
p.Wait()

lr, err := runn.NewLoadtResult(len(selected), w, d, flgs.LoadTConcurrent, flgs.LoadTMaxRPS, ot.Result)
if err != nil {
Expand Down

0 comments on commit 7782232

Please sign in to comment.