From 74700402f25e7c583b48402113d456800f4baa98 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Thu, 10 Feb 2022 10:25:55 +0200 Subject: [PATCH] Repair it tests --- dispatchers/attributes_it_test.go | 25 ++++---- general_tests/attributes_it_test.go | 63 +++++++++++-------- .../loaders_internal_indexes_it_test.go | 11 ++-- general_tests/routes_cases_it_test.go | 5 -- 4 files changed, 57 insertions(+), 47 deletions(-) diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index 148dcbbc9..1ecc8ffb1 100644 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -262,7 +262,7 @@ func testDspAttrGetAttrFailover(t *testing.T) { }, } - var attrReply *engine.AttributeProfile + var attrReply engine.AttributeProfile var rplyEv engine.AttrSProcessEventReply if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent, ev, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() { @@ -272,9 +272,9 @@ func testDspAttrGetAttrFailover(t *testing.T) { if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent, ev, &rplyEv); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) - } else if reflect.DeepEqual(eRply, &rplyEv) { + } else if reflect.DeepEqual(*eRply, &rplyEv) { t.Errorf("Expecting: %s, received: %s", - utils.ToJSON(eRply), utils.ToJSON(rplyEv)) + utils.ToJSON(*eRply), utils.ToJSON(rplyEv)) } allEngine2.stopEngine(t) @@ -283,10 +283,11 @@ func testDspAttrGetAttrFailover(t *testing.T) { ev, &attrReply); err != nil { t.Error(err) } + attrReply.Compile() sort.Strings(eAttrPrf.FilterIDs) sort.Strings(attrReply.FilterIDs) - if !reflect.DeepEqual(eAttrPrf, attrReply) { - t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply)) + if !reflect.DeepEqual(*eAttrPrf, attrReply) { + t.Errorf("Expecting: %s, received: %s", utils.ToJSON(*eAttrPrf), utils.ToJSON(attrReply)) } if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent, @@ -426,15 +427,16 @@ func testDspAttrTestAuthKey2(t *testing.T) { if *encoding == utils.MetaGOB { eAttrPrf.Attributes[0].FilterIDs = nil // empty slice are nil in gob } - var attrReply *engine.AttributeProfile + var attrReply engine.AttributeProfile if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent, ev, &attrReply); err != nil { t.Error(err) } + attrReply.Compile() sort.Strings(eAttrPrf.FilterIDs) sort.Strings(attrReply.FilterIDs) - if !reflect.DeepEqual(eAttrPrf, attrReply) { - t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply)) + if !reflect.DeepEqual(*eAttrPrf, attrReply) { + t.Errorf("Expecting: %s, received: %s", utils.ToJSON(*eAttrPrf), utils.ToJSON(attrReply)) } eRply := &engine.AttrSProcessEventReply{ @@ -536,7 +538,7 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) { }, } - var attrReply *engine.AttributeProfile + var attrReply engine.AttributeProfile var rplyEv engine.AttrSProcessEventReply // To ALL2 if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent, @@ -550,10 +552,11 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) { t.Error(err) } + attrReply.Compile() sort.Strings(eAttrPrf.FilterIDs) sort.Strings(attrReply.FilterIDs) - if !reflect.DeepEqual(eAttrPrf, attrReply) { - t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply)) + if !reflect.DeepEqual(*eAttrPrf, attrReply) { + t.Errorf("Expecting: %s, received: %s", utils.ToJSON(*eAttrPrf), utils.ToJSON(attrReply)) } // To ALL2 diff --git a/general_tests/attributes_it_test.go b/general_tests/attributes_it_test.go index 0faab533d..a36b72f26 100644 --- a/general_tests/attributes_it_test.go +++ b/general_tests/attributes_it_test.go @@ -208,13 +208,14 @@ func testAttributeSProcessEventWithAccount(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_ACCOUNT"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -279,13 +280,14 @@ func testAttributeSProcessEventWithAccountFull(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_ACCOUNT2"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -391,13 +393,14 @@ func testAttributeSProcessEventWithStat(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_STATS"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -463,13 +466,14 @@ func testAttributeSProcessEventWithStatFull(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_STATS2"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -598,13 +602,14 @@ func testAttributeSProcessEventWithResource(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_RESOURCE"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -674,13 +679,14 @@ func testAttributeSProcessEventWithResourceFull(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_RESOURCE2"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -758,13 +764,14 @@ func testAttributeSProcessEventWithLibPhoneNumber(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_LIBPHONENUMBER2"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -846,13 +853,14 @@ func testAttributeSProcessEventWithLibPhoneNumberComposed(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_LIBPHONENUMBER_COMPOSED"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ @@ -924,13 +932,14 @@ func testAttributeSProcessEventWithLibPhoneNumberFull(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - var replyAttr *engine.AttributeProfile + var replyAttr engine.AttributeProfile if err := attrRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_LIBPHONENUMBER"}}, &replyAttr); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(alsPrf.AttributeProfile, replyAttr) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, replyAttr) + replyAttr.Compile() + if !reflect.DeepEqual(*alsPrf.AttributeProfile, replyAttr) { + t.Errorf("Expecting : %+v, received: %+v", *alsPrf.AttributeProfile, replyAttr) } ev := &utils.CGREvent{ diff --git a/general_tests/loaders_internal_indexes_it_test.go b/general_tests/loaders_internal_indexes_it_test.go index d0a460e54..0a4a77204 100644 --- a/general_tests/loaders_internal_indexes_it_test.go +++ b/general_tests/loaders_internal_indexes_it_test.go @@ -128,7 +128,7 @@ func testLoadersIDBIdxItLoad(t *testing.T) { } func testLoadersIDBIdxCheckAttributes(t *testing.T) { - exp := &engine.AttributeProfile{ + exp := engine.AttributeProfile{ Tenant: "cgrates.org", ID: "ATTR_1001_SIMPLEAUTH", FilterIDs: []string{"*string:~*opts.*context:simpleauth", "*string:~*req.Account:1001"}, @@ -144,7 +144,7 @@ func testLoadersIDBIdxCheckAttributes(t *testing.T) { }, } - var reply *engine.AttributeProfile + var reply engine.AttributeProfile if err := loadersIDBIdxRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile, &utils.TenantIDWithAPIOpts{ TenantID: &utils.TenantID{ @@ -153,8 +153,11 @@ func testLoadersIDBIdxCheckAttributes(t *testing.T) { }, }, &reply); err != nil { t.Error(err) - } else if !reflect.DeepEqual(exp, reply) { - t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(exp), utils.ToJSON(reply)) + } else { + reply.Compile() + if !reflect.DeepEqual(exp, reply) { + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(exp), utils.ToJSON(reply)) + } } } diff --git a/general_tests/routes_cases_it_test.go b/general_tests/routes_cases_it_test.go index b41f39b08..b4ca3f108 100644 --- a/general_tests/routes_cases_it_test.go +++ b/general_tests/routes_cases_it_test.go @@ -193,11 +193,6 @@ func testV1RtsCaseGetRoutesAfterLoading(t *testing.T) { }, }, }, - Weights: utils.DynamicWeights{ - { - Weight: 0, - }, - }, } var reply *engine.RouteProfile if err := rtsCaseSv1BiRpc.Call(context.Background(), utils.AdminSv1GetRouteProfile,