Remove flaky test for udp_listener
This commit is contained in:
parent
f405bca034
commit
aa84011dc3
|
@ -8,14 +8,11 @@ import (
|
|||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/influxdata/telegraf/plugins/parsers"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -42,42 +39,42 @@ func newTestUdpListener() (*UdpListener, chan []byte) {
|
|||
return listener, in
|
||||
}
|
||||
|
||||
func TestHighTrafficUDP(t *testing.T) {
|
||||
listener := UdpListener{
|
||||
ServiceAddress: ":8126",
|
||||
AllowedPendingMessages: 100000,
|
||||
}
|
||||
var err error
|
||||
listener.parser, err = parsers.NewInfluxParser()
|
||||
require.NoError(t, err)
|
||||
acc := &testutil.Accumulator{}
|
||||
// func TestHighTrafficUDP(t *testing.T) {
|
||||
// listener := UdpListener{
|
||||
// ServiceAddress: ":8126",
|
||||
// AllowedPendingMessages: 100000,
|
||||
// }
|
||||
// var err error
|
||||
// listener.parser, err = parsers.NewInfluxParser()
|
||||
// require.NoError(t, err)
|
||||
// acc := &testutil.Accumulator{}
|
||||
|
||||
// send multiple messages to socket
|
||||
err = listener.Start(acc)
|
||||
require.NoError(t, err)
|
||||
// // send multiple messages to socket
|
||||
// err = listener.Start(acc)
|
||||
// require.NoError(t, err)
|
||||
|
||||
conn, err := net.Dial("udp", "127.0.0.1:8126")
|
||||
require.NoError(t, err)
|
||||
mlen := int64(len(testMsgs))
|
||||
var sent int64
|
||||
for i := 0; i < 20000; i++ {
|
||||
for sent > listener.BytesRecv.Get()+32000 {
|
||||
// more than 32kb sitting in OS buffer, let it drain
|
||||
runtime.Gosched()
|
||||
}
|
||||
conn.Write([]byte(testMsgs))
|
||||
sent += mlen
|
||||
}
|
||||
for sent > listener.BytesRecv.Get() {
|
||||
runtime.Gosched()
|
||||
}
|
||||
for len(listener.in) > 0 {
|
||||
runtime.Gosched()
|
||||
}
|
||||
listener.Stop()
|
||||
// conn, err := net.Dial("udp", "127.0.0.1:8126")
|
||||
// require.NoError(t, err)
|
||||
// mlen := int64(len(testMsgs))
|
||||
// var sent int64
|
||||
// for i := 0; i < 20000; i++ {
|
||||
// for sent > listener.BytesRecv.Get()+32000 {
|
||||
// // more than 32kb sitting in OS buffer, let it drain
|
||||
// runtime.Gosched()
|
||||
// }
|
||||
// conn.Write([]byte(testMsgs))
|
||||
// sent += mlen
|
||||
// }
|
||||
// for sent > listener.BytesRecv.Get() {
|
||||
// runtime.Gosched()
|
||||
// }
|
||||
// for len(listener.in) > 0 {
|
||||
// runtime.Gosched()
|
||||
// }
|
||||
// listener.Stop()
|
||||
|
||||
assert.Equal(t, uint64(100000), acc.NMetrics())
|
||||
}
|
||||
// assert.Equal(t, uint64(100000), acc.NMetrics())
|
||||
// }
|
||||
|
||||
func TestConnectUDP(t *testing.T) {
|
||||
listener := UdpListener{
|
||||
|
|
Loading…
Reference in New Issue