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

Update vegeta and expose dns caching #204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion benchmarktests/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
vegeta "github.com/tsenart/vegeta/v12/lib"
)

func Attack(tm *TargetMulti, client *api.Client, duration time.Duration, rps int, workers int) (*Reporter, error) {
func Attack(tm *TargetMulti, client *api.Client, duration time.Duration, rps int, workers int, dnsCaching time.Duration) (*Reporter, error) {
rate := vegeta.Rate{Freq: rps, Per: time.Second}
opts := []func(*vegeta.Attacker){
vegeta.Workers(uint64(workers)),
vegeta.MaxWorkers(uint64(workers)),
vegeta.DNSCaching(dnsCaching),
}
if client != nil {
opts = append(opts, vegeta.Client(client.CloneConfig().HttpClient))
Expand Down
22 changes: 21 additions & 1 deletion command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (

type RunCommand struct {
*BaseCommand
flagDNSCaching time.Duration
flagDuration time.Duration
flagPPROFInterval time.Duration
flagVaultAddr string
Expand Down Expand Up @@ -223,6 +224,13 @@ func (r *RunCommand) Flags() *FlagSets {
Usage: "Force HTTP/1.1",
})

f.DurationVar(&DurationVar{
Name: "dns_caching",
Target: &r.flagDNSCaching,
Default: 0,
Usage: "DNS Cache Duration. Set to 0 for forever and -1 for disabled.",
})

// Add any additional flags from tests
for _, vbTest := range benchmarktests.TestList {
vbTest().Flags(f.mainSet)
Expand Down Expand Up @@ -277,6 +285,11 @@ func (r *RunCommand) Run(args []string) int {
}
}

parsedDnsCaching, err := time.ParseDuration(conf.DNSCaching)
if err != nil {
benchmarkLogger.Error("error parsing dns cache duration from configuration", "error", hclog.Fmt("%v", err))
}

if (!conf.RandomMounts) && (conf.Cleanup) {
benchmarkLogger.Error("cleanup can only be enabled when random mounts is enabled")
return 1
Expand Down Expand Up @@ -459,7 +472,7 @@ func (r *RunCommand) Run(args []string) int {
l.Unlock()
}

rpt, err := benchmarktests.Attack(tm, client, parsedDuration, conf.RPS, conf.Workers)
rpt, err := benchmarktests.Attack(tm, client, parsedDuration, conf.RPS, conf.Workers, parsedDnsCaching)
if err != nil {
benchmarkLogger.Error("attack error", "err", hclog.Fmt("%v", err))
os.Exit(1)
Expand Down Expand Up @@ -623,6 +636,13 @@ func (r *RunCommand) applyConfigOverrides(f *FlagSets, config *vbConfig.VaultBen
Default: false,
})
config.DisableHTTP2 = r.flagDisableHTTP2

r.setDurationFlag(f, config.DNSCaching, &DurationVar{
Name: "dns_caching",
Target: &r.flagDNSCaching,
Default: 0,
})
config.DNSCaching = r.flagDNSCaching.String()
}

func (r *RunCommand) setBoolFlag(f *FlagSets, configVal bool, fVar *BoolVar) {
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type VaultBenchmarkCoreConfig struct {
Cleanup bool `hcl:"cleanup,optional"`
Debug bool `hcl:"debug,optional"`
DisableHTTP2 bool `hcl:"disable_http2,optional"`
DNSCaching string `hcl:"dns_caching,optional"`
}

func NewVaultBenchmarkCoreConfig() *VaultBenchmarkCoreConfig {
Expand Down
39 changes: 20 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hashicorp/vault-benchmark
go 1.20

require (
cloud.google.com/go/compute/metadata v0.2.3
cloud.google.com/go/compute/metadata v0.3.0
github.com/docker/docker v24.0.9+incompatible
github.com/go-jose/go-jose/v3 v3.0.3
github.com/google/uuid v1.3.0
Expand All @@ -22,16 +22,15 @@ require (
github.com/mitchellh/cli v1.1.5
github.com/mitchellh/mapstructure v1.5.0
github.com/posener/complete v1.2.3
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/client_golang v1.19.1
github.com/sethvargo/go-password v0.2.0
github.com/tsenart/vegeta/v12 v12.8.4
golang.org/x/crypto v0.21.0
golang.org/x/oauth2 v0.10.0
github.com/tsenart/vegeta/v12 v12.12.0
golang.org/x/crypto v0.25.0
golang.org/x/oauth2 v0.21.0
google.golang.org/api v0.130.0
)

require (
cloud.google.com/go/compute v1.21.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
Expand All @@ -44,17 +43,17 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
Expand All @@ -73,36 +72,38 @@ require (
github.com/klauspost/compress v1.16.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.11.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
Loading