Skip to content

Commit

Permalink
[chore][cmd/otelcontribcol] Re-enable exporters and receivers tests o…
Browse files Browse the repository at this point in the history
…n Windows (#29532)

**Description:**
Last part to re-enable all Windows tests disabled due to issue #11451.

Notes:

* The default test timeout is not enough for the `cmd` GROUP on CI and
it was increased to 1200s just for this group on Windows, the default
stays at 300s (which was also enough for my local run).
* The `fileexporter` life cycle test indicates an issue that shouldn't
affect most usages of the collector: if the same configuration is used
to export multiple signals it opens one file handle for each signal but
just closes the one of them at shutdown (the helper only executes the
shutdown for the one signal). This is an issue for the test because
during cleanup the testing attempts to delete the test folder and there
are still handles open to the file that lives inside it. This shouldn't
be a problem for collector users. That said the exporter should close
all file handles on shutdown. I will take look at what can be done to
correct this behavior.
* Fixed a minor typo on the receivers test that affected many lines.

**Link to tracking Issue:**
Fix #28679 - last part.

**Testing:**
Local run and GH CI on my fork with `Run Windows` label.

**Documentation:**
N/A
  • Loading branch information
pjanotti authored Dec 1, 2023
1 parent d7b940b commit 5343a85
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 71 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
~\go\pkg\mod
~\AppData\Local\go-build
key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }}
- if: matrix.group == 'cmd'
name: Increasing GOTEST_TIMEOUT for group 'cmd'
run: echo "GOTEST_TIMEOUT=1200s" >> $Env:GITHUB_ENV
- name: Run Unit tests
run: make -j2 gotest GROUP=${{ matrix.group }}
windows-unittest:
Expand Down
3 changes: 2 additions & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ SRC_ROOT := $(shell git rev-parse --show-toplevel)

# build tags required by any component should be defined as an independent variables and later added to GO_BUILD_TAGS below
GO_BUILD_TAGS=""
GOTEST_OPT?= -race -timeout 300s -parallel 4 --tags=$(GO_BUILD_TAGS)
GOTEST_TIMEOUT?= 300s
GOTEST_OPT?= -race -timeout $(GOTEST_TIMEOUT) -parallel 4 --tags=$(GO_BUILD_TAGS)
GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -run=Integration
Expand Down
10 changes: 4 additions & 6 deletions cmd/otelcontribcol/exporters_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Skip tests on Windows temporarily, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/11451
//go:build !windows
// +build !windows

package main

import (
"context"
"errors"
"path/filepath"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -104,9 +101,10 @@ func TestDefaultExporters(t *testing.T) {
exporter: "file",
getConfigFn: func() component.Config {
cfg := expFactories["file"].CreateDefaultConfig().(*fileexporter.Config)
cfg.Path = filepath.Join(t.TempDir(), "random.file")
cfg.Path = filepath.Join(t.TempDir(), "file.exporter.random.file")
return cfg
},
skipLifecycle: runtime.GOOS == "windows", // On Windows not all handles are closed when the exporter is shutdown.
},
{
exporter: "kafka",
Expand Down Expand Up @@ -415,7 +413,7 @@ func TestDefaultExporters(t *testing.T) {
cfg := expFactories["f5cloud"].CreateDefaultConfig().(*f5cloudexporter.Config)
cfg.Endpoint = "http://" + endpoint
cfg.Source = "magic-source"
cfg.AuthConfig.CredentialFile = filepath.Join(t.TempDir(), "random.file")
cfg.AuthConfig.CredentialFile = filepath.Join(t.TempDir(), "f5cloud.exporter.random.file")
// disable queue/retry to validate passing the test data synchronously
cfg.QueueSettings.Enabled = false
cfg.RetrySettings.Enabled = false
Expand Down
131 changes: 67 additions & 64 deletions cmd/otelcontribcol/receivers_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Skip tests on Windows temporarily, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/11451
//go:build !windows
// +build !windows

package main

import (
Expand Down Expand Up @@ -41,6 +37,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver"
)

func TestDefaultReceivers(t *testing.T) {
Expand All @@ -50,13 +47,13 @@ func TestDefaultReceivers(t *testing.T) {
rcvrFactories := allFactories.Receivers

tests := []struct {
getConfigFn getReceiverConfigFn
receiver component.Type
skipLifecyle bool
getConfigFn getReceiverConfigFn
receiver component.Type
skipLifecycle bool
}{
{
receiver: "active_directory_ds",
skipLifecyle: true, // Requires a running windows service
receiver: "active_directory_ds",
skipLifecycle: true, // Requires a running windows service
},
{
receiver: "aerospike",
Expand All @@ -79,18 +76,18 @@ func TestDefaultReceivers(t *testing.T) {
{
receiver: "awscontainerinsightreceiver",
// TODO: skipped since it will only function in a container environment with procfs in expected location.
skipLifecyle: true,
skipLifecycle: true,
},
{
receiver: "awsecscontainermetrics",
skipLifecyle: true, // Requires container metaendpoint to be running
receiver: "awsecscontainermetrics",
skipLifecycle: true, // Requires container metaendpoint to be running
},
{
receiver: "awsfirehose",
},
{
receiver: "awsxray",
skipLifecyle: true, // Requires AWS endpoint to check identity to run
receiver: "awsxray",
skipLifecycle: true, // Requires AWS endpoint to check identity to run
},
{
receiver: "azureblob",
Expand All @@ -100,7 +97,7 @@ func TestDefaultReceivers(t *testing.T) {
cfg.EventHub.EndPoint = "DefaultEndpointsProtocol=http;SharedAccessKeyName=secret;SharedAccessKey=secret;Endpoint=test.test"
return cfg
},
skipLifecyle: true, // Requires Azure event hub to run
skipLifecycle: true, // Requires Azure event hub to run
},
{
receiver: "azureeventhub",
Expand All @@ -109,7 +106,7 @@ func TestDefaultReceivers(t *testing.T) {
cfg.Connection = "Endpoint=sb://example.com/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=superSecret1234=;EntityPath=hubName"
return cfg
},
skipLifecyle: true, // Requires Azure event hub to run
skipLifecycle: true, // Requires Azure event hub to run
},
{
receiver: "azuremonitor",
Expand All @@ -121,7 +118,7 @@ func TestDefaultReceivers(t *testing.T) {
cfg.ClientSecret = "client_secret"
return cfg
},
skipLifecyle: true, // Requires Azure event hub to run
skipLifecycle: true, // Requires Azure event hub to run
},
{
receiver: "bigip",
Expand All @@ -133,15 +130,15 @@ func TestDefaultReceivers(t *testing.T) {
cfg.Endpoint = "0.0.0.0:0"
return cfg
},
skipLifecyle: true, // Panics after test have completed, requires a wait group
skipLifecycle: true, // Panics after test have completed, requires a wait group
},
{
receiver: "cloudflare",
skipLifecyle: true,
receiver: "cloudflare",
skipLifecycle: true,
},
{
receiver: "cloudfoundry",
skipLifecyle: true, // Requires UAA (auth) endpoint to run
receiver: "cloudfoundry",
skipLifecycle: true, // Requires UAA (auth) endpoint to run
},
{
receiver: "chrony",
Expand All @@ -166,8 +163,8 @@ func TestDefaultReceivers(t *testing.T) {
},
},
{
receiver: "docker_stats",
skipLifecyle: true,
receiver: "docker_stats",
skipLifecycle: true,
},
{
receiver: "elasticsearch",
Expand All @@ -184,8 +181,8 @@ func TestDefaultReceivers(t *testing.T) {
},
},
{
receiver: "file",
skipLifecyle: true, // Requires an existing JSONL file
receiver: "file",
skipLifecycle: true, // Requires an existing JSONL file
},
{
receiver: "filestats",
Expand All @@ -200,8 +197,8 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "googlecloudspanner",
},
{
receiver: "googlecloudpubsub",
skipLifecyle: true, // Requires a pubsub subscription
receiver: "googlecloudpubsub",
skipLifecycle: true, // Requires a pubsub subscription
},
{
receiver: "haproxy",
Expand All @@ -216,15 +213,15 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "influxdb",
},
{
receiver: "iis",
skipLifecyle: true, // Requires a running windows process
receiver: "iis",
skipLifecycle: true, // Requires a running windows process
},
{
receiver: "jaeger",
},
{
receiver: "jmx",
skipLifecyle: true, // Requires a running instance with JMX
receiver: "jmx",
skipLifecycle: true, // Requires a running instance with JMX
getConfigFn: func() component.Config {
cfg := jmxreceiver.NewFactory().CreateDefaultConfig().(*jmxreceiver.Config)
cfg.Endpoint = "localhost:1234"
Expand All @@ -233,31 +230,31 @@ func TestDefaultReceivers(t *testing.T) {
},
},
{
receiver: "journald",
skipLifecyle: runtime.GOOS != "linux",
receiver: "journald",
skipLifecycle: runtime.GOOS != "linux",
},
{
receiver: "k8s_events",
skipLifecyle: true, // need a valid Kubernetes host and port
receiver: "k8s_events",
skipLifecycle: true, // need a valid Kubernetes host and port
},
{
receiver: "k8sobjects",
skipLifecyle: true, // need a valid Kubernetes host and port
receiver: "k8sobjects",
skipLifecycle: true, // need a valid Kubernetes host and port
},
{
receiver: "kafka",
skipLifecyle: true, // TODO: It needs access to internals to successful start.
receiver: "kafka",
skipLifecycle: true, // TODO: It needs access to internals to successful start.
},
{
receiver: "kafkametrics",
},
{
receiver: "k8s_cluster",
skipLifecyle: true, // Requires access to the k8s host and port in order to run
receiver: "k8s_cluster",
skipLifecycle: true, // Requires access to the k8s host and port in order to run
},
{
receiver: "kubeletstats",
skipLifecyle: true, // Requires access to certificates to auth against kubelet
receiver: "kubeletstats",
skipLifecycle: true, // Requires access to certificates to auth against kubelet
},
{
receiver: "loki",
Expand All @@ -266,8 +263,8 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "memcached",
},
{
receiver: "mongodb",
skipLifecyle: true, // Causes tests to timeout
receiver: "mongodb",
skipLifecycle: true, // Causes tests to timeout
},
{
receiver: "mongodbatlas",
Expand All @@ -287,8 +284,8 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "nsxt",
},
{
receiver: "opencensus",
skipLifecyle: true, // TODO: Usage of CMux doesn't allow proper shutdown.
receiver: "opencensus",
skipLifecycle: true, // TODO: Usage of CMux doesn't allow proper shutdown.
},
{
receiver: "oracledb",
Expand All @@ -305,8 +302,8 @@ func TestDefaultReceivers(t *testing.T) {
},
},
{
receiver: "podman_stats",
skipLifecyle: true, // Requires a running podman daemon
receiver: "podman_stats",
skipLifecycle: true, // Requires a running podman daemon
},
{
receiver: "postgresql",
Expand All @@ -324,8 +321,8 @@ func TestDefaultReceivers(t *testing.T) {
},
},
{
receiver: "pulsar",
skipLifecyle: true, // TODO It requires a running pulsar instance to start successfully.
receiver: "pulsar",
skipLifecycle: true, // TODO It requires a running pulsar instance to start successfully.
},
{
receiver: "rabbitmq",
Expand Down Expand Up @@ -388,19 +385,20 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "sqlquery",
},
{
receiver: "sqlserver",
skipLifecyle: true, // Requires a running windows process
receiver: "sqlserver",
skipLifecycle: true, // Requires a running windows process
},
{
receiver: "sshcheck",
receiver: "sshcheck",
skipLifecycle: runtime.GOOS == "windows",
},

{
receiver: "statsd",
},
{
receiver: "wavefront",
skipLifecyle: true, // Depends on carbon receiver to be running correctly
receiver: "wavefront",
skipLifecycle: true, // Depends on carbon receiver to be running correctly
},
{
receiver: "webhookevent",
Expand All @@ -411,12 +409,17 @@ func TestDefaultReceivers(t *testing.T) {
},
},
{
receiver: "windowseventlog",
skipLifecyle: true, // Requires a running windows process
receiver: "windowseventlog",
skipLifecycle: runtime.GOOS != "windows",
getConfigFn: func() component.Config {
cfg := rcvrFactories["windowseventlog"].CreateDefaultConfig().(*windowseventlogreceiver.WindowsLogConfig)
cfg.InputConfig.Channel = "Application"
return cfg
},
},
{
receiver: "windowsperfcounters",
skipLifecyle: true, // Requires a running windows process
receiver: "windowsperfcounters",
skipLifecycle: runtime.GOOS != "windows",
},
{
receiver: "zipkin",
Expand Down Expand Up @@ -454,8 +457,8 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "vcenter",
},
{
receiver: "solace",
skipLifecyle: true, // Requires a solace broker to connect to
receiver: "solace",
skipLifecycle: true, // Requires a solace broker to connect to
},
}

Expand All @@ -469,7 +472,7 @@ func TestDefaultReceivers(t *testing.T) {
verifyReceiverShutdown(t, factory, tt.getConfigFn)
})
t.Run("lifecycle", func(t *testing.T) {
if tt.skipLifecyle {
if tt.skipLifecycle {
t.SkipNow()
}
verifyReceiverLifecycle(t, factory, tt.getConfigFn)
Expand Down

0 comments on commit 5343a85

Please sign in to comment.