diff --git a/config/config_it_test.go b/config/config_it_test.go index 83b86559d..db370dca6 100644 --- a/config/config_it_test.go +++ b/config/config_it_test.go @@ -20,54 +20,67 @@ along with this program. If not, see package config import ( + "net" "os" + "path" + "reflect" "testing" + "time" "github.com/cgrates/cgrates/utils" ) -// func TestNewCgrJsonCfgFromHttp(t *testing.T) { -// addr := "https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/tutmongo/cgrates.json" -// expVal, err := NewCgrJsonCfgFromFile(path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo", "cgrates.json")) -// if err != nil { -// t.Fatal(err) -// } +func TestNewCgrJsonCfgFromHttp(t *testing.T) { + addr := "https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/tutmongo/cgrates.json" + expVal, err := NewDefaultCGRConfig() + if err != nil { + t.Fatal(err) + } + err = expVal.loadConfigFromPath(path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), + []func(*CgrJsonCfg) error{expVal.loadFromJsonCfg}) + if err != nil { + t.Fatal(err) + } -// if _, err = net.DialTimeout("tcp", addr, time.Second); err != nil { // check if site is up -// return -// } + if _, err = net.DialTimeout("tcp", addr, time.Second); err != nil { // check if site is up + return + } -// if rply, err := NewCgrJsonCfgFromHttp(addr); err != nil { -// t.Error(err) -// } else if !reflect.DeepEqual(expVal, rply) { -// t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expVal), utils.ToJSON(rply)) -// } + rply, err := NewDefaultCGRConfig() + if err != nil { + t.Fatal(err) + } + if err = rply.loadConfigFromPath(addr, []func(*CgrJsonCfg) error{rply.loadFromJsonCfg}); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(expVal, rply) { + t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expVal), utils.ToJSON(rply)) + } -// } +} -// func TestNewCGRConfigFromPath(t *testing.T) { -// for key, val := range map[string]string{"LOGGER": "*syslog", "LOG_LEVEL": "6", "TLS_VERIFY": "false", "ROUND_DEC": "5", -// "DB_ENCODING": "*msgpack", "TP_EXPORT_DIR": "/var/spool/cgrates/tpe", "FAILED_POSTS_DIR": "/var/spool/cgrates/failed_posts", -// "DF_TENANT": "cgrates.org", "TIMEZONE": "Local"} { -// os.Setenv(key, val) -// } -// addr := "https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/a.json;https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/b/b.json;https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/c.json;https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/d.json" -// expVal, err := NewCGRConfigFromPath(path.Join("/usr", "share", "cgrates", "conf", "samples", "multifiles")) -// if err != nil { -// t.Fatal(err) -// } +func TestNewCGRConfigFromPath(t *testing.T) { + for key, val := range map[string]string{"LOGGER": "*syslog", "LOG_LEVEL": "6", "TLS_VERIFY": "false", "ROUND_DEC": "5", + "DB_ENCODING": "*msgpack", "TP_EXPORT_DIR": "/var/spool/cgrates/tpe", "FAILED_POSTS_DIR": "/var/spool/cgrates/failed_posts", + "DF_TENANT": "cgrates.org", "TIMEZONE": "Local"} { + os.Setenv(key, val) + } + addr := "https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/a.json;https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/b/b.json;https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/c.json;https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/d.json" + expVal, err := NewCGRConfigFromPath(path.Join("/usr", "share", "cgrates", "conf", "samples", "multifiles")) + if err != nil { + t.Fatal(err) + } -// if _, err = net.DialTimeout("tcp", addr, time.Second); err != nil { // check if site is up -// return -// } + if _, err = net.DialTimeout("tcp", addr, time.Second); err != nil { // check if site is up + return + } -// if rply, err := NewCGRConfigFromPath(addr); err != nil { -// t.Error(err) -// } else if !reflect.DeepEqual(expVal, rply) { -// t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expVal), utils.ToJSON(rply)) -// } + if rply, err := NewCGRConfigFromPath(addr); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(expVal, rply) { + t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expVal), utils.ToJSON(rply)) + } -// } +} func TestCgrCfgV1ReloadConfigSection(t *testing.T) { for _, dir := range []string{"/tmp/ers/in", "/tmp/ers/out"} { diff --git a/services/attributes.go b/services/attributes.go index 5b7b29219..41b4191fe 100644 --- a/services/attributes.go +++ b/services/attributes.go @@ -76,7 +76,9 @@ func (attrS *AttributeService) GetIntenternalChan() (conn chan rpcclient.RpcClie } // Reload handles the change of config -func (attrS *AttributeService) Reload(sp servmanager.ServiceProvider) (err error) { return } +func (attrS *AttributeService) Reload(sp servmanager.ServiceProvider) (err error) { + return +} // Shutdown stops the service func (attrS *AttributeService) Shutdown() (err error) {