From 1683f9183a52f09b35405791ab273e277ae27eb9 Mon Sep 17 00:00:00 2001 From: Juha Hyttinen Date: Fri, 17 Apr 2020 10:39:57 +0300 Subject: [PATCH] Preparing next release and fixed ut timing issue. Change-Id: Id8b14aa17e722b4825b875c15e30e6ce34e2f224 Signed-off-by: Juha Hyttinen --- container-tag.yaml | 2 +- pkg/control/ut_ctrl_submgr_test.go | 54 ++++++++++++++++++++++++++++++-------- pkg/control/ut_messaging_test.go | 27 ++++++++++++++----- 3 files changed, 65 insertions(+), 18 deletions(-) diff --git a/container-tag.yaml b/container-tag.yaml index 0da006d..331240f 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -2,4 +2,4 @@ # By default this file is in the docker build directory, # but the location can configured in the JJB template. --- -tag: "0.4.1-1" +tag: "0.4.2" diff --git a/pkg/control/ut_ctrl_submgr_test.go b/pkg/control/ut_ctrl_submgr_test.go index 45147c8..85cbe8f 100644 --- a/pkg/control/ut_ctrl_submgr_test.go +++ b/pkg/control/ut_ctrl_submgr_test.go @@ -59,6 +59,27 @@ func (mc *testingSubmgrControl) wait_registry_empty(t *testing.T, secs int) bool return false } +func (mc *testingSubmgrControl) get_registry_next_subid(t *testing.T) uint32 { + mc.c.registry.mutex.Lock() + defer mc.c.registry.mutex.Unlock() + return mc.c.registry.subIds[0] +} + +func (mc *testingSubmgrControl) wait_registry_next_subid_change(t *testing.T, origSubId uint32, secs int) (uint32, bool) { + i := 1 + for ; i <= secs*2; i++ { + mc.c.registry.mutex.Lock() + currSubId := mc.c.registry.subIds[0] + mc.c.registry.mutex.Unlock() + if currSubId != origSubId { + return currSubId, true + } + time.Sleep(500 * time.Millisecond) + } + mc.TestError(t, "(submgr) no subId change within %d secs", secs) + return 0, false +} + func (mc *testingSubmgrControl) wait_subs_clean(t *testing.T, e2SubsId uint32, secs int) bool { var subs *Subscription i := 1 @@ -99,27 +120,38 @@ func (mc *testingSubmgrControl) wait_subs_trans_clean(t *testing.T, e2SubsId uin return false } -func (mc *testingSubmgrControl) get_subid(t *testing.T) uint32 { - mc.c.registry.mutex.Lock() - defer mc.c.registry.mutex.Unlock() - return mc.c.registry.subIds[0] +func (mc *testingSubmgrControl) get_subs_entrypoint_cnt(t *testing.T, origSubId uint32) int { + subs := mc.c.registry.GetSubscription(origSubId) + if subs == nil { + mc.TestError(t, "(submgr) no subs %d exists during entrypoint cnt get", origSubId) + return -1 + } + return subs.EpList.Size() } -func (mc *testingSubmgrControl) wait_subid_change(t *testing.T, origSubId uint32, secs int) (uint32, bool) { +func (mc *testingSubmgrControl) wait_subs_entrypoint_cnt_change(t *testing.T, origSubId uint32, orig int, secs int) (int, bool) { + + subs := mc.c.registry.GetSubscription(origSubId) + if subs == nil { + mc.TestError(t, "(submgr) no subs %d exists during entrypoint cnt wait", origSubId) + return -1, true + } + i := 1 for ; i <= secs*2; i++ { - mc.c.registry.mutex.Lock() - currSubId := mc.c.registry.subIds[0] - mc.c.registry.mutex.Unlock() - if currSubId != origSubId { - return currSubId, true + curr := subs.EpList.Size() + if curr != orig { + return curr, true } time.Sleep(500 * time.Millisecond) } - mc.TestError(t, "(submgr) no subId change within %d secs", secs) + mc.TestError(t, "(submgr) no subs %d entrypoint cnt change within %d secs", origSubId, secs) return 0, false } +// +// Counter check for received message. Note might not be yet handled +// func (mc *testingSubmgrControl) get_msgcounter(t *testing.T) uint64 { return mc.c.CntRecvMsg } diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index 5241537..1e196f0 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -25,6 +25,7 @@ import ( "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" "github.com/stretchr/testify/assert" "testing" + "time" ) //----------------------------------------------------------------------------- @@ -54,7 +55,7 @@ func TestSubReqAndRouteNok(t *testing.T) { CaseBegin("TestSubReqAndRouteNok") waiter := rtmgrHttp.AllocNextEvent(false) - newSubsId := mainCtrl.get_subid(t) + newSubsId := mainCtrl.get_registry_next_subid(t) xappConn1.SendSubsReq(t, nil, nil) waiter.WaitResult(t) @@ -169,6 +170,10 @@ func TestSubReqRetransmission(t *testing.T) { xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq mainCtrl.wait_msgcounter_change(t, seqBef, 10) + // hack as there is no real way to see has message be handled. + // Previuos counter check just tells that is has been received by submgr + // --> artificial delay + <-time.After(1 * time.Second) e2termConn1.SendSubsResp(t, crereq, cremsg) e2SubsId := xappConn1.RecvSubsResp(t, cretrans) @@ -233,6 +238,11 @@ func TestSubDelReqRetransmission(t *testing.T) { xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq mainCtrl.wait_msgcounter_change(t, seqBef, 10) + // hack as there is no real way to see has message be handled. + // Previuos counter check just tells that is has been received by submgr + // --> artificial delay + <-time.After(1 * time.Second) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) xappConn1.RecvSubsDelResp(t, deltrans) @@ -297,6 +307,11 @@ func TestSubDelReqCollision(t *testing.T) { xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq mainCtrl.wait_msgcounter_change(t, seqBef, 10) + // hack as there is no real way to see has message be handled. + // Previuos counter check just tells that is has been received by submgr + // --> artificial delay + <-time.After(1 * time.Second) + // Del resp for first and second e2termConn1.SendSubsDelResp(t, delreq1, delmsg1) @@ -1266,9 +1281,9 @@ func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) { //Req2 rparams2 := &teststube2ap.E2StubSubsReqParams{} rparams2.Init() - seqBef2 := mainCtrl.get_msgcounter(t) + subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId) cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil) - mainCtrl.wait_msgcounter_change(t, seqBef2, 10) + mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10) // E2t: send SubsFail (first) fparams1 := &teststube2ap.E2StubSubsFailParams{} @@ -1330,14 +1345,14 @@ func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) { rparams1.Init() xappConn1.SendSubsReq(t, rparams1, nil) - e2termConn1.RecvSubsReq(t) + crereq1, _ := e2termConn1.RecvSubsReq(t) //Req2 rparams2 := &teststube2ap.E2StubSubsReqParams{} rparams2.Init() - seqBef2 := mainCtrl.get_msgcounter(t) + subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId) xappConn2.SendSubsReq(t, rparams2, nil) - mainCtrl.wait_msgcounter_change(t, seqBef2, 10) + mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10) //Req1 (retransmitted) e2termConn1.RecvSubsReq(t) -- 2.16.6