summaryrefslogtreecommitdiff
path: root/tests/plugins/server/plugin_sockets.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-09-16 21:46:50 +0300
committerGitHub <[email protected]>2021-09-16 21:46:50 +0300
commit3581b45f237a3f7aa29591ceb2bf6f4a4642a2f5 (patch)
treee723b19ec1ac16b7ccc7b3c2da69d4a416d63d81 /tests/plugins/server/plugin_sockets.go
parent337d292dd2d6ff0a555098b1970d8194d8df8bc2 (diff)
parent823d831b57b75f70c7c3bbbee355f2016633bb3b (diff)
[#803]: feat(plugins): move plugins to a separate repositoryv2.5.0-alpha.2
[#803]: feat(plugins): move plugins to a separate repository
Diffstat (limited to 'tests/plugins/server/plugin_sockets.go')
-rw-r--r--tests/plugins/server/plugin_sockets.go109
1 files changed, 0 insertions, 109 deletions
diff --git a/tests/plugins/server/plugin_sockets.go b/tests/plugins/server/plugin_sockets.go
deleted file mode 100644
index 143a604c..00000000
--- a/tests/plugins/server/plugin_sockets.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package server
-
-import (
- "context"
-
- "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"
-)
-
-type Foo2 struct {
- configProvider config.Configurer
- wf server.Server
- pool pool.Pool
-}
-
-func (f *Foo2) Init(p config.Configurer, workerFactory server.Server) error {
- f.configProvider = p
- f.wf = workerFactory
- return nil
-}
-
-func (f *Foo2) Serve() chan error {
- const op = errors.Op("serve")
- var err error
- errCh := make(chan error, 1)
- conf := &server.Config{}
-
- // test payload for echo
- r := &payload.Payload{
- Context: nil,
- Body: []byte(Response),
- }
-
- 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, "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 *Foo2) Stop() error {
- f.pool.Destroy(context.Background())
- return nil
-}