Skip to content

Commit 541c6f3

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 c50224d commit 541c6f3

File tree

7 files changed

+136
-61
lines changed

7 files changed

+136
-61
lines changed

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,20 @@ require (
66
contrib.go.opencensus.io/exporter/prometheus v0.1.0
77
contrib.go.opencensus.io/exporter/zipkin v0.1.1
88
contrib.go.opencensus.io/resource v0.1.1
9-
github.com/VividCortex/gohistogram v1.0.0 // indirect
109
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7
11-
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b // indirect
1210
github.com/census-instrumentation/opencensus-proto v0.2.0
1311
github.com/go-kit/kit v0.8.0
14-
github.com/gogo/googleapis v1.2.0 // indirect
1512
github.com/golang/protobuf v1.3.1
1613
github.com/google/go-cmp v0.3.0
1714
github.com/gorilla/mux v1.6.2
1815
github.com/grpc-ecosystem/grpc-gateway v1.9.0
19-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2016
github.com/jaegertracing/jaeger v1.9.0
2117
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024
2218
github.com/omnition/scribe-go v0.0.0-20190131012523-9e3c68f31124
19+
github.com/open-telemetry/opentelemetry-service/testbed v0.0.0-20190702215910-6b130d62dbaa // indirect
2320
github.com/openzipkin/zipkin-go v0.1.6
2421
github.com/orijtech/prometheus-go-metrics-exporter v0.0.3-0.20190313163149-b321c5297f60
2522
github.com/pkg/errors v0.8.0
26-
github.com/prashantv/protectmem v0.0.0-20171002184600-e20412882b3a // indirect
2723
github.com/prometheus/client_golang v0.9.3
2824
github.com/prometheus/common v0.4.0
2925
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084
@@ -33,7 +29,6 @@ require (
3329
github.com/spf13/cast v1.3.0
3430
github.com/spf13/cobra v0.0.3
3531
github.com/spf13/viper v1.4.0
36-
github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 // indirect
3732
github.com/stretchr/testify v1.3.0
3833
github.com/uber-go/atomic v1.4.0 // indirect
3934
github.com/uber/jaeger-lib v2.0.0+incompatible

go.sum

Lines changed: 35 additions & 0 deletions
Large diffs are not rendered by default.

testbed/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ go 1.12
44

55
require (
66
contrib.go.opencensus.io/exporter/jaeger v0.1.1-0.20190430175949-e8b55949d948
7+
github.com/gogo/googleapis v1.2.0 // indirect
78
github.com/open-telemetry/opentelemetry-service v0.0.0-20190625135304-4bd705a25a35
89
github.com/shirou/gopsutil v2.18.12+incompatible
9-
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
1010
github.com/spf13/viper v1.4.0
1111
github.com/stretchr/testify v1.3.0
1212
go.opencensus.io v0.22.0

testbed/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
185185
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
186186
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
187187
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
188+
github.com/open-telemetry/opentelemetry-service/testbed v0.0.0-20190702215910-6b130d62dbaa/go.mod h1:55KQ0SPaonTFJxENtpPuZkIV853aovZ6bUtZYB9ROj0=
188189
github.com/opentracing-contrib/go-stdlib v0.0.0-20170113013457-1de4cc2120e7/go.mod h1:PLldrQSroqzH70Xl+1DQcGnefIbqsKR7UDaiux3zV+w=
189190
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
190191
github.com/opentracing/opentracing-go v1.0.1 h1:IYN/cK5AaULfeMAlgFZSIBLSpsZ5MRHDy1fKBEqqJfQ=

testbed/testbed/test_case.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (tc *TestCase) StartAgent(args ...string) {
139139
name: "Agent",
140140
logFilePath: logFileName,
141141
cmd: testBedConfig.Agent,
142-
cmdArgs: args,
142+
cmdArgs: args,
143143
resourceSpec: &tc.resourceSpec,
144144
})
145145

@@ -189,7 +189,7 @@ func (tc *TestCase) StopBackend() {
189189
tc.MockBackend.Stop()
190190
}
191191

192-
// AgentMemoryInfo returns raw memory info struct about the agent
192+
// AgentMemoryInfo returns raw memory info struct about the agent
193193
// as returned by github.com/shirou/gopsutil/process
194194
func (tc *TestCase) AgentMemoryInfo() (uint32, uint32, error) {
195195
stat, err := tc.agentProc.processMon.MemoryInfo()
@@ -297,7 +297,7 @@ func (tc *TestCase) WaitForN(cond func() bool, duration time.Duration, errMsg ..
297297

298298
// WaitFor is like WaitForN but with a fixed duration of 10 seconds
299299
func (tc *TestCase) WaitFor(cond func() bool, errMsg ...interface{}) bool {
300-
return tc.WaitForN(cond, time.Second * 10, errMsg...)
300+
return tc.WaitForN(cond, time.Second*10, errMsg...)
301301
}
302302

303303
func (tc *TestCase) indicateError(err error) {

testbed/tests/perf_test.go

Lines changed: 80 additions & 40 deletions
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/BASELINE.md

Lines changed: 15 additions & 11 deletions
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: Wed, 03 Jul 2019 05:42:19 +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| 1.0| 25| 34| 0| 0
7+
Test10kSPS |PASS | 16s| 72.6| 92.0| 34| 41| 144520| 144520
8+
TestNoBackend10kSPS |PASS | 10s| 75.6| 78.3| 29| 40| 97460| 0
9+
Test1000SPSWithAttributes/0*0bytes |PASS | 11s| 22.3| 24.0| 31| 42| 10000| 10000
10+
Test1000SPSWithAttributes/100*50bytes |PASS | 11s| 92.3| 106.3| 33| 46| 9990| 9990
11+
Test1000SPSWithAttributes/10*1000bytes |PASS | 11s| 86.2| 93.3| 34| 46| 10000| 10000
12+
Test1000SPSWithAttributes/20*5000bytes |PASS | 11s| 126.3| 130.0| 47| 64| 9990| 9990
13+
TestBallast1000SPSWithAttributes/0*0bytes|PASS | 11s| 20.4| 21.7| 71| 109| 10000| 10000
14+
TestBallast1000SPSWithAttributes/100*50bytes|PASS | 11s| 64.4| 68.0| 492| 845| 9950| 9950
15+
TestBallast1000SPSWithAttributes/10*1000bytes|PASS | 11s| 55.1| 59.7| 350| 575| 9990| 9990
16+
TestBallast1000SPSWithAttributes/20*5000bytes|PASS | 11s| 67.8| 69.3| 786| 1081| 9950| 9950
1317

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

0 commit comments

Comments
 (0)