Loading go-apps/meep-tm/server/mts/mts.go +1 −1 Original line number Diff line number Diff line Loading @@ -1149,7 +1149,7 @@ func mtsSessionPut(w http.ResponseWriter, r *http.Request) { // Prepare & send response jsonResponse := convertMtsSessionInfoToJson(&requestBodyPut) w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusOK) fmt.Fprint(w, jsonResponse) } Loading go-apps/meep-tm/server/traffic-mgmt_test.go +81 −11 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import ( "time" mts "github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-tm/server/mts" dkm "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" mod "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model" mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq" Loading Loading @@ -498,7 +499,7 @@ func testMtsSessionPost(t *testing.T) (string, string) { ******************************/ expectedRequestType := uint32(0) // Application specific MTS Session expectedAppInsId := "ue1-iperf" expectedAppInsId := "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7" expectedMtsMode := uint32(0) expectedTrafficDirection := "00" expectedMtsSessionInfo := mts.MtsSessionInfo{ Loading @@ -519,7 +520,7 @@ func testMtsSessionPost(t *testing.T) (string, string) { requestType := uint32(0) // Application specific MTS Session mtsMode := uint32(0) requestedMtsSessionInfo := mts.MtsSessionInfo{ AppInsId: "ue1-iperf", AppInsId: "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7", RequestType: &requestType, MtsMode: &mtsMode, TrafficDirection: "00", Loading @@ -534,7 +535,7 @@ func testMtsSessionPost(t *testing.T) (string, string) { * request execution section ******************************/ rr, err := sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), nil, nil, http.StatusOK, mts.MtsSessionPOST) rr, err := sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), nil, nil, http.StatusCreated, mts.MtsSessionPOST) if err != nil { t.Fatalf(err.Error()) } Loading @@ -553,10 +554,10 @@ func testMtsSessionPost(t *testing.T) (string, string) { if expectedMtsSessionInfo.AppInsId != respBody.AppInsId { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.RequestType != respBody.RequestType { if *expectedMtsSessionInfo.RequestType != *respBody.RequestType { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.MtsMode != respBody.MtsMode { if *expectedMtsSessionInfo.MtsMode != *respBody.MtsMode { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.TrafficDirection != respBody.TrafficDirection { Loading @@ -565,6 +566,9 @@ func testMtsSessionPost(t *testing.T) (string, string) { if respBody.SessionId == "" { t.Fatalf("Failed to get expected response") } if respBody.TimeStamp == nil { t.Fatalf("Failed to get expected response") } return respBody.SessionId, string(expectedResponseStr) } Loading Loading @@ -655,12 +659,38 @@ func testMtsSessionsGet(t *testing.T, sessionId string, expectedResponse string) t.Fatalf("Failed to get expected response") } } else { var expectedResp mts.MtsSessionInfo err := json.Unmarshal([]byte(expectedResponse), &expectedResp) if err != nil { t.Fatalf("Failed to get expected response") } rr, err := sendRequest(http.MethodGet, "/mts/v1/mts_sessions", nil, vars, nil, http.StatusOK, mts.MtsSessionGET) if err != nil { t.Fatalf("Failed to get expected response") } var respBody mts.MtsSessionInfo err = json.Unmarshal([]byte(rr), &respBody) if err != nil { t.Fatalf("Failed to get expected response") } if rr != expectedResponse { if expectedResp.AppInsId != respBody.AppInsId { t.Fatalf("Failed to get expected response") } if *expectedResp.RequestType != *respBody.RequestType { t.Fatalf("Failed to get expected response") } if *expectedResp.MtsMode != *respBody.MtsMode { t.Fatalf("Failed to get expected response") } if expectedResp.TrafficDirection != respBody.TrafficDirection { t.Fatalf("Failed to get expected response") } if respBody.SessionId == "" { t.Fatalf("Failed to get expected response") } if respBody.TimeStamp == nil { t.Fatalf("Failed to get expected response") } } Loading @@ -672,8 +702,8 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin ******************************/ expectedRequestType := uint32(0) // Application specific MTS Session expectedAppInsId := "ue1-iperf" expectedMtsMode := uint32(0) expectedAppInsId := "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7" expectedMtsMode := uint32(1) expectedTrafficDirection := "00" expectedMtsSessionInfo := mts.MtsSessionInfo{ AppInsId: expectedAppInsId, Loading @@ -699,7 +729,7 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin requestType := uint32(0) // Application specific MTS Session mtsMode := uint32(1) requestedMtsSessionInfo := mts.MtsSessionInfo{ AppInsId: "ue1-iperf", AppInsId: "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7", RequestType: &requestType, MtsMode: &mtsMode, TrafficDirection: "00", Loading @@ -719,7 +749,7 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin ******************************/ if expectSuccess { rr, err := sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), vars, nil, http.StatusOK, mts.MtsSessionPUT) rr, err := sendRequest(http.MethodPut, "/mts/v1/mts_sessions", bytes.NewBuffer(body), vars, nil, http.StatusOK, mts.MtsSessionPUT) if err != nil { t.Fatalf("Failed to get expected response") } Loading @@ -729,9 +759,26 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin if err != nil { t.Fatalf("Failed to get expected response") } if rr != string(expectedResponseStr) { if expectedMtsSessionInfo.AppInsId != respBody.AppInsId { t.Fatalf("Failed to get expected response") } if *expectedMtsSessionInfo.RequestType != *respBody.RequestType { t.Fatalf("Failed to get expected response") } if *expectedMtsSessionInfo.MtsMode != *respBody.MtsMode { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.TrafficDirection != respBody.TrafficDirection { t.Fatalf("Failed to get expected response") } if respBody.SessionId == "" { t.Fatalf("Failed to get expected response") } if respBody.TimeStamp == nil { t.Fatalf("Failed to get expected response") } return string(expectedResponseStr) } else { _, err = sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), vars, nil, http.StatusNotFound, mts.MtsSessionPUT) Loading Loading @@ -965,6 +1012,29 @@ func initialiseScenario(testScenario string) { time.Sleep(100 * time.Millisecond) // Load Redis with AppInstanceId appEnablementKey := "app-enablement" appInfo := make(map[string]string) // same as in testScenario appInfo["id"] = "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7" appInfo["name"] = "ue1-iperf" appInfo["node"] = "" appInfo["type"] = "UE-APP" appInfo["persist"] = "false" appInfo["state"] = "READY" entry := make(map[string]interface{}, len(appInfo)) for k, v := range appInfo { entry[k] = v } baseKeyAppEn := dkm.GetKeyRoot(sandboxName) + appEnablementKey + ":mep:" + mepName + ":" key := baseKeyAppEn + "app:" + appInfo["id"] + ":info" err = rc.SetEntry(key, entry) if err != nil { log.Error("Failed to write appInstanceId to Redis DB") return } } func sendRequest(method string, url string, body io.Reader, vars map[string]string, query map[string]string, code int, f http.HandlerFunc) (string, error) { Loading Loading
go-apps/meep-tm/server/mts/mts.go +1 −1 Original line number Diff line number Diff line Loading @@ -1149,7 +1149,7 @@ func mtsSessionPut(w http.ResponseWriter, r *http.Request) { // Prepare & send response jsonResponse := convertMtsSessionInfoToJson(&requestBodyPut) w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusOK) fmt.Fprint(w, jsonResponse) } Loading
go-apps/meep-tm/server/traffic-mgmt_test.go +81 −11 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import ( "time" mts "github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-tm/server/mts" dkm "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" mod "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model" mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq" Loading Loading @@ -498,7 +499,7 @@ func testMtsSessionPost(t *testing.T) (string, string) { ******************************/ expectedRequestType := uint32(0) // Application specific MTS Session expectedAppInsId := "ue1-iperf" expectedAppInsId := "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7" expectedMtsMode := uint32(0) expectedTrafficDirection := "00" expectedMtsSessionInfo := mts.MtsSessionInfo{ Loading @@ -519,7 +520,7 @@ func testMtsSessionPost(t *testing.T) (string, string) { requestType := uint32(0) // Application specific MTS Session mtsMode := uint32(0) requestedMtsSessionInfo := mts.MtsSessionInfo{ AppInsId: "ue1-iperf", AppInsId: "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7", RequestType: &requestType, MtsMode: &mtsMode, TrafficDirection: "00", Loading @@ -534,7 +535,7 @@ func testMtsSessionPost(t *testing.T) (string, string) { * request execution section ******************************/ rr, err := sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), nil, nil, http.StatusOK, mts.MtsSessionPOST) rr, err := sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), nil, nil, http.StatusCreated, mts.MtsSessionPOST) if err != nil { t.Fatalf(err.Error()) } Loading @@ -553,10 +554,10 @@ func testMtsSessionPost(t *testing.T) (string, string) { if expectedMtsSessionInfo.AppInsId != respBody.AppInsId { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.RequestType != respBody.RequestType { if *expectedMtsSessionInfo.RequestType != *respBody.RequestType { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.MtsMode != respBody.MtsMode { if *expectedMtsSessionInfo.MtsMode != *respBody.MtsMode { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.TrafficDirection != respBody.TrafficDirection { Loading @@ -565,6 +566,9 @@ func testMtsSessionPost(t *testing.T) (string, string) { if respBody.SessionId == "" { t.Fatalf("Failed to get expected response") } if respBody.TimeStamp == nil { t.Fatalf("Failed to get expected response") } return respBody.SessionId, string(expectedResponseStr) } Loading Loading @@ -655,12 +659,38 @@ func testMtsSessionsGet(t *testing.T, sessionId string, expectedResponse string) t.Fatalf("Failed to get expected response") } } else { var expectedResp mts.MtsSessionInfo err := json.Unmarshal([]byte(expectedResponse), &expectedResp) if err != nil { t.Fatalf("Failed to get expected response") } rr, err := sendRequest(http.MethodGet, "/mts/v1/mts_sessions", nil, vars, nil, http.StatusOK, mts.MtsSessionGET) if err != nil { t.Fatalf("Failed to get expected response") } var respBody mts.MtsSessionInfo err = json.Unmarshal([]byte(rr), &respBody) if err != nil { t.Fatalf("Failed to get expected response") } if rr != expectedResponse { if expectedResp.AppInsId != respBody.AppInsId { t.Fatalf("Failed to get expected response") } if *expectedResp.RequestType != *respBody.RequestType { t.Fatalf("Failed to get expected response") } if *expectedResp.MtsMode != *respBody.MtsMode { t.Fatalf("Failed to get expected response") } if expectedResp.TrafficDirection != respBody.TrafficDirection { t.Fatalf("Failed to get expected response") } if respBody.SessionId == "" { t.Fatalf("Failed to get expected response") } if respBody.TimeStamp == nil { t.Fatalf("Failed to get expected response") } } Loading @@ -672,8 +702,8 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin ******************************/ expectedRequestType := uint32(0) // Application specific MTS Session expectedAppInsId := "ue1-iperf" expectedMtsMode := uint32(0) expectedAppInsId := "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7" expectedMtsMode := uint32(1) expectedTrafficDirection := "00" expectedMtsSessionInfo := mts.MtsSessionInfo{ AppInsId: expectedAppInsId, Loading @@ -699,7 +729,7 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin requestType := uint32(0) // Application specific MTS Session mtsMode := uint32(1) requestedMtsSessionInfo := mts.MtsSessionInfo{ AppInsId: "ue1-iperf", AppInsId: "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7", RequestType: &requestType, MtsMode: &mtsMode, TrafficDirection: "00", Loading @@ -719,7 +749,7 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin ******************************/ if expectSuccess { rr, err := sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), vars, nil, http.StatusOK, mts.MtsSessionPUT) rr, err := sendRequest(http.MethodPut, "/mts/v1/mts_sessions", bytes.NewBuffer(body), vars, nil, http.StatusOK, mts.MtsSessionPUT) if err != nil { t.Fatalf("Failed to get expected response") } Loading @@ -729,9 +759,26 @@ func testMtsSessionPut(t *testing.T, sessionId string, expectSuccess bool) strin if err != nil { t.Fatalf("Failed to get expected response") } if rr != string(expectedResponseStr) { if expectedMtsSessionInfo.AppInsId != respBody.AppInsId { t.Fatalf("Failed to get expected response") } if *expectedMtsSessionInfo.RequestType != *respBody.RequestType { t.Fatalf("Failed to get expected response") } if *expectedMtsSessionInfo.MtsMode != *respBody.MtsMode { t.Fatalf("Failed to get expected response") } if expectedMtsSessionInfo.TrafficDirection != respBody.TrafficDirection { t.Fatalf("Failed to get expected response") } if respBody.SessionId == "" { t.Fatalf("Failed to get expected response") } if respBody.TimeStamp == nil { t.Fatalf("Failed to get expected response") } return string(expectedResponseStr) } else { _, err = sendRequest(http.MethodPost, "/mts/v1/mts_sessions", bytes.NewBuffer(body), vars, nil, http.StatusNotFound, mts.MtsSessionPUT) Loading Loading @@ -965,6 +1012,29 @@ func initialiseScenario(testScenario string) { time.Sleep(100 * time.Millisecond) // Load Redis with AppInstanceId appEnablementKey := "app-enablement" appInfo := make(map[string]string) // same as in testScenario appInfo["id"] = "9bdd6acd-f6e4-44f6-a26c-8fd9abd338a7" appInfo["name"] = "ue1-iperf" appInfo["node"] = "" appInfo["type"] = "UE-APP" appInfo["persist"] = "false" appInfo["state"] = "READY" entry := make(map[string]interface{}, len(appInfo)) for k, v := range appInfo { entry[k] = v } baseKeyAppEn := dkm.GetKeyRoot(sandboxName) + appEnablementKey + ":mep:" + mepName + ":" key := baseKeyAppEn + "app:" + appInfo["id"] + ":info" err = rc.SetEntry(key, entry) if err != nil { log.Error("Failed to write appInstanceId to Redis DB") return } } func sendRequest(method string, url string, body io.Reader, vars map[string]string, query map[string]string, code int, f http.HandlerFunc) (string, error) { Loading