diff --git a/api/nighthawk.go b/apinighthawk/nighthawk.go similarity index 83% rename from api/nighthawk.go rename to apinighthawk/nighthawk.go index 75cbad3e..428528db 100644 --- a/api/nighthawk.go +++ b/apinighthawk/nighthawk.go @@ -1,5 +1,5 @@ -// Package api defines nighthawk runner and config -package api +// Package apinighthawk defines nighthawk runner and config +package apinighthawk import ( "fmt" @@ -14,8 +14,8 @@ import ( // NighthawkConfig describes the configuration structure for loadtest type NighthawkConfig struct { Thread int - DurationInSeconds int - QPS int + DurationInSeconds float64 + QPS float64 URL string } @@ -37,8 +37,8 @@ func NighthawkRun(config *NighthawkConfig) ([]byte, error) { return nil, err } - duration := strconv.Itoa(config.DurationInSeconds) - qps := strconv.Itoa(config.QPS) + duration := strconv.FormatFloat(config.DurationInSeconds, 'f', -1, 64) + qps := strconv.FormatFloat(config.QPS, 'f', -1, 64) c := strconv.Itoa(config.Thread) args := []string{"--rps " + qps, "--concurrency " + c, "--duration " + duration, rURL.String(), "--output-format json"} diff --git a/cmd/main.go b/cmd/main.go index d5baa418..2ad4475a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/layer5io/nighthawk-go/api" + "github.com/layer5io/nighthawk-go/apinighthawk" "github.com/pkg/errors" log "github.com/sirupsen/logrus" ) @@ -21,14 +21,14 @@ func init() { } func main() { // Duration in seconds nighthawk default format - testConfig := &api.NighthawkConfig{ + testConfig := &apinighthawk.NighthawkConfig{ Thread: 1, DurationInSeconds: 5, QPS: 1, URL: "https://www.github.com", } - result, err := api.NighthawkRun(testConfig) + result, err := apinighthawk.NighthawkRun(testConfig) if err != nil { msg := "Failed to run load-test"