Skip to content

Commit

Permalink
Refactor integration tests to use dockertest
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Sep 28, 2021
1 parent 544d55e commit 2700b7c
Show file tree
Hide file tree
Showing 5 changed files with 369 additions and 199 deletions.
29 changes: 2 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
pull_request:
workflow_dispatch:

env:
DEFAULT_GO_VERSION: 1.17

jobs:
goyek:
strategy:
Expand All @@ -26,7 +23,7 @@ jobs:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-go@v2.1.4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
go-version: '1.17'
- run: ${{ matrix.run-script }}
- uses: codecov/codecov-action@v2.1.0
with:
Expand All @@ -53,28 +50,6 @@ jobs:
- uses: actions/setup-go@v2.1.4
with:
go-version: ${{ matrix.go-version }}
- name: make test-short (exclude splunkkafka)
if: "matrix.arch == '386' || contains(matrix.os, 'windows')"
env:
EXCLUDEPKGS: "%/splunkkafka %/splunkkafka/test"
GOARCH: ${{ matrix.arch }}
run: make test-short
- if: "!(matrix.arch == '386' || contains(matrix.os, 'windows'))"
- run: make test-short
env:
GOARCH: ${{ matrix.arch }}
run: make test-short

integration-tests:
strategy:
matrix:
target: [test-kafka]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-go@v2.1.4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- env:
INTEGRATION: ${{ matrix.target }}
run: |
make ${{ matrix.target }}
35 changes: 2 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Q = $(if $(filter 1,$V),,@)
# ALL_MODULES includes ./* dirs (excludes . and ./build dir).
ALL_MODULES := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort )
# All directories with go.mod files related to opentelemetry library. Used for building, testing and linting.
ALL_GO_MOD_DIRS := $(filter-out $(EXCLUDEPKGS) $(BUILD_DIR), $(ALL_MODULES))
ALL_GO_MOD_DIRS := $(filter-out $(BUILD_DIR), $(ALL_MODULES))
# All directories sub-modules. Used for tagging.
SUBMODULES = $(filter-out ., $(ALL_GO_MOD_DIRS))

Expand All @@ -36,6 +36,7 @@ SUBMODULES = $(filter-out ., $(ALL_GO_MOD_DIRS))
goyek:
./goyek.sh


# Build and test targets

.PHONY: build
Expand All @@ -54,38 +55,6 @@ $(TEST_TARGETS): test
test tests:
${call for-all-modules,$(GO) test -timeout $(TIMEOUT)s $(ARGS) $(PKGS)}

.PHONY: test-kafka
test-kafka:
@set -e; \
docker network create confluent; \
docker run \
-d \
--rm \
--name zookeeper \
--network confluent \
-p 2181:2181 \
-e ZOOKEEPER_CLIENT_PORT=2181 \
confluentinc/cp-zookeeper:5.0.0; \
docker run \
-d \
--rm \
--name kafka \
--network confluent \
-p 9092:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
-e KAFKA_CREATE_TOPICS=gotest:1:1 \
-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
confluentinc/cp-kafka:5.0.0; \
( \
cd instrumentation/github.com/confluentinc/confluent-kafka-go/kafka/splunkkafka/test && \
$(GO) test -timeout $(TIMEOUT)s ./... ; \
); \
docker stop kafka; \
docker stop zookeeper; \
docker network rm confluent;

# Pre-release targets

.PHONY: add-tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ go 1.15

require (
github.com/confluentinc/confluent-kafka-go v1.7.0
github.com/ory/dockertest/v3 v3.8.0
github.com/signalfx/splunk-otel-go/instrumentation/github.com/confluentinc/confluent-kafka-go/kafka/splunkkafka v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0
go.opentelemetry.io/otel/sdk v1.0.0-RC3
go.opentelemetry.io/otel/trace v1.0.0
go.uber.org/goleak v1.1.11
)

replace github.com/signalfx/splunk-otel-go/instrumentation/github.com/confluentinc/confluent-kafka-go/kafka/splunkkafka => ../
Loading

0 comments on commit 2700b7c

Please sign in to comment.