Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Commit

Permalink
Add progress bar to show entire testing time and current status
Browse files Browse the repository at this point in the history
  • Loading branch information
urangurang authored and alessfg committed Jun 30, 2020
1 parent 52365ef commit 3a47217
Show file tree
Hide file tree
Showing 223 changed files with 46,745 additions and 37,333 deletions.
3 changes: 3 additions & 0 deletions go.mod
Expand Up @@ -5,7 +5,10 @@ go 1.13
require (
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca // indirect
github.com/gobuffalo/packr/v2 v2.8.0
github.com/gosuri/uilive v0.0.4 // indirect
github.com/gosuri/uiprogress v0.0.1
github.com/jung-kurt/gofpdf v1.16.2
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/tsenart/vegeta/v12 v12.8.3
github.com/urfave/cli/v2 v2.2.0
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Expand Up @@ -80,6 +80,10 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY=
github.com/gosuri/uilive v0.0.4/go.mod h1:V/epo5LjjlDE5RJUcqx8dbw+zc93y5Ya3yg8tfZ74VI=
github.com/gosuri/uiprogress v0.0.1 h1:0kpv/XY/qTmFWl/SkaJykZXrBBzwwadmW8fRb7RJSxw=
github.com/gosuri/uiprogress v0.0.1/go.mod h1:C1RTYn4Sc7iEyf6j8ft5dyoZ4212h8G1ol9QQluh5+0=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
Expand Down Expand Up @@ -115,6 +119,8 @@ github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY
github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI=
github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.1.17/go.mod h1:WgzbA6oji13JREwiNsRDNfl7jYdPnmz+VEuLrA+/48M=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand Down Expand Up @@ -227,6 +233,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
22 changes: 22 additions & 0 deletions rtapi.go
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"github.com/gobuffalo/packr/v2"
"github.com/gosuri/uiprogress"
"github.com/jung-kurt/gofpdf"
"github.com/tsenart/vegeta/v12/lib"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -91,6 +92,18 @@ func main() {
} else if c.IsSet("data") {
endpointList = parseJSONString(c.String("data"))
}

// Show progress bar
var sum float64
for i := range endpointList {
duration, err := time.ParseDuration(endpointList[i].Query.Duration)
if err != nil {
log.Fatal(err)
}
sum += duration.Seconds()
}
go showProgressBar(int(sum))

// Query each endpoint specified
for i := range endpointList {
endpointList[i].metrics = queryAPI(endpointList[i])
Expand Down Expand Up @@ -382,6 +395,15 @@ func createPDF(endpoints []endpointDetails, output string) {
os.Stdout.Write([]byte("PDF report generated successfully!\n"))
}

func showProgressBar(sum int) {
os.Stdout.Write([]byte("rtapi will take " + strconv.Itoa(sum) + " seconds to run\n"))
uiprogress.Start()
progressBar := uiprogress.AddBar(sum * 10).AppendCompleted().PrependElapsed()
for progressBar.Incr() {
time.Sleep(time.Second / 10)
}
}

func createGraph(endpoints []endpointDetails) *bytes.Buffer {
// Rearrange HdrHistogram data to plottable data
var stringArray [][]string
Expand Down
28 changes: 28 additions & 0 deletions vendor/github.com/gosuri/uilive/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/gosuri/uilive/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions vendor/github.com/gosuri/uilive/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions vendor/github.com/gosuri/uilive/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/gosuri/uilive/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/gosuri/uilive/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions vendor/github.com/gosuri/uilive/terminal_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions vendor/github.com/gosuri/uilive/terminal_size_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a47217

Please sign in to comment.