-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added memory ballast e2e behavior test (#85)
Added a new test that verifies that the ballast behaves only counts to virtual memory and is not actually allocated. Also added `tests/results/BASELINE.md` to act as the baseline test results file. The TESTRESULTS.md file was modified on every run and it would change in every PR from every contributor. It added additional work when one didn't want to include it in a PR which was most of the time. Only time it should be updated is when someone adds or updates a new perf test.
- Loading branch information
1 parent
4979bbd
commit 6b130d6
Showing
5 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2019, OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package tests contains test cases. To run the tests go to tests directory and run: | ||
// TESTBED_CONFIG=local.yaml go test -v | ||
|
||
package testbed | ||
|
||
// TestCaseOption defines a TestCase option | ||
type TestCaseOption struct { | ||
option func(t *TestCase) | ||
} | ||
|
||
// Apply takes a TestCase and runs the option function on it | ||
func (o TestCaseOption) Apply(t *TestCase) { | ||
o.option(t) | ||
} | ||
|
||
// WithSkipResults option disables writing out results file for a TestCase | ||
func WithSkipResults() TestCaseOption { | ||
return TestCaseOption{func(t *TestCase) { | ||
t.skipResults = true | ||
}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
results/* | ||
!results/BASELINE.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2019, OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package tests contains test cases. To run the tests go to tests directory and run: | ||
// TESTBED_CONFIG=local.yaml go test -v | ||
|
||
package tests | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
"strconv" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/open-telemetry/opentelemetry-service/testbed/testbed" | ||
) | ||
|
||
func TestBallastMemory(t *testing.T) { | ||
tests := []struct{ | ||
ballastSize uint32 | ||
maxRSS uint32 | ||
}{ | ||
{100, 50}, | ||
{500, 70}, | ||
{1000, 100}, | ||
} | ||
|
||
for _, test := range tests { | ||
tc := testbed.NewTestCase(t, testbed.WithSkipResults()) | ||
tc.SetExpectedMaxRAM(test.maxRSS) | ||
|
||
tc.StartAgent("--mem-ballast-size-mib", strconv.Itoa(int(test.ballastSize))) | ||
|
||
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, "VMS must be greater than %d", test.ballastSize) | ||
|
||
assert.True(t, rss <= test.maxRSS, fmt.Sprintf("RSS must be less than or equal to %d", test.maxRSS)) | ||
tc.Stop() | ||
} | ||
} |
File renamed without changes.