Commit 712e2673 authored by Yann Garcia's avatar Yann Garcia
Browse files

Updating meep-gis asset test scripts

parent 268df8b8
Loading
Loading
Loading
Loading
+56 −3
Original line number Diff line number Diff line
@@ -8,8 +8,6 @@ import (
	"io"
	"net/http"
	"net/http/httptest"

	//"strconv"
	"testing"
	"time"

@@ -506,7 +504,9 @@ func TestPredictedQosPost(t *testing.T) {

	fmt.Println("Set a scenario")
	initialiseScenario(testScenario)
	fmt.Println("Scenario was set")

	time.Sleep(1000 * time.Millisecond)
	updateScenario("mobility1")

	/******************************
	 * expected response section
@@ -652,6 +652,59 @@ func initialiseScenario(testScenario string) {

}

func updateScenario(testUpdate string) {

	switch testUpdate {
	case "mobility1":
		// mobility event of ue1 to zone2-poa1
		elemName := "ue1"
		destName := "zone2-poa1"

		_, _, err := m.MoveNode(elemName, destName, nil)
		if err != nil {
			log.Error("Error sending mobility event")
		}

		msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName)
		err = mqLocal.SendMsg(msg)
		if err != nil {
			log.Error("Failed to send message: ", err)
		}
	case "mobility2":
		// mobility event of ue1 to zone2-poa1
		elemName := "ue1"
		destName := "zone1-poa-cell1"

		_, _, err := m.MoveNode(elemName, destName, nil)
		if err != nil {
			log.Error("Error sending mobility event")
		}

		msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName)
		err = mqLocal.SendMsg(msg)
		if err != nil {
			log.Error("Failed to send message: ", err)
		}
	case "mobility3":
		// mobility event of ue1 to zone1-poa-cell2
		elemName := "ue1"
		destName := "zone1-poa-cell2"

		_, _, err := m.MoveNode(elemName, destName, nil)
		if err != nil {
			log.Error("Error sending mobility event")
		}

		msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName)
		err = mqLocal.SendMsg(msg)
		if err != nil {
			log.Error("Failed to send message: ", err)
		}
	default:
	}
	time.Sleep(100 * time.Millisecond)
}

func terminateScenario() {
	if mqLocal != nil {
		_ = Stop()
+93 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import (
	"fmt"
	"sort"
	"strings"
	"strconv"
	"regexp"
	"testing"

	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
@@ -1573,3 +1575,94 @@ func TestAssetMgrWithinRange(t *testing.T) {
		t.Fatalf("Expected within range")
	}
}

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

	// Create Connector
	fmt.Println("Create valid GIS Asset Manager")
	am, err := NewAssetMgr(amName, amNamespace, amDBUser, amDBPwd, amDBHost, amDBPort)
	if err != nil || am == nil {
		t.Fatalf("Failed to create GIS Asset Manager")
	}

	// Cleanup
	_ = am.DeleteTables()

	// Create tables
	fmt.Println("Create Tables")
	err = am.CreateTables()
	if err != nil {
		t.Fatalf("Failed to create tables")
	}

	// Add on POA (poa1, r=160m) and one UE1 at point1, inside of the poa1 area and UE4 at point 5, outside of the poa1 area
	fmt.Println("Add one POA and two UEs")
	// poa1
	poaData := map[string]interface{}{
		FieldSubtype:  poa1Type,
		FieldPosition: poa1Loc,
		FieldRadius:   poa1Radius,
	}
	err = am.CreatePoa(poa1Id, poa1Name, poaData)
	if err != nil {
		t.Fatalf("Failed to create asset: " + err.Error())
	}
	// ue1
	ueData := map[string]interface{}{
		FieldPosition:  ue1Loc,
		FieldPath:      ue1Path,
		FieldMode:      ue1PathMode,
		FieldVelocity:  ue1Velocity,
		FieldPriority:  strings.Join(ue1Priority, ","),
		FieldConnected: true,
	}
	err = am.CreateUe(ue1Id, ue1Name, ueData)
	// ue4
	ueData = map[string]interface{}{
		FieldPosition:  ue4Loc,
		FieldPath:      ue4Path,
		FieldMode:      ue4PathMode,
		FieldVelocity:  ue4Velocity,
		FieldPriority:  strings.Join(ue4Priority, ","),
		FieldConnected: true,
	}
	err = am.CreateUe(ue4Id, ue1Name, ueData)

	// Check an empty list of coordinates
	var coordinates []Coordinate = make([]Coordinate, 0)
	ret_value, ret_code := am.GetPowerValuesForCoordinates(coordinates)
	fmt.Println("--- len ret_value", len(ret_value))
	fmt.Println("--- ret_code", ret_code)
	/*if ret_value == nil || ret_code != nil {
		t.Fatalf("Unexpected returned value for an empty list")
	}*/

	r := regexp.MustCompile("\\[(?P<lon>.*),(?P<lat>.*)\\]")
	fmt.Println("After compile")
	m := r.FindStringSubmatch(point1)
	if m == nil {
		t.Fatalf("Failed to resolv point")
	}
	fmt.Println(m[1])
	fmt.Println(m[2])
	lon, err := strconv.ParseFloat(m[1], 32)
	if err != nil {
		t.Fatalf("Failed to convert longitude")
	}
	lat, err := strconv.ParseFloat(m[2], 32)
	if err != nil {
		t.Fatalf("Failed to convert latitude")
	}
	fmt.Println(lon)
	fmt.Println(lat)
	coordinates = make([]Coordinate, 1)
	coordinates[0] = Coordinate { float32(lat), float32(lon) }
	/*coordinates[0][0] =	lon
	coordinates[0][1] = lat*/
	//ret_value, ret_code := am.GetPowerValuesForCoordinates(coordinates)
	//fmt.Println("--- ret_value", ret_value)
	//fmt.Println("--- ret_code", ret_code)

}
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ module github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-asset-mgr
go 1.12

require (
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model v0.0.0-20211214133749-f203f7ab4f1c
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger v0.0.0
	github.com/lib/pq v1.5.2
)
+3 −0
Original line number Diff line number Diff line
github.com/InterDigitalInc/AdvantEDGE v1.8.1 h1:2jZJ/Hu6IDweJifEpbOD8PP9pX03AQlZGNnrhv1Die8=
github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model v0.0.0-20211214133749-f203f7ab4f1c h1:enMVVX7j6tb6KbI6Bp0iaCde1fbai8ddBefqVMmOo68=
github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model v0.0.0-20211214133749-f203f7ab4f1c/go.mod h1:IAOr9MhG0XgSEMTJOt6JA4iacKrNgTZuCxk7ofjrQBs=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=