summaryrefslogtreecommitdiff
path: root/tests/plugins/server/plugin_pipes.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/server/plugin_pipes.go')
-rw-r--r--tests/plugins/server/plugin_pipes.go128
1 files changed, 0 insertions, 128 deletions
diff --git a/tests/plugins/server/plugin_pipes.go b/tests/plugins/server/plugin_pipes.go
deleted file mode 100644
index d136da1e..00000000
--- a/tests/plugins/server/plugin_pipes.go
+++ /dev/null
@@ -1,128 +0,0 @@
-package server
-
-import (
- "context"
- "time"
-
- "github.com/spiral/errors"
- "github.com/spiral/roadrunner/v2/pkg/payload"
- "github.com/spiral/roadrunner/v2/pkg/pool"
- "github.com/spiral/roadrunner/v2/pkg/worker"
- "github.com/spiral/roadrunner/v2/plugins/config"
- "github.com/spiral/roadrunner/v2/plugins/server"
-)
-
-const ConfigSection = "server"
-const Response = "test"
-
-var testPoolConfig = &pool.Config{
- NumWorkers: 10,
- MaxJobs: 100,
- AllocateTimeout: time.Second * 10,
- DestroyTimeout: time.Second * 10,
- Supervisor: &pool.SupervisorConfig{
- WatchTick: 60 * time.Second,
- TTL: 1000 * time.Second,
- IdleTTL: 10 * time.Second,
- ExecTTL: 10 * time.Second,
- MaxWorkerMemory: 1000,
- },
-}
-
-type Foo struct {
- configProvider config.Configurer
- wf server.Server
- pool pool.Pool
-}
-
-func (f *Foo) Init(p config.Configurer, workerFactory server.Server) error {
- f.configProvider = p
- f.wf = workerFactory
- return nil
-}
-
-func (f *Foo) Serve() chan error {
- const op = errors.Op("serve")
-
- // test payload for echo
- r := &payload.Payload{
- Context: nil,
- Body: []byte(Response),
- }
-
- errCh := make(chan error, 1)
-
- conf := &server.Config{}
- var err error
- err = f.configProvider.UnmarshalKey(ConfigSection, conf)
- if err != nil {
- errCh <- err
- return errCh
- }
-
- // test CMDFactory
- cmd, err := f.wf.CmdFactory(nil)
- if err != nil {
- errCh <- err
- return errCh
- }
- if cmd == nil {
- errCh <- errors.E(op, errors.Str("command is nil"))
- return errCh
- }
-
- // test worker creation
- w, err := f.wf.NewWorker(context.Background(), nil)
- if err != nil {
- errCh <- err
- return errCh
- }
-
- // test that our worker is functional
- sw := worker.From(w)
-
- rsp, err := sw.Exec(r)
- if err != nil {
- errCh <- err
- return errCh
- }
-
- if string(rsp.Body) != Response {
- errCh <- errors.E("response from worker is wrong", errors.Errorf("response: %s", rsp.Body))
- return errCh
- }
-
- // should not be errors
- err = sw.Stop()
- if err != nil {
- errCh <- err
- return errCh
- }
-
- // test pool
- f.pool, err = f.wf.NewWorkerPool(context.Background(), testPoolConfig, nil)
- if err != nil {
- errCh <- err
- return errCh
- }
-
- // test pool execution
- rsp, err = f.pool.Exec(r)
- if err != nil {
- errCh <- err
- return errCh
- }
-
- // echo of the "test" should be -> test
- if string(rsp.Body) != Response {
- errCh <- errors.E("response from worker is wrong", errors.Errorf("response: %s", rsp.Body))
- return errCh
- }
-
- return errCh
-}
-
-func (f *Foo) Stop() error {
- f.pool.Destroy(context.Background())
- return nil
-}