Commit a6acedc3 authored by Yann Garcia's avatar Yann Garcia
Browse files

Enhance System tests for VIS micro-service

parent a7b01505
Loading
Loading
Loading
Loading
+1197 −0

File added.

Preview size limit exceeded, changes collapsed.

test/system/dai-test.yaml

deleted100644 → 0
+0 −0

Empty file deleted.

+1 −1
Original line number Diff line number Diff line
#!/bin/bash

#set -e
set -vx
#set -vx

# This script executes go test X times
export MEEP_HOST_TEST_URL="http://172.29.10.52"
+4400 −310

File changed.

Preview size limit exceeded, changes collapsed.

+149 −25
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ import (
var visAppClient *visClient.APIClient
var visServerUrl string

// MEC-030 Clause 6.2.5	Type: PredictedQos, replaced by inteface{} in models

func init() {

	err := startSystemTest()
@@ -83,7 +81,15 @@ func Test_VIS_load_scenarios(t *testing.T) {
	}
}

func Test_VIS_periodic_4g_5gNei(t *testing.T) {
//not a real test, just the last test that stops the system test environment
func Test_VIS_stopSystemTest(t *testing.T) {
	err := deleteScenario("vis-system-test")
	if err != nil {
		log.Error("cannot delete scenario :", err)
	}
}

func Test_VIS_with_prediction_model(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

@@ -91,14 +97,13 @@ func Test_VIS_periodic_4g_5gNei(t *testing.T) {
	defer clearUpVisTest()

	// Initialize the data structure for the POST request
	// MEC-030 Clause 6.2.5
	// MEC-030 Clause 7.6.3.4
	pointA := visClient.LocationInfoGeoArea{Longitude: 7.413917, Latitude: 43.733505}
	// See https://docbox.etsi.org/ISG/MEC/DECODE/05-CONTRIBUTIONS/2022//MECDECODE(22)000044_Demo_of_MEC-030_V2X_Information_Service_API_in_MEC_Sandbox.pptx Slide #9
	pointA := visClient.LocationInfoGeoArea{Longitude: 7.414853, Latitude: 43.729416}
	locationInfoA := visClient.LocationInfo{GeoArea: &pointA}
	tsA := visClient.TimeStamp{NanoSeconds: 0, Seconds: 45}
	pointB := visClient.LocationInfoGeoArea{Longitude: 7.413916, Latitude: 43.733515}
	tsA := visClient.TimeStamp{NanoSeconds: 0, Seconds: 1653295620} // Using Prediction model
	pointB := visClient.LocationInfoGeoArea{Longitude: 7.418417, Latitude: 43.732456}
	locationInfoB := visClient.LocationInfo{GeoArea: &pointB}
	tsB := visClient.TimeStamp{NanoSeconds: 0, Seconds: 45}
	tsB := visClient.TimeStamp{NanoSeconds: 0, Seconds: 1653295620} // Using Prediction model
	// Fill PredictedQosRoutesRouteInfo with LocationInfo list
	routeInfo := make([]visClient.PredictedQosRoutesRouteInfo, 2)
	routeInfo[0] = visClient.PredictedQosRoutesRouteInfo{
@@ -118,25 +123,109 @@ func Test_VIS_periodic_4g_5gNei(t *testing.T) {
	// Fill PredictedQos with PredictedQosRoutes list
	routes := make([]visClient.PredictedQosRoutes, 1)
	routes[0] = predictedQosRoutes
	predictedQos := visClient.PredictedQos{
		LocationGranularity: "1",
		Routes:              routes,
	}
	fmt.Println("predictedQos: ", predictedQos)
	testPredictedQos := visClient.PredictedQos{
		LocationGranularity: "1",
		Routes:              routes,
	}
	testPredictedQos.Routes[0].RouteInfo[0].Rsrq = 20
	testPredictedQos.Routes[0].RouteInfo[0].Rsrp = 60
	testPredictedQos.Routes[0].RouteInfo[1].Rsrq = 13
	testPredictedQos.Routes[0].RouteInfo[1].Rsrp = 55
	fmt.Println("testPredictedQos: ", predictedQos)

	// Moving to initial position: 4g-macro-cell-2/Residential
	testAddress := "ue1"
	geMoveAssetCoordinates(testAddress, 7.414853, 43.729416)
	time.Sleep(2000 * time.Millisecond)

	// Request to test with time set to 08:47:00 for congestion
	err := visPredictedQoSPOST(predictedQos)
	if err != nil {
		t.Fatal("PredictedQoS Post failed: ", err)
	}

	if len(httpReqBody) > 1 {
		var body visClient.PredictedQos
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validatePredictedQos(&body, &testPredictedQos)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

}

func Test_VIS_without_prediction_model(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseVisTest()
	defer clearUpVisTest()

	// Initialize the data structure for the POST request
	// See https://docbox.etsi.org/ISG/MEC/DECODE/05-CONTRIBUTIONS/2022//MECDECODE(22)000044_Demo_of_MEC-030_V2X_Information_Service_API_in_MEC_Sandbox.pptx Slide #9
	pointA := visClient.LocationInfoGeoArea{Longitude: 7.414853, Latitude: 43.729416}
	locationInfoA := visClient.LocationInfo{GeoArea: &pointA}
	pointB := visClient.LocationInfoGeoArea{Longitude: 7.418417, Latitude: 43.732456}
	locationInfoB := visClient.LocationInfo{GeoArea: &pointB}
	// Fill PredictedQosRoutesRouteInfo with LocationInfo list
	routeInfo := make([]visClient.PredictedQosRoutesRouteInfo, 2)
	routeInfo[0] = visClient.PredictedQosRoutesRouteInfo{
		Location: &locationInfoA,
		Rsrq:     0,
		Rsrp:     0,
		Time:     nil,
	}
	routeInfo[1] = visClient.PredictedQosRoutesRouteInfo{
		Location: &locationInfoB,
		Rsrq:     0,
		Rsrp:     0,
		Time:     nil,
	}
	// PredictedQosRoutes with PredictedQosRoutesRouteInfo list
	predictedQosRoutes := visClient.PredictedQosRoutes{RouteInfo: routeInfo}
	// Fill PredictedQos with PredictedQosRoutes list
	routes := make([]visClient.PredictedQosRoutes, 1)
	routes[0] = predictedQosRoutes
	predictedQos := visClient.PredictedQos{
		LocationGranularity: "1",
		Routes:              routes,
	}
	fmt.Println("predictedQos: ", predictedQos)
	testPredictedQos := visClient.PredictedQos{
		LocationGranularity: "100",
		LocationGranularity: "1",
		Routes:              routes,
	}
	fmt.Println("testPredictedQos: ", testPredictedQos)
	testPredictedQos.Routes[0].RouteInfo[0].Rsrq = 21
	testPredictedQos.Routes[0].RouteInfo[0].Rsrp = 63
	testPredictedQos.Routes[0].RouteInfo[1].Rsrq = 13
	testPredictedQos.Routes[0].RouteInfo[1].Rsrp = 55
	fmt.Println("testPredictedQos: ", predictedQos)

	// Moving to initial position
	testAddress := "ue2"
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	// Moving to initial position: 4g-macro-cell-2/Residential
	testAddress := "ue1"
	geMoveAssetCoordinates(testAddress, 7.414853, 43.729416)
	time.Sleep(2000 * time.Millisecond)

	// Request to test
	err := visPeriodicSubPOST(testPredictedQos)
	// Request to test with time set to 08:47:00 for congestion
	err := visPredictedQoSPOST(predictedQos)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
		t.Fatal("PredictedQoS Post failed: ", err)
	}

	//only check the first one, the same one is repeated every second
	//hard to say if the period should cover 2 or 3 response... based on the timer timing
	if len(httpReqBody) > 1 {
		var body visClient.PredictedQos
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
@@ -156,7 +245,7 @@ func Test_VIS_periodic_4g_5gNei(t *testing.T) {

}

func visPeriodicSubPOST(testPredictedQos visClient.PredictedQos) error {
func visPredictedQoSPOST(testPredictedQos visClient.PredictedQos) error {
	//PredictedQosPOST(ctx context.Context, body PredictedQos) (PredictedQos, *http.Response, error)
	_, _, err := visAppClient.V2xiApi.PredictedQosPOST(context.TODO(), testPredictedQos)
	if err != nil {
@@ -167,13 +256,48 @@ func visPeriodicSubPOST(testPredictedQos visClient.PredictedQos) error {
	return nil
}

func validatePredictedQos(response *visClient.PredictedQos, expectedAssocId *visClient.PredictedQos) string {
func validatePredictedQos(response *visClient.PredictedQos, expected_response *visClient.PredictedQos) string {
	fmt.Println(">>> validatePredictedQos: ", response)
	fmt.Println(">>> validatePredictedQos: ", expectedAssocId)
	fmt.Println(">>> validatePredictedQos: ", expected_response)

	if response.LocationGranularity != expected_response.LocationGranularity {
		return ("PredictedQos.LocationGranularity not as expected: " + response.LocationGranularity + " instead of " + expected_response.LocationGranularity)
	}
	if len(response.Routes) != len(expected_response.Routes) {
		return ("response.Routes not as expected")
	}
	if len(response.Routes[0].RouteInfo) != len(expected_response.Routes[0].RouteInfo) {
		return ("response.Routes[0].RouteInfo not as expected")
	}

	if response.LocationGranularity != expectedAssocId.LocationGranularity {
		return ("PredictedQos.LocationGranularity not as expected: " + response.LocationGranularity + " instead of " + expectedAssocId.LocationGranularity)
	var s string = ""
	for _, item := range response.Routes[0].RouteInfo {
		found := false
		for _, item1 := range expected_response.Routes[0].RouteInfo {
			if item.Location != nil && item1.Location != nil {
				if item.Location.GeoArea != nil && item1.Location.GeoArea != nil {
					if item.Location.GeoArea.Latitude == item1.Location.GeoArea.Latitude && item.Location.GeoArea.Longitude == item1.Location.GeoArea.Longitude {
						if item.Rsrp == item1.Rsrp && item.Rsrq == item1.Rsrq {
							// Found it
							found = true
							break
						} else {
							s = ("response.Rsrx != Rsrx")
						}
					} else {
						s = ("response.Latitude/Longitude != Latitude/Longitude")
					}
				} else {
					s = ("response.GeoArea != GeoArea")
				}
			} else {
				s = ("response.Location != Location")
			}
		} // End of 'for' statement
		if !found {
			break
		}
	}

	return ""
	return s
}