Skip to content

Commit

Permalink
Add functional test (#26)
Browse files Browse the repository at this point in the history
Problem:
Ensure the exporter library correctly sends telemetry data via OTel

Solution:
Add a functional test:
- Exporter sends telemetry data to an OTel collector
- Ensure the collector successfully receives the data by looking at
its logs
- Include the test into GitHub pipeline.

CLOSES #7

Co-authored-by: Ciara Stacke <18287516+ciarams87@users.noreply.github.com>
Co-authored-by: Saylor Berman <s.berman@f5.com>
Co-authored-by: Luca Comellini <luca.com@gmail.com>
  • Loading branch information
4 people authored Mar 6, 2024
1 parent f5b0474 commit e74e64e
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ updates:
directory: /
schedule:
interval: daily

- package-ecosystem: docker
directory: /tests
schedule:
interval: daily
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,22 @@ jobs:
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: cover-${{ github.run_id }}.html
path: ${{ github.workspace }}/cmd-cover.html
path: |
${{ github.workspace }}/cover.html
${{ github.workspace }}/generator-cover.html
if: always()

functional-tests:
name: Functional Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Golang Environment
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable

- name: Run Functional Tests
run: make functional-test
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ help: Makefile ## Display this help

.PHONY: unit-test
unit-test:
go test ./... -race -coverprofile cmd-cover.out
go tool cover -html=cmd-cover.out -o cmd-cover.html
go test -tags generator ./cmd/generator/... -race -coverprofile generator-cmd-cover.out
go tool cover -html=generator-cmd-cover.out -o generator-cmd-cover.html
go test ./pkg/... -race -shuffle=on -coverprofile=cover.out -covermode=atomic
go tool cover -html=cover.out -o cover.html
go test -tags generator ./cmd/generator/... -race -coverprofile=generator-cover.out
go tool cover -html=generator-cover.out -o generator-cover.html

.PHONY: clean-go-cache
clean-go-cache: ## Clean go cache
Expand Down Expand Up @@ -43,4 +43,8 @@ generate: ## Run go generate
.PHONY: generator-tests
generator-tests: ## Regenerate the generator generated files and run generator unit tests
go generate -tags generator ./cmd/generator/... # ensure the generated files generated by the generator are up to date
go test -tags generator ./cmd/generator/... -race -coverprofile cmd-cover.out
go test -tags generator ./cmd/generator/... -race -coverprofile=generator-cover.out

.PHONY: functional-test
functional-test: ## Run functional tests
go run github.com/onsi/ginkgo/v2/ginkgo --randomize-all --randomize-suites --race --keep-going --fail-on-pending --trace --covermode=atomic --coverprofile=functional-cover.out -r tests
36 changes: 36 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1
github.com/onsi/ginkgo/v2 v2.16.0
github.com/onsi/gomega v1.31.1
github.com/testcontainers/testcontainers-go v0.28.0
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
Expand All @@ -15,16 +16,51 @@ require (
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v25.0.3+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
Expand Down
Loading

0 comments on commit e74e64e

Please sign in to comment.