mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Refactor emitter.go and fix test accordingly.
This commit is contained in:
+8
-6
@@ -119,7 +119,6 @@ func TestEchoMiddleware(t *testing.T) {
|
||||
// Catch traffic from one service
|
||||
fromAddr := strings.Replace(from.Listener.Addr().String(), "[::]", "127.0.0.1", -1)
|
||||
input := NewRAWInput(fromAddr, EnginePcap, true, testRawExpire, "", "", "", 0)
|
||||
defer input.Close()
|
||||
|
||||
// And redirect to another
|
||||
output := NewHTTPOutput(to.URL, &HTTPOutputConfig{Debug: false})
|
||||
@@ -128,9 +127,11 @@ func TestEchoMiddleware(t *testing.T) {
|
||||
Inputs: []io.Reader{input},
|
||||
Outputs: []io.Writer{output},
|
||||
}
|
||||
plugins.All = append(plugins.All, input, output)
|
||||
|
||||
// Start Gor
|
||||
go Start(plugins, quit)
|
||||
emitter := NewEmitter(quit)
|
||||
go emitter.Start(plugins, Settings.middleware)
|
||||
|
||||
// Wait till middleware initialization
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
@@ -148,7 +149,7 @@ func TestEchoMiddleware(t *testing.T) {
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(quit)
|
||||
emitter.Close()
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
Settings.middleware = ""
|
||||
@@ -183,7 +184,6 @@ func TestTokenMiddleware(t *testing.T) {
|
||||
fromAddr := strings.Replace(from.Listener.Addr().String(), "[::]", "127.0.0.1", -1)
|
||||
// Catch traffic from one service
|
||||
input := NewRAWInput(fromAddr, EnginePcap, true, testRawExpire, "", "", "", 0)
|
||||
defer input.Close()
|
||||
|
||||
// And redirect to another
|
||||
output := NewHTTPOutput(to.URL, &HTTPOutputConfig{Debug: true})
|
||||
@@ -192,9 +192,11 @@ func TestTokenMiddleware(t *testing.T) {
|
||||
Inputs: []io.Reader{input},
|
||||
Outputs: []io.Writer{output},
|
||||
}
|
||||
plugins.All = append(plugins.All, input, output)
|
||||
|
||||
// Start Gor
|
||||
go Start(plugins, quit)
|
||||
emitter := NewEmitter(quit)
|
||||
go emitter.Start(plugins, Settings.middleware)
|
||||
|
||||
// Wait for middleware to initialize
|
||||
// Give go compiller time to build programm
|
||||
@@ -219,7 +221,7 @@ func TestTokenMiddleware(t *testing.T) {
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(quit)
|
||||
emitter.Close()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
Settings.middleware = ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user