-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring, need to add telemetrygen to k8s via code
- Loading branch information
1 parent
9a1b574
commit 8e2640f
Showing
5 changed files
with
101 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...est/testdata/telemetrygen-deployment.yaml → ...e2e-test/k8s/telemetrygen-deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: apps/v1 | ||
apiVersion: app/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/component/componenttest" | ||
"go.opentelemetry.io/collector/consumer/consumertest" | ||
"go.opentelemetry.io/collector/receiver/otlpreceiver" | ||
"go.opentelemetry.io/collector/receiver/receivertest" | ||
) | ||
|
||
type ReceiverSinks struct { | ||
MetricsConsumer *consumertest.MetricsSink | ||
TracesConsumer *consumertest.TracesSink | ||
} | ||
|
||
func StartUpSinks(t *testing.T, sinks ReceiverSinks) func() { | ||
shutDownFuncs := []func(){} | ||
|
||
if sinks.MetricsConsumer != nil { | ||
fMetric := otlpreceiver.NewFactory() | ||
cfg := fMetric.CreateDefaultConfig().(*otlpreceiver.Config) | ||
metricsRcvr, err := fMetric.CreateMetricsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, sinks.MetricsConsumer) | ||
require.NoError(t, metricsRcvr.Start(context.Background(), componenttest.NewNopHost())) | ||
require.NoError(t, err, "failed creating metrics receiver") | ||
shutDownFuncs = append(shutDownFuncs, func() { | ||
assert.NoError(t, metricsRcvr.Shutdown(context.Background())) | ||
}) | ||
} | ||
|
||
if sinks.TracesConsumer != nil { | ||
fTrace := otlpreceiver.NewFactory() | ||
cfg := fTrace.CreateDefaultConfig().(*otlpreceiver.Config) | ||
traceRcvr, err := fTrace.CreateTracesReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, sinks.TracesConsumer) | ||
require.NoError(t, traceRcvr.Start(context.Background(), componenttest.NewNopHost())) | ||
require.NoError(t, err, "failed creating traces receiver") | ||
shutDownFuncs = append(shutDownFuncs, func() { | ||
assert.NoError(t, traceRcvr.Shutdown(context.Background())) | ||
}) | ||
} | ||
|
||
return func() { | ||
for _, f := range shutDownFuncs { | ||
f() | ||
} | ||
} | ||
} | ||
|
||
func WaitForMetrics(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) { | ||
timeoutMinutes := 5 | ||
require.Eventually(t, func() bool { | ||
return len(mc.AllMetrics()) >= entriesNum | ||
}, time.Duration(timeoutMinutes)*time.Minute, time.Second, | ||
"failed to receive %d entries, received %d metrics in %d minutes", | ||
entriesNum, len(mc.AllMetrics()), timeoutMinutes) | ||
} | ||
|
||
func WaitForTraces(t *testing.T, entriesNum int, tc *consumertest.TracesSink) { | ||
timeoutMinutes := 5 | ||
require.Eventually(t, func() bool { | ||
return len(tc.AllTraces()) >= entriesNum | ||
}, time.Duration(timeoutMinutes)*time.Minute, time.Second, | ||
"failed to receive %d entries, received %d traces in %d minutes", | ||
entriesNum, len(tc.AllTraces()), timeoutMinutes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package e2e | ||
|
||
// import ( | ||
// "testing" | ||
// "strings" | ||
// "time" | ||
// } | ||
|
||
// type TelemetrygenObjInfo struct { | ||
// Namespace string | ||
// PodLabelSelectors map[string]any | ||
// DataType string | ||
// Workload string | ||
// } | ||
|
||
// type TelemetrygenCreateOpts struct { | ||
// TestID string | ||
// ManifestsDir string | ||
// OtlpEndpoint string | ||
// DataTypes []string | ||
// } |