Skip to content

Commit

Permalink
[chore] fix carbonexporter flacky tests (#14627)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdandrutu authored Sep 30, 2022
1 parent 84d0767 commit 1303178
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions exporter/carbonexporter/metricdata_to_plaintext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestBuildPath(t *testing.T) {
name: "happy_path",
attributes: func() pcommon.Map {
attr := pcommon.NewMap()
attr.FromRaw(map[string]interface{}{"key0": "val0"})
attr.PutString("key0", "val0")
return attr
}(),
want: "happy_path;key0=val0",
Expand All @@ -99,7 +99,8 @@ func TestBuildPath(t *testing.T) {
name: "empty_value",
attributes: func() pcommon.Map {
attr := pcommon.NewMap()
attr.FromRaw(map[string]interface{}{"k0": "", "k1": "v1"})
attr.PutString("k0", "")
attr.PutString("k1", "v1")
return attr
}(),
want: "empty_value;k0=" + tagValueEmptyPlaceholder + ";k1=v1",
Expand All @@ -108,7 +109,7 @@ func TestBuildPath(t *testing.T) {
name: "int_value",
attributes: func() pcommon.Map {
attr := pcommon.NewMap()
attr.FromRaw(map[string]interface{}{"k": 1})
attr.PutInt("k", 1)
return attr
}(),
want: "int_value;k=1",
Expand Down Expand Up @@ -194,29 +195,29 @@ func TestToPlaintext(t *testing.T) {
ms.AppendEmpty().SetName("gauge_double_with_dims")
dps1 := ms.At(0).SetEmptyGauge().DataPoints()
dps1.AppendEmpty().SetTimestamp(pcommon.NewTimestampFromTime(tsUnix))
dps1.At(0).Attributes().FromRaw(map[string]interface{}{"k0": "v0", "k1": "v1"})
dps1.At(0).Attributes().Sort() // ensures result order
dps1.At(0).Attributes().PutString("k0", "v0")
dps1.At(0).Attributes().PutString("k1", "v1")
dps1.At(0).SetDoubleValue(doubleVal)
ms.AppendEmpty().SetName("gauge_int_with_dims")
dps2 := ms.At(1).SetEmptyGauge().DataPoints()
dps2.AppendEmpty().SetTimestamp(pcommon.NewTimestampFromTime(tsUnix))
dps2.At(0).Attributes().FromRaw(map[string]interface{}{"k0": "v0", "k1": "v1"})
dps2.At(0).Attributes().Sort() // ensures result order
dps2.At(0).Attributes().PutString("k0", "v0")
dps2.At(0).Attributes().PutString("k1", "v1")
dps2.At(0).SetIntValue(int64Val)

ms.AppendEmpty().SetName("cumulative_double_with_dims")
ms.At(2).SetEmptySum().SetIsMonotonic(true)
dps3 := ms.At(2).Sum().DataPoints()
dps3.AppendEmpty().SetTimestamp(pcommon.NewTimestampFromTime(tsUnix))
dps3.At(0).Attributes().FromRaw(map[string]interface{}{"k0": "v0", "k1": "v1"})
dps3.At(0).Attributes().Sort() // ensures result order
dps3.At(0).Attributes().PutString("k0", "v0")
dps3.At(0).Attributes().PutString("k1", "v1")
dps3.At(0).SetDoubleValue(doubleVal)
ms.AppendEmpty().SetName("cumulative_int_with_dims")
ms.At(3).SetEmptySum().SetIsMonotonic(true)
dps4 := ms.At(3).Sum().DataPoints()
dps4.AppendEmpty().SetTimestamp(pcommon.NewTimestampFromTime(tsUnix))
dps4.At(0).Attributes().FromRaw(map[string]interface{}{"k0": "v0", "k1": "v1"})
dps4.At(0).Attributes().Sort() // ensures result order
dps4.At(0).Attributes().PutString("k0", "v0")
dps4.At(0).Attributes().PutString("k1", "v1")
dps4.At(0).SetIntValue(int64Val)
return md
},
Expand Down

0 comments on commit 1303178

Please sign in to comment.