From 31c635e3f7203dd5e534abdb3cf03cb0232765c6 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 5 Nov 2020 09:48:26 +0200 Subject: [PATCH] Updated dispatcherH integration tests --- config/configsanity.go | 2 +- data/conf/samples/dispatcherh/all2_mongo/cgrates.json | 4 ++-- data/conf/samples/dispatcherh/all2_mysql/cgrates.json | 4 ++-- data/conf/samples/dispatcherh/all_mongo/cgrates.json | 4 ++-- data/conf/samples/dispatcherh/all_mysql/cgrates.json | 4 ++-- data/conf/samples/dispatcherh/dispatchers_mongo/cgrates.json | 3 ++- data/conf/samples/dispatcherh/dispatchers_mysql/cgrates.json | 3 ++- dispatcherh/dispatcherh_it_test.go | 2 ++ services/dispatcherh.go | 2 +- services/dispatchers.go | 2 +- 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/config/configsanity.go b/config/configsanity.go index 92b92135f..6f118aed6 100644 --- a/config/configsanity.go +++ b/config/configsanity.go @@ -719,7 +719,7 @@ func (cfg *CGRConfig) checkConfigSanity() error { if !has { return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.DispatcherH, connID) } - if len(connCfg.Conns) != 0 { + if len(connCfg.Conns) != 1 { return fmt.Errorf("<%s> connection with id: <%s> needs to have only one host", utils.DispatcherH, connID) } if connCfg.Conns[0].Transport != rpcclient.HTTPjson { diff --git a/data/conf/samples/dispatcherh/all2_mongo/cgrates.json b/data/conf/samples/dispatcherh/all2_mongo/cgrates.json index 915d76308..3646c6992 100644 --- a/data/conf/samples/dispatcherh/all2_mongo/cgrates.json +++ b/data/conf/samples/dispatcherh/all2_mongo/cgrates.json @@ -36,7 +36,7 @@ }, "dispConn": { "strategy": "*first", - "conns": [{"address": "127.0.0.1:2012/registar", "transport":"*http_jsonrpc"}] + "conns": [{"address": "http://127.0.0.1:2080/dispatchers_registrar", "transport":"*http_jsonrpc"}] } }, @@ -105,7 +105,7 @@ "dispatcherh":{ - "enabled": false, + "enabled": true, "dispatchers_conns": ["dispConn"], "hosts": { "*default":[{"ID":"ALL", "register_transport": "*json", "register_tls": false}] diff --git a/data/conf/samples/dispatcherh/all2_mysql/cgrates.json b/data/conf/samples/dispatcherh/all2_mysql/cgrates.json index 896f46033..b9372ecaa 100644 --- a/data/conf/samples/dispatcherh/all2_mysql/cgrates.json +++ b/data/conf/samples/dispatcherh/all2_mysql/cgrates.json @@ -34,7 +34,7 @@ }, "dispConn": { "strategy": "*first", - "conns": [{"address": "127.0.0.1:2012/registar", "transport":"*http_jsonrpc"}] + "conns": [{"address": "http://127.0.0.1:2080/dispatchers_registrar", "transport":"*http_jsonrpc"}] } }, @@ -104,7 +104,7 @@ "dispatcherh":{ - "enabled": false, + "enabled": true, "dispatchers_conns": ["dispConn"], "hosts": { "*default":[{"ID":"ALL2", "register_transport": "*json", "register_tls": false}] diff --git a/data/conf/samples/dispatcherh/all_mongo/cgrates.json b/data/conf/samples/dispatcherh/all_mongo/cgrates.json index 437841e99..b5a143d5c 100644 --- a/data/conf/samples/dispatcherh/all_mongo/cgrates.json +++ b/data/conf/samples/dispatcherh/all_mongo/cgrates.json @@ -40,7 +40,7 @@ }, "dispConn": { "strategy": "*first", - "conns": [{"address": "127.0.0.1:2012/registar", "transport":"*http_jsonrpc"}] + "conns": [{"address": "http://127.0.0.1:2080/dispatchers_registrar", "transport":"*http_jsonrpc"}] } }, @@ -109,7 +109,7 @@ "dispatcherh":{ - "enabled": false, + "enabled": true, "dispatchers_conns": ["dispConn"], "hosts": { "*default":[{"ID":"ALL", "register_transport": "*json", "register_tls": false}] diff --git a/data/conf/samples/dispatcherh/all_mysql/cgrates.json b/data/conf/samples/dispatcherh/all_mysql/cgrates.json index 04250527c..b0213f935 100644 --- a/data/conf/samples/dispatcherh/all_mysql/cgrates.json +++ b/data/conf/samples/dispatcherh/all_mysql/cgrates.json @@ -37,7 +37,7 @@ }, "dispConn": { "strategy": "*first", - "conns": [{"address": "127.0.0.1:2012/registar", "transport":"*http_jsonrpc"}] + "conns": [{"address": "http://127.0.0.1:2080/dispatchers_registrar", "transport":"*http_jsonrpc"}] } }, @@ -107,7 +107,7 @@ "dispatcherh":{ - "enabled": false, + "enabled": true, "dispatchers_conns": ["dispConn"], "hosts": { "*default":[{"ID":"ALL2", "register_transport": "*json", "register_tls": false}] diff --git a/data/conf/samples/dispatcherh/dispatchers_mongo/cgrates.json b/data/conf/samples/dispatcherh/dispatchers_mongo/cgrates.json index 29096d20a..3d763cbf2 100644 --- a/data/conf/samples/dispatcherh/dispatchers_mongo/cgrates.json +++ b/data/conf/samples/dispatcherh/dispatchers_mongo/cgrates.json @@ -34,7 +34,8 @@ "caches":{ "partitions": { - "*dispatcher_routes": {"limit": -1, "ttl": "2s"} + "*dispatcher_routes": {"limit": -1, "ttl": "2s"}, + "*dispatcher_hosts": {"limit": -1, "ttl": "2s"} }, }, diff --git a/data/conf/samples/dispatcherh/dispatchers_mysql/cgrates.json b/data/conf/samples/dispatcherh/dispatchers_mysql/cgrates.json index b50361d35..bec156c79 100755 --- a/data/conf/samples/dispatcherh/dispatchers_mysql/cgrates.json +++ b/data/conf/samples/dispatcherh/dispatchers_mysql/cgrates.json @@ -25,7 +25,8 @@ "caches":{ "partitions": { - "*dispatcher_routes": {"limit": -1, "ttl": "2s"} + "*dispatcher_routes": {"limit": -1, "ttl": "2s"}, + "*dispatcher_hosts": {"limit": -1, "ttl": "2s"} }, }, diff --git a/dispatcherh/dispatcherh_it_test.go b/dispatcherh/dispatcherh_it_test.go index 9dc6e481a..35babf186 100644 --- a/dispatcherh/dispatcherh_it_test.go +++ b/dispatcherh/dispatcherh_it_test.go @@ -26,6 +26,7 @@ import ( "os/exec" "path" "testing" + "time" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" @@ -172,6 +173,7 @@ func testDsphStopEngines(t *testing.T) { if err := all2Cmd.Process.Kill(); err != nil { t.Fatal(err) } + time.Sleep(2 * time.Second) if _, err := testDsphGetNodeID(); err == nil || err.Error() != utils.ErrHostNotFound.Error() { t.Errorf("Expected error: %s received: %v", utils.ErrHostNotFound, err) } diff --git a/services/dispatcherh.go b/services/dispatcherh.go index c3375f8ee..56f2067ad 100644 --- a/services/dispatcherh.go +++ b/services/dispatcherh.go @@ -64,7 +64,7 @@ func (dspS *DispatcherHostsService) Start() (err error) { if dspS.IsRunning() { return utils.ErrServiceAlreadyRunning } - utils.Logger.Info("Starting CGRateS Dispatcher service.") + utils.Logger.Info("Starting CGRateS DispatcherH service.") dspS.Lock() defer dspS.Unlock() diff --git a/services/dispatchers.go b/services/dispatchers.go index efc60a208..7a845a3b7 100644 --- a/services/dispatchers.go +++ b/services/dispatchers.go @@ -72,7 +72,7 @@ func (dspS *DispatcherService) Start() (err error) { if dspS.IsRunning() { return utils.ErrServiceAlreadyRunning } - utils.Logger.Info("Starting CGRateS Dispatcher service.") + utils.Logger.Info("Starting CGRateS DispatcherS service.") fltrS := <-dspS.filterSChan dspS.filterSChan <- fltrS <-dspS.cacheS.GetPrecacheChannel(utils.CacheDispatcherProfiles)