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

Commit 3a47217

Browse files
jinsoo.parkalessfg
authored andcommitted
Add progress bar to show entire testing time and current status
1 parent 52365ef commit 3a47217

223 files changed

Lines changed: 46745 additions & 37333 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ go 1.13
55
require (
66
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca // indirect
77
github.com/gobuffalo/packr/v2 v2.8.0
8+
github.com/gosuri/uilive v0.0.4 // indirect
9+
github.com/gosuri/uiprogress v0.0.1
810
github.com/jung-kurt/gofpdf v1.16.2
11+
github.com/mattn/go-isatty v0.0.12 // indirect
912
github.com/tsenart/vegeta/v12 v12.8.3
1013
github.com/urfave/cli/v2 v2.2.0
1114
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ
8080
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
8181
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
8282
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
83+
github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY=
84+
github.com/gosuri/uilive v0.0.4/go.mod h1:V/epo5LjjlDE5RJUcqx8dbw+zc93y5Ya3yg8tfZ74VI=
85+
github.com/gosuri/uiprogress v0.0.1 h1:0kpv/XY/qTmFWl/SkaJykZXrBBzwwadmW8fRb7RJSxw=
86+
github.com/gosuri/uiprogress v0.0.1/go.mod h1:C1RTYn4Sc7iEyf6j8ft5dyoZ4212h8G1ol9QQluh5+0=
8387
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
8488
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
8589
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
@@ -115,6 +119,8 @@ github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY
115119
github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI=
116120
github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=
117121
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
122+
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
123+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
118124
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
119125
github.com/miekg/dns v1.1.17/go.mod h1:WgzbA6oji13JREwiNsRDNfl7jYdPnmz+VEuLrA+/48M=
120126
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
@@ -227,6 +233,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
227233
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
228234
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0=
229235
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
236+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
237+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
230238
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
231239
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
232240
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=

rtapi.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"github.com/gobuffalo/packr/v2"
7+
"github.com/gosuri/uiprogress"
78
"github.com/jung-kurt/gofpdf"
89
"github.com/tsenart/vegeta/v12/lib"
910
"github.com/urfave/cli/v2"
@@ -91,6 +92,18 @@ func main() {
9192
} else if c.IsSet("data") {
9293
endpointList = parseJSONString(c.String("data"))
9394
}
95+
96+
// Show progress bar
97+
var sum float64
98+
for i := range endpointList {
99+
duration, err := time.ParseDuration(endpointList[i].Query.Duration)
100+
if err != nil {
101+
log.Fatal(err)
102+
}
103+
sum += duration.Seconds()
104+
}
105+
go showProgressBar(int(sum))
106+
94107
// Query each endpoint specified
95108
for i := range endpointList {
96109
endpointList[i].metrics = queryAPI(endpointList[i])
@@ -382,6 +395,15 @@ func createPDF(endpoints []endpointDetails, output string) {
382395
os.Stdout.Write([]byte("PDF report generated successfully!\n"))
383396
}
384397

398+
func showProgressBar(sum int) {
399+
os.Stdout.Write([]byte("rtapi will take " + strconv.Itoa(sum) + " seconds to run\n"))
400+
uiprogress.Start()
401+
progressBar := uiprogress.AddBar(sum * 10).AppendCompleted().PrependElapsed()
402+
for progressBar.Incr() {
403+
time.Sleep(time.Second / 10)
404+
}
405+
}
406+
385407
func createGraph(endpoints []endpointDetails) *bytes.Buffer {
386408
// Rearrange HdrHistogram data to plottable data
387409
var stringArray [][]string

vendor/github.com/gosuri/uilive/.travis.yml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gosuri/uilive/LICENSE

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gosuri/uilive/Makefile

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gosuri/uilive/README.md

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gosuri/uilive/doc.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gosuri/uilive/go.mod

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gosuri/uilive/terminal_size.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)