diff --git a/data/tariffplans/gocs/au_site/Chargers.csv b/data/tariffplans/gocs/au_site/Chargers.csv deleted file mode 100644 index c270b5867..000000000 --- a/data/tariffplans/gocs/au_site/Chargers.csv +++ /dev/null @@ -1,2 +0,0 @@ -#Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight -cgrates.org,DEFAULT,,,*default,*none,0 \ No newline at end of file diff --git a/data/tariffplans/gocs/au_site/DestinationRates.csv b/data/tariffplans/gocs/au_site/DestinationRates.csv deleted file mode 100644 index ec0002962..000000000 --- a/data/tariffplans/gocs/au_site/DestinationRates.csv +++ /dev/null @@ -1,4 +0,0 @@ -#Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy -DR_1002_20CNT,DST_1002,RT_20CNT,*up,4,0, -DR_1001_10CNT,DST_1001,RT_10CNT,*up,4,0, - diff --git a/data/tariffplans/gocs/au_site/Destinations.csv b/data/tariffplans/gocs/au_site/Destinations.csv deleted file mode 100644 index 27b629107..000000000 --- a/data/tariffplans/gocs/au_site/Destinations.csv +++ /dev/null @@ -1,3 +0,0 @@ -#Id,Prefix -DST_1002,1002 -DST_1001,1001 \ No newline at end of file diff --git a/data/tariffplans/gocs/au_site/Rates.csv b/data/tariffplans/gocs/au_site/Rates.csv deleted file mode 100644 index 0924201a6..000000000 --- a/data/tariffplans/gocs/au_site/Rates.csv +++ /dev/null @@ -1,5 +0,0 @@ -#Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart -RT_10CNT,0.2,0.1,60s,60s,0s -RT_10CNT,0,0.05,60s,1s,60s -RT_20CNT,0.4,0.2,60s,60s,0s -RT_20CNT,0,0.1,60s,1s,60s \ No newline at end of file diff --git a/data/tariffplans/gocs/au_site/RatingPlans.csv b/data/tariffplans/gocs/au_site/RatingPlans.csv deleted file mode 100644 index 391fa1234..000000000 --- a/data/tariffplans/gocs/au_site/RatingPlans.csv +++ /dev/null @@ -1,3 +0,0 @@ -#Id,DestinationRatesId,TimingTag,Weight -RP_1001,DR_1002_20CNT,*any,10 -RP_1002,DR_1001_10CNT,*any,10 \ No newline at end of file diff --git a/data/tariffplans/gocs/au_site/RatingProfiles.csv b/data/tariffplans/gocs/au_site/RatingProfiles.csv deleted file mode 100644 index 267aaa2c8..000000000 --- a/data/tariffplans/gocs/au_site/RatingProfiles.csv +++ /dev/null @@ -1,3 +0,0 @@ -#Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject -cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_1001, -cgrates.org,call,1002,2014-01-14T00:00:00Z,RP_1002, \ No newline at end of file diff --git a/data/tariffplans/gocs/us_site/Chargers.csv b/data/tariffplans/gocs/us_site/Chargers.csv deleted file mode 100644 index c270b5867..000000000 --- a/data/tariffplans/gocs/us_site/Chargers.csv +++ /dev/null @@ -1,2 +0,0 @@ -#Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight -cgrates.org,DEFAULT,,,*default,*none,0 \ No newline at end of file diff --git a/data/tariffplans/gocs/us_site/DestinationRates.csv b/data/tariffplans/gocs/us_site/DestinationRates.csv deleted file mode 100644 index ec0002962..000000000 --- a/data/tariffplans/gocs/us_site/DestinationRates.csv +++ /dev/null @@ -1,4 +0,0 @@ -#Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy -DR_1002_20CNT,DST_1002,RT_20CNT,*up,4,0, -DR_1001_10CNT,DST_1001,RT_10CNT,*up,4,0, - diff --git a/data/tariffplans/gocs/us_site/Destinations.csv b/data/tariffplans/gocs/us_site/Destinations.csv deleted file mode 100644 index 27b629107..000000000 --- a/data/tariffplans/gocs/us_site/Destinations.csv +++ /dev/null @@ -1,3 +0,0 @@ -#Id,Prefix -DST_1002,1002 -DST_1001,1001 \ No newline at end of file diff --git a/data/tariffplans/gocs/us_site/Rates.csv b/data/tariffplans/gocs/us_site/Rates.csv deleted file mode 100644 index 0924201a6..000000000 --- a/data/tariffplans/gocs/us_site/Rates.csv +++ /dev/null @@ -1,5 +0,0 @@ -#Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart -RT_10CNT,0.2,0.1,60s,60s,0s -RT_10CNT,0,0.05,60s,1s,60s -RT_20CNT,0.4,0.2,60s,60s,0s -RT_20CNT,0,0.1,60s,1s,60s \ No newline at end of file diff --git a/data/tariffplans/gocs/us_site/RatingPlans.csv b/data/tariffplans/gocs/us_site/RatingPlans.csv deleted file mode 100644 index 391fa1234..000000000 --- a/data/tariffplans/gocs/us_site/RatingPlans.csv +++ /dev/null @@ -1,3 +0,0 @@ -#Id,DestinationRatesId,TimingTag,Weight -RP_1001,DR_1002_20CNT,*any,10 -RP_1002,DR_1001_10CNT,*any,10 \ No newline at end of file diff --git a/data/tariffplans/gocs/us_site/RatingProfiles.csv b/data/tariffplans/gocs/us_site/RatingProfiles.csv deleted file mode 100644 index 267aaa2c8..000000000 --- a/data/tariffplans/gocs/us_site/RatingProfiles.csv +++ /dev/null @@ -1,3 +0,0 @@ -#Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject -cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_1001, -cgrates.org,call,1002,2014-01-14T00:00:00Z,RP_1002, \ No newline at end of file diff --git a/general_tests/gocs_it_test.go b/general_tests/gocs_it_test.go index 83f78c604..2b1e03c2f 100644 --- a/general_tests/gocs_it_test.go +++ b/general_tests/gocs_it_test.go @@ -24,9 +24,12 @@ import ( "net/rpc" "os/exec" "path" + "reflect" "testing" "time" + v1 "github.com/cgrates/cgrates/apier/v1" + "github.com/cgrates/cgrates/sessions" "github.com/cgrates/cgrates/utils" @@ -137,24 +140,47 @@ func testGOCSApierRpcConn(t *testing.T) { } func testGOCSLoadData(t *testing.T) { - attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "gocs", "us_site")} - var loadInst utils.LoadInstance - if err := usRPC.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &loadInst); err != nil { - t.Error(err) + chargerProfile := &v1.ChargerWithCache{ + ChargerProfile: &engine.ChargerProfile{ + Tenant: "cgrates.org", + ID: "DEFAULT", + RunID: utils.MetaDefault, + AttributeIDs: []string{utils.META_NONE}, + Weight: 10, + }, } - attrs = &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "gocs", "au_site")} - if err := auRPC.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &loadInst); err != nil { + var result string + if err := usRPC.Call(utils.ApierV1SetChargerProfile, chargerProfile, &result); err != nil { t.Error(err) + } else if result != utils.OK { + t.Error("Unexpected reply returned", result) } - time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups on au_site - attrs = &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "gocs", "dsp_site")} + var rpl *engine.ChargerProfile + if err := usRPC.Call(utils.ApierV1GetChargerProfile, + &utils.TenantID{Tenant: "cgrates.org", ID: "DEFAULT"}, &rpl); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(chargerProfile.ChargerProfile, rpl) { + t.Errorf("Expecting : %+v, received: %+v", chargerProfile.ChargerProfile, rpl) + } + if err := usRPC.Call(utils.ApierV1SetChargerProfile, chargerProfile, &result); err != nil { + t.Error(err) + } else if result != utils.OK { + t.Error("Unexpected reply returned", result) + } + if err := usRPC.Call(utils.ApierV1GetChargerProfile, + &utils.TenantID{Tenant: "cgrates.org", ID: "DEFAULT"}, &rpl); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(chargerProfile.ChargerProfile, rpl) { + t.Errorf("Expecting : %+v, received: %+v", chargerProfile.ChargerProfile, rpl) + } + wchan := make(chan struct{}, 1) go func() { loaderPath, err := exec.LookPath("cgr-loader") if err != nil { t.Error(err) } - loader := exec.Command(loaderPath, "-config_path", dspCfgPath, "-path", attrs.FolderPath) + loader := exec.Command(loaderPath, "-config_path", dspCfgPath, "-path", path.Join(*dataDir, "tariffplans", "gocs", "dsp_site")) if err := loader.Start(); err != nil { t.Error(err) @@ -194,6 +220,7 @@ func testGOCSLoadData(t *testing.T) { } else if rply := acnt.BalanceMap[utils.VOICE].GetTotalValue(); rply != expectedVoice { t.Errorf("Expecting: %v, received: %v", expectedVoice, rply) } + time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups on au_site } func testGOCSAuthSession(t *testing.T) {