diff options
author | Valery Piashchynski <[email protected]> | 2021-03-31 19:10:42 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-03-31 19:33:27 +0300 |
commit | 0d5ddfc3952b03c37fc728017fc33d2c2db3fbff (patch) | |
tree | a39fd013243266f28da0e968d44bb419c2229a9b | |
parent | 486f576a70302978ce98654c318d5525359bacc6 (diff) |
- Add tests and update CHANGELOGv2.1.0-beta.1
-rw-r--r-- | CHANGELOG.md | 11 | ||||
-rwxr-xr-x | tests/plugins/config/config_test.go | 55 | ||||
-rwxr-xr-x | tests/plugins/config/plugin3.go | 34 |
3 files changed, 99 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 82086de1..d652e1d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,18 @@ CHANGELOG ========= -v2.0.3 (-.-.2021) +v2.1.0 (06.04.2021) ------------------- +## 🩹 Fixes: + +- 🐛 Fix: bug with the temporal worker which does not follow general graceful shutdown period. + +v2.0.3 (29.03.2021) +------------------- + +## 🩹 Fixes: + - 🐛 Fix: slow last response when reached `max_jobs` limit. v2.0.2 (06.04.2021) diff --git a/tests/plugins/config/config_test.go b/tests/plugins/config/config_test.go index a0c2932b..79de2f59 100755 --- a/tests/plugins/config/config_test.go +++ b/tests/plugins/config/config_test.go @@ -215,3 +215,58 @@ func TestConfigEnvVariablesFail(t *testing.T) { _, err = container.Serve() assert.Error(t, err) } + +func TestConfigProvider_GeneralSection(t *testing.T) { + container, err := endure.NewContainer(nil, endure.RetryOnFail(true), endure.SetLogLevel(endure.ErrorLevel)) + if err != nil { + t.Fatal(err) + } + vp := &config.Viper{} + vp.Path = "configs/.rr.yaml" + vp.Prefix = "rr" + vp.Flags = nil + vp.CommonConfig = &config.General{GracefulTimeout: time.Second * 10} + + err = container.Register(vp) + if err != nil { + t.Fatal(err) + } + + err = container.Register(&Foo3{}) + if err != nil { + t.Fatal(err) + } + + err = container.Init() + if err != nil { + t.Fatal(err) + } + + errCh, err := container.Serve() + if err != nil { + t.Fatal(err) + } + + // stop by CTRL+C + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + + tt := time.NewTicker(time.Second * 2) + defer tt.Stop() + + for { + select { + case e := <-errCh: + assert.NoError(t, e.Error) + assert.NoError(t, container.Stop()) + return + case <-c: + er := container.Stop() + assert.NoError(t, er) + return + case <-tt.C: + assert.NoError(t, container.Stop()) + return + } + } +} diff --git a/tests/plugins/config/plugin3.go b/tests/plugins/config/plugin3.go new file mode 100755 index 00000000..41b79259 --- /dev/null +++ b/tests/plugins/config/plugin3.go @@ -0,0 +1,34 @@ +package config + +import ( + "time" + + "github.com/spiral/errors" + "github.com/spiral/roadrunner/v2/plugins/config" +) + +type Foo3 struct { + configProvider config.Configurer +} + +// Depends on S2 and DB (S3 in the current case) +func (f *Foo3) Init(p config.Configurer) error { + f.configProvider = p + return nil +} + +func (f *Foo3) Serve() chan error { + const op = errors.Op("foo_plugin_serve") + errCh := make(chan error, 1) + + if f.configProvider.GetCommonConfig().GracefulTimeout != time.Second*10 { + errCh <- errors.E(op, errors.Str("GracefulTimeout should be eq to 10 seconds")) + return errCh + } + + return errCh +} + +func (f *Foo3) Stop() error { + return nil +} |