Skip to content

Commit

Permalink
Fix Test
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Dec 13, 2024
1 parent 00d1835 commit 602d9c7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/query/app/querysvc/adjuster/ipattribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestIPAttributeAdjuster(t *testing.T) {

resourceAttributes := resourceSpans.Resource().Attributes()
resourceAttributes.PutInt("a", 42)
resourceAttributes.PutInt("ip", 1<<26|2<<16|3<<8|4)
resourceAttributes.PutInt("ip", 1<<24|2<<16|3<<8|4)
resourceAttributes.PutStr("peer.ipv4", "something")

spans := resourceSpans.ScopeSpans().AppendEmpty().Spans()
Expand All @@ -39,12 +39,12 @@ func TestIPAttributeAdjuster(t *testing.T) {

createSpan(map[string]any{
"a": 42,
"ip": int(1<<24 | 2<<16 | 3<<8 | 4),
"ip": int(1<<25 | 2<<16 | 3<<8 | 4),
"peer.ipv4": "something else",
})

createSpan(map[string]any{
"ip": float64(1<<25 | 2<<16 | 3<<8 | 4),
"ip": float64(1<<26 | 2<<16 | 3<<8 | 4),
})

assertAttribute := func(attributes pcommon.Map, key string, expected any) {
Expand All @@ -65,17 +65,17 @@ func TestIPAttributeAdjuster(t *testing.T) {
assert.Equal(t, 3, resourceSpan.Resource().Attributes().Len())

assertAttribute(resourceSpan.Resource().Attributes(), "a", 42)
assertAttribute(resourceSpan.Resource().Attributes(), "ip", "4.2.3.4")
assertAttribute(resourceSpan.Resource().Attributes(), "ip", "1.2.3.4")
assertAttribute(resourceSpan.Resource().Attributes(), "peer.ipv4", "something")

gotSpans := resourceSpan.ScopeSpans().At(0).Spans()
assert.Equal(t, 2, gotSpans.Len())

assert.Equal(t, 3, gotSpans.At(0).Attributes().Len())
assertAttribute(gotSpans.At(0).Attributes(), "a", 42)
assertAttribute(gotSpans.At(0).Attributes(), "ip", "1.2.3.4")
assertAttribute(gotSpans.At(0).Attributes(), "ip", "2.2.3.4")
assertAttribute(gotSpans.At(0).Attributes(), "peer.ipv4", "something else")

assert.Equal(t, 1, gotSpans.At(1).Attributes().Len())
assertAttribute(gotSpans.At(1).Attributes(), "ip", "2.2.3.4")
assertAttribute(gotSpans.At(1).Attributes(), "ip", "4.2.3.4")
}

0 comments on commit 602d9c7

Please sign in to comment.