Commit 40e63e7b authored by Simon Pastor's avatar Simon Pastor
Browse files

pr comments

parent 954f246f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ require (
	github.com/gorilla/handlers v1.5.1
	github.com/gorilla/mux v1.7.4
	github.com/lkysow/go-gitlab v0.7.1
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/prometheus/client_golang v1.9.0
	github.com/roymx/viper v1.3.3-0.20190416163942-b9a223fc58a3
	golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
	google.golang.org/protobuf v1.25.0 // indirect
	gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
)

replace (
+47 −11
Original line number Diff line number Diff line
@@ -28,13 +28,49 @@ import (

const moduleName string = "meep-rnis-sbi"

type UeDataSbi struct {
	Name         string
	Mnc          string
	Mcc          string
	CellId       string
	NrCellId     string
	ErabIdValid  bool
	AppNames     []string
	Latency      int32
	ThroughputUL int32
	ThroughputDL int32
	PacketLoss   float64
}

type PoaInfoSbi struct {
	Name         string
	PoaType      string
	Mnc          string
	Mcc          string
	CellId       string
	Latency      int32
	ThroughputUL int32
	ThroughputDL int32
	PacketLoss   float64
}

type AppInfoSbi struct {
	Name         string
	ParentType   string
	ParentName   string
	Latency      int32
	ThroughputUL int32
	ThroughputDL int32
	PacketLoss   float64
}

type SbiCfg struct {
	SandboxName    string
	RedisAddr      string
	UeDataCb       func(string, string, string, string, string, bool, []string, int32, int32, int32, float64)
	UeDataCb       func(UeDataSbi)
	MeasInfoCb     func(string, string, []string, []int32, []int32)
	PoaInfoCb      func(string, string, string, string, string, int32, int32, int32, float64)
	AppInfoCb      func(string, string, string, int32, int32, int32, float64)
	PoaInfoCb      func(PoaInfoSbi)
	AppInfoCb      func(AppInfoSbi)
	DomainDataCb   func(string, string, string, string)
	ScenarioNameCb func(string)
	CleanUpCb      func()
@@ -47,10 +83,10 @@ type RnisSbi struct {
	activeModel          *mod.Model
	gisCache             *gc.GisCache
	refreshTicker        *time.Ticker
	updateUeDataCB       func(string, string, string, string, string, bool, []string, int32, int32, int32, float64)
	updateUeDataCB       func(UeDataSbi)
	updateMeasInfoCB     func(string, string, []string, []int32, []int32)
	updatePoaInfoCB      func(string, string, string, string, string, int32, int32, int32, float64)
	updateAppInfoCB      func(string, string, string, int32, int32, int32, float64)
	updatePoaInfoCB      func(PoaInfoSbi)
	updateAppInfoCB      func(AppInfoSbi)
	updateDomainDataCB   func(string, string, string, string)
	updateScenarioNameCB func(string)
	cleanUpCB            func()
@@ -290,7 +326,7 @@ func processActiveScenarioUpdate() {
						throughputUL = ue.NetChar.ThroughputUl
					}

					sbi.updateUeDataCB(name, mnc, mcc, cellId, nrcellId, erabIdValid, appNames, latency, throughputUL, throughputDL, ploss)
					sbi.updateUeDataCB(UeDataSbi{name, mnc, mcc, cellId, nrcellId, erabIdValid, appNames, latency, throughputUL, throughputDL, ploss})
				}
			}
		}
@@ -306,7 +342,7 @@ func processActiveScenarioUpdate() {
			}
		}
		if !found {
			sbi.updateUeDataCB(prevUeName, "", "", "", "", false, nil, 0, 0, 0, 0.0)
			sbi.updateUeDataCB(UeDataSbi{prevUeName, "", "", "", "", false, nil, 0, 0, 0, 0.0})
			log.Info("Ue removed : ", prevUeName)
		}
	}
@@ -338,7 +374,7 @@ func processActiveScenarioUpdate() {
				throughputUL = pl.NetChar.ThroughputUl
			}

			sbi.updateAppInfoCB(appName, pl.Type_, pl.Name, latency, throughputUL, throughputDL, ploss)
			sbi.updateAppInfoCB(AppInfoSbi{appName, pl.Type_, pl.Name, latency, throughputUL, throughputDL, ploss})
		}
	}

@@ -352,7 +388,7 @@ func processActiveScenarioUpdate() {
			}
		}
		if !found {
			sbi.updateAppInfoCB(prevApp, "", "", 0, 0, 0, 0.0)
			sbi.updateAppInfoCB(AppInfoSbi{prevApp, "", "", 0, 0, 0, 0.0})
			log.Info("App removed : ", prevApp)
		}
	}
@@ -398,7 +434,7 @@ func processActiveScenarioUpdate() {
					throughputUL = nl.NetChar.ThroughputUl
				}

				sbi.updatePoaInfoCB(name, nl.Type_, mnc, mcc, cellId, latency, throughputUL, throughputDL, ploss)
				sbi.updatePoaInfoCB(PoaInfoSbi{name, nl.Type_, mnc, mcc, cellId, latency, throughputUL, throughputDL, ploss})
			}
		}
	}
+136 −130

File changed.

Preview size limit exceeded, changes collapsed.

+4 −4
Original line number Diff line number Diff line
@@ -2224,17 +2224,17 @@ func TestSbi(t *testing.T) {

	time.Sleep(1000 * time.Millisecond)

	jsonInfo, _ := rc[RNIS_DB_CONNECTOR_INDEX].JSONGetEntry(baseKey+"UE:"+ueName, ".")
	jsonInfo, _ := rc.JSONGetEntry(baseKey+"UE:"+ueName, ".")
	if string(jsonInfo) != expectedUeDataStr[INITIAL] {
		t.Fatalf("Failed to get expected response")
	}

	jsonInfo, _ = rc[RNIS_DB_CONNECTOR_INDEX].JSONGetEntry(baseKey+"APP:"+appName, ".")
	jsonInfo, _ = rc.JSONGetEntry(baseKey+"APP:"+appName, ".")
	if string(jsonInfo) != expectedAppInfoStr {
		t.Fatalf("Failed to get expected response")
	}

	jsonInfo, _ = rc[RNIS_DB_CONNECTOR_INDEX].JSONGetEntry(baseKey+"POA:"+poaName, ".")
	jsonInfo, _ = rc.JSONGetEntry(baseKey+"POA:"+poaName, ".")
	if string(jsonInfo) != expectedPoaInfoStr {
		t.Fatalf("Failed to get expected response")
	}
@@ -2242,7 +2242,7 @@ func TestSbi(t *testing.T) {
	updateScenario("mobility1")
	time.Sleep(1000 * time.Millisecond)

	jsonInfo, _ = rc[RNIS_DB_CONNECTOR_INDEX].JSONGetEntry(baseKey+"UE:"+ueName, ".")
	jsonInfo, _ = rc.JSONGetEntry(baseKey+"UE:"+ueName, ".")
	if string(jsonInfo) != expectedUeDataStr[UPDATED] {
		t.Fatalf("Failed to get expected response")
	}
+33 −0
Original line number Diff line number Diff line
@@ -79,6 +79,38 @@ func (ms *MetricStore) SetCachedNetworkMetric(metric NetworkMetric) (err error)
	return nil
}

// GetCachedNetworkMetrics
func (ms *MetricStore) GetCachedNetworkMetrics(src string, dst string) (metric []NetworkMetric, err error) {
        // Make sure we have set a store
        if ms.name == "" {
                err = errors.New("Store name not specified")
                return
        }

        // Get current Network metric
        tagStr := src + ":" + dst
        var valuesArray []map[string]interface{}
        valuesArray, err = ms.GetRedisMetric(NetMetName, tagStr)
        if err != nil {
                log.Error("Failed to retrieve metrics with error: ", err.Error())
                return
        }

        metricList := make([]NetworkMetric, len(valuesArray))
        for index, values := range valuesArray {
                // Format network metric
                nm, err := ms.formatCachedNetworkMetric(values)
                if err != nil {
                        continue
                }
                // Add metric to list
                metricList[index] = nm
        }

        // Return formatted metric
        return metricList, nil
}

// GetCachedNetworkMetric
func (ms *MetricStore) GetCachedNetworkMetric(src string, dst string) (metric NetworkMetric, err error) {
	// Make sure we have set a store
@@ -95,6 +127,7 @@ func (ms *MetricStore) GetCachedNetworkMetric(src string, dst string) (metric Ne
		log.Error("Failed to retrieve metrics with error: ", err.Error())
		return
	}

	if len(valuesArray) != 1 {
		err = errors.New("Metric list length != 1")
		return
Loading