Skip to content

Commit

Permalink
Use gotesplit for integration tests (#2576)
Browse files Browse the repository at this point in the history
* Use gotesplit for integration tests

* Use kindest/node:v1.26.0 image

* Add testutils tag

* Rename gotesplit to integration-test-split
  • Loading branch information
jeffreyc-splunk authored Feb 21, 2023
1 parent efc2e8b commit 697c4a4
Show file tree
Hide file tree
Showing 29 changed files with 145 additions and 8 deletions.
42 changes: 40 additions & 2 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ concurrency:

env:
GO_VERSION: "1.19.4"
GOTESPLIT_TOTAL: "10"

jobs:
docker-otelcol:
Expand Down Expand Up @@ -53,11 +54,46 @@ jobs:
name: otelcol
path: ./bin

integration-vet:
name: integration-vet
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [docker-otelcol]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- id: module-cache
uses: actions/cache@v3
env:
cache-name: cache-go-modules
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- uses: actions/download-artifact@v3
with:
name: otelcol
path: ./bin
- run: docker load -i ./bin/image.tar
- run: chmod a+x ./bin/*
- run: make integration-vet
env:
SPLUNK_OTEL_COLLECTOR_IMAGE: 'otelcol:latest'

integration-test:
name: integration-test
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [docker-otelcol]
strategy:
matrix:
GOTESPLIT_INDEX: [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -73,13 +109,15 @@ jobs:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
key: go-${{ github.job }}-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- uses: actions/download-artifact@v3
with:
name: otelcol
path: ./bin
- run: docker load -i ./bin/image.tar
- run: chmod a+x ./bin/*
- run: make integration-test
- run: make integration-test-split
env:
SPLUNK_OTEL_COLLECTOR_IMAGE: 'otelcol:latest'
GOTESPLIT_TOTAL: "${{ env.GOTESPLIT_TOTAL }}"
GOTESPLIT_INDEX: "${{ matrix.GOTESPLIT_INDEX }}"
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ ALL_PYTHON_DEPS := $(shell find . -type f \( -name "setup.py" -o -name "requirem
ALL_DOCKERFILES := $(shell find . -type f -name Dockerfile -exec dirname {} \; | grep -v '^./tests' | sort)
DEPENDABOT_PATH=./.github/dependabot.yml

GOTESPLIT_TOTAL?=1
GOTESPLIT_INDEX?=0

### TARGETS

.DEFAULT_GOAL := all
Expand All @@ -73,7 +76,7 @@ for-all:

.PHONY: integration-vet
integration-vet:
cd tests && go vet -tags integration,endtoend ./...
@set -e; cd tests && go vet -tags integration,endtoend,testutils ./... && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) -tags testutils -v -timeout 5m -count 1 ./...

.PHONY: integration-test
integration-test: integration-vet
Expand Down Expand Up @@ -225,3 +228,11 @@ endif
.PHONY: update-examples
update-examples:
cd examples && $(MAKE) update-examples

.PHONY: install-test-tools
install-test-tools:
cd ./tests/tools && go install github.com/Songmu/gotesplit/cmd/gotesplit

.PHONY: integration-test-split
integration-test-split: install-test-tools
@set -e; cd tests && gotesplit --total=$(GOTESPLIT_TOTAL) --index=$(GOTESPLIT_INDEX) ./... -- -p 1 $(BUILD_INFO_TESTS) --tags=integration -v -timeout 5m -count 1
2 changes: 1 addition & 1 deletion tests/testutils/collector_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build integration
//go:build testutils

package testutils

Expand Down
2 changes: 1 addition & 1 deletion tests/testutils/collector_process_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// 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.
//go:build integration
//go:build testutils

package testutils

Expand Down
2 changes: 1 addition & 1 deletion tests/testutils/collector_process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build integration
//go:build testutils

package testutils

Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package testutils

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package testutils

import (
Expand Down
1 change: 1 addition & 0 deletions tests/testutils/kubeutils/kind_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const kindConfigTemplate = `kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.26.0
{{- if .ExposedPorts }}
extraPortMappings:
{{- range $hostPort, $containerPort := .ExposedPorts }}
Expand Down
3 changes: 2 additions & 1 deletion tests/testutils/kubeutils/kind_cluster_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build integration
//go:build testutils

package kubeutils

Expand Down Expand Up @@ -66,6 +66,7 @@ func TestKindCluster(t *testing.T) {
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.26.0
extraPortMappings:
- containerPort: 12345
hostPort: %d
Expand Down
3 changes: 3 additions & 0 deletions tests/testutils/kubeutils/kind_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package kubeutils

import (
Expand All @@ -33,6 +35,7 @@ func TestKindClusterConfig(t *testing.T) {
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.26.0
extraPortMappings:
- containerPort: 2
hostPort: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package manifests

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/kubeutils/manifests/cluster_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package manifests

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/kubeutils/manifests/config_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package manifests

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/kubeutils/manifests/daemon_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package manifests

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/kubeutils/manifests/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package manifests

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/otlp_receiver_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package testutils

import (
Expand Down
2 changes: 1 addition & 1 deletion tests/testutils/subprocess/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build integration && !windows
//go:build testutils && !windows

package subprocess

Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/subprocess/subprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package subprocess

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/telemetry/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package telemetry

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/telemetry/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package telemetry

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/telemetry/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package telemetry

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/telemetry/pdata_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package telemetry

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/telemetry/pdata_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package telemetry

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/testutils/telemetry/pdata_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build testutils

package telemetry

import (
Expand Down
1 change: 1 addition & 0 deletions tests/tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
10 changes: 10 additions & 0 deletions tests/tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/signalfx/splunk-otel-collector/tests/tools

go 1.19

require github.com/Songmu/gotesplit v0.2.1

require (
github.com/jstemmer/go-junit-report v1.0.0 // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect
)
6 changes: 6 additions & 0 deletions tests/tools/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/Songmu/gotesplit v0.2.1 h1:qJFvR75nJpeKyMQFwyDtFrcc6zDWhrHAkks7DvM8oLo=
github.com/Songmu/gotesplit v0.2.1/go.mod h1:sVBfmLT26b1H5VhUpq8cRhCVK75GAmW9c8r2NiK0gzk=
github.com/jstemmer/go-junit-report v1.0.0 h1:8X1gzZpR+nVQLAht+L/foqOeX2l9DTZoaIPbEQHxsds=
github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4=
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
21 changes: 21 additions & 0 deletions tests/tools/tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright Splunk, Inc.
//
// 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.

//go:build tools
// +build tools

package tools

// based on https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/internal/tools/tools.go
import _ "github.com/Songmu/gotesplit"
15 changes: 15 additions & 0 deletions tests/tools/tools_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright Splunk, Inc.
//
// 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 tools

0 comments on commit 697c4a4

Please sign in to comment.