Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize testbed #1062

Merged
merged 25 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3a683a6
refactor out TestResultSummary
kbrockhoff May 29, 2020
9e9613d
refactor out DataProvider
kbrockhoff Jun 1, 2020
90b8605
refactor out OtelcolRunner
kbrockhoff Jun 5, 2020
2557a0f
Merge branch 'master' into generalize-testbed
kbrockhoff Jun 5, 2020
49440b9
update to latest upstream
kbrockhoff Jun 5, 2020
36bafbc
initial dev of correctness tests
kbrockhoff Jun 5, 2020
55275e4
Merge branch 'master' into generalize-testbed
kbrockhoff Jun 6, 2020
9d9ac71
Refactor NewTestCase to specify DataProvider and OtelcolRunner
kbrockhoff Jun 8, 2020
3df9ed2
Golden dataset provider bug fixes
kbrockhoff Jun 10, 2020
be5f6e8
Extract validators and inprocess runner bug fixes
kbrockhoff Jun 11, 2020
712b782
Fixed correctness processors config
kbrockhoff Jun 11, 2020
d6ded01
Merge branch 'master' into generalize-testbed
kbrockhoff Jun 12, 2020
e3b78f8
Update to latest metrics API
kbrockhoff Jun 12, 2020
6673d25
Added span data validation
kbrockhoff Jun 12, 2020
b0bb782
Merge branch 'master' into generalize-testbed
kbrockhoff Jun 13, 2020
239c6c5
consolidate assertion failures reporting
kbrockhoff Jun 13, 2020
004e716
improve test coverage
kbrockhoff Jun 13, 2020
68ec886
Document test suite creation procedures.
kbrockhoff Jun 13, 2020
dffab9d
Merge branch 'master' into generalize-testbed
kbrockhoff Jun 16, 2020
0eab46d
Fix PR comments and wire in correctness tests in Makefile
kbrockhoff Jun 16, 2020
a0b4915
Fix more PR comments
kbrockhoff Jun 16, 2020
36e0026
Merge branch 'master' into generalize-testbed
kbrockhoff Jun 17, 2020
6aad53c
Remove ResourceSpec because not applicable
kbrockhoff Jun 17, 2020
00afa6f
Improve OtelcolRunner Config by returning cleanup function
kbrockhoff Jun 17, 2020
6f6545e
Shorten test name
kbrockhoff Jun 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ all: checklicense impi lint misspell test otelcol

.PHONY: testbed-runtests
testbed-runtests: otelcol
cd ./testbed/correctness && ./runtests.sh
cd ./testbed/tests && ./runtests.sh

.PHONY: testbed-listtests
testbed-listtests:
TESTBED_CONFIG=local.yaml $(GOTEST) -v ./testbed/tests --test.list '.*'|head -n -1
TESTBED_CONFIG=inprocess.yaml $(GOTEST) -v ./testbed/correctness --test.list '.*'|head -n 10
TESTBED_CONFIG=local.yaml $(GOTEST) -v ./testbed/tests --test.list '.*'|head -n 20

.PHONY: test
test:
Expand Down
9 changes: 9 additions & 0 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ func (app *Application) RegisterZPages(mux *http.ServeMux, pathPrefix string) {
mux.HandleFunc(path.Join(pathPrefix, extensionzPath), app.handleExtensionzRequest)
}

func (app *Application) SignalTestComplete() {
defer func() {
if r := recover(); r != nil {
app.logger.Info("stopTestChan already closed")
}
}()
close(app.stopTestChan)
}

func (app *Application) init() error {
l, err := newLogger()
if err != nil {
Expand Down
71 changes: 71 additions & 0 deletions service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/internal/version"
"go.opentelemetry.io/collector/service/defaultcomponents"
"go.opentelemetry.io/collector/testutils"
)
Expand Down Expand Up @@ -74,6 +75,47 @@ func TestApplication_Start(t *testing.T) {
assert.Equal(t, Closed, <-app.GetStateChannel())
}

func TestApplication_StartAsGoRoutine(t *testing.T) {
factories, err := defaultcomponents.Components()
require.NoError(t, err)

params := Parameters{
ApplicationStartInfo: ApplicationStartInfo{
ExeName: "otelcol",
LongName: "InProcess Collector",
Version: version.Version,
GitHash: version.GitHash,
},
ConfigFactory: func(v *viper.Viper, factories config.Factories) (*configmodels.Config, error) {
return constructMimumalOpConfig(t, factories), nil
},
Factories: factories,
}
app, err := New(params)
require.NoError(t, err)
app.Command().SetArgs([]string{
"--metrics-level=NONE",
})

appDone := make(chan struct{})
go func() {
defer close(appDone)
appErr := app.Start()
if appErr != nil {
err = appErr
}
}()

assert.Equal(t, Starting, <-app.GetStateChannel())
assert.Equal(t, Running, <-app.GetStateChannel())

app.SignalTestComplete()
app.SignalTestComplete()
<-appDone
assert.Equal(t, Closing, <-app.GetStateChannel())
assert.Equal(t, Closed, <-app.GetStateChannel())
}

// isAppAvailable checks if the healthcheck server at the given endpoint is
// returning `available`.
func isAppAvailable(t *testing.T, healthCheckEndPoint string) bool {
Expand Down Expand Up @@ -412,3 +454,32 @@ func TestApplication_GetExporters(t *testing.T) {
close(app.stopTestChan)
<-appDone
}

func constructMimumalOpConfig(t *testing.T, factories config.Factories) *configmodels.Config {
configStr := `
receivers:
otlp:
exporters:
logging:
processors:
batch:

extensions:

service:
extensions:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging]
`
v := viper.NewWithOptions(viper.KeyDelimiter("::"))
v.SetConfigType("yaml")
v.ReadConfig(strings.NewReader(configStr))
cfg, err := config.Load(v, factories)
assert.NoError(t, err)
err = config.ValidateConfig(cfg, zap.NewNop())
assert.NoError(t, err)
return cfg
}
41 changes: 39 additions & 2 deletions testbed/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
# OpenTelemetry Collector Testbed

Testbed is a controlled environment and tools for conducting performance tests for the Otel Collector,
including reproducible short-term benchmarks,long-running stability tests and maximum load stress tests.
Testbed is a controlled environment and tools for conducting end-to-end tests for the Otel Collector,
including reproducible short-term benchmarks, correctness tests, long-running stability tests and
maximum load stress tests.

## Usage

For each type of tests that should have a summary report create a new directory and then a test suite function
which utilizes `*testing.M`. This function should delegate all functionality to `testbed.DoTestMain` supplying
a global instance of `testbed.TestResultsSummary` to it.

Each test case within the suite should create a `testbed.TestCase` and supply implementations of each of the various
interfaces the `NewTestCase` function takes as parameters.

## Pluggable Test Components
tigrannajaryan marked this conversation as resolved.
Show resolved Hide resolved

* `DataProvider` - Generates test data to send to receiver under test.
* `PerfTestDataProvider` - Implementation of the `DataProvider` for use in performance tests. Tracing IDs are based on the incremented batch and data items counters.
* `GoldenDataProvider` - Implementation of `DataProvider` for use in correctness tests. Provides data from the "Golden" dataset generated using pairwise combinatorial testing techniques.
* `DataSender` - Sends data to the collector instance under test.
* `JaegerGRPCDataSender` - Implementation of `DataSender` which sends to `jaeger` receiver.
* `OCTraceDataSender` - Implementation of `DataSender` which sends to `opencensus` receiver.
* `OCMetricsDataSender` - Implementation of `DataSender` which sends to `opencensus` receiver.
* `OTLPTraceDataSender` - Implementation of `DataSender` which sends to `otlp` receiver.
* `OTLPMetricsDataSender` - Implementation of `DataSender` which sends to `otlp` receiver.
* `ZipkinDataSender` - Implementation of `DataSender` which sends to `zipkin` receiver.
* `DataReceiver` - Receives data from the collector instance under test and stores it for use in test assertions.
* `OCDataReceiver` - Implementation of `DataReceiver` which receives data from `opencensus` exporter.
* `JaegerDataReceiver` - Implementation of `DataReceiver` which receives data from `jaeger` exporter.
* `OTLPDataReceiver` - Implementation of `DataReceiver` which receives data from `otlp` exporter.
* `ZipkinDataReceiver` - Implementation of `DataReceiver` which receives data from `zipkin` exporter.
* `OtelcolRunner` - Configures, starts and stops one or more instances of otelcol which will be the subject of testing being executed.
* `ChildProcess` - Implementation of `OtelcolRunner` runs a single otelcol as a child process on the same machine as the test executor.
* `InProcessCollector` - Implementation of `OtelcolRunner` runs a single otelcol as a go routine within the same process as the test executor.
* `TestCaseValidator` - Validates and reports on test results.
* `PerfTestValidator` - Implementation of `TestCaseValidator` for test suites using `PerformanceResults` for summarizing results.
* `CorrectnessTestValidator` - Implementation of `TestCaseValidator` for test suites using `CorrectnessResults` for summarizing results.
* `TestResultsSummary` - Records itemized test case results plus a summary of one category of testing.
* `PerformanceResults` - Implementation of `TestResultsSummary` with fields suitable for reporting performance test results.
* `CorrectnessResults` - Implementation of `TestResultsSummary` with fields suitable for reporting data translation correctness test results.
2 changes: 2 additions & 0 deletions testbed/correctness/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
results/*
!results/BASELINE.md
Loading