Beispiel #1
0
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)
}
Beispiel #2
0
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)
}
Beispiel #3
0
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)
}
Beispiel #4
0
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)
}
Beispiel #5
0
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)
}
Beispiel #6
0
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)
}
Beispiel #7
0
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)
}
Beispiel #8
0
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)
}
Beispiel #9
0
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)
}
Beispiel #10
0
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)
}
Beispiel #11
0
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)
}
Beispiel #12
0
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)
}
Beispiel #13
0
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)
}
Beispiel #14
0
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)
}
Beispiel #15
0
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)
}
Beispiel #16
0
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)
}
Beispiel #17
0
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)
}
Beispiel #18
0
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)
}
Beispiel #19
0
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)
}
Beispiel #20
0
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)
}