From 126a8f0dbd040c96168a7dc73986fc76f7d661f4 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Tue, 19 Jun 2018 22:26:40 +0300 Subject: stricter pool validations --- service/http/config.go | 4 ++++ service/http/config_test.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/service/http/config.go b/service/http/config.go index fb4574b1..76a0f539 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -34,6 +34,10 @@ func (cfg *Config) Valid() error { return errors.New("mailformed workers config") } + if cfg.Workers.Pool == nil { + return errors.New("mailformed workers config (pool config is missing)") + } + if !strings.Contains(cfg.Address, ":") { return errors.New("mailformed server address") } diff --git a/service/http/config_test.go b/service/http/config_test.go index 44c58f35..d47934ea 100644 --- a/service/http/config_test.go +++ b/service/http/config_test.go @@ -64,6 +64,25 @@ func Test_Config_NoWorkers(t *testing.T) { assert.Error(t, cfg.Valid()) } + +func Test_Config_NoPool(t *testing.T) { + cfg := &Config{ + Enable: true, + Address: ":8080", + MaxRequest: 1024, + Uploads: &UploadsConfig{ + Dir: os.TempDir(), + Forbid: []string{".go"}, + }, + Workers: &roadrunner.ServerConfig{ + Command: "php php-src/tests/client.php echo pipes", + Relay: "pipes", + }, + } + + assert.Error(t, cfg.Valid()) +} + func Test_Config_InvalidAddress(t *testing.T) { cfg := &Config{ Enable: true, -- cgit v1.2.3 From 5ba260aa4eef1b79e941129a8b20c95754d494b9 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Tue, 19 Jun 2018 22:32:43 +0300 Subject: stricter pool validations --- service/http/config.go | 4 ++++ service/http/config_test.go | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/service/http/config.go b/service/http/config.go index 76a0f539..19a2e71d 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -38,6 +38,10 @@ func (cfg *Config) Valid() error { return errors.New("mailformed workers config (pool config is missing)") } + if err := cfg.Workers.Pool.Valid(); err != nil { + return err + } + if !strings.Contains(cfg.Address, ":") { return errors.New("mailformed server address") } diff --git a/service/http/config_test.go b/service/http/config_test.go index d47934ea..cb804f4a 100644 --- a/service/http/config_test.go +++ b/service/http/config_test.go @@ -64,8 +64,30 @@ func Test_Config_NoWorkers(t *testing.T) { assert.Error(t, cfg.Valid()) } - func Test_Config_NoPool(t *testing.T) { + cfg := &Config{ + Enable: true, + Address: ":8080", + MaxRequest: 1024, + Uploads: &UploadsConfig{ + Dir: os.TempDir(), + Forbid: []string{".go"}, + }, + Workers: &roadrunner.ServerConfig{ + Command: "php php-src/tests/client.php echo pipes", + Relay: "pipes", + Pool: &roadrunner.Config{ + NumWorkers: 0, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + }, + } + + assert.Error(t, cfg.Valid()) +} + +func Test_Config_DeadPool(t *testing.T) { cfg := &Config{ Enable: true, Address: ":8080", -- cgit v1.2.3