Loading go-packages/meep-data-key-mgr/data-key-mgr.go +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ const keyRootGlobal = keyRoot + "global:" const keyRootSandbox = keyRoot + "sbox:" func GetKeyRoot(namespace string) string { // TODO: Should validate that a namespace exists or return an error return keyRootSandbox + namespace + ":" } Loading go-packages/meep-pdu-sessions-store/go.mod +2 −0 Original line number Diff line number Diff line Loading @@ -4,12 +4,14 @@ go 1.12 require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis v0.0.0 ) replace ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr => ../../go-packages/meep-data-key-mgr github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model => ../../go-packages/meep-data-model github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger => ../../go-packages/meep-logger github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis => ../../go-packages/meep-redis ) go-packages/meep-pdu-sessions-store/go.sum 0 → 100644 +28 −0 Original line number Diff line number Diff line github.com/KromDaniel/jonson v0.0.0-20180630143114-d2f9c3c389db/go.mod h1:RU+6d0CNIRSp6yo1mXLIIrnFa/3LHhvcDVLVJyovptM= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351 h1:1u1XrfCBnY+GijnyU6O1k4odp5TnqZQTsp5v7+n/E4Y= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351/go.mod h1:HxwfbuElTuGf+/uKZfjJrCnv0BmmpkPJDI7gBwj1KkM= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4= github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= go-packages/meep-pdu-sessions-store/pdu-session.go→go-packages/meep-pdu-sessions-store/pdu-session-store.go +232 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,11 @@ package pdusessionstore import ( "errors" "strings" dkm "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr" dataModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" redis "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis" ) Loading @@ -26,12 +30,12 @@ const redisTable = 0 // Redis Data Structure const pduSessionsRootKey = "pdu-sessions:" // Key format: /pdu-sessions/[ue.name]/[pdu-session-uid] // Value(s): dnn=[dnn], (others TBD) // DB Fields // const fieldSandboxName = "sbox-name" // const fieldScenarioName = "scenario-name" const fieldDnn = "dnn" type PduSessionStore struct { rc *redis.Connector Loading @@ -40,8 +44,13 @@ type PduSessionStore struct { // NewPduSessionStore - Creates and initialize a PDU Session Store instance func NewPduSessionStore(namespace string, redisAddr string) (ss *PduSessionStore, err error) { // Validate params if namespace == "" { return nil, errors.New("Invalid namespace") } // Create new Sandbox Store instance ss = new(PsuSessionStore) ss = new(PduSessionStore) // Root key ss.keyRoot = dkm.GetKeyRoot(namespace) + pduSessionsRootKey Loading @@ -58,8 +67,8 @@ func NewPduSessionStore(namespace string, redisAddr string) (ss *PduSessionStore return ss, nil } // Set - Create PDU Session in DB func (ss *PduSessionStore) Create(ueName string, pduId string, info *pduSessionInfo) error { // CreatePduSession - Create PDU Session in DB func (pss *PduSessionStore) CreatePduSession(ueName string, pduId string, info *dataModel.PduSessionInfo) error { // Validate params if ueName == "" { return errors.New("Invalid UE name") Loading @@ -70,26 +79,26 @@ func (ss *PduSessionStore) Create(ueName string, pduId string, info *pduSessionI if info == nil { return errors.New("Nil PDU Sesison Info") } if info.dnn == "" { if info.Dnn == "" { return errors.New("Invalid DNN") } // Prepare key key := ss.keyRoot + ueName + ":" + pduId key := pss.keyRoot + ueName + ":" + pduId // Error if PDU session already exist (not allowed to modify) if ss.rc.EntryExists(key) { if pss.rc.EntryExists(key) { err := errors.New("PDU Session already exists:") log.Error(err.Error(), key) return nil, err return err } // Prepare data fields := make(map[string]interface{}) fields[fieldDnn] = info.dnn fields[fieldDnn] = info.Dnn // Update entry in DB err := ss.rc.SetEntry(key, fields) err := pss.rc.SetEntry(key, fields) if err != nil { log.Error("Failed to create PDU Session with error: ", err.Error()) return err Loading @@ -97,8 +106,8 @@ func (ss *PduSessionStore) Create(ueName string, pduId string, info *pduSessionI return nil } // Del - Remove PDU Session from DB func (ss *PduSessionStore) Delete(ueName string, pduId string) { // DeletePduSession - Remove PDU Session from DB func (pss *PduSessionStore) DeletePduSession(ueName string, pduId string) error { // Validate params if ueName == "" { return errors.New("Invalid UE name") Loading @@ -108,17 +117,116 @@ func (ss *PduSessionStore) Delete(ueName string, pduId string) { } // Prepare key key := ss.keyRoot + ueName + ":" + pduId key := pss.keyRoot + ueName + ":" + pduId // Error if PDU session does not exist if !ss.rc.EntryExists(key) { if !pss.rc.EntryExists(key) { err := errors.New("PDU Session does not exist:") log.Error(err.Error(), key) return err } err := pss.rc.DelEntry(key) if err != nil { log.Error("Failed to delete PDU Session ", key, " with err: ", err.Error()) return err } return nil } // GetPduSessions - Returns all PDU Sessions for a given UE func (pss *PduSessionStore) GetPduSessions(ueName string) (map[string]*dataModel.PduSessionInfo, error) { // Validate params if ueName == "" { return nil, errors.New("Invalid UE name") } pduMap := make(map[string]*dataModel.PduSessionInfo) keyMatchStr := pss.keyRoot + ueName + "*" // Get all PDU Sessions entry details err := pss.rc.ForEachEntry(keyMatchStr, getPduSessions, &pduMap) if err != nil { log.Error("Failed to get all entries with error: ", err.Error()) return nil, err } return pduMap, nil } err := ss.rc.DelEntry(key) // GetPduSession - Returns a PDU Session func (pss *PduSessionStore) GetPduSession(ueName string, pduId string) (*dataModel.PduSessionInfo, error) { // Validate params if ueName == "" { return nil, errors.New("Invalid UE name") } if pduId == "" { return nil, errors.New("Invalid PDU Session id") } key := pss.keyRoot + ueName + ":" + pduId // Make sure entry exists if !pss.rc.EntryExists(key) { err := errors.New("Entry not found") log.Error(err.Error()) return nil, err } // Find entry fields, err := pss.rc.GetEntry(key) if err != nil { log.Error("Failed to delete PSU Session ", key, " with err: ", err.Error()) log.Error("Failed to get entry with error: ", err.Error()) return nil, err } // Prepare PDU Session pdu := new(dataModel.PduSessionInfo) pdu.Dnn = fields[fieldDnn] return pdu, nil } // HasPduToDnn - Validates if a given UE has a PDU Sessionto the specified DNN, returns the PDU Session Id func (pss *PduSessionStore) HasPduToDnn(ueName string, dnn string) (string, error) { // Validate params if ueName == "" { return "", errors.New("Invalid UE name") } if dnn == "" { return "", errors.New("Invalid DNN") } pduMap := make(map[string]*dataModel.PduSessionInfo) keyMatchStr := pss.keyRoot + ueName + "*" // Get all PDU Sessions entry details err := pss.rc.ForEachEntry(keyMatchStr, getPduSessions, &pduMap) if err != nil { log.Error("Failed to get all entries with error: ", err.Error()) return "", err } // Parse result to see if a PDU Session Exists for the DNN for pduId, pdu := range pduMap { if dnn == pdu.Dnn { return pduId, nil } } return "", nil } func getPduSessions(key string, fields map[string]string, userData interface{}) error { pduMap := *(userData.(*map[string]*dataModel.PduSessionInfo)) // Prepare PDU Session pdu := new(dataModel.PduSessionInfo) pdu.Dnn = fields[fieldDnn] // Extract PDI id kk := strings.Split(key, ":") k := kk[len(kk)-1] // Add sandbox to pduMap[k] = pdu return nil } go-packages/meep-pdu-sessions-store/pdu-session-store_test.go 0 → 100644 +358 −0 Original line number Diff line number Diff line /* * Copyright (c) 2019 InterDigital Communications, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package pdusessionstore import ( "fmt" "testing" dataModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" ) const redisAddr string = "localhost:30380" const sbox1 = "testSbox1" const sbox2 = "testSbox2" const ue1 = "ue1" const ue2 = "ue2" const ue3 = "ue3" const pdu1 = "pdu1" const pdu2 = "pdu2" const pdu3 = "pdu3" const dnn1 = "dnn1" const dnn2 = "dnn2" const dnn3 = "dnn3" var pss1 *PduSessionStore var pss2 *PduSessionStore var pduInfo1 *dataModel.PduSessionInfo var pduInfo2 *dataModel.PduSessionInfo var pduInfo3 *dataModel.PduSessionInfo func TestPduSessionStore(t *testing.T) { fmt.Println("--- ", t.Name()) log.MeepTextLogInit(t.Name()) // NewPduSessionStore(namespace string, redisAddr string) (ss *PduSessionStore, err error) { fmt.Println("Create invalid store (namespace)") pss, err := NewPduSessionStore("", redisAddr) if err == nil { t.Fatalf("Should report error on invalid namespace") } if pss != nil { t.Fatalf("Should have a nil store") } fmt.Println("Create invalid store (redis address)") pss, err = NewPduSessionStore(sbox1, "ExpectedFailure-InvalidStoreAddr") if err == nil { t.Fatalf("Should report error on invalid db addr") } if pss != nil { t.Fatalf("Should have a nil store") } // ------------ NewPduSessionStore ------------ fmt.Println("Create valid stores") pss1, err = NewPduSessionStore(sbox1, redisAddr) if err != nil { t.Fatalf("Unable to create store") } pss2, err = NewPduSessionStore(sbox2, redisAddr) if err != nil { t.Fatalf("Unable to create store") } if pss1 == pss2 { t.Fatalf("Stores should be different") } // ------------ CreatePduSession ------------ pduInfo1 = new(dataModel.PduSessionInfo) pduInfo1.Dnn = dnn1 // pduInfo2 := new(dataModel.PduSessionInfo) // pduInfo3 := new(dataModel.PduSessionInfo) fmt.Println("Create Invalid PDU Sessions") err = pss1.CreatePduSession("", pdu1, pduInfo1) if err == nil { t.Fatalf("Creating PDU Session should fail (invalid UE)") } err = pss1.CreatePduSession(ue1, "", pduInfo1) if err == nil { t.Fatalf("Creating PDU Session should fail (invalid PduId)") } err = pss1.CreatePduSession(ue1, pdu1, nil) if err == nil { t.Fatalf("Creating PDU Session should fail (nil PduInfo)") } pduInfo1.Dnn = "" err = pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err == nil { t.Fatalf("Creating PDU Session should fail (nil PduInfo)") } fmt.Println("Create Valid PDU Sessions") pduInfo2 = new(dataModel.PduSessionInfo) pduInfo3 = new(dataModel.PduSessionInfo) pduInfo1.Dnn = dnn1 pduInfo2.Dnn = dnn2 pduInfo3.Dnn = dnn3 err = pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err != nil { t.Fatalf("Creating PDU Session failed (pdu1)") } err = pss1.CreatePduSession(ue1, pdu2, pduInfo2) if err != nil { t.Fatalf("Creating PDU Session failed (pdu2)") } err = pss1.CreatePduSession(ue1, pdu3, pduInfo3) if err != nil { t.Fatalf("Creating PDU Session failed (pdu3)") } fmt.Println("Create Duplicate PDU Session") err = pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err == nil { t.Fatalf("Creating duplicate PDU Session should fail") } // ------------ DeletePduSession ------------ fmt.Println("Delete Invalid PDU Sessions") err = pss1.DeletePduSession("", pdu1) if err == nil { t.Fatalf("Deleting PDU Session should fail (invalid UE)") } err = pss1.DeletePduSession(ue1, "") if err == nil { t.Fatalf("Delete PDU Session should fail (invalid PduId)") } fmt.Println("Delete Valid PDU Sessions") err = pss1.DeletePduSession(ue1, pdu1) if err != nil { t.Fatalf("Delete PDU Session failed (pdu1)") } err = pss1.DeletePduSession(ue1, pdu2) if err != nil { t.Fatalf("Delete PDU Session failed (pdu2)") } err = pss1.DeletePduSession(ue1, pdu3) if err != nil { t.Fatalf("Delete PDU Session failed (pdu3)") } fmt.Println("Delete Inexisting PDU Session should fail (pdu1)") err = pss1.DeletePduSession(ue1, pdu1) if err == nil { t.Fatalf("Deleting inexisting PDU Session should fail") } // ------------ GetPduSessions ------------ fmt.Println("Get Invalid PDU Sessions") _, err = pss1.GetPduSessions("") if err == nil { t.Fatalf("Getting PDU Sessions should fail (invalid UE)") } prepareData() defer clearData() fmt.Println("Get PDU Sessions Sbox1") ps, err := pss1.GetPduSessions(ue1) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox1-ue1)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox1-ue1)") } if ps[pdu1].Dnn != dnn1 { t.Fatalf("Invalid PDU Sessions (sbox1-ue1)") } ps, err = pss1.GetPduSessions(ue2) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox1-ue2)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox1-ue2)") } if ps[pdu2].Dnn != dnn2 { t.Fatalf("Invalid PDU Sessions (sbox1-ue2)") } ps, err = pss1.GetPduSessions(ue3) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox1-ue3)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox1-ue3)") } if ps[pdu3].Dnn != dnn3 { t.Fatalf("Invalid PDU Sessions (sbox1-ue3)") } fmt.Println("Get PDU Sessions Sbox2") ps, err = pss2.GetPduSessions(ue1) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox2-ue1)") } if len(ps) != 2 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 2 PDU Sessions (sbox2-ue1)") } if ps[pdu1].Dnn != dnn1 { t.Fatalf("Invalid PDU Sessions (sbox2-ue1-pdu1)") } if ps[pdu2].Dnn != dnn2 { t.Fatalf("Invalid PDU Sessions (sbox2-ue1-pdu2)") } ps, err = pss2.GetPduSessions(ue2) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox2-ue2)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox2-ue2)") } if ps[pdu3].Dnn != dnn3 { t.Fatalf("Invalid PDU Sessions (sbox2-ue2-pdu3)") } // ------------ GetPduSession ------------ fmt.Println("Get Invalid PDU Session Sbox2") _, err = pss2.GetPduSession("", pdu1) if err == nil { t.Fatalf("Getting PDU Session should fail (invalid UE)") } _, err = pss2.GetPduSession(ue1, "") if err == nil { t.Fatalf("Getting PDU Session should fail (invalid PduId)") } fmt.Println("Get Inexistent PDU Session Sbox2") _, err = pss2.GetPduSession(ue1, pdu3) if err == nil { t.Fatalf("Getting Inexistent PDU Session should fail (sbox2-ue1-pdu3)") } fmt.Println("Get Valid PDU Session Sbox2") psInfo, err := pss2.GetPduSession(ue1, pdu2) if err != nil { t.Fatalf("Getting Valid PDU Session failed (sbox2-ue1-pdu2)") } if psInfo.Dnn != dnn2 { t.Fatalf("Invalid PDU Sessions (sbox2-ue1-pdu2)") } // ------------ HasPduToDnn ------------ fmt.Println("Invalid parameters Sbox2") _, err = pss2.HasPduToDnn("", pdu1) if err == nil { t.Fatalf("Has PDU To DNN should fail (invalid UE)") } _, err = pss2.HasPduToDnn(ue1, "") if err == nil { t.Fatalf("Has PDU To DNN should fail (invalid DNN)") } fmt.Println("Inexistent DNN Sbox2") psId, err := pss2.HasPduToDnn(ue1, dnn3) if err != nil { t.Fatalf("Has PDU To DNN failed (inexistent DNN)") } if psId != "" { fmt.Println("Got ", psId) t.Fatalf("DNN should be empty string (inexistent DNN)") } fmt.Println("Valid DNN Sbox2") psId, err = pss2.HasPduToDnn(ue1, dnn2) if err != nil { fmt.Println(err.Error()) t.Fatalf("Has PDU To DNN failed (inexistent DNN)") } if psId != pdu2 { fmt.Println("Got ", psId) t.Fatalf("PDU sesison should be pdu1") } // t.Fatalf("DONE") } func prepareData() { err := pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err != nil { fmt.Println("Error creating sbox1-ue1-pdu1 PDU Session", err.Error()) } err = pss1.CreatePduSession(ue2, pdu2, pduInfo2) if err != nil { fmt.Println("Error creating sbox1-ue2-pdu2 PDU Session") } err = pss1.CreatePduSession(ue3, pdu3, pduInfo3) if err != nil { fmt.Println("Error creating sbox1-ue3-pdu3 PDU Session") } err = pss2.CreatePduSession(ue1, pdu1, pduInfo1) if err != nil { fmt.Println("Error creating sbox2-ue1-pdu1 PDU Session") } err = pss2.CreatePduSession(ue1, pdu2, pduInfo2) if err != nil { fmt.Println("Error creating sbox2-ue1-pdu2 PDU Session") } err = pss2.CreatePduSession(ue2, pdu3, pduInfo3) if err != nil { fmt.Println("Error creating sbox2-ue2-pdu3 PDU Session") } } func clearData() { err := pss1.DeletePduSession(ue1, pdu1) if err != nil { fmt.Println("Error deleting sbox1-ue1-pdu1 PDU Session") } err = pss1.DeletePduSession(ue2, pdu2) if err != nil { fmt.Println("Error deleting sbox1-ue2-pdu2 PDU Session") } err = pss1.DeletePduSession(ue3, pdu3) if err != nil { fmt.Println("Error deleting sbox1-ue3-pdu3 PDU Session") } err = pss2.DeletePduSession(ue1, pdu1) if err != nil { fmt.Println("Error deleting sbox2-ue1-pdu1 PDU Session") } err = pss2.DeletePduSession(ue1, pdu2) if err != nil { fmt.Println("Error deleting sbox2-ue1-pdu2 PDU Session") } err = pss2.DeletePduSession(ue2, pdu3) if err != nil { fmt.Println("Error deleting sbox2-ue2-pdu3 PDU Session") } } Loading
go-packages/meep-data-key-mgr/data-key-mgr.go +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ const keyRootGlobal = keyRoot + "global:" const keyRootSandbox = keyRoot + "sbox:" func GetKeyRoot(namespace string) string { // TODO: Should validate that a namespace exists or return an error return keyRootSandbox + namespace + ":" } Loading
go-packages/meep-pdu-sessions-store/go.mod +2 −0 Original line number Diff line number Diff line Loading @@ -4,12 +4,14 @@ go 1.12 require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis v0.0.0 ) replace ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr => ../../go-packages/meep-data-key-mgr github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model => ../../go-packages/meep-data-model github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger => ../../go-packages/meep-logger github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis => ../../go-packages/meep-redis )
go-packages/meep-pdu-sessions-store/go.sum 0 → 100644 +28 −0 Original line number Diff line number Diff line github.com/KromDaniel/jonson v0.0.0-20180630143114-d2f9c3c389db/go.mod h1:RU+6d0CNIRSp6yo1mXLIIrnFa/3LHhvcDVLVJyovptM= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351 h1:1u1XrfCBnY+GijnyU6O1k4odp5TnqZQTsp5v7+n/E4Y= github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351/go.mod h1:HxwfbuElTuGf+/uKZfjJrCnv0BmmpkPJDI7gBwj1KkM= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4= github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
go-packages/meep-pdu-sessions-store/pdu-session.go→go-packages/meep-pdu-sessions-store/pdu-session-store.go +232 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,11 @@ package pdusessionstore import ( "errors" "strings" dkm "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr" dataModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" redis "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis" ) Loading @@ -26,12 +30,12 @@ const redisTable = 0 // Redis Data Structure const pduSessionsRootKey = "pdu-sessions:" // Key format: /pdu-sessions/[ue.name]/[pdu-session-uid] // Value(s): dnn=[dnn], (others TBD) // DB Fields // const fieldSandboxName = "sbox-name" // const fieldScenarioName = "scenario-name" const fieldDnn = "dnn" type PduSessionStore struct { rc *redis.Connector Loading @@ -40,8 +44,13 @@ type PduSessionStore struct { // NewPduSessionStore - Creates and initialize a PDU Session Store instance func NewPduSessionStore(namespace string, redisAddr string) (ss *PduSessionStore, err error) { // Validate params if namespace == "" { return nil, errors.New("Invalid namespace") } // Create new Sandbox Store instance ss = new(PsuSessionStore) ss = new(PduSessionStore) // Root key ss.keyRoot = dkm.GetKeyRoot(namespace) + pduSessionsRootKey Loading @@ -58,8 +67,8 @@ func NewPduSessionStore(namespace string, redisAddr string) (ss *PduSessionStore return ss, nil } // Set - Create PDU Session in DB func (ss *PduSessionStore) Create(ueName string, pduId string, info *pduSessionInfo) error { // CreatePduSession - Create PDU Session in DB func (pss *PduSessionStore) CreatePduSession(ueName string, pduId string, info *dataModel.PduSessionInfo) error { // Validate params if ueName == "" { return errors.New("Invalid UE name") Loading @@ -70,26 +79,26 @@ func (ss *PduSessionStore) Create(ueName string, pduId string, info *pduSessionI if info == nil { return errors.New("Nil PDU Sesison Info") } if info.dnn == "" { if info.Dnn == "" { return errors.New("Invalid DNN") } // Prepare key key := ss.keyRoot + ueName + ":" + pduId key := pss.keyRoot + ueName + ":" + pduId // Error if PDU session already exist (not allowed to modify) if ss.rc.EntryExists(key) { if pss.rc.EntryExists(key) { err := errors.New("PDU Session already exists:") log.Error(err.Error(), key) return nil, err return err } // Prepare data fields := make(map[string]interface{}) fields[fieldDnn] = info.dnn fields[fieldDnn] = info.Dnn // Update entry in DB err := ss.rc.SetEntry(key, fields) err := pss.rc.SetEntry(key, fields) if err != nil { log.Error("Failed to create PDU Session with error: ", err.Error()) return err Loading @@ -97,8 +106,8 @@ func (ss *PduSessionStore) Create(ueName string, pduId string, info *pduSessionI return nil } // Del - Remove PDU Session from DB func (ss *PduSessionStore) Delete(ueName string, pduId string) { // DeletePduSession - Remove PDU Session from DB func (pss *PduSessionStore) DeletePduSession(ueName string, pduId string) error { // Validate params if ueName == "" { return errors.New("Invalid UE name") Loading @@ -108,17 +117,116 @@ func (ss *PduSessionStore) Delete(ueName string, pduId string) { } // Prepare key key := ss.keyRoot + ueName + ":" + pduId key := pss.keyRoot + ueName + ":" + pduId // Error if PDU session does not exist if !ss.rc.EntryExists(key) { if !pss.rc.EntryExists(key) { err := errors.New("PDU Session does not exist:") log.Error(err.Error(), key) return err } err := pss.rc.DelEntry(key) if err != nil { log.Error("Failed to delete PDU Session ", key, " with err: ", err.Error()) return err } return nil } // GetPduSessions - Returns all PDU Sessions for a given UE func (pss *PduSessionStore) GetPduSessions(ueName string) (map[string]*dataModel.PduSessionInfo, error) { // Validate params if ueName == "" { return nil, errors.New("Invalid UE name") } pduMap := make(map[string]*dataModel.PduSessionInfo) keyMatchStr := pss.keyRoot + ueName + "*" // Get all PDU Sessions entry details err := pss.rc.ForEachEntry(keyMatchStr, getPduSessions, &pduMap) if err != nil { log.Error("Failed to get all entries with error: ", err.Error()) return nil, err } return pduMap, nil } err := ss.rc.DelEntry(key) // GetPduSession - Returns a PDU Session func (pss *PduSessionStore) GetPduSession(ueName string, pduId string) (*dataModel.PduSessionInfo, error) { // Validate params if ueName == "" { return nil, errors.New("Invalid UE name") } if pduId == "" { return nil, errors.New("Invalid PDU Session id") } key := pss.keyRoot + ueName + ":" + pduId // Make sure entry exists if !pss.rc.EntryExists(key) { err := errors.New("Entry not found") log.Error(err.Error()) return nil, err } // Find entry fields, err := pss.rc.GetEntry(key) if err != nil { log.Error("Failed to delete PSU Session ", key, " with err: ", err.Error()) log.Error("Failed to get entry with error: ", err.Error()) return nil, err } // Prepare PDU Session pdu := new(dataModel.PduSessionInfo) pdu.Dnn = fields[fieldDnn] return pdu, nil } // HasPduToDnn - Validates if a given UE has a PDU Sessionto the specified DNN, returns the PDU Session Id func (pss *PduSessionStore) HasPduToDnn(ueName string, dnn string) (string, error) { // Validate params if ueName == "" { return "", errors.New("Invalid UE name") } if dnn == "" { return "", errors.New("Invalid DNN") } pduMap := make(map[string]*dataModel.PduSessionInfo) keyMatchStr := pss.keyRoot + ueName + "*" // Get all PDU Sessions entry details err := pss.rc.ForEachEntry(keyMatchStr, getPduSessions, &pduMap) if err != nil { log.Error("Failed to get all entries with error: ", err.Error()) return "", err } // Parse result to see if a PDU Session Exists for the DNN for pduId, pdu := range pduMap { if dnn == pdu.Dnn { return pduId, nil } } return "", nil } func getPduSessions(key string, fields map[string]string, userData interface{}) error { pduMap := *(userData.(*map[string]*dataModel.PduSessionInfo)) // Prepare PDU Session pdu := new(dataModel.PduSessionInfo) pdu.Dnn = fields[fieldDnn] // Extract PDI id kk := strings.Split(key, ":") k := kk[len(kk)-1] // Add sandbox to pduMap[k] = pdu return nil }
go-packages/meep-pdu-sessions-store/pdu-session-store_test.go 0 → 100644 +358 −0 Original line number Diff line number Diff line /* * Copyright (c) 2019 InterDigital Communications, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package pdusessionstore import ( "fmt" "testing" dataModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" ) const redisAddr string = "localhost:30380" const sbox1 = "testSbox1" const sbox2 = "testSbox2" const ue1 = "ue1" const ue2 = "ue2" const ue3 = "ue3" const pdu1 = "pdu1" const pdu2 = "pdu2" const pdu3 = "pdu3" const dnn1 = "dnn1" const dnn2 = "dnn2" const dnn3 = "dnn3" var pss1 *PduSessionStore var pss2 *PduSessionStore var pduInfo1 *dataModel.PduSessionInfo var pduInfo2 *dataModel.PduSessionInfo var pduInfo3 *dataModel.PduSessionInfo func TestPduSessionStore(t *testing.T) { fmt.Println("--- ", t.Name()) log.MeepTextLogInit(t.Name()) // NewPduSessionStore(namespace string, redisAddr string) (ss *PduSessionStore, err error) { fmt.Println("Create invalid store (namespace)") pss, err := NewPduSessionStore("", redisAddr) if err == nil { t.Fatalf("Should report error on invalid namespace") } if pss != nil { t.Fatalf("Should have a nil store") } fmt.Println("Create invalid store (redis address)") pss, err = NewPduSessionStore(sbox1, "ExpectedFailure-InvalidStoreAddr") if err == nil { t.Fatalf("Should report error on invalid db addr") } if pss != nil { t.Fatalf("Should have a nil store") } // ------------ NewPduSessionStore ------------ fmt.Println("Create valid stores") pss1, err = NewPduSessionStore(sbox1, redisAddr) if err != nil { t.Fatalf("Unable to create store") } pss2, err = NewPduSessionStore(sbox2, redisAddr) if err != nil { t.Fatalf("Unable to create store") } if pss1 == pss2 { t.Fatalf("Stores should be different") } // ------------ CreatePduSession ------------ pduInfo1 = new(dataModel.PduSessionInfo) pduInfo1.Dnn = dnn1 // pduInfo2 := new(dataModel.PduSessionInfo) // pduInfo3 := new(dataModel.PduSessionInfo) fmt.Println("Create Invalid PDU Sessions") err = pss1.CreatePduSession("", pdu1, pduInfo1) if err == nil { t.Fatalf("Creating PDU Session should fail (invalid UE)") } err = pss1.CreatePduSession(ue1, "", pduInfo1) if err == nil { t.Fatalf("Creating PDU Session should fail (invalid PduId)") } err = pss1.CreatePduSession(ue1, pdu1, nil) if err == nil { t.Fatalf("Creating PDU Session should fail (nil PduInfo)") } pduInfo1.Dnn = "" err = pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err == nil { t.Fatalf("Creating PDU Session should fail (nil PduInfo)") } fmt.Println("Create Valid PDU Sessions") pduInfo2 = new(dataModel.PduSessionInfo) pduInfo3 = new(dataModel.PduSessionInfo) pduInfo1.Dnn = dnn1 pduInfo2.Dnn = dnn2 pduInfo3.Dnn = dnn3 err = pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err != nil { t.Fatalf("Creating PDU Session failed (pdu1)") } err = pss1.CreatePduSession(ue1, pdu2, pduInfo2) if err != nil { t.Fatalf("Creating PDU Session failed (pdu2)") } err = pss1.CreatePduSession(ue1, pdu3, pduInfo3) if err != nil { t.Fatalf("Creating PDU Session failed (pdu3)") } fmt.Println("Create Duplicate PDU Session") err = pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err == nil { t.Fatalf("Creating duplicate PDU Session should fail") } // ------------ DeletePduSession ------------ fmt.Println("Delete Invalid PDU Sessions") err = pss1.DeletePduSession("", pdu1) if err == nil { t.Fatalf("Deleting PDU Session should fail (invalid UE)") } err = pss1.DeletePduSession(ue1, "") if err == nil { t.Fatalf("Delete PDU Session should fail (invalid PduId)") } fmt.Println("Delete Valid PDU Sessions") err = pss1.DeletePduSession(ue1, pdu1) if err != nil { t.Fatalf("Delete PDU Session failed (pdu1)") } err = pss1.DeletePduSession(ue1, pdu2) if err != nil { t.Fatalf("Delete PDU Session failed (pdu2)") } err = pss1.DeletePduSession(ue1, pdu3) if err != nil { t.Fatalf("Delete PDU Session failed (pdu3)") } fmt.Println("Delete Inexisting PDU Session should fail (pdu1)") err = pss1.DeletePduSession(ue1, pdu1) if err == nil { t.Fatalf("Deleting inexisting PDU Session should fail") } // ------------ GetPduSessions ------------ fmt.Println("Get Invalid PDU Sessions") _, err = pss1.GetPduSessions("") if err == nil { t.Fatalf("Getting PDU Sessions should fail (invalid UE)") } prepareData() defer clearData() fmt.Println("Get PDU Sessions Sbox1") ps, err := pss1.GetPduSessions(ue1) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox1-ue1)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox1-ue1)") } if ps[pdu1].Dnn != dnn1 { t.Fatalf("Invalid PDU Sessions (sbox1-ue1)") } ps, err = pss1.GetPduSessions(ue2) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox1-ue2)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox1-ue2)") } if ps[pdu2].Dnn != dnn2 { t.Fatalf("Invalid PDU Sessions (sbox1-ue2)") } ps, err = pss1.GetPduSessions(ue3) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox1-ue3)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox1-ue3)") } if ps[pdu3].Dnn != dnn3 { t.Fatalf("Invalid PDU Sessions (sbox1-ue3)") } fmt.Println("Get PDU Sessions Sbox2") ps, err = pss2.GetPduSessions(ue1) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox2-ue1)") } if len(ps) != 2 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 2 PDU Sessions (sbox2-ue1)") } if ps[pdu1].Dnn != dnn1 { t.Fatalf("Invalid PDU Sessions (sbox2-ue1-pdu1)") } if ps[pdu2].Dnn != dnn2 { t.Fatalf("Invalid PDU Sessions (sbox2-ue1-pdu2)") } ps, err = pss2.GetPduSessions(ue2) if err != nil { t.Fatalf("Getting PDU Sessions failed (sbox2-ue2)") } if len(ps) != 1 { fmt.Println("Got ", len(ps), "PDU Sessions") t.Fatalf("Expected 1 PDU Sessions (sbox2-ue2)") } if ps[pdu3].Dnn != dnn3 { t.Fatalf("Invalid PDU Sessions (sbox2-ue2-pdu3)") } // ------------ GetPduSession ------------ fmt.Println("Get Invalid PDU Session Sbox2") _, err = pss2.GetPduSession("", pdu1) if err == nil { t.Fatalf("Getting PDU Session should fail (invalid UE)") } _, err = pss2.GetPduSession(ue1, "") if err == nil { t.Fatalf("Getting PDU Session should fail (invalid PduId)") } fmt.Println("Get Inexistent PDU Session Sbox2") _, err = pss2.GetPduSession(ue1, pdu3) if err == nil { t.Fatalf("Getting Inexistent PDU Session should fail (sbox2-ue1-pdu3)") } fmt.Println("Get Valid PDU Session Sbox2") psInfo, err := pss2.GetPduSession(ue1, pdu2) if err != nil { t.Fatalf("Getting Valid PDU Session failed (sbox2-ue1-pdu2)") } if psInfo.Dnn != dnn2 { t.Fatalf("Invalid PDU Sessions (sbox2-ue1-pdu2)") } // ------------ HasPduToDnn ------------ fmt.Println("Invalid parameters Sbox2") _, err = pss2.HasPduToDnn("", pdu1) if err == nil { t.Fatalf("Has PDU To DNN should fail (invalid UE)") } _, err = pss2.HasPduToDnn(ue1, "") if err == nil { t.Fatalf("Has PDU To DNN should fail (invalid DNN)") } fmt.Println("Inexistent DNN Sbox2") psId, err := pss2.HasPduToDnn(ue1, dnn3) if err != nil { t.Fatalf("Has PDU To DNN failed (inexistent DNN)") } if psId != "" { fmt.Println("Got ", psId) t.Fatalf("DNN should be empty string (inexistent DNN)") } fmt.Println("Valid DNN Sbox2") psId, err = pss2.HasPduToDnn(ue1, dnn2) if err != nil { fmt.Println(err.Error()) t.Fatalf("Has PDU To DNN failed (inexistent DNN)") } if psId != pdu2 { fmt.Println("Got ", psId) t.Fatalf("PDU sesison should be pdu1") } // t.Fatalf("DONE") } func prepareData() { err := pss1.CreatePduSession(ue1, pdu1, pduInfo1) if err != nil { fmt.Println("Error creating sbox1-ue1-pdu1 PDU Session", err.Error()) } err = pss1.CreatePduSession(ue2, pdu2, pduInfo2) if err != nil { fmt.Println("Error creating sbox1-ue2-pdu2 PDU Session") } err = pss1.CreatePduSession(ue3, pdu3, pduInfo3) if err != nil { fmt.Println("Error creating sbox1-ue3-pdu3 PDU Session") } err = pss2.CreatePduSession(ue1, pdu1, pduInfo1) if err != nil { fmt.Println("Error creating sbox2-ue1-pdu1 PDU Session") } err = pss2.CreatePduSession(ue1, pdu2, pduInfo2) if err != nil { fmt.Println("Error creating sbox2-ue1-pdu2 PDU Session") } err = pss2.CreatePduSession(ue2, pdu3, pduInfo3) if err != nil { fmt.Println("Error creating sbox2-ue2-pdu3 PDU Session") } } func clearData() { err := pss1.DeletePduSession(ue1, pdu1) if err != nil { fmt.Println("Error deleting sbox1-ue1-pdu1 PDU Session") } err = pss1.DeletePduSession(ue2, pdu2) if err != nil { fmt.Println("Error deleting sbox1-ue2-pdu2 PDU Session") } err = pss1.DeletePduSession(ue3, pdu3) if err != nil { fmt.Println("Error deleting sbox1-ue3-pdu3 PDU Session") } err = pss2.DeletePduSession(ue1, pdu1) if err != nil { fmt.Println("Error deleting sbox2-ue1-pdu1 PDU Session") } err = pss2.DeletePduSession(ue1, pdu2) if err != nil { fmt.Println("Error deleting sbox2-ue1-pdu2 PDU Session") } err = pss2.DeletePduSession(ue2, pdu3) if err != nil { fmt.Println("Error deleting sbox2-ue2-pdu3 PDU Session") } }