@@ -100,55 +100,25 @@ func TestNoBackend10kSPS(t *testing.T) {
100
100
tc .Sleep (10 * time .Second )
101
101
}
102
102
103
- func Test1000SPSWithAttributes (t * testing.T ) {
104
-
105
- tests := []struct {
106
- attrCount int
107
- attrSizeByte int
108
- expectedCPU uint32
109
- }{
110
- // No attributes.
111
- {
112
- attrCount : 0 ,
113
- attrSizeByte : 0 ,
114
- expectedCPU : 20 ,
115
- },
116
-
117
- // We generate 10 attributes each with average key length of 100 bytes and
118
- // average value length of 50 bytes so total size of attributes values is
119
- // 15000 bytes.
120
- {
121
- attrCount : 100 ,
122
- attrSizeByte : 50 ,
123
- expectedCPU : 120 ,
124
- },
125
-
126
- // Approx 10 KiB attributes.
127
- {
128
- attrCount : 10 ,
129
- attrSizeByte : 1000 ,
130
- expectedCPU : 100 ,
131
- },
132
-
133
- // Approx 100 KiB attributes.
134
- {
135
- attrCount : 20 ,
136
- attrSizeByte : 5000 ,
137
- expectedCPU : 250 ,
138
- },
139
- }
103
+ type testCase struct {
104
+ attrCount int
105
+ attrSizeByte int
106
+ expectedMaxCPU uint32
107
+ expectedMaxRAM uint32
108
+ }
140
109
110
+ func test1000SPSWithAttributes (t * testing.T , args []string , tests []testCase ) {
141
111
for _ , test := range tests {
142
112
t .Run (fmt .Sprintf ("%d*%dbytes" , test .attrCount , test .attrSizeByte ), func (t * testing.T ) {
143
113
144
114
tc := testbed .NewTestCase (t )
145
115
defer tc .Stop ()
146
116
147
- tc .SetExpectedMaxCPU (test .expectedCPU )
148
- tc .SetExpectedMaxRAM (100 )
117
+ tc .SetExpectedMaxCPU (test .expectedMaxCPU )
118
+ tc .SetExpectedMaxRAM (test . expectedMaxRAM )
149
119
150
120
tc .StartBackend (testbed .BackendOC )
151
- tc .StartAgent ()
121
+ tc .StartAgent (args ... )
152
122
153
123
options := testbed.LoadOptions {SpansPerSecond : 1000 }
154
124
options .Attributes = make (map [string ]interface {})
@@ -172,3 +142,73 @@ func Test1000SPSWithAttributes(t *testing.T) {
172
142
})
173
143
}
174
144
}
145
+
146
+
147
+ func Test1000SPSWithAttributes (t * testing.T ) {
148
+ test1000SPSWithAttributes (t , []string {}, []testCase {
149
+ // No attributes.
150
+ {
151
+ attrCount : 0 ,
152
+ attrSizeByte : 0 ,
153
+ expectedMaxCPU : 30 ,
154
+ expectedMaxRAM : 100 ,
155
+ },
156
+
157
+ // We generate 10 attributes each with average key length of 100 bytes and
158
+ // average value length of 50 bytes so total size of attributes values is
159
+ // 15000 bytes.
160
+ {
161
+ attrCount : 100 ,
162
+ attrSizeByte : 50 ,
163
+ expectedMaxCPU : 120 ,
164
+ expectedMaxRAM : 100 ,
165
+ },
166
+
167
+ // Approx 10 KiB attributes.
168
+ {
169
+ attrCount : 10 ,
170
+ attrSizeByte : 1000 ,
171
+ expectedMaxCPU : 100 ,
172
+ expectedMaxRAM : 100 ,
173
+ },
174
+
175
+ // Approx 100 KiB attributes.
176
+ {
177
+ attrCount : 20 ,
178
+ attrSizeByte : 5000 ,
179
+ expectedMaxCPU : 250 ,
180
+ expectedMaxRAM : 100 ,
181
+ },
182
+ })
183
+ }
184
+
185
+ func TestBallast1000SPSWithAttributes (t * testing.T ) {
186
+ args := []string {"--mem-ballast-size-mib" , "1000" }
187
+ test1000SPSWithAttributes (t , args , []testCase {
188
+ // No attributes.
189
+ {
190
+ attrCount : 0 ,
191
+ attrSizeByte : 0 ,
192
+ expectedMaxCPU : 30 ,
193
+ expectedMaxRAM : 2000 ,
194
+ },
195
+ {
196
+ attrCount : 100 ,
197
+ attrSizeByte : 50 ,
198
+ expectedMaxCPU : 80 ,
199
+ expectedMaxRAM : 2000 ,
200
+ },
201
+ {
202
+ attrCount : 10 ,
203
+ attrSizeByte : 1000 ,
204
+ expectedMaxCPU : 80 ,
205
+ expectedMaxRAM : 2000 ,
206
+ },
207
+ {
208
+ attrCount : 20 ,
209
+ attrSizeByte : 5000 ,
210
+ expectedMaxCPU : 120 ,
211
+ expectedMaxRAM : 2000 ,
212
+ },
213
+ })
214
+ }
0 commit comments