-
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
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
Showing
5 changed files
with
100 additions
and
3 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,18 @@ | ||
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,55 @@ | ||
// 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" | ||
"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))) | ||
|
||
rss, vms, err := tc.AgentMemoryInfo() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assert.True(t, rss <= test.maxRSS, fmt.Sprintf("RSS must be less than or equal to %d", test.maxRSS)) | ||
assert.True(t, vms > test.ballastSize, fmt.Sprintf("VMS must be greater than %d", test.ballastSize)) | ||
tc.Stop() | ||
} | ||
} |
File renamed without changes.