-
Notifications
You must be signed in to change notification settings - Fork 220
/
main_test.go
56 lines (47 loc) · 1.15 KB
/
main_test.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 2022 NetApp, Inc. All Rights Reserved.
package main
import (
"context"
"io"
"math"
"os"
"testing"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"k8s.io/utils/pointer"
"github.com/netapp/trident/config"
)
func TestMain(m *testing.M) {
// Disable any standard log output
log.SetOutput(io.Discard)
os.Exit(m.Run())
}
func TestMain_processCommandLineArgs_QPS(t *testing.T) {
type parameters struct {
k8sApiQPS float64
expectedK8sApiQPS float32
}
tests := map[string]parameters{
"QPS is set to 100.0": {
k8sApiQPS: 100.0,
expectedK8sApiQPS: 100.0,
},
"QPS is set to maxFloat32": {
k8sApiQPS: math.MaxFloat32,
expectedK8sApiQPS: math.MaxFloat32,
},
"QPS is set to maxFloat64 + 1": {
k8sApiQPS: math.MaxFloat64 + 1,
expectedK8sApiQPS: config.DefaultK8sAPIQPS,
},
}
for name, params := range tests {
t.Run(name, func(t *testing.T) {
csiEndpoint = pointer.String("true")
useInMemory = pointer.Bool(true)
k8sApiQPS = ¶ms.k8sApiQPS
processCmdLineArgs(context.TODO())
assert.Equal(t, params.expectedK8sApiQPS, config.K8sAPIQPS)
})
}
}