mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated configuration integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
a5850abbcc
commit
f50fecee65
@@ -20,54 +20,67 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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"} {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user