Skip to content

Commit 2adb37c

Browse files
committed
Added end to end test for mem ballast
This commit adds an end to end test to verify performance gain acheived with memory ballast It mainly checks the CPU usage and does not test against memory usage. I'll be submitting another PR that will specifically test memory behaviour and ensure the ballast does not actually consume memory. `TestNoBackend10kSPS` test was very reliably consuming >20 CPU on my machine so I increased the accepted values to 30 for this test.
1 parent 21339fb commit 2adb37c

File tree

3 files changed

+99
-53
lines changed

3 files changed

+99
-53
lines changed

testbed/testbed/test_case.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,16 @@ func (tc *TestCase) SetExpectedMaxRAM(ramMiB uint32) {
123123

124124
// StartAgent starts the agent and redirects its standard output and standard error
125125
// to "agent.log" file located in the test directory.
126-
func (tc *TestCase) StartAgent() {
126+
func (tc *TestCase) StartAgent(args ...string) {
127+
args = append(args, "--config")
128+
args = append(args, tc.agentConfigFile)
127129
logFileName := tc.composeTestResultFileName("agent.log")
128130

129131
err := tc.agentProc.start(startParams{
130132
name: "Agent",
131133
logFilePath: logFileName,
132134
cmd: testBedConfig.Agent,
133-
cmdArgs: []string{"--config", tc.agentConfigFile},
135+
cmdArgs: args,
134136
resourceSpec: &tc.resourceSpec,
135137
})
136138

testbed/tests/perf_test.go

+80-40
Original file line numberDiff line numberDiff line change
@@ -100,55 +100,25 @@ func TestNoBackend10kSPS(t *testing.T) {
100100
tc.Sleep(10 * time.Second)
101101
}
102102

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+
}
140109

110+
func test1000SPSWithAttributes(t *testing.T, args []string, tests []testCase) {
141111
for _, test := range tests {
142112
t.Run(fmt.Sprintf("%d*%dbytes", test.attrCount, test.attrSizeByte), func(t *testing.T) {
143113

144114
tc := testbed.NewTestCase(t)
145115
defer tc.Stop()
146116

147-
tc.SetExpectedMaxCPU(test.expectedCPU)
148-
tc.SetExpectedMaxRAM(100)
117+
tc.SetExpectedMaxCPU(test.expectedMaxCPU)
118+
tc.SetExpectedMaxRAM(test.expectedMaxRAM)
149119

150120
tc.StartBackend(testbed.BackendOC)
151-
tc.StartAgent()
121+
tc.StartAgent(args...)
152122

153123
options := testbed.LoadOptions{SpansPerSecond: 1000}
154124
options.Attributes = make(map[string]interface{})
@@ -172,3 +142,73 @@ func Test1000SPSWithAttributes(t *testing.T) {
172142
})
173143
}
174144
}
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+
}

testbed/tests/results/TESTRESULTS.md

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# Test Results
2-
Started: Tue, 25 Jun 2019 10:31:56 -0400
2+
Started: Mon, 01 Jul 2019 23:04:29 +0530
33

4-
Test|Result|Duration|CPU Avg%|CPU Max%|RAM Avg MiB|RAM Max MiB|Sent Spans|Received Spans
5-
----|------|-------:|-------:|-------:|----------:|----------:|---------:|-------------:
6-
TestIdleMode|Passed|10s|0.3|1.0|25|34|0|0
7-
Test10kSPS|Passed|17s|91.4|95.7|35|43|149610|149610
8-
TestNoBackend10kSPS|Passed|10s|59.1|59.3|29|40|99910|0
9-
Test1000SPSWithAttributes/0*0bytes|Passed|12s|18.7|19.3|30|41|10000|10000
10-
Test1000SPSWithAttributes/100*50bytes|Passed|12s|70.2|71.0|32|45|10000|10000
11-
Test1000SPSWithAttributes/10*1000bytes|Passed|12s|68.0|74.3|32|44|10000|10000
12-
Test1000SPSWithAttributes/20*5000bytes|Passed|12s|158.2|173.7|39|55|10000|10000
4+
Test |Result|Duration|CPU Avg%|CPU Max%|RAM Avg MiB|RAM Max MiB|Sent Spans|Received Spans
5+
----------------------------------------|------|-------:|-------:|-------:|----------:|----------:|---------:|-------------:
6+
TestIdleMode |PASS | 10s| 0.3| 0.7| 24| 32| 0| 0
7+
Test10kSPS |PASS | 17s| 73.3| 78.3| 34| 42| 148760| 148760
8+
TestNoBackend10kSPS |PASS | 10s| 79.5| 81.7| 29| 40| 98770| 0
9+
Test1000SPSWithAttributes/0*0bytes |PASS | 12s| 25.8| 26.7| 30| 41| 10000| 10000
10+
Test1000SPSWithAttributes/100*50bytes |PASS | 12s| 87.1| 93.7| 34| 47| 9990| 9990
11+
Test1000SPSWithAttributes/10*1000bytes |PASS | 12s| 67.8| 74.3| 32| 44| 10000| 10000
12+
Test1000SPSWithAttributes/20*5000bytes |PASS | 12s| 96.7| 102.0| 46| 71| 10000| 10000
13+
TestBallast1000SPSWithAttributes/0*0bytes|FAIL | 4s| 25.3| 25.3| 41| 82| 2830| 2790
14+
TestBallast1000SPSWithAttributes/100*50bytes|PASS | 12s| 59.6| 62.7| 498| 846| 9990| 9990
15+
TestBallast1000SPSWithAttributes/10*1000bytes|PASS | 12s| 50.1| 57.0| 353| 575| 9980| 9980
16+
TestBallast1000SPSWithAttributes/20*5000bytes|PASS | 12s| 58.9| 63.3| 784| 1081| 9960| 9960
1317

14-
Total duration: 87s
18+
Total duration: 128s

0 commit comments

Comments
 (0)