@@ -53,10 +53,12 @@ func Test_cache_scale(t *testing.T) {
53
53
operationFrequencyForResourceGroup := 10 * time .Millisecond
54
54
testDuration := 2 * time .Minute
55
55
56
- var createCount uint64
57
- var getCount uint64
58
- var listCount uint64
59
- var deleteCount uint64
56
+ var (
57
+ createCount atomic.Uint64
58
+ getCount atomic.Uint64
59
+ listCount atomic.Uint64
60
+ deleteCount atomic.Uint64
61
+ )
60
62
61
63
ctx , cancel := context .WithCancel (context .TODO ())
62
64
defer cancel ()
@@ -95,17 +97,17 @@ func Test_cache_scale(t *testing.T) {
95
97
err := c .Create (resourceGroup , machine )
96
98
if apierrors .IsAlreadyExists (err ) {
97
99
if err = c .Get (resourceGroup , types.NamespacedName {Name : machineName (item )}, machine ); err == nil {
98
- atomic . AddUint64 ( & getCount , 1 )
100
+ getCount . Add ( 1 )
99
101
continue
100
102
}
101
103
}
102
104
g .Expect (err ).ToNot (HaveOccurred ())
103
- atomic . AddUint64 ( & createCount , 1 )
105
+ createCount . Add ( 1 )
104
106
case 1 : // list
105
107
obj := & cloudv1.CloudMachineList {}
106
108
err := c .List (resourceGroup , obj )
107
109
g .Expect (err ).ToNot (HaveOccurred ())
108
- atomic . AddUint64 ( & listCount , 1 )
110
+ listCount . Add ( 1 )
109
111
case 2 : // delete
110
112
g .Expect (err ).ToNot (HaveOccurred ())
111
113
machine := & cloudv1.CloudMachine {
@@ -118,7 +120,7 @@ func Test_cache_scale(t *testing.T) {
118
120
continue
119
121
}
120
122
g .Expect (err ).ToNot (HaveOccurred ())
121
- atomic . AddUint64 ( & deleteCount , 1 )
123
+ deleteCount . Add ( 1 )
122
124
}
123
125
124
126
case <- ctx .Done ():
@@ -130,7 +132,7 @@ func Test_cache_scale(t *testing.T) {
130
132
131
133
time .Sleep (testDuration )
132
134
133
- t .Log ("createCount" , createCount , "getCount" , getCount , "listCount" , listCount , "deleteCount" , deleteCount )
135
+ t .Log ("createCount" , createCount . Load () , "getCount" , getCount . Load () , "listCount" , listCount . Load () , "deleteCount" , deleteCount . Load () )
134
136
135
137
cancel ()
136
138
}
0 commit comments