mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Added `—input-raw-buffer-size` - Controls size of the OS buffer (in bytes) which holds packets until they dispatched. Default value depends by system: in Linux around 2MB. If you see big package drop, increase this value. Additionally snaplen (max number of bytes being read for each packet) now dynamically set based on interface MTU + max header size. In most situations it should reduce package drop, because each packet will consume less space in buffer.
141 lines
3.4 KiB
Go
141 lines
3.4 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
const expectedIndex = "gor"
|
|
|
|
func assertExpectedGorIndex(index string, t *testing.T) {
|
|
if expectedIndex != index {
|
|
t.Fatalf("Expected index %s but got %s", expectedIndex, index)
|
|
}
|
|
}
|
|
|
|
func assertExpectedIndex(expectedIndex string, index string, t *testing.T) {
|
|
if expectedIndex != index {
|
|
t.Fatalf("Expected index %s but got %s", expectedIndex, index)
|
|
}
|
|
}
|
|
|
|
func assertExpectedError(returnedError error, t *testing.T) {
|
|
expectedError := new(ESUriErorr)
|
|
|
|
if expectedError != returnedError {
|
|
t.Errorf("Expected err %s but got %s", expectedError, returnedError)
|
|
}
|
|
}
|
|
|
|
func assertNoError(returnedError error, t *testing.T) {
|
|
if nil != returnedError {
|
|
t.Errorf("Expected no err but got %s", returnedError)
|
|
}
|
|
}
|
|
|
|
// Argument host:port/index_name
|
|
// i.e : localhost:9200/gor
|
|
// Fail because scheme is mandatory
|
|
func TestElasticConnectionBuildFailWithoutScheme(t *testing.T) {
|
|
uri := "localhost:9200/" + expectedIndex
|
|
|
|
err, _ := parseURI(uri)
|
|
assertExpectedError(err, t)
|
|
}
|
|
|
|
// Argument scheme://host:port
|
|
// i.e : http://localhost:9200
|
|
// Fail : explicit index is required
|
|
func TestElasticConnectionBuildFailWithoutIndex(t *testing.T) {
|
|
uri := "http://localhost:9200"
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertExpectedIndex("", index, t)
|
|
|
|
assertExpectedError(err, t)
|
|
}
|
|
|
|
// Argument scheme://host/index_name
|
|
// i.e : http://localhost/gor
|
|
func TestElasticConnectionBuildFailWithoutPort(t *testing.T) {
|
|
uri := "http://localhost/" + expectedIndex
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertNoError(err, t)
|
|
|
|
assertExpectedGorIndex(index, t)
|
|
}
|
|
|
|
// Argument scheme://host:port/index_name
|
|
// i.e : http://localhost:9200/gor
|
|
func TestElasticLocalConnectionBuild(t *testing.T) {
|
|
uri := "http://localhost:9200/" + expectedIndex
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertNoError(err, t)
|
|
|
|
assertExpectedGorIndex(index, t)
|
|
}
|
|
|
|
// Argument scheme://host:port/index_name
|
|
// i.e : http://localhost.local:9200/gor or https://localhost.local:9200/gor
|
|
func TestElasticSimpleLocalWithSchemeConnectionBuild(t *testing.T) {
|
|
uri := "http://localhost.local:9200/" + expectedIndex
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertNoError(err, t)
|
|
|
|
assertExpectedGorIndex(index, t)
|
|
}
|
|
|
|
// Argument scheme://host:port/index_name
|
|
// i.e : http://localhost.local:9200/gor or https://localhost.local:9200/gor
|
|
func TestElasticSimpleLocalWithHTTPSConnectionBuild(t *testing.T) {
|
|
uri := "https://localhost.local:9200/" + expectedIndex
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertNoError(err, t)
|
|
|
|
assertExpectedGorIndex(index, t)
|
|
}
|
|
|
|
// Argument scheme://host:port/index_name
|
|
// i.e : localhost.local:9200/pathtoElastic/gor
|
|
func TestElasticLongPathConnectionBuild(t *testing.T) {
|
|
uri := "http://localhost.local:9200/pathtoElastic/" + expectedIndex
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertNoError(err, t)
|
|
|
|
assertExpectedGorIndex(index, t)
|
|
}
|
|
|
|
// Argument scheme://host:userinfo@port/index_name
|
|
// i.e : http://user:password@localhost.local:9200/gor
|
|
func TestElasticBasicAuthConnectionBuild(t *testing.T) {
|
|
uri := "http://user:password@localhost.local:9200/" + expectedIndex
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertNoError(err, t)
|
|
|
|
assertExpectedGorIndex(index, t)
|
|
}
|
|
|
|
// Argument scheme://host:port/path/index_name
|
|
// i.e : http://localhost.local:9200/path/gor or https://localhost.local:9200/path/gor
|
|
func TestElasticComplexPathConnectionBuild(t *testing.T) {
|
|
uri := "http://localhost.local:9200/path/" + expectedIndex
|
|
|
|
err, index := parseURI(uri)
|
|
|
|
assertNoError(err, t)
|
|
|
|
assertExpectedGorIndex(index, t)
|
|
}
|