Added UT cases for Del Req e2ap un/packing errors 36/6136/4
authorMarkku Virtanen <markku.virtanen@nokia.com>
Tue, 25 May 2021 09:54:42 +0000 (09:54 +0000)
committerMarkku Virtanen <markku.virtanen@nokia.com>
Tue, 25 May 2021 14:22:32 +0000 (14:22 +0000)
Signed-off-by: Markku Virtanen <markku.virtanen@nokia.com>
Change-Id: Ie0846e3c351d73803ac07a189737267c07503035

Dockerfile
e2ap/pkg/e2ap_wrapper/ut_packer_e2ap.go
pkg/control/ut_messaging_test.go

index 0a2b217..ed2e751 100644 (file)
@@ -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)"
index 3449a91..ea21995 100644 (file)
@@ -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
 }
 
index e3d6655..e6d6646 100644 (file)
@@ -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
 //