Skip to content

Commit

Permalink
testbed: increase limit for TestBallastMemory (#6691)
Browse files Browse the repository at this point in the history
This also improves the error message, making it clear that the usage is 10% higher than the max.

Fixes #6535

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling authored and PaurushGarg committed Dec 14, 2021
1 parent c46ad17 commit 93df778
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions testbed/tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestBallastMemory(t *testing.T) {
maxRSS uint32
}{
{100, 70},
{500, 80},
{500, 90},
{1000, 110},
}

Expand All @@ -84,43 +84,45 @@ func TestBallastMemory(t *testing.T) {
options := testbed.LoadOptions{DataItemsPerSecond: 10_000, ItemsPerBatch: 10}
dataProvider := testbed.NewPerfTestDataProvider(options)
for _, test := range tests {
sender := testbed.NewOTLPTraceDataSender(testbed.DefaultHost, testbed.GetAvailablePort(t))
receiver := testbed.NewOTLPDataReceiver(testbed.GetAvailablePort(t))
ballastCfg := createConfigYaml(
t, sender, receiver, resultDir, nil,
map[string]string{"memory_ballast": fmt.Sprintf(ballastConfig, test.ballastSize)})
cp := testbed.NewChildProcessCollector()
cleanup, err := cp.PrepareConfig(ballastCfg)
require.NoError(t, err)
tc := testbed.NewTestCase(
t,
dataProvider,
sender,
receiver,
cp,
&testbed.PerfTestValidator{},
performanceResultsSummary,
testbed.WithSkipResults(),
testbed.WithResourceLimits(testbed.ResourceSpec{ExpectedMaxRAM: test.maxRSS}),
)
tc.StartAgent()

var rss, vms uint32
// It is possible that the process is not ready or the ballast code path
// is not hit immediately so we give the process up to a couple of seconds
// to fire up and setup ballast. 2 seconds is a long time for this case but
// it is short enough to not be annoying if the test fails repeatedly
tc.WaitForN(func() bool {
rss, vms, _ = tc.AgentMemoryInfo()
return vms > test.ballastSize
}, time.Second*2, fmt.Sprintf("VMS must be greater than %d", test.ballastSize))

// https://github.com/open-telemetry/opentelemetry-collector/issues/3233
// given that the maxRSS isn't an absolute maximum and that the actual maximum might be a bit off,
// we give some room here instead of failing when the memory usage isn't that much higher than the max
lenientMax := 1.1 * float32(test.maxRSS)
assert.LessOrEqual(t, float32(rss), lenientMax)
cleanup()
tc.Stop()
t.Run(fmt.Sprintf("ballast-size-%d", test.ballastSize), func(t *testing.T) {
sender := testbed.NewOTLPTraceDataSender(testbed.DefaultHost, testbed.GetAvailablePort(t))
receiver := testbed.NewOTLPDataReceiver(testbed.GetAvailablePort(t))
ballastCfg := createConfigYaml(
t, sender, receiver, resultDir, nil,
map[string]string{"memory_ballast": fmt.Sprintf(ballastConfig, test.ballastSize)})
cp := testbed.NewChildProcessCollector()
cleanup, err := cp.PrepareConfig(ballastCfg)
require.NoError(t, err)
tc := testbed.NewTestCase(
t,
dataProvider,
sender,
receiver,
cp,
&testbed.PerfTestValidator{},
performanceResultsSummary,
testbed.WithSkipResults(),
testbed.WithResourceLimits(testbed.ResourceSpec{ExpectedMaxRAM: test.maxRSS}),
)
tc.StartAgent()

var rss, vms uint32
// It is possible that the process is not ready or the ballast code path
// is not hit immediately so we give the process up to a couple of seconds
// to fire up and setup ballast. 2 seconds is a long time for this case but
// it is short enough to not be annoying if the test fails repeatedly
tc.WaitForN(func() bool {
rss, vms, _ = tc.AgentMemoryInfo()
return vms > test.ballastSize
}, time.Second*2, fmt.Sprintf("VMS must be greater than %d", test.ballastSize))

// https://github.com/open-telemetry/opentelemetry-collector/issues/3233
// given that the maxRSS isn't an absolute maximum and that the actual maximum might be a bit off,
// we give some room here instead of failing when the memory usage isn't that much higher than the max
lenientMax := 1.1 * float32(test.maxRSS)
assert.LessOrEqual(t, float32(rss), lenientMax, fmt.Sprintf("The RSS memory usage (%d) is >10%% higher than the limit (%d).", rss, test.maxRSS))
cleanup()
tc.Stop()
})
}
}

0 comments on commit 93df778

Please sign in to comment.