Loading go-packages/meep-vis-traffic-mgr/traffic-mgr_test.go +69 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ const ( // FIXME To be update with correct values at the end fifteenToEighteen1 = 0 eighteenToTwentyOne1 = 0 twentyOneToTwentyFour1 = 0 hour1 = 133 inRsrp1 = 10 inRsrq1 = 10 ) func TestNewTrafficMgr(t *testing.T) { Loading Loading @@ -239,6 +242,7 @@ func TestTrafficMgrCreateTrafficTable(t *testing.T) { if !validatePoaLoads(trafficMap, poaName1, category1, zeroToThree1, threeToSix1, sixToNine1, nineToTwelve1, twelveToFifteen1, fifteenToEighteen1, eighteenToTwentyOne1, twentyOneToTwentyFour1) { t.Fatalf("Category validation failed") } // Delete all & validate updatespoaMap fmt.Println("Delete all & validate updates") err = tm.DeleteAllPoaLoad() Loading @@ -253,6 +257,71 @@ func TestTrafficMgrCreateTrafficTable(t *testing.T) { // t.Fatalf("DONE") } func TestPredictQosPerTrafficLoad(t *testing.T) { fmt.Println("--- ", t.Name()) log.MeepTextLogInit(t.Name()) // Create Connector fmt.Println("Create valid VIS Asset Manager") tm, _ := NewTrafficMgr(tmName, tmNamespace, tmDBUser, tmDBPwd, tmDBHost, tmDBPort) // Cleanup _ = tm.DeleteTables() // Create tables fmt.Println("Create Tables") _ = tm.CreateTables() // Add Traffic & Validate successfully added catData := map[string]int32{ FieldZeroToThree: zeroToThree1, FieldThreeToSix: threeToSix1, FieldSixToNine: sixToNine1, FieldNineToTwelve: nineToTwelve1, FieldTwelveToFifteen: twelveToFifteen1, FieldFifteenToEighteen: fifteenToEighteen1, FieldEighteenToTwentyOne: eighteenToTwentyOne1, FieldTwentyOneToTwentyFour: twentyOneToTwentyFour1, } _ = tm.CreateCategoryLoad(category1, catData) _ = tm.CreatePoaLoad(poaName1, category1) // Invalid poaName _, _, err := tm.PredictQosPerTrafficLoad(14, 0, 0, "") if err == nil { t.Fatalf("Should have failed due to invalid poaName") } // Invalid hour _, _, err = tm.PredictQosPerTrafficLoad(25, 0, 0, poaName1) if err == nil { t.Fatalf("Should have failed due to invalid hour") } // Invalid inRsrp _, _, err = tm.PredictQosPerTrafficLoad(25, -1, 0, poaName1) if err == nil { t.Fatalf("Should have failed due to invalid inRsrp") } // Invalid inRsrq _, _, err = tm.PredictQosPerTrafficLoad(25, 0, -1, poaName1) if err == nil { t.Fatalf("Should have failed due to invalid inRsrq") } rsrp, rsrq, err := tm.PredictQosPerTrafficLoad(hour1, inRsrp1, inRsrq1, poaName1) if err != nil { t.Fatalf("Failed to delete all Traffic") } fmt.Println("rsrp: ", rsrp) fmt.Println("rsrq: ", rsrq) // Delete all & validate updatespoaMap fmt.Println("Delete all & validate updates") _ = tm.DeleteAllPoaLoad() _, _ = tm.GetAllPoaLoad() // t.Fatalf("DONE") } func validateCategory(categoryLoads *CategoryLoads, category string, zeroToThree int32, threeToSix int32, sixToNine int32, nineToTwelve int32, twelveToFifteen int32, fifteenToEighteen int32, eighteenToTwentyOne int32, twentyOneToTwentyFour int32) bool { if categoryLoads == nil { fmt.Println("categoryLoads == nil") Loading Loading
go-packages/meep-vis-traffic-mgr/traffic-mgr_test.go +69 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ const ( // FIXME To be update with correct values at the end fifteenToEighteen1 = 0 eighteenToTwentyOne1 = 0 twentyOneToTwentyFour1 = 0 hour1 = 133 inRsrp1 = 10 inRsrq1 = 10 ) func TestNewTrafficMgr(t *testing.T) { Loading Loading @@ -239,6 +242,7 @@ func TestTrafficMgrCreateTrafficTable(t *testing.T) { if !validatePoaLoads(trafficMap, poaName1, category1, zeroToThree1, threeToSix1, sixToNine1, nineToTwelve1, twelveToFifteen1, fifteenToEighteen1, eighteenToTwentyOne1, twentyOneToTwentyFour1) { t.Fatalf("Category validation failed") } // Delete all & validate updatespoaMap fmt.Println("Delete all & validate updates") err = tm.DeleteAllPoaLoad() Loading @@ -253,6 +257,71 @@ func TestTrafficMgrCreateTrafficTable(t *testing.T) { // t.Fatalf("DONE") } func TestPredictQosPerTrafficLoad(t *testing.T) { fmt.Println("--- ", t.Name()) log.MeepTextLogInit(t.Name()) // Create Connector fmt.Println("Create valid VIS Asset Manager") tm, _ := NewTrafficMgr(tmName, tmNamespace, tmDBUser, tmDBPwd, tmDBHost, tmDBPort) // Cleanup _ = tm.DeleteTables() // Create tables fmt.Println("Create Tables") _ = tm.CreateTables() // Add Traffic & Validate successfully added catData := map[string]int32{ FieldZeroToThree: zeroToThree1, FieldThreeToSix: threeToSix1, FieldSixToNine: sixToNine1, FieldNineToTwelve: nineToTwelve1, FieldTwelveToFifteen: twelveToFifteen1, FieldFifteenToEighteen: fifteenToEighteen1, FieldEighteenToTwentyOne: eighteenToTwentyOne1, FieldTwentyOneToTwentyFour: twentyOneToTwentyFour1, } _ = tm.CreateCategoryLoad(category1, catData) _ = tm.CreatePoaLoad(poaName1, category1) // Invalid poaName _, _, err := tm.PredictQosPerTrafficLoad(14, 0, 0, "") if err == nil { t.Fatalf("Should have failed due to invalid poaName") } // Invalid hour _, _, err = tm.PredictQosPerTrafficLoad(25, 0, 0, poaName1) if err == nil { t.Fatalf("Should have failed due to invalid hour") } // Invalid inRsrp _, _, err = tm.PredictQosPerTrafficLoad(25, -1, 0, poaName1) if err == nil { t.Fatalf("Should have failed due to invalid inRsrp") } // Invalid inRsrq _, _, err = tm.PredictQosPerTrafficLoad(25, 0, -1, poaName1) if err == nil { t.Fatalf("Should have failed due to invalid inRsrq") } rsrp, rsrq, err := tm.PredictQosPerTrafficLoad(hour1, inRsrp1, inRsrq1, poaName1) if err != nil { t.Fatalf("Failed to delete all Traffic") } fmt.Println("rsrp: ", rsrp) fmt.Println("rsrq: ", rsrq) // Delete all & validate updatespoaMap fmt.Println("Delete all & validate updates") _ = tm.DeleteAllPoaLoad() _, _ = tm.GetAllPoaLoad() // t.Fatalf("DONE") } func validateCategory(categoryLoads *CategoryLoads, category string, zeroToThree int32, threeToSix int32, sixToNine int32, nineToTwelve int32, twelveToFifteen int32, fifteenToEighteen int32, eighteenToTwentyOne int32, twentyOneToTwentyFour int32) bool { if categoryLoads == nil { fmt.Println("categoryLoads == nil") Loading