Loading go-apps/meep-wais/sbi/wais-sbi.go +14 −5 Original line number Diff line number Diff line Loading @@ -37,16 +37,18 @@ var influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" type SbiCfg struct { SandboxName string RedisAddr string InfluxAddr string PostgisHost string PostgisPort string StaInfoCb func(string, string, string, *int32, *int32, *int32) ApInfoCb func(string, string, *float32, *float32, []string) ScenarioNameCb func(string, *bool) ScenarioNameCb func(string) CleanUpCb func() } type WaisSbi struct { sandboxName string scenarioName string mqLocal *mq.MsgQueue handlerId int activeModel *mod.Model Loading @@ -54,7 +56,7 @@ type WaisSbi struct { refreshTicker *time.Ticker updateStaInfoCB func(string, string, string, *int32, *int32, *int32) updateAccessPointInfoCB func(string, string, *float32, *float32, []string) updateScenarioNameCB func(string, *bool) updateScenarioNameCB func(string) cleanUpCB func() mutex sync.Mutex } Loading @@ -70,10 +72,13 @@ func Init(cfg SbiCfg) (err error) { } sbi = new(WaisSbi) sbi.sandboxName = cfg.SandboxName sbi.scenarioName = "" sbi.updateStaInfoCB = cfg.StaInfoCb sbi.updateAccessPointInfoCB = cfg.ApInfoCb sbi.updateScenarioNameCB = cfg.ScenarioNameCb sbi.cleanUpCB = cfg.CleanUpCb redisAddr = cfg.RedisAddr influxAddr = cfg.InfluxAddr // Create message queue sbi.mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(sbi.sandboxName), moduleName, sbi.sandboxName, cfg.RedisAddr) Loading Loading @@ -223,12 +228,16 @@ func processActiveScenarioUpdate() { sbi.activeModel.UpdateScenario() scenarioName := sbi.activeModel.GetScenarioName() var update bool sbi.updateScenarioNameCB(scenarioName, &update) sbi.updateScenarioNameCB(scenarioName) // Connect to Metric Store if update { if scenarioName != sbi.scenarioName { sbi.updateScenarioNameCB(scenarioName) sbi.scenarioName = scenarioName var err error metricStore, err = met.NewMetricStore(scenarioName, sbi.sandboxName, influxAddr, redisAddr) if err != nil { log.Error("Failed connection to metric-store: ", err) Loading go-apps/meep-wais/server/wais.go +4 −10 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ var assocStaSubscriptionMap = map[int]*AssocStaSubscription{} var staDataRateSubscriptionMap = map[int]*StaDataRateSubscription{} var subscriptionExpiryMap = map[int][]int{} var currentStoreName = "" var WAIS_DB = 5 Loading Loading @@ -159,6 +158,7 @@ func Init() (err error) { sbiCfg := sbi.SbiCfg{ SandboxName: sandboxName, RedisAddr: redisAddr, InfluxAddr: influxAddr, StaInfoCb: updateStaInfo, ApInfoCb: updateApInfo, ScenarioNameCb: updateStoreName, Loading Loading @@ -1279,15 +1279,9 @@ func cleanUp() { staDataRateSubscriptionMap = map[int]*StaDataRateSubscription{} subscriptionExpiryMap = map[int][]int{} var update bool updateStoreName("", &update) updateStoreName("") } func updateStoreName(storeName string, update *bool) { if currentStoreName != storeName { currentStoreName = storeName func updateStoreName(storeName string) { _ = httpLog.ReInit(logModuleWAIS, sandboxName, storeName, redisAddr, influxAddr) *update = true } *update = false } go-apps/meep-wais/server/wais_test.go +14 −13 Original line number Diff line number Diff line Loading @@ -5889,7 +5889,8 @@ const testScenario string = ` const redisTestAddr = "localhost:30380" const influxTestAddr = "http://localhost:30986" const testScenarioName = "testScenario" const testSandboxName = "testScenario" const testScenarioName = "4g-5g-wifi-macro" var m *mod.Model var mqLocal *mq.MsgQueue Loading Loading @@ -6032,7 +6033,7 @@ func testSubscriptionAssocStaPost(t *testing.T) string { ******************************/ expectedApId := ApIdentity{"myMacId", []string{"myIp"}, []string{"mySSid"}} expectedCallBackRef := "myCallbakRef" expectedLinkType := LinkType{"/" + testScenarioName + "/wai/v2/subscriptions/" + strconv.Itoa(nextSubscriptionIdAvailable)} expectedLinkType := LinkType{"/" + testSandboxName + "/wai/v2/subscriptions/" + strconv.Itoa(nextSubscriptionIdAvailable)} //expectedExpiry := TimeStamp{0, 1988599770} expectedResponse := AssocStaSubscription{&AssocStaSubscriptionLinks{&expectedLinkType}, &expectedApId, expectedCallBackRef, nil /*&expectedExpiry*/, nil, 0, false, ASSOC_STA_SUBSCRIPTION, nil} Loading Loading @@ -6087,7 +6088,7 @@ func testSubscriptionAssocStaPut(t *testing.T, subscriptionId string, expectSucc ******************************/ expectedApId := ApIdentity{"myMacId", []string{"myIp"}, []string{"mySSid"}} expectedCallBackRef := "myCallbakRef" expectedLinkType := LinkType{"/" + testScenarioName + "/wai/v2/subscriptions/" + subscriptionId} expectedLinkType := LinkType{"/" + testSandboxName + "/wai/v2/subscriptions/" + subscriptionId} expectedExpiry := TimeStamp{0, 1988599770} expectedResponse := AssocStaSubscription{&AssocStaSubscriptionLinks{&expectedLinkType}, &expectedApId, expectedCallBackRef, &expectedExpiry, nil, 0, false, ASSOC_STA_SUBSCRIPTION, nil} Loading Loading @@ -6280,7 +6281,7 @@ func TestExpiryNotification(t *testing.T) { time.Sleep(1 * time.Second) fmt.Println("Create valid Metric Store to get logs from") metricStore, err := met.NewMetricStore(currentStoreName, sandboxName, influxTestAddr, redisTestAddr) metricStore, err := met.NewMetricStore(testScenarioName, sandboxName, influxTestAddr, redisTestAddr) if err != nil { t.Fatalf("Failed to create store") } Loading Loading @@ -6369,7 +6370,7 @@ func TestSubscriptionAssocStaNotification(t *testing.T) { updateScenario("mobility1") fmt.Println("Create valid Metric Store") metricStore, err := met.NewMetricStore(currentStoreName, sandboxName, influxTestAddr, redisTestAddr) metricStore, err := met.NewMetricStore(testScenarioName, sandboxName, influxTestAddr, redisTestAddr) if err != nil { t.Fatalf("Failed to create a store") } Loading Loading @@ -6659,7 +6660,7 @@ func TestStaInfoGet(t *testing.T) { func terminateScenario() { if mqLocal != nil { _ = Stop() msg := mqLocal.CreateMsg(mq.MsgScenarioTerminate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioTerminate, mq.TargetAll, testSandboxName) err := mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6681,7 +6682,7 @@ func updateScenario(testUpdate string) { log.Error("Error sending mobility event") } msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6696,7 +6697,7 @@ func updateScenario(testUpdate string) { log.Error("Error sending mobility event") } msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6711,7 +6712,7 @@ func updateScenario(testUpdate string) { log.Error("Error sending mobility event") } msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6725,7 +6726,7 @@ func initializeVars() { mod.DbAddress = redisTestAddr redisAddr = redisTestAddr influxAddr = influxTestAddr sandboxName = testScenarioName sandboxName = testSandboxName } func initialiseScenario(testScenario string) { Loading @@ -6734,7 +6735,7 @@ func initialiseScenario(testScenario string) { cleanUp() cfg := mod.ModelCfg{ Name: testScenarioName, Name: testSandboxName, Namespace: sandboxName, Module: "test-mod", UpdateCb: nil, Loading @@ -6749,7 +6750,7 @@ func initialiseScenario(testScenario string) { } // Create message queue mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(testScenarioName), "test-mod", testScenarioName, redisAddr) mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(testSandboxName), "test-mod", testSandboxName, redisAddr) if err != nil { log.Error("Failed to create Message Queue with error: ", err) return Loading @@ -6769,7 +6770,7 @@ func initialiseScenario(testScenario string) { return } msg := mqLocal.CreateMsg(mq.MsgScenarioActivate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioActivate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading Loading
go-apps/meep-wais/sbi/wais-sbi.go +14 −5 Original line number Diff line number Diff line Loading @@ -37,16 +37,18 @@ var influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" type SbiCfg struct { SandboxName string RedisAddr string InfluxAddr string PostgisHost string PostgisPort string StaInfoCb func(string, string, string, *int32, *int32, *int32) ApInfoCb func(string, string, *float32, *float32, []string) ScenarioNameCb func(string, *bool) ScenarioNameCb func(string) CleanUpCb func() } type WaisSbi struct { sandboxName string scenarioName string mqLocal *mq.MsgQueue handlerId int activeModel *mod.Model Loading @@ -54,7 +56,7 @@ type WaisSbi struct { refreshTicker *time.Ticker updateStaInfoCB func(string, string, string, *int32, *int32, *int32) updateAccessPointInfoCB func(string, string, *float32, *float32, []string) updateScenarioNameCB func(string, *bool) updateScenarioNameCB func(string) cleanUpCB func() mutex sync.Mutex } Loading @@ -70,10 +72,13 @@ func Init(cfg SbiCfg) (err error) { } sbi = new(WaisSbi) sbi.sandboxName = cfg.SandboxName sbi.scenarioName = "" sbi.updateStaInfoCB = cfg.StaInfoCb sbi.updateAccessPointInfoCB = cfg.ApInfoCb sbi.updateScenarioNameCB = cfg.ScenarioNameCb sbi.cleanUpCB = cfg.CleanUpCb redisAddr = cfg.RedisAddr influxAddr = cfg.InfluxAddr // Create message queue sbi.mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(sbi.sandboxName), moduleName, sbi.sandboxName, cfg.RedisAddr) Loading Loading @@ -223,12 +228,16 @@ func processActiveScenarioUpdate() { sbi.activeModel.UpdateScenario() scenarioName := sbi.activeModel.GetScenarioName() var update bool sbi.updateScenarioNameCB(scenarioName, &update) sbi.updateScenarioNameCB(scenarioName) // Connect to Metric Store if update { if scenarioName != sbi.scenarioName { sbi.updateScenarioNameCB(scenarioName) sbi.scenarioName = scenarioName var err error metricStore, err = met.NewMetricStore(scenarioName, sbi.sandboxName, influxAddr, redisAddr) if err != nil { log.Error("Failed connection to metric-store: ", err) Loading
go-apps/meep-wais/server/wais.go +4 −10 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ var assocStaSubscriptionMap = map[int]*AssocStaSubscription{} var staDataRateSubscriptionMap = map[int]*StaDataRateSubscription{} var subscriptionExpiryMap = map[int][]int{} var currentStoreName = "" var WAIS_DB = 5 Loading Loading @@ -159,6 +158,7 @@ func Init() (err error) { sbiCfg := sbi.SbiCfg{ SandboxName: sandboxName, RedisAddr: redisAddr, InfluxAddr: influxAddr, StaInfoCb: updateStaInfo, ApInfoCb: updateApInfo, ScenarioNameCb: updateStoreName, Loading Loading @@ -1279,15 +1279,9 @@ func cleanUp() { staDataRateSubscriptionMap = map[int]*StaDataRateSubscription{} subscriptionExpiryMap = map[int][]int{} var update bool updateStoreName("", &update) updateStoreName("") } func updateStoreName(storeName string, update *bool) { if currentStoreName != storeName { currentStoreName = storeName func updateStoreName(storeName string) { _ = httpLog.ReInit(logModuleWAIS, sandboxName, storeName, redisAddr, influxAddr) *update = true } *update = false }
go-apps/meep-wais/server/wais_test.go +14 −13 Original line number Diff line number Diff line Loading @@ -5889,7 +5889,8 @@ const testScenario string = ` const redisTestAddr = "localhost:30380" const influxTestAddr = "http://localhost:30986" const testScenarioName = "testScenario" const testSandboxName = "testScenario" const testScenarioName = "4g-5g-wifi-macro" var m *mod.Model var mqLocal *mq.MsgQueue Loading Loading @@ -6032,7 +6033,7 @@ func testSubscriptionAssocStaPost(t *testing.T) string { ******************************/ expectedApId := ApIdentity{"myMacId", []string{"myIp"}, []string{"mySSid"}} expectedCallBackRef := "myCallbakRef" expectedLinkType := LinkType{"/" + testScenarioName + "/wai/v2/subscriptions/" + strconv.Itoa(nextSubscriptionIdAvailable)} expectedLinkType := LinkType{"/" + testSandboxName + "/wai/v2/subscriptions/" + strconv.Itoa(nextSubscriptionIdAvailable)} //expectedExpiry := TimeStamp{0, 1988599770} expectedResponse := AssocStaSubscription{&AssocStaSubscriptionLinks{&expectedLinkType}, &expectedApId, expectedCallBackRef, nil /*&expectedExpiry*/, nil, 0, false, ASSOC_STA_SUBSCRIPTION, nil} Loading Loading @@ -6087,7 +6088,7 @@ func testSubscriptionAssocStaPut(t *testing.T, subscriptionId string, expectSucc ******************************/ expectedApId := ApIdentity{"myMacId", []string{"myIp"}, []string{"mySSid"}} expectedCallBackRef := "myCallbakRef" expectedLinkType := LinkType{"/" + testScenarioName + "/wai/v2/subscriptions/" + subscriptionId} expectedLinkType := LinkType{"/" + testSandboxName + "/wai/v2/subscriptions/" + subscriptionId} expectedExpiry := TimeStamp{0, 1988599770} expectedResponse := AssocStaSubscription{&AssocStaSubscriptionLinks{&expectedLinkType}, &expectedApId, expectedCallBackRef, &expectedExpiry, nil, 0, false, ASSOC_STA_SUBSCRIPTION, nil} Loading Loading @@ -6280,7 +6281,7 @@ func TestExpiryNotification(t *testing.T) { time.Sleep(1 * time.Second) fmt.Println("Create valid Metric Store to get logs from") metricStore, err := met.NewMetricStore(currentStoreName, sandboxName, influxTestAddr, redisTestAddr) metricStore, err := met.NewMetricStore(testScenarioName, sandboxName, influxTestAddr, redisTestAddr) if err != nil { t.Fatalf("Failed to create store") } Loading Loading @@ -6369,7 +6370,7 @@ func TestSubscriptionAssocStaNotification(t *testing.T) { updateScenario("mobility1") fmt.Println("Create valid Metric Store") metricStore, err := met.NewMetricStore(currentStoreName, sandboxName, influxTestAddr, redisTestAddr) metricStore, err := met.NewMetricStore(testScenarioName, sandboxName, influxTestAddr, redisTestAddr) if err != nil { t.Fatalf("Failed to create a store") } Loading Loading @@ -6659,7 +6660,7 @@ func TestStaInfoGet(t *testing.T) { func terminateScenario() { if mqLocal != nil { _ = Stop() msg := mqLocal.CreateMsg(mq.MsgScenarioTerminate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioTerminate, mq.TargetAll, testSandboxName) err := mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6681,7 +6682,7 @@ func updateScenario(testUpdate string) { log.Error("Error sending mobility event") } msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6696,7 +6697,7 @@ func updateScenario(testUpdate string) { log.Error("Error sending mobility event") } msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6711,7 +6712,7 @@ func updateScenario(testUpdate string) { log.Error("Error sending mobility event") } msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioUpdate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading @@ -6725,7 +6726,7 @@ func initializeVars() { mod.DbAddress = redisTestAddr redisAddr = redisTestAddr influxAddr = influxTestAddr sandboxName = testScenarioName sandboxName = testSandboxName } func initialiseScenario(testScenario string) { Loading @@ -6734,7 +6735,7 @@ func initialiseScenario(testScenario string) { cleanUp() cfg := mod.ModelCfg{ Name: testScenarioName, Name: testSandboxName, Namespace: sandboxName, Module: "test-mod", UpdateCb: nil, Loading @@ -6749,7 +6750,7 @@ func initialiseScenario(testScenario string) { } // Create message queue mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(testScenarioName), "test-mod", testScenarioName, redisAddr) mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(testSandboxName), "test-mod", testSandboxName, redisAddr) if err != nil { log.Error("Failed to create Message Queue with error: ", err) return Loading @@ -6769,7 +6770,7 @@ func initialiseScenario(testScenario string) { return } msg := mqLocal.CreateMsg(mq.MsgScenarioActivate, mq.TargetAll, testScenarioName) msg := mqLocal.CreateMsg(mq.MsgScenarioActivate, mq.TargetAll, testSandboxName) err = mqLocal.SendMsg(msg) if err != nil { log.Error("Failed to send message: ", err) Loading