RICPLT-3014 Subs multiple rmr endpoints
[ric-plt/submgr.git] / pkg / control / messaging_test.go
index ed31423..68118ea 100644 (file)
@@ -586,6 +586,41 @@ func (mc *testingMainControl) wait_msgcounter_change(t *testing.T, orig uint64,
        return 0, false
 }
 
+//-----------------------------------------------------------------------------
+// TestSubReqAndRouteNok
+//
+//   stub                          stub
+// +-------+     +---------+    +---------+
+// | xapp  |     | submgr  |    | rtmgr   |
+// +-------+     +---------+    +---------+
+//     |              |              |
+//     | SubReq       |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | RouteCreate  |
+//     |              |------------->|
+//     |              |              |
+//     |              | RouteCreate  |
+//     |              |  status:400  |
+//     |              |<-------------|
+//     |              |              |
+//     |       [SUBS INT DELETE]     |
+//     |              |              |
+//
+//-----------------------------------------------------------------------------
+
+func TestSubReqAndRouteNok(t *testing.T) {
+       xapp.Logger.Info("TestSubReqAndRouteNok")
+
+       waiter := rtmgrHttp.AllocNextEvent(false)
+       newSubsId := mainCtrl.get_subid(t)
+       xappConn1.handle_xapp_subs_req(t, nil)
+       waiter.WaitResult(t)
+
+       //Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, int(newSubsId), 10)
+}
+
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOk
 //
@@ -623,15 +658,20 @@ func (mc *testingMainControl) wait_msgcounter_change(t *testing.T, orig uint64,
 func TestSubReqAndSubDelOk(t *testing.T) {
        xapp.Logger.Info("TestSubReqAndSubDelOk")
 
+       waiter := rtmgrHttp.AllocNextEvent(true)
        cretrans := xappConn1.handle_xapp_subs_req(t, nil)
+       waiter.WaitResult(t)
+
        crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
        e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
        e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
-
        deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
        delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
+
+       waiter = rtmgrHttp.AllocNextEvent(true)
        e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
        xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+       waiter.WaitResult(t)
 
        //Wait that subs is cleaned
        mainCtrl.wait_subs_clean(t, e2SubsId, 10)