summaryrefslogtreecommitdiff
path: root/socket_factory_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2020-10-25 15:55:51 +0300
committerWolfy-J <[email protected]>2020-10-25 15:55:51 +0300
commitba5c562f9038ba434e655fb82c44597fcccaff16 (patch)
treeff112b9dcffda63bc40094a57d0df61622368445 /socket_factory_test.go
parent3bdf7d02d83d1ff4726f3fbb01a45d016f39abec (diff)
- massive update in roadrunner 2.0 abstractions
Diffstat (limited to 'socket_factory_test.go')
-rw-r--r--socket_factory_test.go61
1 files changed, 31 insertions, 30 deletions
diff --git a/socket_factory_test.go b/socket_factory_test.go
index cfb95ca1..6ab87872 100644
--- a/socket_factory_test.go
+++ b/socket_factory_test.go
@@ -98,28 +98,29 @@ func Test_Tcp_StartError(t *testing.T) {
assert.Nil(t, w)
}
-// func Test_Tcp_Failboot(t *testing.T) {
-// time.Sleep(time.Millisecond * 10) // to ensure free socket
-//
-// ls, err := net.Listen("tcp", "localhost:9007")
-// if assert.NoError(t, err) {
-// defer func() {
-// err3 := ls.Close()
-// if err3 != nil {
-// t.Errorf("error closing the listener: error %v", err3)
-// }
-// }()
-// } else {
-// t.Skip("socket is busy")
-// }
-//
-// cmd := exec.Command("php", "tests/failboot.php")
-//
-// w, err2 := NewSocketServer(ls, time.Minute).SpawnWorkerWithContext(cmd)
-// assert.Nil(t, w)
-// assert.Error(t, err2)
-// assert.Contains(t, err2.Error(), "failboot")
-//}
+func Test_Tcp_Failboot(t *testing.T) {
+ time.Sleep(time.Millisecond * 10) // to ensure free socket
+ ctx := context.Background()
+
+ ls, err := net.Listen("tcp", "localhost:9007")
+ if assert.NoError(t, err) {
+ defer func() {
+ err3 := ls.Close()
+ if err3 != nil {
+ t.Errorf("error closing the listener: error %v", err3)
+ }
+ }()
+ } else {
+ t.Skip("socket is busy")
+ }
+
+ cmd := exec.Command("php", "tests/failboot.php")
+
+ w, err2 := NewSocketServer(ls, time.Minute).SpawnWorkerWithContext(ctx, cmd)
+ assert.Nil(t, w)
+ assert.Error(t, err2)
+ assert.Contains(t, err2.Error(), "failboot")
+}
func Test_Tcp_Timeout(t *testing.T) {
time.Sleep(time.Millisecond * 10) // to ensure free socket
@@ -161,7 +162,7 @@ func Test_Tcp_Invalid(t *testing.T) {
cmd := exec.Command("php", "tests/invalid.php")
- w, err := NewSocketServer(ls, time.Second*10).SpawnWorkerWithContext(ctx, cmd)
+ w, err := NewSocketServer(ls, time.Second*1).SpawnWorkerWithContext(ctx, cmd)
assert.Error(t, err)
assert.Nil(t, w)
}
@@ -208,7 +209,7 @@ func Test_Tcp_Broken(t *testing.T) {
t.Fatal(err)
}
- res, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")})
+ res, err := sw.Exec(Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res.Body)
assert.Nil(t, res.Context)
@@ -248,7 +249,7 @@ func Test_Tcp_Echo(t *testing.T) {
t.Fatal(err)
}
- res, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")})
+ res, err := sw.Exec(Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -304,7 +305,7 @@ func Test_Unix_Failboot(t *testing.T) {
cmd := exec.Command("php", "tests/failboot.php")
- w, err := NewSocketServer(ls, time.Second*2).SpawnWorkerWithContext(ctx, cmd)
+ w, err := NewSocketServer(ls, time.Second*1).SpawnWorkerWithContext(ctx, cmd)
assert.Nil(t, w)
assert.Error(t, err)
assert.Contains(t, err.Error(), "failboot")
@@ -393,7 +394,7 @@ func Test_Unix_Broken(t *testing.T) {
t.Fatal(err)
}
- res, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")})
+ res, err := sw.Exec(Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res.Context)
@@ -436,7 +437,7 @@ func Test_Unix_Echo(t *testing.T) {
t.Fatal(err)
}
- res, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")})
+ res, err := sw.Exec(Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -512,7 +513,7 @@ func Benchmark_Tcp_Worker_ExecEcho(b *testing.B) {
}
for n := 0; n < b.N; n++ {
- if _, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")}); err != nil {
+ if _, err := sw.Exec(Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
@@ -580,7 +581,7 @@ func Benchmark_Unix_Worker_ExecEcho(b *testing.B) {
}
for n := 0; n < b.N; n++ {
- if _, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")}); err != nil {
+ if _, err := sw.Exec(Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}