-
Notifications
You must be signed in to change notification settings - Fork 797
/
stress.go
56 lines (44 loc) · 1.07 KB
/
stress.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package main
import (
"context"
"fmt"
"os"
"sort"
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/internal/eh/stress/tests"
)
func main() {
tests := []struct {
name string
fn func(ctx context.Context) error
}{
{name: "batch", fn: tests.BatchStressTester},
{name: "balance", fn: tests.BalanceTester},
{name: "multibalance", fn: tests.MultiBalanceTester},
{name: "processor", fn: tests.ProcessorStressTester},
}
sort.Slice(tests, func(i, j int) bool {
return tests[i].name < tests[j].name
})
if len(os.Args) < 2 {
fmt.Printf("Usage: stress <scenario-name>\n")
fmt.Printf("Scenarios:\n")
for _, test := range tests {
fmt.Printf(" %s\n", test.name)
}
os.Exit(1)
}
testName := os.Args[1]
for _, test := range tests {
if test.name == testName {
if err := test.fn(context.Background()); err != nil {
fmt.Printf("ERROR: %s\n", err)
os.Exit(1)
}
os.Exit(0)
}
}
fmt.Printf("No test with name %s", testName)
os.Exit(1)
}