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

Bug fixed for TC_MEC_MEC011_SRV_APPSAQ_001_NF & TC_MEC_MEC011_SRV_APPSAQ_004_OK

parent 5f1c66ef
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -681,7 +681,7 @@ func appRegistrationPOST(w http.ResponseWriter, r *http.Request) {
		return
	}

	if appInfo.IsInsByMec == false && appInfo.Endpoint == nil {
	if !appInfo.IsInsByMec && appInfo.Endpoint == nil {
		log.Error("Shall be present when IsInsByMec is FALSE")
		errHandlerProblemDetails(w, "Endpoint shall be present when IsInsByMec is FALSE.", http.StatusBadRequest)
		return
@@ -827,7 +827,7 @@ func appRegistrationPUT(w http.ResponseWriter, r *http.Request) {
		return
	}

	if appInfoPut.IsInsByMec == false && appInfoPut.Endpoint == nil {
	if !appInfoPut.IsInsByMec && appInfoPut.Endpoint == nil {
		log.Error("Shall be present when IsInsByMec is FALSE")
		errHandlerProblemDetails(w, "Shall be present when IsInsByMec is FALSE.", http.StatusBadRequest)
		return
+8 −7
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import (

	apps "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-applications"
	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"

	//	met "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metrics"
	mod "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model"
	mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq"
@@ -6310,7 +6311,7 @@ func TestIndividualSubscriptionGET(t *testing.T) {
	if err != nil {
		t.Fatalf(err.Error())
	}
	fmt.Sprintf("expectedRespBody: %v", expectedRespBody)
	fmt.Println(fmt.Sprintf("expectedRespBody: %v", expectedRespBody))

	// GET Subscriptions
	var vars = make(map[string]string)
@@ -6327,7 +6328,7 @@ func TestIndividualSubscriptionGET(t *testing.T) {
	if err != nil {
		t.Fatalf(err.Error())
	}
	fmt.Sprintf("respBody: %v", respBody)
	fmt.Println(fmt.Sprintf("respBody: %v", respBody))

	if !validateAppTerminationNotificationSubscription(respBody, expectedRespBody) {
		t.Fatalf("MecAppSuptApiSubscriptionLinkList mismatch")
@@ -6607,7 +6608,7 @@ func validateMecAppSuptApiSubscriptionLinkListLinks(received as.MecAppSuptApiSub
	fmt.Println("validateMecAppSuptApiSubscriptionLinkListLinks: expected: ", expected)

	if received.Self != nil && expected.Self != nil {
	} else if received.Self != nil && expected.Self != nil {
	} else if received.Self != nil || expected.Self != nil {
		fmt.Println("validateMecAppSuptApiSubscriptionLinkListLinks.Self mismatch")
		return false
	}
@@ -7289,7 +7290,7 @@ func TestTimingCapsGET(t *testing.T) {
	 * expected response section
	 ******************************/
	expectedTimingCaps := as.TimingCaps{
		TimeStamp:  &as.TimingCapsTimeStamp{int32(time.Now().Unix()), 0},
		TimeStamp:  &as.TimingCapsTimeStamp{Seconds: int32(time.Now().Unix()), NanoSeconds: 0},
		NtpServers: make([]as.TimingCapsNtpServers, 0),
		PtpMasters: make([]as.TimingCapsPtpMasters, 0),
	}
@@ -7335,8 +7336,8 @@ func TestTimingCapsGET(t *testing.T) {
}

func validateTimingCaps(received as.TimingCaps, expected as.TimingCaps, delta float64) bool {
	fmt.Sprintf(">>> validateTimingCaps: received: %v", received)
	fmt.Sprintf(">>> validateTimingCaps: expected: %v", received)
	fmt.Println(fmt.Sprintf(">>> validateTimingCaps: received: %v", received))
	fmt.Println(fmt.Sprintf(">>> validateTimingCaps: expected: %v", received))
	fmt.Println(">>> validateTimingCaps: delta: ", delta)

	if received.TimeStamp != nil && expected.TimeStamp != nil {
@@ -7422,7 +7423,7 @@ func TestTimingCurrentTimeGET(t *testing.T) {
}

func validateTimeStamp(received as.TimingCapsTimeStamp, delta float64) bool {
	fmt.Sprintf(">>> validateTimeStamp: received: %v", received)
	fmt.Println(fmt.Sprintf(">>> validateTimeStamp: received: %v", received))
	fmt.Println(">>> validateTimeStamp: delta: ", delta)

	currentSeconds := int32(time.Now().Unix())
+8 −0
Original line number Diff line number Diff line
@@ -71,6 +71,14 @@ func ServicesServiceIdGET(w http.ResponseWriter, r *http.Request) {
	servicesByIdGET(w, r)
}

func GetIndividualMECService(w http.ResponseWriter, r *http.Request) {
	getIndividualMECService(w, r)
}

func PatchIndividualMECService(w http.ResponseWriter, r *http.Request) {
	patchIndividualMECService(w, r)
}

func TransportsGET(w http.ResponseWriter, r *http.Request) {
	transportsGET(w, r)
}
+37 −5
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import (
	"strconv"
	"strings"
	"sync"
	"time"

	dkm "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr"
	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
@@ -76,6 +77,10 @@ type ServiceInfoList struct {
	Filters                  *FilterParameters
}

type LivenessTimer struct {
	ticker *time.Ticker
}

type FilterParameters struct {
	serInstanceId     []string
	serName           []string
@@ -90,6 +95,8 @@ type StateData struct {
	AppId string
}

var livenessTimerList map[string]LivenessTimer

func Init(sandbox string, mep string, host *url.URL, msgQueue *mq.MsgQueue, redisAddr_ string, globalMutex *sync.Mutex) (err error) {
	redisAddr = redisAddr_
	sandboxName = sandbox
@@ -137,6 +144,8 @@ func Init(sandbox string, mep string, host *url.URL, msgQueue *mq.MsgQueue, redi
	}
	log.Info("Created Subscription Manager")

	livenessTimerList = make(map[string]LivenessTimer)

	// TODO -- Initialize subscriptions from DB

	return nil
@@ -158,6 +167,18 @@ func Run() (err error) {

// Stop - Stop Service Mgmt
func Stop() (err error) {

	if len(livenessTimerList) != 0 {
		log.Info("Stop all Liveness timers")
		for _, livenessTimer := range livenessTimerList {
			if livenessTimer.ticker != nil {
				livenessTimer.ticker.Stop()
			}
			livenessTimer.ticker = nil
		} // End of 'for' statement
		livenessTimerList = make(map[string]LivenessTimer)
	}

	return nil
}

@@ -298,6 +319,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) {
		ConsumedLocalOnly: sInfoPost.ConsumedLocalOnly,
		// although IsLocal is reevaluated when a query is replied to, value stored in sInfo as is for now
		IsLocal:          sInfoPost.IsLocal,
		LivenessInterval: sInfoPost.LivenessInterval,
	}
	sInfo.Links = &ServiceInfoLinks{
		Self: &LinkType{
@@ -382,13 +404,14 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) {
	sInfo.IsLocal = sInfoPrev.IsLocal

	// Compare service information as JSON strings
	/* FSCOM: It is not specified that only the ServiceInfo state property may be changed in ETSI GS MEC 011 V3.2.1 (2024-04)
	sInfoJson := convertServiceInfoToJson(&sInfo)
	if sInfoJson != sInfoPrevJson {
		errStr := "Only the ServiceInfo state property may be changed"
		log.Error(errStr)
		errHandlerProblemDetails(w, errStr, http.StatusBadRequest)
		return
	}
	}*/

	// Compare service info states & update DB if necessary
	*sInfo.State = state
@@ -827,13 +850,15 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, convertMecServiceMgmtApiSubscriptionLinkListToJson(subscriptionLinkList))
}

func GetIndividualMECService(w http.ResponseWriter, r *http.Request) {
func getIndividualMECService(w http.ResponseWriter, r *http.Request) {
	log.Info("getIndividualMECService")
	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	// FIXME FSCOM TODO
	w.WriteHeader(http.StatusOK)
}

func PatchIndividualMECService(w http.ResponseWriter, r *http.Request) {
func patchIndividualMECService(w http.ResponseWriter, r *http.Request) {
	log.Info("patchIndividualMECService")
	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	// FIXME FSCOM TODO
	w.WriteHeader(http.StatusOK)
@@ -982,6 +1007,11 @@ func setService(appId string, sInfo *ServiceInfo, changeType ServiceAvailability
	// Send local service availability notifications
	checkSerAvailNotification(sInfo, mepName, changeType)

	// FIXME FSCOM
	// if sInfo.LivenessTimerList == -1 {
	// 	livenessTimerList = append(LivenessTimer{sInfo.serInstanceId, time.NewTicker(sInfo.LivenessTimerList * time.Second) })
	// }

	return nil, http.StatusOK
}

@@ -1099,7 +1129,9 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId
	}

	// Validate result
	if len(sInfoList.Services) != 1 {
	log.Info("Service: ", sInfoList.Services)          // FIXME To be removed
	log.Info("Service len: ", len(sInfoList.Services)) // FIXME To be removed
	if len(sInfoList.Services) == 0 {
		w.WriteHeader(http.StatusNotFound)
		return
	}