From: Markku Virtanen Date: Tue, 25 May 2021 09:54:42 +0000 (+0000) Subject: Added UT cases for Del Req e2ap un/packing errors X-Git-Tag: 0.7.1~18^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=ac8bde486e4453d613db6ae05f6839661068a4ab;p=ric-plt%2Fsubmgr.git Added UT cases for Del Req e2ap un/packing errors Signed-off-by: Markku Virtanen Change-Id: Ie0846e3c351d73803ac07a189737267c07503035 --- diff --git a/Dockerfile b/Dockerfile index 0a2b217..ed2e751 100644 --- a/Dockerfile +++ b/Dockerfile @@ -183,7 +183,7 @@ RUN sed -r "s/^(::1.*)/#\1/" /etc/hosts > /etc/hosts.new \ && cat /etc/hosts.new > /etc/hosts \ && cat /etc/hosts \ && go test -failfast -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control \ - && go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html + && go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html # test formating (not important) RUN test -z "$(gofmt -l pkg/control/*.go)" diff --git a/e2ap/pkg/e2ap_wrapper/ut_packer_e2ap.go b/e2ap/pkg/e2ap_wrapper/ut_packer_e2ap.go index 3449a91..ea21995 100644 --- a/e2ap/pkg/e2ap_wrapper/ut_packer_e2ap.go +++ b/e2ap/pkg/e2ap_wrapper/ut_packer_e2ap.go @@ -49,7 +49,6 @@ var allowAction = map[int]bool{ } func AllowE2apToProcess(mtype int, actionFail bool) { - fmt.Printf("INFO: AllowE2apToProcess setting %d : %t -> %t", mtype, allowAction[mtype], actionFail) allowAction[mtype] = actionFail } diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index e3d6655..e6d6646 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -30,14 +30,56 @@ import ( "github.com/stretchr/testify/assert" ) -func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) { - +func TestSuiteSetup(t *testing.T) { // The effect of this call shall endure thgough the UT suite! // If this causes any issues, the previout interface can be restored - // like this: + // like this:git log // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker()) SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker()) +} + +//----------------------------------------------------------------------------- +// TestRESTSubReqAndDeleteOkWithE2apUtWrapper +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | | RouteCreate | | +// | |--------------------------->| // The order of these events may vary +// | | | | +// | RESTSubResp | | | // The order of these events may vary +// |<----------------| | | +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | | | +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | | | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | | | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | | | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) { restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil) @@ -46,6 +88,114 @@ func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) } +//----------------------------------------------------------------------------- +// TestRESTSubReqAndE1apDeleteReqPackingError +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | | RouteCreate | | +// | |--------------------------->| // The order of these events may vary +// | | | | +// | RESTSubResp | | | // The order of these events may vary +// |<----------------| | | +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | | | +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | | | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | | | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) { + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil) + + e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false) + xappConn1.SendRESTSubsDelReq(t, &restSubId) + defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true) + + waitSubsCleanup(t, e2SubsId, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTSubReqAndE1apDeleteRespUnpackingError +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | | RouteCreate | | +// | |--------------------------->| // The order of these events may vary +// | | | | +// | RESTSubResp | | | // The order of these events may vary +// |<----------------| | | +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | | | +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | | | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | | | | +// | RESTSubDelResp| | | +// |<----------------| | | // The order of these events may vary +// | | | | +// | | SubDelResp | | +// | |<-------------| | // 1.st NOK +// | | | | +// | | SubDelReq | | +// | |------------->| | +// | | | | +// | | SubDelResp | | +// | |<-------------| | // 2.nd NOK +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) { + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true) + + waitSubsCleanup(t, e2SubsId, 10) +} + //----------------------------------------------------------------------------- // TestSubReqAndRouteNok //