Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up
Browse files Browse the repository at this point in the history
ryantanjunming committed Nov 19, 2024
1 parent 8888cc2 commit 95bcd64
Showing 2 changed files with 9 additions and 52 deletions.
23 changes: 9 additions & 14 deletions otel-integration/k8s-helm/e2e-test/main_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
package e2e

import (
"fmt"
"os"
"path/filepath"
"strings"
@@ -24,8 +23,6 @@ import (
func TestE2E_Agent(t *testing.T) {

//Check if the HOST_ENDPOINT is set
fmt.Println("Detected HostEndpoint: " + k8stest.HostEndpoint(t))
fmt.Println("Env HostEndpoint: " + os.Getenv("HOSTENDPOINT"))
require.Equal(t, k8stest.HostEndpoint(t), os.Getenv("HOSTENDPOINT"), "HostEndpoints does not match env and detected")

k8sDir := filepath.Join("k8s")
@@ -51,28 +48,26 @@ func TestE2E_Agent(t *testing.T) {
shutdownSink := StartUpSinks(t, metricsConsumer, tracesConsumer)
defer shutdownSink()

nodeIP := os.Getenv("NODE_IP")
fmt.Print("Node IP: ", nodeIP)
testID := uuid.NewString()[:8]
createTeleOpts := &k8stest.TelemetrygenCreateOpts{
ManifestsDir: filepath.Join(k8sDir, "telemetrygen"),
TestID: testID,
OtlpEndpoint: fmt.Sprintf("%s:4317", nodeIP),
OtlpEndpoint: "", //unused
DataTypes: []string{"traces"},
}
//defer delete and check
_, telemetryGenObjInfos := k8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
// defer func() {
// for _, obj := range {
// require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
// }
// }()

telemetryGenObjs, telemetryGenObjInfos := k8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
defer func() {
for _, obj := range telemetryGenObjs {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
}
}()

for _, info := range telemetryGenObjInfos {
k8stest.WaitForTelemetryGenToStart(t, k8sClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType)
}

// WaitForMetrics(t, 5, metricsConsumer)
WaitForMetrics(t, 5, metricsConsumer)
WaitForTraces(t, 5, tracesConsumer)

checkResourceMetrics(t, metricsConsumer.AllMetrics())
38 changes: 0 additions & 38 deletions otel-integration/k8s-helm/e2e-test/sinks.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ import (
"fmt"
"regexp"
"slices"
"strconv"
"testing"
"time"

@@ -44,32 +43,6 @@ func NewExpectedValue(mode ExpectedValueMode, value string) ExpectedValue {
}
}

type ReceiverSinks struct {
Metrics *MetricSinkConfig
Traces *TraceSinkConfig
Logs *LogSinkConfig
}

type MetricSinkConfig struct {
Ports *ReceiverPorts
Consumer *consumertest.MetricsSink
}

type TraceSinkConfig struct {
Ports *ReceiverPorts
Consumer *consumertest.TracesSink
}

type LogSinkConfig struct {
Ports *ReceiverPorts
Consumer *consumertest.LogsSink
}

type ReceiverPorts struct {
Grpc int
Http int
}

func StartUpSinks(t *testing.T, mc *consumertest.MetricsSink, tc *consumertest.TracesSink) func() {
f := otlpreceiver.NewFactory()
cfg := f.CreateDefaultConfig().(*otlpreceiver.Config)
@@ -87,17 +60,6 @@ func StartUpSinks(t *testing.T, mc *consumertest.MetricsSink, tc *consumertest.T
}
}

func setupReceiverPorts(cfg *otlpreceiver.Config, ports *ReceiverPorts) {
if ports != nil {
cfg.GRPC.NetAddr.Endpoint = "0.0.0.0:" + strconv.Itoa(ports.Grpc)
cfg.HTTP.Endpoint = "0.0.0.0:" + strconv.Itoa(ports.Http)
} else {
fmt.Println("Receiver ports not set, using default ports")
cfg.GRPC.NetAddr.Endpoint = "0.0.0.0:4317"
cfg.HTTP.Endpoint = "0.0.0.0:4318"
}
}

func WaitForMetrics(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) {
timeoutSeconds := 180 // 3 minutes
require.Eventuallyf(t, func() bool {

0 comments on commit 95bcd64

Please sign in to comment.