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

feat: Initiate Nighthawk performance test #1

Merged
merged 9 commits into from
Jul 26, 2020
Merged
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: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Dependency directories (remove the comment below to include it)
# vendor/

# Ignore OS-X Trash
*.DS_Store
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
setup:
docker pull envoyproxy/nighthawk-dev; cd cmd; go mod tidy;
run:
go run cmd/main.go
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# NightHawk-go for Meshery
# Nighthawk-go for Meshery

Nighthawk adapter to run load-test with Meshery.


<div>&nbsp;</div>
Expand Down
46 changes: 46 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"fmt"
"os"
"os/exec"
"strconv"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)

func init() {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})

// Output to stdout instead of the default stderr
log.SetOutput(os.Stdout)

}

func runNighthawk(duration int, qps int, c int, url string) []byte {

out, err := exec.Command("docker", "run", "envoyproxy/nighthawk-dev:latest", "nighthawk_client", "--rps "+strconv.Itoa(qps), "--concurrency "+strconv.Itoa(c), "--duration "+strconv.Itoa(duration), url, "--output-format json").Output()
if err != nil {
log.Fatal(err)
err = errors.Wrapf(err, "unable to run nighthawk")
log.Fatal(err)
}

return out

}
func main() {

//Duration in seconds nighthawk default format
var duration int = 15
var qps int = 50
var c int = 10
var url string = "https://www.github.com"

result := runNighthawk(duration, qps, c, url)

fmt.Printf(string(result))

}
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/layer5io/nighthawk-go

go 1.14

require (
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.6.0
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
226 changes: 226 additions & 0 deletions sample_data/sample_data
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
{
"Labels": "",
"RequestedQPS": 5,
"ActualQPS": 4.9999995930000329,
"ActualDuration": 5000000407,
"NumThreads": 100,
"DurationHistogram": {
"Count": "25",
"Data": [
{
"Start": 0.024088575,
"End": 0.024088575,
"Percent": 0,
"Count": "1"
},
{
"Start": 0.024088575,
"End": 0.024779775,
"Percent": 10,
"Count": "2"
},
{
"Start": 0.024779775,
"End": 0.025127935,
"Percent": 20,
"Count": "2"
},
{
"Start": 0.025127935,
"End": 0.025554943,
"Percent": 30,
"Count": "3"
},
{
"Start": 0.025554943,
"End": 0.025939967,
"Percent": 40,
"Count": "2"
},
{
"Start": 0.025939967,
"End": 0.026267647,
"Percent": 50,
"Count": "3"
},
{
"Start": 0.026267647,
"End": 0.026441727,
"Percent": 55.000000000000007,
"Count": "1"
},
{
"Start": 0.026441727,
"End": 0.026473471,
"Percent": 60,
"Count": "1"
},
{
"Start": 0.026473471,
"End": 0.026583039,
"Percent": 65,
"Count": "2"
},
{
"Start": 0.026583039,
"End": 0.027447295,
"Percent": 70,
"Count": "1"
},
{
"Start": 0.027447295,
"End": 0.055091199,
"Percent": 75,
"Count": "1"
},
{
"Start": 0.055091199,
"End": 0.076689407,
"Percent": 77.5,
"Count": "1"
},
{
"Start": 0.076689407,
"End": 0.076689407,
"Percent": 80,
"Count": "0"
},
{
"Start": 0.076689407,
"End": 0.097136639,
"Percent": 82.5,
"Count": "1"
},
{
"Start": 0.097136639,
"End": 0.107311103,
"Percent": 85,
"Count": "1"
},
{
"Start": 0.107311103,
"End": 0.107311103,
"Percent": 87.5,
"Count": "0"
},
{
"Start": 0.107311103,
"End": 0.112869375,
"Percent": 88.75,
"Count": "1"
},
{
"Start": 0.112869375,
"End": 0.112869375,
"Percent": 90,
"Count": "0"
},
{
"Start": 0.112869375,
"End": 0.112869375,
"Percent": 91.25,
"Count": "0"
},
{
"Start": 0.112869375,
"End": 0.138584063,
"Percent": 92.5,
"Count": "1"
},
{
"Start": 0.138584063,
"End": 0.138584063,
"Percent": 93.75,
"Count": "0"
},
{
"Start": 0.138584063,
"End": 0.138584063,
"Percent": 94.375,
"Count": "0"
},
{
"Start": 0.138584063,
"End": 0.138584063,
"Percent": 95,
"Count": "0"
},
{
"Start": 0.138584063,
"End": 0.138584063,
"Percent": 95.625,
"Count": "0"
},
{
"Start": 0.138584063,
"End": 0.148004863,
"Percent": 96.25,
"Count": "1"
},
{
"Start": 0.148004863,
"End": 0.148004863,
"Percent": 100,
"Count": "0"
}
],
"Min": 0.024088575,
"Max": 0.148004863,
"Sum": 1.199209475,
"Avg": 0.047968379,
"StdDev": 0.039058392,
"Percentiles": [
{
"Percentile": 50,
"Value": 0.026267647
},
{
"Percentile": 75,
"Value": 0.055091199
},
{
"Percentile": 80,
"Value": 0.076689407
},
{
"Percentile": 90,
"Value": 0.112869375
},
{
"Percentile": 95,
"Value": 0.138584063
}
]
},
"RetCodes": {
"200": "0"
},
"URL": "https://www.github.com",
"Version": "0.3.0",
"Jitter": false,
"RunType": "HTTP",
"Sizes": {
"Count": "25",
"Data": [],
"Min": 0,
"Max": 0,
"Sum": 0,
"Avg": 0,
"StdDev": 0,
"Percentiles": []
},
"HeaderSizes": {
"Count": "25",
"Data": [],
"Min": 52,
"Max": 52,
"Sum": 1300,
"Avg": 52,
"StdDev": 0,
"Percentiles": []
},
"BytesSent": "1575",
"BytesReceived": "2100",
"StartTime": "2020-07-26T03:45:38.190799729Z",
"RequestedDuration": "5s"
}