Exemple #1
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)
}
Exemple #2
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)
}
Exemple #3
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)
}
Exemple #4
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)
}
Exemple #5
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)
}
Exemple #6
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)
}
Exemple #7
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)
}
Exemple #8
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)
}