Skip to content

Commit

Permalink
reduce flaky test run (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinja2 authored Mar 6, 2025
1 parent 1f4ed43 commit a1490ae
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions functional_tests/k8sevents/k8sevents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package k8sevents

import (
"bytes"
"context"
"fmt"
"os"
"path/filepath"
Expand All @@ -19,13 +18,10 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/plogtest"
k8stest "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/xk8stest"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/splunkhecreceiver"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/receiver/receivertest"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/kube"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -108,6 +104,7 @@ func Test_K8SEvents(t *testing.T) {
plogtest.IgnoreLogRecordAttributeValue("k8s.object.uid"),
plogtest.IgnoreLogRecordAttributeValue("k8s.pod.uid"),
plogtest.IgnoreLogRecordAttributeValue("k8s.object.resource_version"),
plogtest.IgnoreResourceAttributeValue("com.splunk.index"), // this is flaky, the index can be the value from pod annotation due to the k8sattributes processor in the pipeline or main
plogtest.IgnoreResourceLogsOrder(),
plogtest.IgnoreScopeLogsOrder(),
plogtest.IgnoreLogRecordsOrder(),
Expand Down Expand Up @@ -240,23 +237,6 @@ metadata:
`)
}

func setupHECLogsReceiver(t *testing.T, port int) *consumertest.LogsSink {
f := splunkhecreceiver.NewFactory()
cfg := f.CreateDefaultConfig().(*splunkhecreceiver.Config)
cfg.Endpoint = fmt.Sprintf("0.0.0.0:%d", internal.HECLogsReceiverPort)

receiver := new(consumertest.LogsSink)
rcvr, err := f.CreateLogs(context.Background(), receivertest.NewNopSettings(f.Type()), cfg, receiver)
require.NoError(t, err)

require.NoError(t, rcvr.Start(context.Background(), componenttest.NewNopHost()))
t.Cleanup(func() {
require.NoError(t, rcvr.Shutdown(context.Background()))
})

return receiver
}

func deleteObject(t *testing.T, k8sClient *k8stest.K8sClient, objYAML string) {
obj := &unstructured.Unstructured{}
err := yaml.Unmarshal([]byte(objYAML), obj)
Expand Down

0 comments on commit a1490ae

Please sign in to comment.