Skip to content

Commit

Permalink
lowercase unexport types and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanjunming committed Dec 3, 2024
1 parent 2f15228 commit be03b35
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
60 changes: 30 additions & 30 deletions otel-integration/k8s-helm/e2e-test/expected_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,59 +220,59 @@ var expectedTracesSchemaURL = map[string]bool{
func expectedTraces(testID string, testNs string) map[string]struct {
name string
service string
attrs map[string]ExpectedValue
attrs map[string]expectedValue
} {
return map[string]struct {
name string
service string
attrs map[string]ExpectedValue
attrs map[string]expectedValue
}{
"test-traces-job": {
name: "traces-job",
service: "test-traces-job",
attrs: map[string]ExpectedValue{
"cx.otel_integration.name": NewExpectedValue(AttributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": NewExpectedValue(AttributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.job.name": NewExpectedValue(AttributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-job"),
"k8s.namespace.name": NewExpectedValue(AttributeMatchTypeEqual, testNs),
"k8s.node.name": NewExpectedValue(AttributeMatchTypeExist, ""),
"k8s.pod.name": NewExpectedValue(AttributeMatchTypeRegex, "telemetrygen-"+testID+"-traces-job-[a-z0-9]*"),
attrs: map[string]expectedValue{
"cx.otel_integration.name": newExpectedValue(attributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": newExpectedValue(attributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.job.name": newExpectedValue(attributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-job"),
"k8s.namespace.name": newExpectedValue(attributeMatchTypeEqual, testNs),
"k8s.node.name": newExpectedValue(attributeMatchTypeExist, ""),
"k8s.pod.name": newExpectedValue(attributeMatchTypeRegex, "telemetrygen-"+testID+"-traces-job-[a-z0-9]*"),
},
},
"test-traces-statefulset": {
name: "traces-statefulset",
service: "test-traces-statefulset",
attrs: map[string]ExpectedValue{
"cx.otel_integration.name": NewExpectedValue(AttributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": NewExpectedValue(AttributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.namespace.name": NewExpectedValue(AttributeMatchTypeEqual, testNs),
"k8s.node.name": NewExpectedValue(AttributeMatchTypeExist, ""),
"k8s.pod.name": NewExpectedValue(AttributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-statefulset-0"),
"k8s.statefulset.name": NewExpectedValue(AttributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-statefulset"),
attrs: map[string]expectedValue{
"cx.otel_integration.name": newExpectedValue(attributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": newExpectedValue(attributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.namespace.name": newExpectedValue(attributeMatchTypeEqual, testNs),
"k8s.node.name": newExpectedValue(attributeMatchTypeExist, ""),
"k8s.pod.name": newExpectedValue(attributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-statefulset-0"),
"k8s.statefulset.name": newExpectedValue(attributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-statefulset"),
},
},
"test-traces-deployment": {
name: "traces-deployment",
service: "test-traces-deployment",
attrs: map[string]ExpectedValue{
"cx.otel_integration.name": NewExpectedValue(AttributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": NewExpectedValue(AttributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.deployment.name": NewExpectedValue(AttributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-deployment"),
"k8s.namespace.name": NewExpectedValue(AttributeMatchTypeEqual, testNs),
"k8s.node.name": NewExpectedValue(AttributeMatchTypeExist, ""),
"k8s.pod.name": NewExpectedValue(AttributeMatchTypeRegex, "telemetrygen-"+testID+"-traces-deployment-[a-z0-9]*-[a-z0-9]*"),
attrs: map[string]expectedValue{
"cx.otel_integration.name": newExpectedValue(attributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": newExpectedValue(attributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.deployment.name": newExpectedValue(attributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-deployment"),
"k8s.namespace.name": newExpectedValue(attributeMatchTypeEqual, testNs),
"k8s.node.name": newExpectedValue(attributeMatchTypeExist, ""),
"k8s.pod.name": newExpectedValue(attributeMatchTypeRegex, "telemetrygen-"+testID+"-traces-deployment-[a-z0-9]*-[a-z0-9]*"),
},
},
"test-traces-daemonset": {
name: "traces-daemonset",
service: "test-traces-daemonset",
attrs: map[string]ExpectedValue{
"cx.otel_integration.name": NewExpectedValue(AttributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": NewExpectedValue(AttributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.daemonset.name": NewExpectedValue(AttributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-daemonset"),
"k8s.namespace.name": NewExpectedValue(AttributeMatchTypeEqual, testNs),
"k8s.node.name": NewExpectedValue(AttributeMatchTypeExist, ""),
"k8s.pod.name": NewExpectedValue(AttributeMatchTypeRegex, "telemetrygen-"+testID+"-traces-daemonset-[a-z0-9]*"),
attrs: map[string]expectedValue{
"cx.otel_integration.name": newExpectedValue(attributeMatchTypeEqual, "coralogix-integration-helm"),
"k8s.cluster.name": newExpectedValue(attributeMatchTypeEqual, "otel-integration-agent-e2e"),
"k8s.daemonset.name": newExpectedValue(attributeMatchTypeEqual, "telemetrygen-"+testID+"-traces-daemonset"),
"k8s.namespace.name": newExpectedValue(attributeMatchTypeEqual, testNs),
"k8s.node.name": newExpectedValue(attributeMatchTypeExist, ""),
"k8s.pod.name": newExpectedValue(attributeMatchTypeRegex, "telemetrygen-"+testID+"-traces-daemonset-[a-z0-9]*"),
},
},
}
Expand Down
22 changes: 11 additions & 11 deletions otel-integration/k8s-helm/e2e-test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestE2E_Agent(t *testing.T) {

metricsConsumer := new(consumertest.MetricsSink)
tracesConsumer := new(consumertest.TracesSink)
shutdownSink := StartUpSinks(t, metricsConsumer, tracesConsumer)
shutdownSink := startUpSinks(t, metricsConsumer, tracesConsumer)
defer shutdownSink()

testID := uuid.NewString()[:8]
Expand All @@ -68,8 +68,8 @@ func TestE2E_Agent(t *testing.T) {
}
})

WaitForMetrics(t, 20, metricsConsumer)
WaitForTraces(t, 20, tracesConsumer)
waitForMetrics(t, 20, metricsConsumer)
waitForTraces(t, 20, tracesConsumer)

checkResourceMetrics(t, metricsConsumer.AllMetrics())
checkTracesAttributes(t, tracesConsumer.AllTraces(), testID, testNs)
Expand Down Expand Up @@ -208,7 +208,7 @@ func checkTracesAttributes(t *testing.T, actual []ptrace.Traces, testID string,
}

resource := rspans.Resource()
service, exist := resource.Attributes().Get(ServiceNameAttribute)
service, exist := resource.Attributes().Get(serviceNameAttribute)

expectedTrace := expectedTraces(testID, testNs)[service.AsString()]
require.NotEmpty(t, expectedTrace, "traces: unexpected service name %v", service.AsString())
Expand All @@ -222,7 +222,7 @@ func checkTracesAttributes(t *testing.T, actual []ptrace.Traces, testID string,
return nil
}

func assertExpectedAttributes(attrs pcommon.Map, kvs map[string]ExpectedValue) error {
func assertExpectedAttributes(attrs pcommon.Map, kvs map[string]expectedValue) error {
foundAttrs := make(map[string]bool)
for k := range kvs {
foundAttrs[k] = false
Expand All @@ -231,17 +231,17 @@ func assertExpectedAttributes(attrs pcommon.Map, kvs map[string]ExpectedValue) e

attrs.Range(func(k string, v pcommon.Value) bool {
if val, ok := kvs[k]; ok {
switch val.Mode {
case AttributeMatchTypeEqual:
if val.Value == v.AsString() {
switch val.mode {
case attributeMatchTypeEqual:
if val.value == v.AsString() {
foundAttrs[k] = true
}
case AttributeMatchTypeRegex:
matched, _ := regexp.MatchString(val.Value, v.AsString())
case attributeMatchTypeRegex:
matched, _ := regexp.MatchString(val.value, v.AsString())
if matched {
foundAttrs[k] = true
}
case AttributeMatchTypeExist:
case attributeMatchTypeExist:
foundAttrs[k] = true
}
} else {
Expand Down
34 changes: 17 additions & 17 deletions otel-integration/k8s-helm/e2e-test/sinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ const (
regex
exist

AttributeMatchTypeEqual ExpectedValueMode = iota
AttributeMatchTypeRegex
AttributeMatchTypeExist
attributeMatchTypeEqual expectedValueMode = iota
attributeMatchTypeRegex
attributeMatchTypeExist

ServiceNameAttribute = "service.name"
serviceNameAttribute = "service.name"
)

type ExpectedValueMode int
type expectedValueMode int

type ExpectedTrace struct {
type expectedTrace struct {
name string
service string
attrs map[string]ExpectedValue
attrs map[string]expectedValue
}

type ExpectedValue struct {
Mode ExpectedValueMode
Value string
type expectedValue struct {
mode expectedValueMode
value string
}

func NewExpectedValue(mode ExpectedValueMode, value string) ExpectedValue {
return ExpectedValue{
Mode: mode,
Value: value,
func newExpectedValue(mode expectedValueMode, value string) expectedValue {
return expectedValue{
mode: mode,
value: value,
}
}

func StartUpSinks(t *testing.T, mc *consumertest.MetricsSink, tc *consumertest.TracesSink) func() {
func startUpSinks(t *testing.T, mc *consumertest.MetricsSink, tc *consumertest.TracesSink) func() {
f := otlpreceiver.NewFactory()
cfg := f.CreateDefaultConfig().(*otlpreceiver.Config)
cfg.HTTP = nil
Expand All @@ -62,7 +62,7 @@ func StartUpSinks(t *testing.T, mc *consumertest.MetricsSink, tc *consumertest.T
}
}

func WaitForMetrics(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) {
func waitForMetrics(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) {
timeout := 5 * time.Minute // 5 minutes
require.Eventuallyf(t, func() bool {
count := len(mc.AllMetrics())
Expand All @@ -72,7 +72,7 @@ func WaitForMetrics(t *testing.T, entriesNum int, mc *consumertest.MetricsSink)
entriesNum, timeout)
}

func WaitForTraces(t *testing.T, entriesNum int, tc *consumertest.TracesSink) {
func waitForTraces(t *testing.T, entriesNum int, tc *consumertest.TracesSink) {
timeout := 5 * time.Minute // 5 minutes
require.Eventuallyf(t, func() bool {
count := len(tc.AllTraces())
Expand Down

0 comments on commit be03b35

Please sign in to comment.