Skip to content

Commit b4c9671

Browse files
Add End-to-end test bed (#54)
Problem ======= We need a way to run E2E tests with real agent and a load generator. Particularly important class of E2E tests are performance tests in controlled environment. Solution ======== The test bed allows to easily set up a test that requires running the agent and a load generator, measure and define resource consumption expectations for the agent, fail tests automatically when expectations are exceeded. Each test case requires a agent configuration file and (optionally) load generator spec file. Test cases are defined as regular Go tests, see examples in perf_test.go. To run E2E tests go to testbed directory and run "make runtests" or run "make perf-tests" from top-level directory. Note that E2E tests are skipped when running regular "make test" target. The reason is that because E2E tests take a lot of time and require non-concurrent execution while other tests are typical run with -race flag. See also design doc here: https://docs.google.com/document/d/1omU06mBYGY0slT1yojttn9BCyp18pHaRjkkYZrY8H4Q/edit# TODO ===== We plan to add the following functionality later: - Ability for load generator to record what it generated and then use that information to validate data received by mock backend from the agent. - Enforce resource consumption limits on the agent to allow testing scenarios under specific available resource situations (as opposed to measuring and failing tests which is already implemented and which is useful in different scenarios).
1 parent d05ec08 commit b4c9671

19 files changed

+1951
-0
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# More exclusions can be added similar with: -not -path './vendor/*'
22
ALL_SRC := $(shell find . -name '*.go' \
33
-not -path './vendor/*' \
4+
-not -path './testbed/*' \
45
-not -path './tools/*' \
56
-type f | sort)
67

@@ -34,6 +35,10 @@ all-srcs:
3435
.PHONY: fmt-vet-lint-test
3536
fmt-vet-lint-test: fmt vet lint test
3637

38+
.PHONY: perf-test
39+
perf-test: otelsvc
40+
$(MAKE) -C testbed runtests
41+
3742
.PHONY: test
3843
test:
3944
$(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)

go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5i
191191
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
192192
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3 h1:/UewZcckqhvnnS0C6r3Sher2hSEbVmM6Ogpcjen08+Y=
193193
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
194+
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024 h1:rBMNdlhTLzJjJSDIjNEXX1Pz3Hmwmz91v+zycvx9PJc=
194195
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
195196
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
196197
github.com/julienschmidt/httprouter v0.0.0-20150905172533-109e267447e9/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=

testbed/Makefile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
GOTEST_OPT?=-v -race -timeout 30s
2+
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
3+
GOTEST=go test
4+
GOFMT=gofmt
5+
GOLINT=golint
6+
GOVET=go vet
7+
GOOS=$(shell go env GOOS)
8+
9+
.DEFAULT_GOAL := fmt-vet-lint-test
10+
11+
.PHONY: fmt-vet-lint-test
12+
fmt-vet-lint-test: fmt vet lint test
13+
14+
.PHONY: test
15+
test:
16+
$(GOTEST) $(GOTEST_OPT) ./...
17+
18+
.PHONY: runtests
19+
runtests: test
20+
cd tests && TESTBED_CONFIG=local.yaml go test -v 2>&1 | tee results/testoutput.log
21+
cd tests && mkdir -p results/junit && go-junit-report < results/testoutput.log > results/junit/results.xml
22+
23+
.PHONY: fmt
24+
fmt:
25+
@FMTOUT=`$(GOFMT) -s -l ./.. 2>&1`; \
26+
if [ "$$FMTOUT" ]; then \
27+
echo "$(GOFMT) FAILED => gofmt the following files:\n"; \
28+
echo "$$FMTOUT\n"; \
29+
exit 1; \
30+
else \
31+
echo "Fmt finished successfully"; \
32+
fi
33+
34+
.PHONY: lint
35+
lint:
36+
@LINTOUT=`$(GOLINT) $(ALL_PKGS) 2>&1`; \
37+
if [ "$$LINTOUT" ]; then \
38+
echo "$(GOLINT) FAILED => clean the following lint errors:\n"; \
39+
echo "$$LINTOUT\n"; \
40+
exit 1; \
41+
else \
42+
echo "Lint finished successfully"; \
43+
fi
44+
45+
.PHONY: vet
46+
vet:
47+
$(GOVET) ./...
48+
49+
.PHONY: install-tools
50+
install-tools:
51+
go install golang.org/x/lint/golint
52+
go install github.com/jstemmer/go-junit-report

testbed/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# OpenTelemetry Service Testbed
2+
3+
Testbed is a controlled environment and tools for conducting performance tests for the Agent, including reproducible short-term benchmarks,long-running stability tests and maximum load stress tests.

testbed/go.mod

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module github.com/open-telemetry/opentelemetry-service/testbed
2+
3+
go 1.12
4+
5+
require (
6+
contrib.go.opencensus.io/exporter/jaeger v0.1.1-0.20190430175949-e8b55949d948
7+
github.com/open-telemetry/opentelemetry-service v0.0.0-20190625135304-4bd705a25a35
8+
github.com/shirou/gopsutil v2.18.12+incompatible
9+
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
10+
github.com/spf13/viper v1.4.0
11+
github.com/stretchr/testify v1.3.0
12+
go.opencensus.io v0.22.0
13+
)

testbed/go.sum

+415
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)