func testSingleSendFlakyGuaranteed(t *testing.T, events []modetest.EventInfo) { var collected [][]outputs.Data mode, _ := New( modetest.NewMockClient(&modetest.MockClient{ CBPublish: modetest.PublishCollectAfterFailStart(25, &collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testGuaranteed, events, modetest.Signals(true), &collected) }
func testSingleSendFlakyFail(t *testing.T, events []modetest.EventInfo) { var collected [][]common.MapStr mode, _ := New( modetest.NewMockClient(&modetest.MockClient{ CBPublish: modetest.PublishCollectAfterFailStart(3, &collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(false), &collected) }
func testLoadBalancerFlakyGuaranteed(t *testing.T, events []modetest.EventInfo) { var collected [][]common.MapStr mode, _ := NewSync( modetest.SyncClients(2, &modetest.MockClient{ Connected: true, CBPublish: modetest.PublishCollectAfterFailStart(25, &collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testGuaranteed, events, modetest.Signals(true), &collected) }
func testSingleSendOneEvent(t *testing.T, events []modetest.EventInfo) { var collected [][]outputs.Data mode, _ := New( modetest.NewMockClient(&modetest.MockClient{ Connected: true, CBPublish: modetest.PublishCollect(&collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testLoadBalancerOKSend(t *testing.T, events []modetest.EventInfo) { var collected [][]outputs.Data mode, _ := NewSync( modetest.SyncClients(1, &modetest.MockClient{ Connected: false, CBPublish: modetest.PublishCollect(&collected), }), 2, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testLoadBalancerFlakyConnectionOkSend(t *testing.T, events []modetest.EventInfo) { var collected [][]outputs.Data mode, _ := NewSync( modetest.SyncClients(2, &modetest.MockClient{ Connected: true, CBPublish: modetest.PublishCollectAfterFailStart(1, &collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testAsyncLBFailSendWithoutActiveConnection(t *testing.T, events []modetest.EventInfo) { enableLogging([]string{"*"}) errFail := errors.New("fail connect") mode, _ := NewAsync( modetest.AsyncClients(2, &modetest.MockClient{ CBConnect: modetest.ConnectFail(errFail), }), 2, 100*time.Millisecond, 100*time.Millisecond, 1*time.Second, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(false), nil) }
func testAsyncLBTemporayFailure(t *testing.T, events []modetest.EventInfo) { var collected [][]common.MapStr mode, _ := NewAsync( modetest.AsyncClients(1, &modetest.MockClient{ Connected: true, CBAsyncPublish: modetest.AsyncPublishCollectAfterFailStartWith( 1, mode.ErrTempBulkFailure, &collected), }), 3, 100*time.Millisecond, 100*time.Millisecond, 1*time.Second, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testAsyncLBOKSend(t *testing.T, events []modetest.EventInfo) { enableLogging([]string{"*"}) var collected [][]common.MapStr mode, _ := NewAsync( modetest.AsyncClients(1, &modetest.MockClient{ CBAsyncPublish: modetest.AsyncPublishCollect(&collected), }), 2, 100*time.Millisecond, 100*time.Millisecond, 1*time.Second, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testAsyncLBFlakyConnectionOkSend(t *testing.T, events []modetest.EventInfo) { var collected [][]common.MapStr tmpl := &modetest.MockClient{ Connected: true, CBAsyncPublish: modetest.AsyncPublishCollectAfterFailStart(1, &collected), } mode, _ := NewAsync( modetest.AsyncClients(2, tmpl), 3, 100*time.Millisecond, 100*time.Millisecond, 1*time.Second, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testLoadBalancerTempFlakyInfAttempts(t *testing.T, events []modetest.EventInfo) { var collected [][]common.MapStr err := mode.ErrTempBulkFailure mode, _ := NewSync( modetest.SyncClients(2, &modetest.MockClient{ Connected: true, CBPublish: modetest.PublishCollectAfterFailStartWith(25, err, &collected), }), 0, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testSingleSendFlakyInfAttempts(t *testing.T, events []modetest.EventInfo) { enableLogging([]string{"*"}) var collected [][]outputs.Data mode, _ := New( modetest.NewMockClient(&modetest.MockClient{ CBPublish: modetest.PublishCollectAfterFailStart(25, &collected), }), 0, // infinite number of send attempts 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testLoadBalancerTempFlakyGuaranteed(t *testing.T, events []modetest.EventInfo) { var collected [][]outputs.Data err := mode.ErrTempBulkFailure mode, _ := NewSync( modetest.SyncClients(2, &modetest.MockClient{ Connected: true, CBPublish: modetest.PublishCollectAfterFailStartWith(25, err, &collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testGuaranteed, events, modetest.Signals(true), &collected) }
func testSingleConnectionFail(t *testing.T, events []modetest.EventInfo) { var collected [][]outputs.Data errFail := errors.New("fail connect") mode, _ := New( modetest.NewMockClient(&modetest.MockClient{ Connected: false, CBConnect: modetest.ConnectFail(errFail), CBPublish: modetest.PublishCollect(&collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(false), &collected) }
func testSingleConnectFailConnectAndSend(t *testing.T, events []modetest.EventInfo) { var collected [][]common.MapStr errFail := errors.New("fail connect") mode, _ := New( modetest.NewMockClient(&modetest.MockClient{ Connected: false, CBConnect: modetest.ConnectFailN(2, errFail), CBPublish: modetest.PublishCollect(&collected), }), 3, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testAsyncLBTempFlakyFail(t *testing.T, events []modetest.EventInfo) { enableLogging([]string{"*"}) var collected [][]outputs.Data mode, _ := NewAsync( modetest.AsyncClients(2, &modetest.MockClient{ Connected: true, CBAsyncPublish: modetest.AsyncPublishCollectAfterFailStartWith( 6, mode.ErrTempBulkFailure, &collected), }), 3, 100*time.Millisecond, 100*time.Millisecond, 1*time.Second, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(false), &collected) }
func testLoadBalancerFailSendWithoutActiveConnections( t *testing.T, events []modetest.EventInfo, ) { errFail := errors.New("fail connect") mode, _ := NewSync( modetest.SyncClients(2, &modetest.MockClient{ Connected: false, CBConnect: modetest.ConnectFail(errFail), }), 2, 1*time.Millisecond, 1*time.Millisecond, 10*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(false), nil) }
func testAsyncLBFlakyFail(t *testing.T, events []modetest.EventInfo) { enableLogging([]string{"*"}) var collected [][]common.MapStr err := errors.New("flaky") mode, _ := NewAsync( modetest.AsyncClients(2, &modetest.MockClient{ Connected: true, CBAsyncPublish: modetest.AsyncPublishCollectAfterFailStartWith(3, err, &collected), }), 3, 100*time.Millisecond, 100*time.Millisecond, 1*time.Second, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(false), &collected) }
func testAsyncLBFlakyInfAttempts2(t *testing.T, events []modetest.EventInfo) { if testing.Verbose() { logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"*"}) } var collected [][]common.MapStr err := errors.New("flaky") mode, _ := NewAsync( modetest.AsyncClients(2, &modetest.MockClient{ CBAsyncPublish: modetest.AsyncPublishCollectAfterFailStartWith( 50, err, &collected), }), 0, 1*time.Nanosecond, 1*time.Millisecond, 4*time.Millisecond, ) modetest.TestMode(t, mode, testNoOpts, events, modetest.Signals(true), &collected) }
func testAsyncLBFlakyGuaranteed2(t *testing.T, events []modetest.EventInfo) { if testing.Verbose() { logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"*"}) } var collected [][]outputs.Data err := errors.New("flaky") tmpl := &modetest.MockClient{ Connected: true, CBAsyncPublish: modetest.AsyncPublishCollectAfterFailStartWith(50, err, &collected), } mode, _ := NewAsync( modetest.AsyncClients(2, tmpl), 3, 1*time.Nanosecond, 1*time.Millisecond, 4*time.Millisecond, ) modetest.TestMode(t, mode, testGuaranteed, events, modetest.Signals(true), &collected) }