Skip to content

Commit

Permalink
Added end to end test for mem ballast
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
owais committed Jul 2, 2019
1 parent 4979bbd commit d7d3398
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 53 deletions.
6 changes: 4 additions & 2 deletions testbed/testbed/test_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,16 @@ func (tc *TestCase) SetExpectedMaxRAM(ramMiB uint32) {

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

err := tc.agentProc.start(startParams{
name: "Agent",
logFilePath: logFileName,
cmd: testBedConfig.Agent,
cmdArgs: []string{"--config", tc.agentConfigFile},
cmdArgs: args,
resourceSpec: &tc.resourceSpec,
})

Expand Down
120 changes: 80 additions & 40 deletions testbed/tests/perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,55 +100,25 @@ func TestNoBackend10kSPS(t *testing.T) {
tc.Sleep(10 * time.Second)
}

func Test1000SPSWithAttributes(t *testing.T) {

tests := []struct {
attrCount int
attrSizeByte int
expectedCPU uint32
}{
// No attributes.
{
attrCount: 0,
attrSizeByte: 0,
expectedCPU: 20,
},

// We generate 10 attributes each with average key length of 100 bytes and
// average value length of 50 bytes so total size of attributes values is
// 15000 bytes.
{
attrCount: 100,
attrSizeByte: 50,
expectedCPU: 120,
},

// Approx 10 KiB attributes.
{
attrCount: 10,
attrSizeByte: 1000,
expectedCPU: 100,
},

// Approx 100 KiB attributes.
{
attrCount: 20,
attrSizeByte: 5000,
expectedCPU: 250,
},
}
type testCase struct {
attrCount int
attrSizeByte int
expectedMaxCPU uint32
expectedMaxRAM uint32
}

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

tc := testbed.NewTestCase(t)
defer tc.Stop()

tc.SetExpectedMaxCPU(test.expectedCPU)
tc.SetExpectedMaxRAM(100)
tc.SetExpectedMaxCPU(test.expectedMaxCPU)
tc.SetExpectedMaxRAM(test.expectedMaxRAM)

tc.StartBackend(testbed.BackendOC)
tc.StartAgent()
tc.StartAgent(args...)

options := testbed.LoadOptions{SpansPerSecond: 1000}
options.Attributes = make(map[string]interface{})
Expand All @@ -172,3 +142,73 @@ func Test1000SPSWithAttributes(t *testing.T) {
})
}
}


func Test1000SPSWithAttributes(t *testing.T) {
test1000SPSWithAttributes(t, []string{}, []testCase{
// No attributes.
{
attrCount: 0,
attrSizeByte: 0,
expectedMaxCPU: 30,
expectedMaxRAM: 100,
},

// We generate 10 attributes each with average key length of 100 bytes and
// average value length of 50 bytes so total size of attributes values is
// 15000 bytes.
{
attrCount: 100,
attrSizeByte: 50,
expectedMaxCPU: 120,
expectedMaxRAM: 100,
},

// Approx 10 KiB attributes.
{
attrCount: 10,
attrSizeByte: 1000,
expectedMaxCPU: 100,
expectedMaxRAM: 100,
},

// Approx 100 KiB attributes.
{
attrCount: 20,
attrSizeByte: 5000,
expectedMaxCPU: 250,
expectedMaxRAM: 100,
},
})
}

func TestBallast1000SPSWithAttributes(t *testing.T) {
args := []string{"--mem-ballast-size-mib", "1000"}
test1000SPSWithAttributes(t, args, []testCase{
// No attributes.
{
attrCount: 0,
attrSizeByte: 0,
expectedMaxCPU: 30,
expectedMaxRAM: 2000,
},
{
attrCount: 100,
attrSizeByte: 50,
expectedMaxCPU: 80,
expectedMaxRAM: 2000,
},
{
attrCount: 10,
attrSizeByte: 1000,
expectedMaxCPU: 80,
expectedMaxRAM: 2000,
},
{
attrCount: 20,
attrSizeByte: 5000,
expectedMaxCPU: 120,
expectedMaxRAM: 2000,
},
})
}
26 changes: 15 additions & 11 deletions testbed/tests/results/TESTRESULTS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Test Results
Started: Tue, 25 Jun 2019 10:31:56 -0400
Started: Mon, 01 Jul 2019 23:04:29 +0530

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

Total duration: 87s
Total duration: 128s

0 comments on commit d7d3398

Please sign in to comment.