コード例 #1
0
ファイル: single_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #2
0
ファイル: single_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #3
0
ファイル: lbsync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #4
0
ファイル: single_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #5
0
ファイル: lbsync_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #6
0
ファイル: lbsync_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #7
0
ファイル: lbasync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #8
0
ファイル: lbasync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #9
0
ファイル: lbasync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #10
0
ファイル: lbasync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #11
0
ファイル: lbsync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #12
0
ファイル: single_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #13
0
ファイル: lbsync_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #14
0
ファイル: single_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #15
0
ファイル: single_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #16
0
ファイル: lbasync_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #17
0
ファイル: lbsync_test.go プロジェクト: YaSuenag/hsbeat
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)
}
コード例 #18
0
ファイル: lbasync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #19
0
ファイル: lbasync_test.go プロジェクト: ChongFeng/beats
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)
}
コード例 #20
0
ファイル: lbasync_test.go プロジェクト: YaSuenag/hsbeat
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)
}