summaryrefslogtreecommitdiff
path: root/pkg/pool/static_pool_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-18 22:57:33 +0300
committerValery Piashchynski <[email protected]>2020-12-18 22:57:33 +0300
commitad39466afb39fac49977cfb97f20f682f54bf35e (patch)
tree59b630ad0ef9b52eb13e0df5c8e41d92ce277950 /pkg/pool/static_pool_test.go
parentee0cb478c74c393a35155c2bf51e1ef260e0e5e2 (diff)
Move roadrunner payload out of internal to pkgv2.0.0-alpha25
Diffstat (limited to 'pkg/pool/static_pool_test.go')
-rwxr-xr-xpkg/pool/static_pool_test.go39
1 files changed, 20 insertions, 19 deletions
diff --git a/pkg/pool/static_pool_test.go b/pkg/pool/static_pool_test.go
index dd33a1a6..b96e9214 100755
--- a/pkg/pool/static_pool_test.go
+++ b/pkg/pool/static_pool_test.go
@@ -14,6 +14,7 @@ import (
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2/interfaces/events"
"github.com/spiral/roadrunner/v2/internal"
+ "github.com/spiral/roadrunner/v2/pkg/payload"
"github.com/spiral/roadrunner/v2/pkg/pipe"
"github.com/stretchr/testify/assert"
)
@@ -80,7 +81,7 @@ func Test_StaticPool_Echo(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -104,7 +105,7 @@ func Test_StaticPool_Echo_NilContext(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(internal.Payload{Body: []byte("hello"), Context: nil})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello"), Context: nil})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -128,7 +129,7 @@ func Test_StaticPool_Echo_Context(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(internal.Payload{Body: []byte("hello"), Context: []byte("world")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello"), Context: []byte("world")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -151,7 +152,7 @@ func Test_StaticPool_JobError(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res.Body)
@@ -189,7 +190,7 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
}
})
- res, err := p.ExecWithContext(ctx, internal.Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, payload.Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res.Context)
assert.Nil(t, res.Body)
@@ -212,7 +213,7 @@ func Test_StaticPool_Broken_FromOutside(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -287,11 +288,11 @@ func Test_StaticPool_Replace_Worker(t *testing.T) {
var lastPID string
lastPID = strconv.Itoa(int(p.Workers()[0].Pid()))
- res, _ := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, _ := p.Exec(payload.Payload{Body: []byte("hello")})
assert.Equal(t, lastPID, string(res.Body))
for i := 0; i < 10; i++ {
- res, err := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -323,14 +324,14 @@ func Test_StaticPool_Debug_Worker(t *testing.T) {
assert.Len(t, p.Workers(), 0)
var lastPID string
- res, _ := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, _ := p.Exec(payload.Payload{Body: []byte("hello")})
assert.NotEqual(t, lastPID, string(res.Body))
assert.Len(t, p.Workers(), 0)
for i := 0; i < 10; i++ {
assert.Len(t, p.Workers(), 0)
- res, err := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -363,14 +364,14 @@ func Test_StaticPool_Stop_Worker(t *testing.T) {
var lastPID string
lastPID = strconv.Itoa(int(p.Workers()[0].Pid()))
- res, err := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello")})
if err != nil {
t.Fatal(err)
}
assert.Equal(t, lastPID, string(res.Body))
for i := 0; i < 10; i++ {
- res, err := p.Exec(internal.Payload{Body: []byte("hello")})
+ res, err := p.Exec(payload.Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -400,7 +401,7 @@ func Test_Static_Pool_Destroy_And_Close(t *testing.T) {
assert.NoError(t, err)
p.Destroy(ctx)
- _, err = p.Exec(internal.Payload{Body: []byte("100")})
+ _, err = p.Exec(payload.Payload{Body: []byte("100")})
assert.Error(t, err)
}
@@ -422,7 +423,7 @@ func Test_Static_Pool_Destroy_And_Close_While_Wait(t *testing.T) {
assert.NoError(t, err)
go func() {
- _, err := p.Exec(internal.Payload{Body: []byte("100")})
+ _, err := p.Exec(payload.Payload{Body: []byte("100")})
if err != nil {
t.Errorf("error executing payload: error %v", err)
}
@@ -430,7 +431,7 @@ func Test_Static_Pool_Destroy_And_Close_While_Wait(t *testing.T) {
time.Sleep(time.Millisecond * 10)
p.Destroy(ctx)
- _, err = p.Exec(internal.Payload{Body: []byte("100")})
+ _, err = p.Exec(payload.Payload{Body: []byte("100")})
assert.Error(t, err)
}
@@ -456,7 +457,7 @@ func Test_Static_Pool_Handle_Dead(t *testing.T) {
w.State().Set(internal.StateErrored)
}
- _, err = p.Exec(internal.Payload{Body: []byte("hello")})
+ _, err = p.Exec(payload.Payload{Body: []byte("hello")})
assert.Error(t, err)
}
@@ -494,7 +495,7 @@ func Benchmark_Pool_Echo(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
- if _, err := p.Exec(internal.Payload{Body: []byte("hello")}); err != nil {
+ if _, err := p.Exec(payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
@@ -520,7 +521,7 @@ func Benchmark_Pool_Echo_Batched(b *testing.B) {
wg.Add(1)
go func() {
defer wg.Done()
- if _, err := p.Exec(internal.Payload{Body: []byte("hello")}); err != nil {
+ if _, err := p.Exec(payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
log.Println(err)
}
@@ -549,7 +550,7 @@ func Benchmark_Pool_Echo_Replaced(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
- if _, err := p.Exec(internal.Payload{Body: []byte("hello")}); err != nil {
+ if _, err := p.Exec(payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
log.Println(err)
}