Skip to content

Commit

Permalink
Merge pull request #12 from kushthedude/api
Browse files Browse the repository at this point in the history
feat: Restructure nighthawk api to resolve conflict with wrk2
  • Loading branch information
kushthedude authored Aug 25, 2020
2 parents 59ae7e1 + 0b81094 commit 7839288
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions api/nighthawk.go → apinighthawk/nighthawk.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package api defines nighthawk runner and config
package api
// Package apinighthawk defines nighthawk runner and config
package apinighthawk

import (
"fmt"
Expand All @@ -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
}

Expand All @@ -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"}
Expand Down
6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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"
Expand Down

0 comments on commit 7839288

Please sign in to comment.