From ecab4d7eaab79788516dacffa0164aa68688537e Mon Sep 17 00:00:00 2001 From: andronache Date: Wed, 24 Feb 2021 09:48:10 +0200 Subject: [PATCH] Refactor tests in config --- config/config_it_test.go | 78 ++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/config/config_it_test.go b/config/config_it_test.go index 3d4f38828..beb0958bd 100644 --- a/config/config_it_test.go +++ b/config/config_it_test.go @@ -135,7 +135,9 @@ func testNewCGRConfigFromPath(t *testing.T) { } func testCGRConfigReloadAttributeS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -163,7 +165,9 @@ func testCGRConfigReloadAttributeS(t *testing.T) { func testCGRConfigReloadChargerSDryRun(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -183,7 +187,9 @@ func testCGRConfigReloadChargerSDryRun(t *testing.T) { func testCGRConfigReloadChargerS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -208,7 +214,9 @@ func testCGRConfigReloadChargerS(t *testing.T) { func testCGRConfigReloadThresholdS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -232,7 +240,9 @@ func testCGRConfigReloadThresholdS(t *testing.T) { func testCGRConfigReloadStatS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -257,7 +267,9 @@ func testCGRConfigReloadStatS(t *testing.T) { func testCGRConfigReloadResourceS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -282,7 +294,9 @@ func testCGRConfigReloadResourceS(t *testing.T) { func testCGRConfigReloadSupplierS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -311,7 +325,9 @@ func testCGRConfigReloadSupplierS(t *testing.T) { func testCGRConfigV1ReloadConfigFromPathInvalidSection(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } expectedErr := "Invalid section: " var reply string if err := cfg.V1ReloadConfig(&ReloadArgs{ @@ -333,6 +349,9 @@ func testV1ReloadConfigFromPathConfigSanity(t *testing.T) { expectedErr := " not enabled but requested by component" var reply string cfg := NewDefaultCGRConfig() + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } if err := cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutinternal"), Section: ChargerSCfgJson}, &reply); err == nil || err.Error() != expectedErr { @@ -351,7 +370,9 @@ func testLoadConfigFromHTTPValidURL(t *testing.T) { func testCGRConfigReloadSchedulerS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), @@ -375,7 +396,9 @@ func testCGRConfigReloadSchedulerS(t *testing.T) { func testCGRConfigReloadCDRs(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.RalsCfg().Enabled = true var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ @@ -410,7 +433,9 @@ func testCGRConfigReloadCDRs(t *testing.T) { func testCGRConfigReloadRALs(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } blMap := cfg.RalsCfg().BalanceRatingSubject maxComp := cfg.RalsCfg().MaxComputedUsage var reply string @@ -441,7 +466,9 @@ func testCGRConfigReloadRALs(t *testing.T) { func testCGRConfigReloadSessionS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.RalsCfg().Enabled = true cfg.ChargerSCfg().Enabled = true cfg.CdrsCfg().Enabled = true @@ -500,7 +527,9 @@ func testCGRConfigReloadERs(t *testing.T) { } cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.SessionSCfg().Enabled = true var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ @@ -575,7 +604,9 @@ func testCGRConfigReloadERs(t *testing.T) { func testCGRConfigReloadDNSAgent(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.SessionSCfg().Enabled = true var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ @@ -601,7 +632,9 @@ func testCGRConfigReloadDNSAgent(t *testing.T) { func testCGRConfigReloadFreeswitchAgent(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.SessionSCfg().Enabled = true var reply string if err = cfg.V1ReloadConfig(&ReloadArgs{ @@ -774,6 +807,9 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { } cfg := NewDefaultCGRConfig() + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } var reply string var rcv map[string]interface{} @@ -804,7 +840,9 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { func testCGRConfigReloadConfigFromJSONSessionS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.RalsCfg().Enabled = true cfg.ChargerSCfg().Enabled = true cfg.CdrsCfg().Enabled = true @@ -863,7 +901,9 @@ func testCGRConfigReloadConfigFromJSONSessionS(t *testing.T) { func testCGRConfigReloadConfigFromStringSessionS(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.RalsCfg().Enabled = true cfg.ChargerSCfg().Enabled = true cfg.CdrsCfg().Enabled = true @@ -927,7 +967,9 @@ func testCGRConfigReloadConfigFromStringSessionS(t *testing.T) { func testCGRConfigReloadAll(t *testing.T) { cfg := NewDefaultCGRConfig() - + for _, section := range sortedCfgSections { + cfg.rldChans[section] = make(chan struct{}, 1) + } cfg.RalsCfg().Enabled = true cfg.ChargerSCfg().Enabled = true cfg.CdrsCfg().Enabled = true