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

Separate smart agent and integration tests #4531

Merged
merged 12 commits into from Mar 26, 2024
149 changes: 107 additions & 42 deletions .github/workflows/integration-test.yml
Expand Up @@ -101,6 +101,109 @@ jobs:
runs-on: ubuntu-20.04
needs: [docker-otelcol]
services:
# Cassandra image for collectd-cassandra test:
cassandra:
image: quay.io/splunko11ytest/cassandra:latest
ports:
- "7199:7199"
# httpd_basicauth image for lightprometheus test
httpd_basicauth:
image: quay.io/splunko11ytest/httpd_basicauth:latest
ports:
- "8001:80"
kong:
image: quay.io/splunko11ytest/kong:latest
ports:
- "18001:8001"
oracle:
image: quay.io/splunko11ytest/oracle:latest
ports:
- "1521:1521"
postgres:
image: quay.io/splunko11ytest/postgres:latest
ports:
- "15432:5432"
redis_server:
image: quay.io/splunko11ytest/redis_server:latest
ports:
- "6379:6379"
mysql:
image: quay.io/splunko11ytest/mysql:latest
ports:
- "3306:3306"
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- uses: actions/download-artifact@v4
with:
name: otelcol-${{ matrix.ARCH }}
path: ./bin
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- run: docker load -i ./bin/image.tar
- run: chmod a+x ./bin/*
- uses: shogo82148/actions-setup-redis@v1
with:
auto-start: false
redis-port: "6379"
- run: redis-cli ping
- run: redis-cli set tempkey tempvalue
- name: Run Integration Test
run: |
set -o pipefail
make integration-test 2>&1 | tee ${{ github.job }}-${{ github.run_id }}.out
exit_status=${PIPESTATUS[0]}
echo "Exit status: $exit_status"
exit $exit_status
env:
SPLUNK_OTEL_COLLECTOR_IMAGE: 'otelcol:latest'
# The Integration Test output is extremely large so we upload it as an artifact
- name: Upload Integration Test Output as Artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ github.job }}-${{ github.run_id }}-${{ matrix.ARCH }}.out
path: ${{ github.job }}-${{ github.run_id }}-${{ matrix.ARCH }}.out
retention-days: 5

smartagent-integration-test:
name: smartagent-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]
services:
# ActiveMQ image for collectd-activemq test:
activemq:
image: quay.io/splunko11ytest/activemq:latest
ports:
- "1099:1099"
# Apache image for collectd-apache test
apache:
image: quay.io/splunko11ytest/apache
ports:
- "18080:80"
# Cassandra image for collectd-cassandra test:
cassandra:
image: quay.io/splunko11ytest/cassandra:latest
ports:
- "7199:7199"
# Couchbase image for collectd-couchbase test:
couchbase:
image: quay.io/splunko11ytest/couchbase:latest
ports:
- "8091:8091"
# Tomcat image for collectd-tomcat test:
tomcat:
image: tomcat
Expand Down Expand Up @@ -167,36 +270,16 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Cassandra image for collectd-cassandra test:
cassandra:
image: quay.io/splunko11ytest/cassandra:latest
ports:
- "7199:7199"
# Nginx image for collectd-nginx test:
nginx:
image: quay.io/splunko11ytest/nginx:latest
ports:
- "8123:80"
# Couchbase image for collectd-couchbase test:
couchbase:
image: quay.io/splunko11ytest/couchbase:latest
ports:
- "8091:8091"
# ActiveMQ image for collectd-activemq test:
activemq:
image: quay.io/splunko11ytest/activemq:latest
ports:
- "1099:1099"
# Haproxy image for haproxy test:
haproxy:
image: quay.io/splunko11ytest/haproxy:latest
ports:
- "8082:8080"
# Apache image for collectd-apache test
apache:
image: quay.io/splunko11ytest/apache
ports:
- "18080:80"
# httpd image for prometheus-exporter test
httpd:
image: quay.io/splunko11ytest/httpd:latest
Expand All @@ -207,24 +290,6 @@ jobs:
image: quay.io/splunko11ytest/httpd_basicauth:latest
ports:
- "8001:80"
kong:
image: quay.io/splunko11ytest/kong:latest
ports:
- "18001:8001"
oracle:
image: quay.io/splunko11ytest/oracle:latest
ports:
- "1521:1521"
postgres:
image: quay.io/splunko11ytest/postgres:latest
ports:
- "15432:5432"
redis_client:
image: quay.io/splunko11ytest/redis_client:latest
redis_server:
image: quay.io/splunko11ytest/redis_server:latest
ports:
- "6379:6379"
solr:
image: quay.io/splunko11ytest/solr:latest
ports:
Expand Down Expand Up @@ -259,7 +324,7 @@ jobs:
- name: Run Integration Test
run: |
set -o pipefail
make integration-test 2>&1 | tee ${{ github.job }}-${{ github.run_id }}.out
make smartagent-integration-test 2>&1 | tee ${{ github.job }}-${{ github.run_id }}.out
exit_status=${PIPESTATUS[0]}
echo "Exit status: $exit_status"
exit $exit_status
Expand All @@ -270,6 +335,6 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ github.job }}-${{ github.run_id }}.out
path: ${{ github.job }}-${{ github.run_id }}.out
retention-days: 5
name: smartagent-${{ github.job }}-${{ github.run_id }}-${{ matrix.ARCH }}.out
path: smartagent-${{ github.job }}-${{ github.run_id }}-${{ matrix.ARCH }}.out
retention-days: 5
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -72,9 +72,13 @@ integration-vet:
@set -e; cd tests && go vet -tags integration,testutilsintegration,zeroconfig,testutils ./... && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) -tags testutils,testutilsintegration -v -timeout 5m -count 1 ./...

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

.PHONY: smartagent-integration-test
smartagent-integration-test:
@set -e; cd tests && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) --tags=smartagent_integration -v -timeout 5m -count 1 ./...

.PHONY: test-with-cover
test-with-cover:
@echo Verifying that all packages have test files to count in coverage
Expand Down
12 changes: 3 additions & 9 deletions tests/general/container_test.go
Expand Up @@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build integration
//go:build smartagent_integration

package tests

import (
"fmt"
"path/filepath"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -177,13 +176,8 @@ func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) {
func TestNonDefaultGIDCanAccessPythonInAgentBundle(t *testing.T) {
testutils.SkipIfNotContainerTest(t)
testutils.AssertAllMetricsReceived(t, "solr.yaml", "solr_config.yaml",
[]testutils.Container{
testutils.NewContainer().WithContext(
filepath.Join("..", "receivers", "smartagent", "collectd-solr", "testdata", "server"),
).WithExposedPorts("8983:8983").WithName(
"solr",
).WillWaitForPorts("8983").WillWaitForLogs("Time spent:"),
}, []testutils.CollectorBuilder{
nil,
[]testutils.CollectorBuilder{
func(collector testutils.Collector) testutils.Collector {
cc := collector.(*testutils.CollectorContainer)
cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890")
Expand Down
2 changes: 1 addition & 1 deletion tests/receivers/mysql/testdata/all_metrics_config.yaml
Expand Up @@ -3,7 +3,7 @@ receivers:
endpoint: "${MYSQLDB_ENDPOINT}"
username: "${MYSQLDB_USERNAME}"
password: "${MYSQLDB_PASSWORD}"
database: otel
database: testdb
tls:
insecure: true
statement_events:
Expand Down
8 changes: 2 additions & 6 deletions tests/receivers/redis/bundled_test.go
Expand Up @@ -18,25 +18,21 @@ package tests

import (
"fmt"
"path"
"runtime"
"testing"

"github.com/signalfx/splunk-otel-collector/tests/testutils"
)

func TestRedisDockerObserver(t *testing.T) {
t.Skip("Discovery mode picks up other Docker containers running, making the test fail.")
testutils.SkipIfNotContainerTest(t)
if runtime.GOOS == "darwin" {
t.Skip("unable to share sockets between mac and d4m vm: https://github.com/docker/for-mac/issues/483#issuecomment-758836836")
}

server := testutils.NewContainer().WithContext(path.Join(".", "testdata", "server")).WithExposedPorts("6379:6379").WithNetworks("redis_network").WithName("redis-server").WillWaitForLogs("Ready to accept connections")
client := testutils.NewContainer().WithContext(path.Join(".", "testdata", "client")).WithName("redis-client").WithNetworks("redis_network").WillWaitForLogs("redis client started")
containers := []testutils.Container{server, client}

testutils.AssertAllMetricsReceived(t, "all_server_bundled.yaml", "otlp_exporter.yaml",
containers, []testutils.CollectorBuilder{
nil, []testutils.CollectorBuilder{
func(c testutils.Collector) testutils.Collector {
cc := c.(*testutils.CollectorContainer)
cc.Container = cc.Container.WithBinds("/var/run/docker.sock:/var/run/docker.sock:ro")
Expand Down
4 changes: 0 additions & 4 deletions tests/receivers/redis/redisreceiver_test.go
Expand Up @@ -22,10 +22,6 @@ import (
"github.com/signalfx/splunk-otel-collector/tests/testutils"
)

func TestRedisReceiverProvidesAllMetrics(t *testing.T) {
testutils.AssertAllMetricsReceived(t, "all.yaml", "all_metrics_config.yaml", nil, nil)
}

func TestRedisReceiverProvidesAllMetricsWithServer(t *testing.T) {
testutils.AssertAllMetricsReceived(t, "all_server.yaml", "all_metrics_config.yaml", nil, nil)
}
60 changes: 0 additions & 60 deletions tests/receivers/redis/testdata/resource_metrics/all.yaml

This file was deleted.

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 smartagent_integration

package tests

Expand Down
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 smartagent_integration

package tests

Expand Down
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 smartagent_integration

package tests

Expand Down
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 smartagent_integration

package tests

Expand Down
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 smartagent_integration

package tests

Expand Down