From afabe6fe14d9e16b203419617f377fdb393b3010 Mon Sep 17 00:00:00 2001 From: DanB Date: Sun, 12 Mar 2017 18:44:35 +0100 Subject: [PATCH] Configurable number of accounts in concurrent A1it tests --- apier/v1/accounts.go | 1 - general_tests/a1_it_test.go | 21 +++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apier/v1/accounts.go b/apier/v1/accounts.go index ad2b98fc8..7ac5c8fd1 100644 --- a/apier/v1/accounts.go +++ b/apier/v1/accounts.go @@ -116,7 +116,6 @@ func (self *ApierV1) RemActionTiming(attrs AttrRemActionTiming, reply *string) ( err = self.RatingDb.SetActionPlan(ap.Id, ap, true, utils.NonTransactional) goto UPDATE } - if attrs.ActionTimingId != "" { // delete only a action timing from action plan for i, at := range ap.ActionTimings { if at.Uuid == attrs.ActionTimingId { diff --git a/general_tests/a1_it_test.go b/general_tests/a1_it_test.go index d6c06a450..df3abbfca 100644 --- a/general_tests/a1_it_test.go +++ b/general_tests/a1_it_test.go @@ -21,6 +21,7 @@ package general_tests import ( "encoding/json" + "fmt" "net/rpc" "net/rpc/jsonrpc" "path" @@ -233,7 +234,10 @@ func TestA1itDataSession1(t *testing.T) { func TestA1itConcurrentAPs(t *testing.T) { var wg sync.WaitGroup - acnts := []string{"acnt1", "acnt2"} + var acnts []string + for i := 0; i < 1000; i++ { + acnts = append(acnts, fmt.Sprintf("acnt_%d", i)) + } // Set initial action plans for _, acnt := range acnts { wg.Add(1) @@ -260,25 +264,32 @@ func TestA1itConcurrentAPs(t *testing.T) { } // Change offer for _, acnt := range acnts { - wg.Add(1) + wg.Add(3) go func(acnt string) { var atms []*v1.AccountActionTiming if err := a1rpc.Call("ApierV1.GetAccountActionPlan", v1.AttrAcntAction{Tenant: "cgrates.org", Account: acnt}, &atms); err != nil { t.Error(err) - } else if len(atms) != 2 || atms[0].ActionPlanId != "PACKAGE_1" { - t.Errorf("Received: %+v", atms) + //} else if len(atms) != 2 || atms[0].ActionPlanId != "PACKAGE_1" { + // t.Errorf("Received: %+v", atms) } + wg.Done() + }(acnt) + go func(acnt string) { var reply string if err := a1rpc.Call("ApierV1.RemActionTiming", v1.AttrRemActionTiming{Tenant: "cgrates.org", Account: acnt, ActionPlanId: "PACKAGE_1"}, &reply); err != nil { t.Error(err) } + wg.Done() + }(acnt) + go func(acnt string) { attrSetAcnt := v2.AttrSetAccount{ Tenant: "cgrates.org", Account: acnt, ActionPlanIDs: &[]string{"PACKAGE_2"}, } + var reply string if err := a1rpc.Call("ApierV2.SetAccount", attrSetAcnt, &reply); err != nil { t.Error(err) } @@ -287,11 +298,13 @@ func TestA1itConcurrentAPs(t *testing.T) { } wg.Wait() // Make sure action plan was properly rem/set + aps = []*engine.ActionPlan{} if err := a1rpc.Call("ApierV1.GetActionPlan", v1.AttrGetActionPlan{ID: "PACKAGE_1"}, &aps); err != nil { t.Error(err) } else if len(aps[0].AccountIDs.Slice()) != 0 { t.Errorf("Received: %+v", aps[0]) } + aps = []*engine.ActionPlan{} if err := a1rpc.Call("ApierV1.GetActionPlan", v1.AttrGetActionPlan{ID: "PACKAGE_2"}, &aps); err != nil { t.Error(err) } else if len(aps[0].AccountIDs.Slice()) != len(acnts) {