Skip to content

Commit

Permalink
Merge branch 'main' into create-database-scheme-cassandra
Browse files Browse the repository at this point in the history
  • Loading branch information
yurishkuro authored Nov 30, 2024
2 parents 154deb9 + 2e5ed05 commit a238455
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 14 deletions.
50 changes: 50 additions & 0 deletions pkg/kafka/auth/options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package auth

import (
"flag"
"testing"

"github.com/stretchr/testify/assert"
)

func TestAddFlags(t *testing.T) {
tests := []struct {
name string
configPrefix string
expectedFlags map[string]string
}{
{
name: "Default configuration with testprefix",
configPrefix: "testprefix",
expectedFlags: map[string]string{
"testprefix" + suffixAuthentication: none,
"testprefix" + kerberosPrefix + suffixKerberosServiceName: defaultKerberosServiceName,
"testprefix" + kerberosPrefix + suffixKerberosRealm: defaultKerberosRealm,
"testprefix" + kerberosPrefix + suffixKerberosUsername: defaultKerberosUsername,
"testprefix" + kerberosPrefix + suffixKerberosPassword: defaultKerberosPassword,
"testprefix" + kerberosPrefix + suffixKerberosConfig: defaultKerberosConfig,
"testprefix" + kerberosPrefix + suffixKerberosUseKeyTab: "false",
"testprefix" + plainTextPrefix + suffixPlainTextUsername: defaultPlainTextUsername,
"testprefix" + plainTextPrefix + suffixPlainTextPassword: defaultPlainTextPassword,
"testprefix" + plainTextPrefix + suffixPlainTextMechanism: defaultPlainTextMechanism,
},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
flagSet := flag.NewFlagSet("test", flag.ContinueOnError)

AddFlags(tt.configPrefix, flagSet)

for flagName, expectedValue := range tt.expectedFlags {
flag := flagSet.Lookup(flagName)
assert.NotNil(t, flag, "Expected flag %q to be registered", flagName)
assert.Equal(t, expectedValue, flag.DefValue, "Default value of flag %q", flagName)
}
})
}
}
44 changes: 30 additions & 14 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ func (s *StorageIntegration) testGetLargeSpan(t *testing.T) {
s.skipIfNeeded(t)
defer s.cleanUp(t)

t.Log("Testing Large Trace over 10K ...")
expected := s.loadParseAndWriteLargeTrace(t)
t.Log("Testing Large Trace over 10K with duplicate IDs...")

expected := s.writeLargeTraceWithDuplicateSpanIds(t)
expectedTraceID := expected.Spans[0].TraceID

var actual *model.Trace
Expand All @@ -219,9 +220,22 @@ func (s *StorageIntegration) testGetLargeSpan(t *testing.T) {
actual, err = s.SpanReader.GetTrace(context.Background(), expectedTraceID)
return err == nil && len(actual.Spans) >= len(expected.Spans)
})

if !assert.True(t, found) {
CompareTraces(t, expected, actual)
return
}

duplicateCount := 0
seenIDs := make(map[model.SpanID]int)

for _, span := range actual.Spans {
seenIDs[span.SpanID]++
if seenIDs[span.SpanID] > 1 {
duplicateCount++
}
}
assert.Positive(t, duplicateCount, "Duplicate SpanIDs should be present in the trace")
}

func (s *StorageIntegration) testGetOperations(t *testing.T) {
Expand Down Expand Up @@ -365,19 +379,21 @@ func (s *StorageIntegration) loadParseAndWriteExampleTrace(t *testing.T) *model.
return trace
}

func (s *StorageIntegration) loadParseAndWriteLargeTrace(t *testing.T) *model.Trace {
func (s *StorageIntegration) writeLargeTraceWithDuplicateSpanIds(t *testing.T) *model.Trace {
trace := s.getTraceFixture(t, "example_trace")
span := trace.Spans[0]
spns := make([]*model.Span, 1, 10008)
trace.Spans = spns
trace.Spans[0] = span
for i := 1; i < 10008; i++ {
s := new(model.Span)
*s = *span
//nolint: gosec // G115
s.SpanID = model.SpanID(i)
s.StartTime = s.StartTime.Add(time.Second * time.Duration(i+1))
trace.Spans = append(trace.Spans, s)
repeatedSpan := trace.Spans[0]
trace.Spans = make([]*model.Span, 0, 10008)
for i := 0; i < 10008; i++ {
newSpan := new(model.Span)
*newSpan = *repeatedSpan
switch {
case i%100 == 0:
newSpan.SpanID = repeatedSpan.SpanID
default:
newSpan.SpanID = model.SpanID(i)
}
newSpan.StartTime = newSpan.StartTime.Add(time.Second * time.Duration(i+1))
trace.Spans = append(trace.Spans, newSpan)
}
s.writeTrace(t, trace)
return trace
Expand Down

0 comments on commit a238455

Please sign in to comment.