Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sporadic test failure #3

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 37 additions & 28 deletions plugins/inputs/sflow_a10/sflow_a10_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,48 @@ func TestSFlow_A10(t *testing.T) {
client, err := net.Dial(sflow.Address().Network(), sflow.Address().String())
require.NoError(t, err)

// send the metrics multiple times to make sure it gets parsed correctly at least once
for i := 0; i < 5; i++ {
// 271 - hex 10f
packetBytes, err := hex.DecodeString("00000005000000010a41101f0000000000008a6766e234bc00000001000000020000005a00000000000210c70000000109f8a10F2468000000020004000000000A0001031EC0A805060F")
require.NoError(t, err)
client.Write(packetBytes)
// Create a rutine to wait for the packets
go acc.Wait(3)

// 260 - hex 104
packetBytes, err = hex.DecodeString("00000005000000010a41101f0000000000008a6766e234bc00000001000000020000005a00000000000210c70000000109f8a10400000046050c00567a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)
// Add sleep times (100 ms) between the packets

// 219 - hex 0db
packetBytes, err = hex.DecodeString("00000005000000010a41101f0000000000008a9066e235c800000002000000020000026c00000000000210c70000000109f8a0db000002580000004a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000007400000000000210c70000000109f8a0d000000060000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)
time.Sleep(100 * time.Millisecond)
// 271 - hex 10f
packetBytes, err := hex.DecodeString("00000005000000010a41101f0000000000008a6766e234bc00000001000000020000005a00000000000210c70000000109f8a10F2468000000020004000000000A0001031EC0A805060F")
require.NoError(t, err)
client.Write(packetBytes)

// 207 - hex 0cf
packetBytes, err = hex.DecodeString("00000005000000010a01000600000000002c6d611a33ba2f00000001000000020000027c000000000000a27e0000000109f8a0cf0000026800a6004c00000000000000000292a4dc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000059b9909a0000002ce72d028c00000000000000000000000000000000000000000000000000000000022e30fc00000000efc72290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001392de4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011c8a000000000000948d000000000001b11500000000026350560000000106f457cc000000000000000000000000000000000000000002c7c2860000000013722fbc00000000000000000000000000000000000000000000004100000000000000400000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012550000000000003795000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)
time.Sleep(100 * time.Millisecond)
// 260 - hex 104
packetBytes, err = hex.DecodeString("00000005000000010a41101f0000000000008a6766e234bc00000001000000020000005a00000000000210c70000000109f8a10400000046050c00567a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)

// 293 - hex 125
packetBytes, err = hex.DecodeString("00000005000000010a1d000800000000000007f70003ae8800000001000000020000002c00000008020001030000000109f8a12500000018000000000000001a00000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)
time.Sleep(100 * time.Millisecond)
// 219 - hex 0db
packetBytes, err = hex.DecodeString("00000005000000010a41101f0000000000008a9066e235c800000002000000020000026c00000000000210c70000000109f8a0db000002580000004a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000007400000000000210c70000000109f8a0d000000060000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)

// 294 - hex 126
packetBytes, err = hex.DecodeString("00000005000000010a1d000800000000000008ac0003d59800000001000000020000006c00000009040000010000000109f8a1260000005800000001000000060000000ba43b7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000150000000000000000")
require.NoError(t, err)
client.Write(packetBytes)
}
acc.Wait(3)
time.Sleep(100 * time.Millisecond)
// 207 - hex 0cf
packetBytes, err = hex.DecodeString("00000005000000010a01000600000000002c6d611a33ba2f00000001000000020000027c000000000000a27e0000000109f8a0cf0000026800a6004c00000000000000000292a4dc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000059b9909a0000002ce72d028c00000000000000000000000000000000000000000000000000000000022e30fc00000000efc72290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001392de4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011c8a000000000000948d000000000001b11500000000026350560000000106f457cc000000000000000000000000000000000000000002c7c2860000000013722fbc00000000000000000000000000000000000000000000004100000000000000400000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012550000000000003795000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)

time.Sleep(100 * time.Millisecond)
// 293 - hex 125
packetBytes, err = hex.DecodeString("00000005000000010a1d000800000000000007f70003ae8800000001000000020000002c00000008020001030000000109f8a12500000018000000000000001a00000000000000000000000000000000")
require.NoError(t, err)
client.Write(packetBytes)

time.Sleep(100 * time.Millisecond)
// 294 - hex 126
packetBytes, err = hex.DecodeString("00000005000000010a1d000800000000000008ac0003d59800000001000000020000006c00000009040000010000000109f8a1260000005800000001000000060000000ba43b7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000150000000000000000")
require.NoError(t, err)
client.Write(packetBytes)

time.Sleep(100 * time.Millisecond)

expected := []telegraf.Metric{
testutil.MustMetric(
Expand Down