summaryrefslogtreecommitdiff
path: root/plugins/app/tests
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/app/tests')
-rw-r--r--plugins/app/tests/.rr.yaml2
-rw-r--r--plugins/app/tests/factory_test.go16
-rw-r--r--plugins/app/tests/hello.php20
-rw-r--r--plugins/app/tests/plugin_1.go4
-rw-r--r--plugins/app/tests/plugin_2.go4
5 files changed, 35 insertions, 11 deletions
diff --git a/plugins/app/tests/.rr.yaml b/plugins/app/tests/.rr.yaml
index 171f51dc..c9d1bd40 100644
--- a/plugins/app/tests/.rr.yaml
+++ b/plugins/app/tests/.rr.yaml
@@ -1,5 +1,5 @@
app:
- command: "php hello.php"
+ command: "php plugins/app/tests/hello.php hello_echo"
user: ""
group: ""
env:
diff --git a/plugins/app/tests/factory_test.go b/plugins/app/tests/factory_test.go
index 7c885797..969c361c 100644
--- a/plugins/app/tests/factory_test.go
+++ b/plugins/app/tests/factory_test.go
@@ -9,24 +9,25 @@ import (
"github.com/spiral/endure"
"github.com/spiral/roadrunner/v2/plugins/app"
"github.com/spiral/roadrunner/v2/plugins/config"
+ "github.com/spiral/roadrunner/v2/plugins/logger"
"github.com/stretchr/testify/assert"
)
func TestFactory(t *testing.T) {
- container, err := endure.NewContainer(endure.DebugLevel, endure.RetryOnFail(true))
+ container, err := endure.NewContainer(nil, endure.RetryOnFail(true), endure.SetLogLevel(endure.DebugLevel))
if err != nil {
t.Fatal(err)
}
// config plugin
- vp := &config.ViperProvider{}
- vp.Path = ".rr.yaml"
+ vp := &config.Viper{}
+ vp.Path = "plugins/app/tests/.rr.yaml"
vp.Prefix = "rr"
err = container.Register(vp)
if err != nil {
t.Fatal(err)
}
- err = container.Register(&app.App{})
+ err = container.Register(&app.Plugin{})
if err != nil {
t.Fatal(err)
}
@@ -41,6 +42,11 @@ func TestFactory(t *testing.T) {
t.Fatal(err)
}
+ err = container.Register(&logger.ZapLogger{})
+ if err != nil {
+ t.Fatal(err)
+ }
+
err = container.Init()
if err != nil {
t.Fatal(err)
@@ -55,7 +61,7 @@ func TestFactory(t *testing.T) {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
- tt := time.NewTicker(time.Second * 2)
+ tt := time.NewTicker(time.Second * 200)
for {
select {
diff --git a/plugins/app/tests/hello.php b/plugins/app/tests/hello.php
index bf9e82cc..4219dcf4 100644
--- a/plugins/app/tests/hello.php
+++ b/plugins/app/tests/hello.php
@@ -1 +1,19 @@
-<?php echo "hello1 - " . time(); \ No newline at end of file
+<?php
+/**
+ * @var Goridge\RelayInterface $relay
+ */
+
+use Spiral\Goridge;
+use Spiral\RoadRunner;
+
+require "/vendor_php/autoload.php";
+
+$rr = new RoadRunner\Worker($relay);
+
+while ($in = $rr->receive($ctx)) {
+ try {
+ $rr->send((string)$in);
+ } catch (\Throwable $e) {
+ $rr->error((string)$e);
+ }
+} \ No newline at end of file
diff --git a/plugins/app/tests/plugin_1.go b/plugins/app/tests/plugin_1.go
index 7259ea9d..c6287f5c 100644
--- a/plugins/app/tests/plugin_1.go
+++ b/plugins/app/tests/plugin_1.go
@@ -9,11 +9,11 @@ import (
)
type Foo struct {
- configProvider config.Provider
+ configProvider config.Configurer
spawner app.WorkerFactory
}
-func (f *Foo) Init(p config.Provider, spw app.WorkerFactory) error {
+func (f *Foo) Init(p config.Configurer, spw app.WorkerFactory) error {
f.configProvider = p
f.spawner = spw
return nil
diff --git a/plugins/app/tests/plugin_2.go b/plugins/app/tests/plugin_2.go
index fbb9ca11..51fb83a4 100644
--- a/plugins/app/tests/plugin_2.go
+++ b/plugins/app/tests/plugin_2.go
@@ -12,11 +12,11 @@ import (
)
type Foo2 struct {
- configProvider config.Provider
+ configProvider config.Configurer
wf app.WorkerFactory
}
-func (f *Foo2) Init(p config.Provider, workerFactory app.WorkerFactory) error {
+func (f *Foo2) Init(p config.Configurer, workerFactory app.WorkerFactory) error {
f.configProvider = p
f.wf = workerFactory
return nil