From d13ba63c1c237882202fc975d70ed5ad21a48fcf Mon Sep 17 00:00:00 2001 From: Anssi Mannila Date: Tue, 4 Jan 2022 14:22:26 +0200 Subject: [PATCH] Test and debug interface improvements part 2 - Documentation added - Some fixed added Change-Id: I2630f9bad26b29d3dd5e2460037cf568e3b57d0c Signed-off-by: Anssi Mannila --- pkg/control/control.go | 4 ++-- pkg/control/registry.go | 4 ++-- pkg/control/sdl_restSubsDb.go | 3 +-- pkg/control/ut_ctrl_submgr_test.go | 5 ++++- pkg/control/ut_messaging_test.go | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/control/control.go b/pkg/control/control.go index e13fc46..42c639b 100755 --- a/pkg/control/control.go +++ b/pkg/control/control.go @@ -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 diff --git a/pkg/control/registry.go b/pkg/control/registry.go index 3de549a..29d82a9 100644 --- a/pkg/control/registry.go +++ b/pkg/control/registry.go @@ -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 diff --git a/pkg/control/sdl_restSubsDb.go b/pkg/control/sdl_restSubsDb.go index 576e6af..ac85d98 100644 --- a/pkg/control/sdl_restSubsDb.go +++ b/pkg/control/sdl_restSubsDb.go @@ -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 diff --git a/pkg/control/ut_ctrl_submgr_test.go b/pkg/control/ut_ctrl_submgr_test.go index 78d9990..0af1da4 100644 --- a/pkg/control/ut_ctrl_submgr_test.go +++ b/pkg/control/ut_ctrl_submgr_test.go @@ -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 } diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index 3e9a51b..79ed694 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -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) -- 2.16.6