summaryrefslogtreecommitdiff
path: root/tests/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-13 15:30:54 +0300
committerGitHub <[email protected]>2021-01-13 15:30:54 +0300
commit2a1c6092056c9dc1d725e393da97b72eb65071c4 (patch)
tree362f0eacdf2373bf208441577c1e69b8337bd71e /tests/plugins
parentf0f2b1aaf8e4df2ab65c6c47d9183f072ac86841 (diff)
parent2eed81d8fdbf8ee5134bb3b3f4c11c63cf6d757c (diff)
Merge pull request #473 from spiral/feature/env_variables
feat(env): Add RR system environment variables
Diffstat (limited to 'tests/plugins')
-rwxr-xr-xtests/plugins/config/.rr.yaml3
-rwxr-xr-xtests/plugins/config/config_test.go6
-rwxr-xr-xtests/plugins/config/plugin1.go47
-rw-r--r--tests/plugins/kv/boltdb/plugin_test.go2
-rw-r--r--tests/plugins/kv/memcached/plugin_test.go2
-rw-r--r--tests/plugins/kv/memory/plugin_test.go2
-rw-r--r--tests/plugins/rpc/configs/.rr-rpc-disabled.yaml3
-rw-r--r--tests/plugins/rpc/configs/.rr.yaml1
8 files changed, 53 insertions, 13 deletions
diff --git a/tests/plugins/config/.rr.yaml b/tests/plugins/config/.rr.yaml
index 732a1366..bad2846a 100755
--- a/tests/plugins/config/.rr.yaml
+++ b/tests/plugins/config/.rr.yaml
@@ -1,3 +1,6 @@
+rpc:
+ listen: tcp://localhost:6060
+
reload:
enabled: true
interval: 1s
diff --git a/tests/plugins/config/config_test.go b/tests/plugins/config/config_test.go
index 858fcb80..6d95ba70 100755
--- a/tests/plugins/config/config_test.go
+++ b/tests/plugins/config/config_test.go
@@ -44,6 +44,7 @@ func TestViperProvider_Init(t *testing.T) {
signal.Notify(c, os.Interrupt)
tt := time.NewTicker(time.Second * 2)
+ defer tt.Stop()
for {
select {
@@ -53,12 +54,9 @@ func TestViperProvider_Init(t *testing.T) {
return
case <-c:
er := container.Stop()
- if er != nil {
- panic(er)
- }
+ assert.NoError(t, er)
return
case <-tt.C:
- tt.Stop()
assert.NoError(t, container.Stop())
return
}
diff --git a/tests/plugins/config/plugin1.go b/tests/plugins/config/plugin1.go
index 2afe79a4..a6c06aec 100755
--- a/tests/plugins/config/plugin1.go
+++ b/tests/plugins/config/plugin1.go
@@ -1,12 +1,41 @@
package config
import (
- "errors"
"time"
+ "github.com/spiral/errors"
"github.com/spiral/roadrunner/v2/plugins/config"
)
+type AllConfig struct {
+ RPC struct {
+ Listen string `yaml:"listen"`
+ } `yaml:"rpc"`
+ Reload struct {
+ Enabled bool `yaml:"enabled"`
+ Interval string `yaml:"interval"`
+ Patterns []string `yaml:"patterns"`
+ Services struct {
+ HTTP struct {
+ Recursive bool `yaml:"recursive"`
+ Ignore []string `yaml:"ignore"`
+ Patterns []string `yaml:"patterns"`
+ Dirs []string `yaml:"dirs"`
+ } `yaml:"http"`
+ Jobs struct {
+ Recursive bool `yaml:"recursive"`
+ Ignore []string `yaml:"ignore"`
+ Dirs []string `yaml:"dirs"`
+ } `yaml:"jobs"`
+ RPC struct {
+ Recursive bool `yaml:"recursive"`
+ Patterns []string `yaml:"patterns"`
+ Dirs []string `yaml:"dirs"`
+ } `yaml:"rpc"`
+ } `yaml:"services"`
+ } `yaml:"reload"`
+}
+
// ReloadConfig is a Reload configuration point.
type ReloadConfig struct {
Interval time.Duration
@@ -33,6 +62,7 @@ func (f *Foo) Init(p config.Configurer) error {
}
func (f *Foo) Serve() chan error {
+ const op = errors.Op("foo serve")
errCh := make(chan error, 1)
r := &ReloadConfig{}
@@ -42,7 +72,20 @@ func (f *Foo) Serve() chan error {
}
if len(r.Patterns) == 0 {
- errCh <- errors.New("should be at least one pattern, but got 0")
+ errCh <- errors.E(op, errors.Str("should be at least one pattern, but got 0"))
+ return errCh
+ }
+
+ var allCfg AllConfig
+ err = f.configProvider.Unmarshal(&allCfg)
+ if err != nil {
+ errCh <- errors.E(op, errors.Str("should be at least one pattern, but got 0"))
+ return errCh
+ }
+
+ if allCfg.RPC.Listen != "tcp://localhost:6060" {
+ errCh <- errors.E(op, errors.Str("RPC.Listen should be parsed"))
+ return errCh
}
return errCh
diff --git a/tests/plugins/kv/boltdb/plugin_test.go b/tests/plugins/kv/boltdb/plugin_test.go
index ba9b695a..5548402d 100644
--- a/tests/plugins/kv/boltdb/plugin_test.go
+++ b/tests/plugins/kv/boltdb/plugin_test.go
@@ -172,7 +172,7 @@ func testRPCMethods(t *testing.T) {
assert.Len(t, ttlRes, 3)
// HAS AFTER TTL
- time.Sleep(time.Second * 11)
+ time.Sleep(time.Second * 15)
ret = make(map[string]bool)
keys = []string{"a", "b", "d"}
err = client.Call("boltdb.Has", keys, &ret)
diff --git a/tests/plugins/kv/memcached/plugin_test.go b/tests/plugins/kv/memcached/plugin_test.go
index 6eff8715..d4cb58bb 100644
--- a/tests/plugins/kv/memcached/plugin_test.go
+++ b/tests/plugins/kv/memcached/plugin_test.go
@@ -172,7 +172,7 @@ func testRPCMethods(t *testing.T) {
assert.Len(t, ttlRes, 0)
// HAS AFTER TTL
- time.Sleep(time.Second * 11)
+ time.Sleep(time.Second * 15)
ret = make(map[string]bool)
keys = []string{"a", "b", "d"}
err = client.Call("memcached.Has", keys, &ret)
diff --git a/tests/plugins/kv/memory/plugin_test.go b/tests/plugins/kv/memory/plugin_test.go
index c6f94602..ee01fabb 100644
--- a/tests/plugins/kv/memory/plugin_test.go
+++ b/tests/plugins/kv/memory/plugin_test.go
@@ -172,7 +172,7 @@ func testRPCMethods(t *testing.T) {
assert.Len(t, ttlRes, 3)
// HAS AFTER TTL
- time.Sleep(time.Second * 11)
+ time.Sleep(time.Second * 15)
ret = make(map[string]bool)
keys = []string{"a", "b", "d"}
err = client.Call("memory.Has", keys, &ret)
diff --git a/tests/plugins/rpc/configs/.rr-rpc-disabled.yaml b/tests/plugins/rpc/configs/.rr-rpc-disabled.yaml
index d5c185e7..5ab359d3 100644
--- a/tests/plugins/rpc/configs/.rr-rpc-disabled.yaml
+++ b/tests/plugins/rpc/configs/.rr-rpc-disabled.yaml
@@ -1,6 +1,3 @@
-rpc:
- listen: tcp://127.0.0.1:6001
- disabled: true
logs:
mode: development
level: error \ No newline at end of file
diff --git a/tests/plugins/rpc/configs/.rr.yaml b/tests/plugins/rpc/configs/.rr.yaml
index d2cb6c70..67d935e3 100644
--- a/tests/plugins/rpc/configs/.rr.yaml
+++ b/tests/plugins/rpc/configs/.rr.yaml
@@ -1,6 +1,5 @@
rpc:
listen: tcp://127.0.0.1:6001
- disabled: false
logs:
mode: development
level: error \ No newline at end of file