summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-13 11:11:36 +0300
committerValery Piashchynski <[email protected]>2021-01-13 11:11:36 +0300
commitc3cf1d988b980e9408862d380f7ae33dae501e05 (patch)
tree79430ed15f75e23242e921a1471633e33279c395 /tests
parent44b0ad21e0d70e413a62814fb408faa033b0d478 (diff)
Update styly of the .rr.yaml
Add comments Add support for the automatically set RR_RPC, RR_HTTP env variables for the worker process.
Diffstat (limited to 'tests')
-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/rpc/configs/.rr-rpc-disabled.yaml3
-rw-r--r--tests/plugins/rpc/configs/.rr.yaml1
5 files changed, 50 insertions, 10 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/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