Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 7 additions & 30 deletions otel-integration/k8s-helm/e2e-test/agent_portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net"
"os"
"os/exec"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -107,38 +106,16 @@ func startPortForward(t *testing.T, kubeconfigPath, namespace, resource string,

waitForLocalPort(t, localPort, doneCh, &output)

monitorCtx, monitorCancel := context.WithCancel(context.Background())
var (
mu sync.Mutex
portForwardErr error
)

go func() {
cleanup := func() {
cancel()
select {
case err := <-doneCh:
if ctx.Err() == context.Canceled || monitorCtx.Err() != nil {
return
}
mu.Lock()
if err != nil {
portForwardErr = fmt.Errorf("kubectl port-forward exited unexpectedly: %w | output: %s", err, output.String())
} else {
portForwardErr = fmt.Errorf("kubectl port-forward exited unexpectedly without error. Output: %s", output.String())
case <-doneCh:
case <-time.After(5 * time.Second):
if cmd.Process != nil {
_ = cmd.Process.Kill()
}
t.Logf("port-forward output: %s", output.String())
mu.Unlock()
case <-monitorCtx.Done():
t.Logf("timed out waiting for kubectl port-forward to exit; output: %s", output.String())
}
}()

cleanup := func() {
monitorCancel()
cancel()
<-doneCh
mu.Lock()
err := portForwardErr
mu.Unlock()
require.NoError(t, err)
}
return localPort, cleanup
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// to a local OTLP sink and that resource attributes mark it as a cluster-collector.
func TestE2E_ClusterCollector_Metrics(t *testing.T) {
// Validate host endpoint detection vs env (parity with agent test)
require.Equal(t, xk8stest.HostEndpoint(t), os.Getenv("HOSTENDPOINT"), "HostEndpoints does not match env and detected")
requireHostEndpoint(t)

// Use kubeconfig from env if set (same as agent test)
kubeconfigPath := testKubeConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
)

func TestE2E_DeltaToCumulativePreset(t *testing.T) {
require.Equal(t, xk8stest.HostEndpoint(t), os.Getenv("HOSTENDPOINT"), "HostEndpoints does not match env and detected")
requireHostEndpoint(t)

kubeconfigPath := testKubeConfig
if kubeConfigFromEnv := os.Getenv(kubeConfigEnvVar); kubeConfigFromEnv != "" {
Expand Down
82 changes: 42 additions & 40 deletions otel-integration/k8s-helm/e2e-test/expected_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var expectedResourceAttributesKubeletstatreceiver = map[string]string{
"azure.vm.size": "",
"cloud.account.id": "",
"cloud.platform": "",
"cloud.provider": "azure",
"cloud.provider": "",
"cloud.region": "",
"cx.otel_integration.name": "coralogix-integration-helm",
"deployment.environment.name": "",
Expand All @@ -74,7 +74,7 @@ var expectedResourceAttributesKubeletstatreceiver = map[string]string{
"k8s.deployment.name": "",
"k8s.job.name": "",
"k8s.namespace.name": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"k8s.node.name": "",
"k8s.pod.name": "",
"k8s.pod.uid": "",
"k8s.statefulset.name": "",
Expand All @@ -88,15 +88,15 @@ var expectedResourceAttributesHostmetricsreceiver = map[string]string{
"azure.vm.scaleset.name": "",
"azure.vm.size": "",
"cloud.account.id": "",
"cloud.platform": "azure.vm",
"cloud.provider": "azure",
"cloud.platform": "",
"cloud.provider": "",
"cloud.region": "",
"cx.otel_integration.name": "coralogix-integration-helm",
"deployment.environment.name": "",
"host.id": "",
"host.name": "",
"k8s.cluster.name": "otel-integration-agent-e2e",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"k8s.node.name": "",
"os.type": "linux",
"process.command_line": "",
"process.command": "",
Expand Down Expand Up @@ -128,12 +128,12 @@ var expectedResourceAttributesK8sattributesprocessor = map[string]string{
"k8s.pod.name": "",
"k8s.namespace.name": "",
"k8s.daemonset.name": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"k8s.node.name": "",
"host.name": "",
"os.type": "linux",
"host.id": "",
"cloud.provider": "azure",
"cloud.platform": "azure.vm",
"cloud.provider": "",
"cloud.platform": "",
"cloud.region": "",
"cloud.account.id": "",
"azure.vm.name": "",
Expand Down Expand Up @@ -165,8 +165,8 @@ var expectedResourceAttributesService = map[string]string{
"host.name": "",
"os.type": "linux",
"host.id": "",
"cloud.provider": "azure",
"cloud.platform": "azure.vm",
"cloud.provider": "",
"cloud.platform": "",
"cloud.region": "",
"cloud.account.id": "",
"azure.vm.name": "",
Expand Down Expand Up @@ -196,12 +196,12 @@ var expectedResourceAttributesMemorylimiterprocessor = map[string]string{
"k8s.pod.name": "",
"k8s.namespace.name": "",
"k8s.daemonset.name": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"k8s.node.name": "",
"host.name": "",
"os.type": "linux",
"host.id": "",
"cloud.provider": "azure",
"cloud.platform": "azure.vm",
"cloud.provider": "",
"cloud.platform": "",
"cloud.region": "",
"cloud.account.id": "",
"azure.vm.name": "",
Expand Down Expand Up @@ -241,12 +241,12 @@ var expectedResourceAttributesSpanmetricsconnector = map[string]string{
"k8s.pod.name": "",
"k8s.namespace.name": "",
"k8s.daemonset.name": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"k8s.node.name": "",
"host.name": "",
"os.type": "linux",
"host.id": "",
"cloud.provider": "azure",
"cloud.platform": "azure.vm",
"cloud.provider": "",
"cloud.platform": "",
"cloud.region": "",
"cloud.account.id": "",
"azure.vm.name": "",
Expand All @@ -266,9 +266,9 @@ var expectedResourceAttributesLoadscraper = map[string]string{
"host.name": "",
"os.type": "linux",
"host.id": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"cloud.provider": "azure",
"cloud.platform": "azure.vm",
"k8s.node.name": "",
"cloud.provider": "",
"cloud.platform": "",
"cloud.region": "",
"cloud.account.id": "",
"azure.vm.name": "",
Expand All @@ -286,7 +286,7 @@ var expectedResourceAttributesPrometheusreceiver = map[string]string{
"azure.vm.size": "",
"cloud.account.id": "",
"cloud.platform": "",
"cloud.provider": "azure",
"cloud.provider": "",
"cloud.region": "",
"cx.otel_integration.name": "coralogix-integration-helm",
"deployment.environment.name": "",
Expand All @@ -298,7 +298,7 @@ var expectedResourceAttributesPrometheusreceiver = map[string]string{
"k8s.daemonset.name": "",
"k8s.deployment.name": "",
"k8s.namespace.name": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"k8s.node.name": "",
"k8s.pod.ip": "",
"k8s.pod.name": "",
"net.host.name": "",
Expand Down Expand Up @@ -327,9 +327,9 @@ var expectedResourceAttributesProcessscraper = map[string]string{
"host.name": "",
"os.type": "linux",
"host.id": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"cloud.provider": "azure",
"cloud.platform": "azure.vm",
"k8s.node.name": "",
"cloud.provider": "",
"cloud.platform": "",
"cloud.region": "",
"cloud.account.id": "",
"azure.vm.name": "",
Expand All @@ -350,7 +350,7 @@ var expectedResourceAttributesProcessorhelper = map[string]string{
"server.port": "",
"url.scheme": "",
"cx.agent.type": "",
"k8s.node.name": "otel-integration-agent-e2e-control-plane",
"k8s.node.name": "",
"service.version": "",
"k8s.cluster.name": "otel-integration-agent-e2e",
"cx.otel_integration.name": "coralogix-integration-helm",
Expand All @@ -361,8 +361,8 @@ var expectedResourceAttributesProcessorhelper = map[string]string{
"host.name": "",
"os.type": "linux",
"host.id": "",
"cloud.provider": "azure",
"cloud.platform": "azure.vm",
"cloud.provider": "",
"cloud.platform": "",
"cloud.region": "",
"cloud.account.id": "",
"azure.vm.name": "",
Expand Down Expand Up @@ -503,7 +503,6 @@ var expectedMetrics map[string]bool = map[string]bool{
"promhttp_metric_handler_errors": false,
"otelcol_fileconsumer_open_files_ratio": false,
"otelcol_fileconsumer_reading_files_ratio": false,
"otelcol_otelsvc_k8s_ip_lookup_miss_ratio": false,
"otelcol_otelsvc_k8s_pod_added_ratio": false,
"otelcol_otelsvc_k8s_pod_table_size_ratio": false,
"otelcol_otelsvc_k8s_pod_updated_ratio": false,
Expand All @@ -522,6 +521,8 @@ var optionalExpectedMetrics = map[string]bool{
"otelcol_exporter_in_flight_requests": false,
// Added in newer collector versions (0.145.0+): internal k8s pod association metric.
"otelcol.k8s.pod.association": false,
// The old-format k8s IP lookup miss counter is only emitted if pod association misses.
"otelcol_otelsvc_k8s_ip_lookup_miss_ratio": false,
// Host filesystem metrics are valid but may not be emitted in containerized CI environments.
"system.filesystem.inodes.usage": false,
"system.filesystem.usage": false,
Expand Down Expand Up @@ -553,18 +554,19 @@ var expectedHostEntityAttributes = map[string]expectedValue{
"host.cpu.model.name": newExpectedValue(attributeMatchTypeExist, ""),
"host.cpu.stepping": newExpectedValue(attributeMatchTypeExist, ""),
"host.cpu.vendor.id": newExpectedValue(attributeMatchTypeExist, ""),
"host.id": newExpectedValue(attributeMatchTypeRegex, "^[a-f0-9-]{32,36}$"),
"host.ip": newExpectedValue(attributeMatchTypeExist, ""),
"host.mac": newExpectedValue(attributeMatchTypeExist, ""),
"host.name": newExpectedValue(attributeMatchTypeExist, ""),
"k8s.cluster.name": newExpectedValue(attributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.node.name": newExpectedValue(attributeMatchTypeOptional, ""),
"os.description": newExpectedValue(attributeMatchTypeRegex, "^Linux .* (aarch64|x86_64)$"),
"os.type": newExpectedValue(attributeMatchTypeEqual, "linux"),
"otel.entity.event.type": newExpectedValue(attributeMatchTypeEqual, "entity_state"),
"otel.entity.id": newExpectedValue(attributeMatchTypeExist, ""),
"otel.entity.interval": newExpectedValue(attributeMatchTypeEqual, "300000"),
"otel.entity.type": newExpectedValue(attributeMatchTypeEqual, "host"),
// Local kind reports UUID-like host IDs; EKS reports EC2 instance IDs.
"host.id": newExpectedValue(attributeMatchTypeRegex, "^([a-f0-9-]{32,36}|i-[a-f0-9]+)$"),
"host.ip": newExpectedValue(attributeMatchTypeExist, ""),
"host.mac": newExpectedValue(attributeMatchTypeExist, ""),
"host.name": newExpectedValue(attributeMatchTypeExist, ""),
"k8s.cluster.name": newExpectedValue(attributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.node.name": newExpectedValue(attributeMatchTypeOptional, ""),
"os.description": newExpectedValue(attributeMatchTypeRegex, "^Linux .* (aarch64|x86_64)$"),
"os.type": newExpectedValue(attributeMatchTypeEqual, "linux"),
"otel.entity.event.type": newExpectedValue(attributeMatchTypeEqual, "entity_state"),
"otel.entity.id": newExpectedValue(attributeMatchTypeExist, ""),
"otel.entity.interval": newExpectedValue(attributeMatchTypeEqual, "300000"),
"otel.entity.type": newExpectedValue(attributeMatchTypeEqual, "host"),

// Optional attributes (may be present in cloud environments)
"azure.resourcegroup.name": newExpectedValue(attributeMatchTypeOptional, ""),
Expand Down
Loading
Loading