Skip to content

Commit

Permalink
benchmark-worker: made benchmarker-path changeable.
Browse files Browse the repository at this point in the history
  • Loading branch information
cubicdaiya committed Aug 31, 2019
1 parent 7dfe2ac commit ad844f7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmd/bench-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ type JobResultStdout struct {
}

const (
apiEndpointDev = "http://portal-dev.isucon9.hinatan.net"
defaultInterval = 3 * time.Second
maxStderrLength = 8 * 1024 * 1024
maxNumMessage = 20
maxBenchmarkTime = 150 * time.Second
apiEndpointDev = "http://portal-dev.isucon9.hinatan.net"
defaultInterval = 3 * time.Second
maxStderrLength = 8 * 1024 * 1024
maxNumMessage = 20
maxBenchmarkTime = 150 * time.Second
defaultBenchmarkerPath = "/home/isucon/isucari/bin/benchmarker"
)

var (
Expand Down Expand Up @@ -164,7 +165,7 @@ func getExternalServiceSuffix() (string, error) {
return strings.TrimPrefix(hostname, "bench"), nil
}

func runBenchmarker(job *Job) (*JobResult, error) {
func runBenchmarker(benchmarkerPath string, job *Job) (*JobResult, error) {
target, err := findBenchmarkTargetServer(job)
if err != nil {
return &JobResult{}, err
Expand All @@ -183,7 +184,7 @@ func runBenchmarker(job *Job) (*JobResult, error) {
defer cancel()
cmd := exec.CommandContext(
ctx,
"/home/isucon/isucari/bin/benchmarker",
benchmarkerPath,
fmt.Sprintf("-payment-url=https://%s", fmt.Sprintf("payment%s.isucon9q.catatsuy.org", suffix)),
fmt.Sprintf("-shipment-url=https://%s", fmt.Sprintf("shipment%s.isucon9q.catatsuy.org", suffix)),
fmt.Sprintf("-target-url=https://%s", target.GlobalIP),
Expand Down Expand Up @@ -215,6 +216,7 @@ func main() {

apiEndpoint := flag.String("ep", apiEndpointDev, "API Endpoint")
interval := flag.Duration("interval", defaultInterval, "Dequeuing interval second")
benchmarkerPath := flag.String("benchmarker", defaultBenchmarkerPath, "Benchmarker path")
flag.Parse()

ticker := time.NewTicker(*interval)
Expand All @@ -225,7 +227,7 @@ func main() {
continue
}

jobResult, err := runBenchmarker(job)
jobResult, err := runBenchmarker(*benchmarkerPath, job)
if err != nil {
log.Println(err)
}
Expand Down

0 comments on commit ad844f7

Please sign in to comment.