|
@@ -2,8 +2,10 @@ package splunk
|
|
|
|
|
|
import (
|
|
|
"compress/gzip"
|
|
|
+ "context"
|
|
|
"fmt"
|
|
|
"os"
|
|
|
+ "runtime"
|
|
|
"testing"
|
|
|
"time"
|
|
|
|
|
@@ -1062,7 +1064,7 @@ func TestSkipVerify(t *testing.T) {
|
|
|
t.Fatal("No messages should be accepted at this point")
|
|
|
}
|
|
|
|
|
|
- hec.simulateServerError = false
|
|
|
+ hec.simulateErr(false)
|
|
|
|
|
|
for i := defaultStreamChannelSize * 2; i < defaultStreamChannelSize*4; i++ {
|
|
|
if err := loggerDriver.Log(&logger.Message{Line: []byte(fmt.Sprintf("%d", i)), Source: "stdout", Timestamp: time.Now()}); err != nil {
|
|
@@ -1110,7 +1112,7 @@ func TestBufferMaximum(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
hec := NewHTTPEventCollectorMock(t)
|
|
|
- hec.simulateServerError = true
|
|
|
+ hec.simulateErr(true)
|
|
|
go hec.Serve()
|
|
|
|
|
|
info := logger.Info{
|
|
@@ -1308,3 +1310,48 @@ func TestCannotSendAfterClose(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestDeadlockOnBlockedEndpoint(t *testing.T) {
|
|
|
+ hec := NewHTTPEventCollectorMock(t)
|
|
|
+ go hec.Serve()
|
|
|
+ info := logger.Info{
|
|
|
+ Config: map[string]string{
|
|
|
+ splunkURLKey: hec.URL(),
|
|
|
+ splunkTokenKey: hec.token,
|
|
|
+ },
|
|
|
+ ContainerID: "containeriid",
|
|
|
+ ContainerName: "/container_name",
|
|
|
+ ContainerImageID: "contaimageid",
|
|
|
+ ContainerImageName: "container_image_name",
|
|
|
+ }
|
|
|
+
|
|
|
+ l, err := New(info)
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ ctx, unblock := context.WithCancel(context.Background())
|
|
|
+ hec.withBlock(ctx)
|
|
|
+ defer unblock()
|
|
|
+
|
|
|
+ batchSendTimeout = 1 * time.Second
|
|
|
+
|
|
|
+ if err := l.Log(&logger.Message{}); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ done := make(chan struct{})
|
|
|
+ go func() {
|
|
|
+ l.Close()
|
|
|
+ close(done)
|
|
|
+ }()
|
|
|
+
|
|
|
+ select {
|
|
|
+ case <-time.After(60 * time.Second):
|
|
|
+ buf := make([]byte, 1e6)
|
|
|
+ buf = buf[:runtime.Stack(buf, true)]
|
|
|
+ t.Logf("STACK DUMP: \n\n%s\n\n", string(buf))
|
|
|
+ t.Fatal("timeout waiting for close to finish")
|
|
|
+ case <-done:
|
|
|
+ }
|
|
|
+}
|