Test and debug interface improvements part 2 94/7494/1
authorAnssi Mannila <anssi.mannila@nokia.com>
Tue, 4 Jan 2022 12:22:26 +0000 (14:22 +0200)
committerAnssi Mannila <anssi.mannila@nokia.com>
Tue, 4 Jan 2022 12:23:04 +0000 (14:23 +0200)
 - Documentation added
 - Some fixed added

Change-Id: I2630f9bad26b29d3dd5e2460037cf568e3b57d0c
Signed-off-by: Anssi Mannila <anssi.mannila@nokia.com>
pkg/control/control.go
pkg/control/registry.go
pkg/control/sdl_restSubsDb.go
pkg/control/ut_ctrl_submgr_test.go
pkg/control/ut_messaging_test.go

index e13fc46..42c639b 100755 (executable)
@@ -165,8 +165,8 @@ func NewControl() *Control {
        xapp.Resource.InjectRoute("/ric/v1/get_xapp_rest_restsubscriptions/{xappServiceName}", c.GetAllXappRestSubscriptions, "GET")
        xapp.Resource.InjectRoute("/ric/v1/get_e2subscriptions/{restId}", c.GetE2Subscriptions, "GET")
 
-       xapp.Resource.InjectRoute("/ric/v1/delete_all_e2node_subscriptions/{ranName}", c.DeleteAllE2nodeSubscriptions, "GET")
-       xapp.Resource.InjectRoute("/ric/v1/delete_all_xapp_subscriptions/{xappServiceName}", c.DeleteAllXappSubscriptions, "GET")
+       xapp.Resource.InjectRoute("/ric/v1/delete_all_e2node_subscriptions/{ranName}", c.DeleteAllE2nodeSubscriptions, "DELETE")
+       xapp.Resource.InjectRoute("/ric/v1/delete_all_xapp_subscriptions/{xappServiceName}", c.DeleteAllXappSubscriptions, "DELETE")
 
        if readSubsFromDb == "true" {
                // Read subscriptions from db
index 3de549a..29d82a9 100644 (file)
@@ -36,7 +36,7 @@ import (
 //-----------------------------------------------------------------------------
 
 type RESTSubscription struct {
-       Created          time.Time
+       Created          string
        xAppServiceName  string
        xAppRmrEndPoint  string
        Meid             string
@@ -233,7 +233,7 @@ func (r *Registry) CreateRESTSubscription(restSubId *string, xappServiceName *st
        r.mutex.Lock()
        defer r.mutex.Unlock()
        newRestSubscription := RESTSubscription{}
-       newRestSubscription.Created = time.Now()
+       newRestSubscription.Created = time.Now().Format("2006-01-02 15:04:05.000")
        newRestSubscription.xAppServiceName = *xappServiceName
        newRestSubscription.xAppRmrEndPoint = *xAppRmrEndPoint
        newRestSubscription.Meid = *maid
index 576e6af..ac85d98 100644 (file)
@@ -22,7 +22,6 @@ package control
 import (
        "encoding/json"
        "fmt"
-       "time"
 
        sdl "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
@@ -31,7 +30,7 @@ import (
 const restSubSdlNs = "submgr_restSubsDb"
 
 type RESTSubscriptionInfo struct {
-       Created          time.Time
+       Created          string
        XAppServiceName  string
        XAppRmrEndPoint  string
        Meid             string
index 78d9990..0af1da4 100644 (file)
@@ -535,7 +535,10 @@ func (mc *testingSubmgrControl) SendDeleteRequest(t *testing.T, addr string, pat
 
        mc.TestLog(t, "Response status: %v", resp.Status)
        mc.TestLog(t, "Response Headers: %v", resp.Header)
-       if !strings.Contains(resp.Status, "204 No Content") {
+
+       // Note that xapp gets '204 No Content' response through Swagger generated delete route.
+       // Inject route returns '200 OK'
+       if !(strings.Contains(resp.Status, "204 No Content") || strings.Contains(resp.Status, "200 OK")) {
                mc.TestError(t, "Wrong response status")
                return
        }
index 3e9a51b..79ed694 100644 (file)
@@ -2745,7 +2745,7 @@ func TestDelAllE2nodeSubsViaDebugIf(t *testing.T) {
        }
 
        // Simulate deletion through REST test and debug interface
-       mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/delete_all_e2node_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
+       mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_e2node_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
        delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
        e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 
@@ -2833,7 +2833,7 @@ func TestDelAllxAppSubsViaDebugIf(t *testing.T) {
        assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("localhost", xappList))
 
        // Simulate deletion through REST test and debug interface
-       mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
+       mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
        delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
        e2termConn1.SendSubsDelResp(t, delreq, delmsg)