Skip to content

Commit

Permalink
Add '--duration' flag, determines duration of the test in seconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesovsky committed Jul 8, 2020
1 parent e601390 commit b042f8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/app.go
Expand Up @@ -13,13 +13,15 @@ import (
"github.com/lesovsky/noisia/waitxacts"
"github.com/rs/zerolog"
"sync"
"time"
)

type config struct {
logger zerolog.Logger
doCleanup bool
postgresConninfo string
jobs uint16 // max 65535
duration int
idleXacts bool
idleXactsNaptimeMin int
idleXactsNaptimeMax int
Expand All @@ -41,12 +43,15 @@ type config struct {
}

func runApplication(ctx context.Context, c *config, log zerolog.Logger) error {

if c.doCleanup {
log.Info().Msg("do cleanup")
return noisia.Cleanup(ctx, c.postgresConninfo)
}

timeout := time.Duration(c.duration) * time.Second
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

var wg sync.WaitGroup

if c.idleXacts {
Expand Down
2 changes: 2 additions & 0 deletions cmd/main.go
Expand Up @@ -21,6 +21,7 @@ func main() {
doCleanup = kingpin.Flag("cleanup", "do cleanup of workloads related tables from database").Default("false").Envar("NOISIA_CLEANUP").Bool()
postgresConninfo = kingpin.Flag("conninfo", "Postgres connection string (DSN or URL), must be specified explicitly").Default("").Envar("NOISIA_POSTGRES_CONNINFO").String()
jobs = kingpin.Flag("jobs", "Run workload with specified number of workers").Default("1").Envar("NOISIA_JOBS").Uint16()
duration = kingpin.Flag("duration", "Duration of tests in seconds").Default("10").Envar("NOISIA_DURATION").Int()
idleXacts = kingpin.Flag("idle-xacts", "Run idle transactions workload").Default("false").Envar("NOISIA_IDLE_XACTS").Bool()
idleXactsNaptimeMin = kingpin.Flag("idle-xacts.naptime-min", "Min transactions naptime, in seconds").Default("5").Envar("NOISIA_IDLE_XACTS_NAPTIME_MIN").Int()
idleXactsNaptimeMax = kingpin.Flag("idle-xacts.naptime-max", "Max transactions naptime, in seconds").Default("20").Envar("NOISIA_IDLE_XACTS_NAPTIME_MAX").Int()
Expand Down Expand Up @@ -54,6 +55,7 @@ func main() {
doCleanup: *doCleanup,
postgresConninfo: *postgresConninfo,
jobs: *jobs,
duration: *duration,
idleXacts: *idleXacts,
idleXactsNaptimeMin: *idleXactsNaptimeMin,
idleXactsNaptimeMax: *idleXactsNaptimeMax,
Expand Down

0 comments on commit b042f8e

Please sign in to comment.