From: Timo Tietavainen Date: Fri, 8 Oct 2021 06:16:20 +0000 (+0300) Subject: Replace deprecated SDL APIs X-Git-Tag: 0.8.0~12 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=ric-plt%2Fsubmgr.git;a=commitdiff_plain;h=f0bb66c95fa3f03ae956cc719cc776ed2f2f3bd4 Replace deprecated SDL APIs Replace deprecated SDL SdlInstance usage with xapp-frame's SdlStorage APIs, which have been built on top of the valid SDL SyncStorage APIs. Upgrade SDL version to v0.8.0. Issue-Id: RIC-805 Signed-off-by: Timo Tietavainen Change-Id: I04142853f74775ae40b71a0bef5431508acbb61a --- diff --git a/RELNOTES b/RELNOTES index 7aef394..5ca454a 100644 --- a/RELNOTES +++ b/RELNOTES @@ -1,3 +1,6 @@ +### v0.10.8 +* Replacing deprecated SDL APIs + ### v0.10.7 * Xapp-frame version update * Dockerfile correction for test applications diff --git a/go.mod b/go.mod index a53afa1..62a10a5 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module gerrit.o-ran-sc.org/r/ric-plt/submgr go 1.12 -replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.7.0 +replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.8.0 replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.9.3 @@ -12,10 +12,13 @@ replace gerrit.o-ran-sc.org/r/ric-plt/e2ap => ./e2ap/ require ( gerrit.o-ran-sc.org/r/ric-plt/e2ap v0.0.0-00010101000000-000000000000 - gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.7.0 + gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.8.0 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.0.0-00010101000000-000000000000 + github.com/go-openapi/errors v0.19.3 github.com/go-openapi/runtime v0.19.4 github.com/go-openapi/strfmt v0.19.4 + github.com/go-openapi/swag v0.19.7 + github.com/go-openapi/validate v0.19.6 github.com/gorilla/mux v1.7.1 github.com/segmentio/ksuid v1.0.3 github.com/spf13/viper v1.4.0 diff --git a/go.sum b/go.sum index 6f01e50..a0fa7a9 100644 --- a/go.sum +++ b/go.sum @@ -4,24 +4,16 @@ gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 h1:Ix6SgFuzd6yW6Ur6+qDlGhDO65UYs8PiIk gerrit.o-ran-sc.org/r/com/golog.git v0.0.2/go.mod h1:A7hUL52YQSO4dFIZNcj76XQ09C9PftAe3LyL7kqBnok= gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0 h1:OKDsIDlttbaoHwleyjflIWVZPgPvYbDhim6gWF0zf5E= gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY= -gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35 h1:TGXHb4DNY8on+ej4S9VUnk2HibIC/5chDy64OE+bQBQ= -gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1 h1:3FFbXx55BODThXfyWAiz6cPXVELXFICDQUmJi13EoxM= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes= -gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35 h1:tkM3yE8UzmuH4nf9TqAmiNBSuIZ2CtcMRH2eBIYIzpQ= -gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35/go.mod h1:G+4sUBMbLfQ+RrGS65U15tKmbnP+/1b5oLTPmMfyfT4= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1 h1:8Z60JRsPgcS1Ona4fEh6d0/03nLq1WHoZcNnBsni5+g= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1/go.mod h1:YaQ+XEI4PcAoISxp9wUpUr2TP0J7JihpQTD0G1Lpd4A= -gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35 h1:LcxnUUDwsCzYEISKmkjkyYfg/lnLt8ofkPiGK69vNIA= -gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35/go.mod h1:2bSaXTpECbZieB8bMnubTqMwF3n+mMBxlTaAXvcduNg= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1 h1:BG3kste8PLVTG0m8CRB/VP2tAV5JImKueBGuOsUNcR8= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1/go.mod h1:zX8rW6YEsagHrRGVW5YO50Ku/Csrpzsuvblhr4DbYi4= -gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.7.0 h1:mxlBo54jxwHHFmGYzFI+fBIkOGwarQP4dx2KBxQ8ln8= -gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.7.0/go.mod h1:KCHu4JkWnw2Ro6P747wU9S2t7zxFLmBNCiYvGZo3CHo= -gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.3 h1:C5nhnmSZLdysSiQ7vMkpNaKrooPwiBZ79dcXWRVtZTU= -gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.3/go.mod h1:MRTeTBLROgTA2t91SXYjTbRsxoOhMMvvkK/ChLVRZUU= -gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.5 h1:PEc4Lv6cn8hQM1Ak3wE3MwhCa4v7triRjdhXwsTUMUw= -gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.5/go.mod h1:Z9SajRPqZ7N1/y+Lzp5lUzq24fvrcjQg3cMBXRQVkiM= +gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.8.0 h1:H7GtCRC+pGn6oOxYalUZr7LinQX5jQCVa+ConX7PB5Q= +gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.8.0/go.mod h1:KCHu4JkWnw2Ro6P747wU9S2t7zxFLmBNCiYvGZo3CHo= +gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.9.3 h1:JokT2aaJkKjYFMayvZHvGb+/IhkqZdnxEdwOZVfzIpg= +gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.9.3/go.mod h1:foKMPQZ+RlM0Pos2GlEPAg6ux7Y9PRQmCUglYM7/Qt8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= @@ -155,8 +147,6 @@ github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -172,6 +162,7 @@ github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= diff --git a/pkg/control/sdl_e2SubsDb.go b/pkg/control/sdl_e2SubsDb.go index 2afa36e..3305e41 100644 --- a/pkg/control/sdl_e2SubsDb.go +++ b/pkg/control/sdl_e2SubsDb.go @@ -29,6 +29,8 @@ import ( "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" ) +const e2SubSdlNs = "submgr_e2SubsDb" + type SubscriptionInfo struct { Valid bool ReqId RequestId @@ -41,7 +43,7 @@ type SubscriptionInfo struct { } func CreateSdl() Sdlnterface { - return sdl.NewSdlInstance("submgr_e2SubsDb", sdl.NewDatabase()) + return sdl.NewSyncStorage() } func (c *Control) WriteSubscriptionToSdl(subId uint32, subs *Subscription) error { @@ -66,7 +68,7 @@ func (c *Control) WriteSubscriptionToSdl(subId uint32, subs *Subscription) error return fmt.Errorf("SDL: WriteSubscriptionToSdl() json.Marshal error: %s", err.Error()) } - if err = c.e2SubsDb.Set(strconv.FormatUint(uint64(subId), 10), jsonData); err != nil { + if err = c.e2SubsDb.Set(e2SubSdlNs, strconv.FormatUint(uint64(subId), 10), jsonData); err != nil { c.UpdateCounter(cSDLWriteFailure) return fmt.Errorf("SDL: WriteSubscriptionToSdl(): %s", err.Error()) } else { @@ -79,7 +81,7 @@ func (c *Control) ReadSubscriptionFromSdl(subId uint32) (*Subscription, error) { // This function is now just for testing purpose key := strconv.FormatUint(uint64(subId), 10) - retMap, err := c.e2SubsDb.Get([]string{key}) + retMap, err := c.e2SubsDb.Get(e2SubSdlNs, []string{key}) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, fmt.Errorf("SDL: ReadSubscriptionFromSdl(): %s", err.Error()) @@ -138,7 +140,7 @@ func (c *Control) CreateSubscription(subscriptionInfo *SubscriptionInfo, jsonSub func (c *Control) RemoveSubscriptionFromSdl(subId uint32) error { key := strconv.FormatUint(uint64(subId), 10) - if err := c.e2SubsDb.Remove([]string{key}); err != nil { + if err := c.e2SubsDb.Remove(e2SubSdlNs, []string{key}); err != nil { return fmt.Errorf("SDL: RemoveSubscriptionfromSdl(): %s\n", err.Error()) } else { xapp.Logger.Debug("SDL: Subscription removed from e2SubsDb. subId = %v", subId) @@ -157,7 +159,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript retMap := make(map[uint32]*Subscription) // Get all keys - keys, err := c.e2SubsDb.GetAll() + keys, err := c.e2SubsDb.GetAll(e2SubSdlNs) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), GetAll(). Error while reading E2 subscriptions keys from DBAAS %s\n", err.Error()) @@ -168,7 +170,7 @@ func (c *Control) ReadAllSubscriptionsFromSdl() ([]uint32, map[uint32]*Subscript } // Get all subscriptionInfos - iSubscriptionMap, err := c.e2SubsDb.Get(keys) + iSubscriptionMap, err := c.e2SubsDb.Get(e2SubSdlNs, keys) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), Get(): Error while reading E2 subscriptions from DBAAS %s\n", err.Error()) @@ -213,7 +215,7 @@ func removeNumber(s []uint32, removedNum uint32) ([]uint32, error) { } func (c *Control) RemoveAllSubscriptionsFromSdl() error { - if err := c.e2SubsDb.RemoveAll(); err != nil { + if err := c.e2SubsDb.RemoveAll(e2SubSdlNs); err != nil { c.UpdateCounter(cSDLRemoveFailure) return fmt.Errorf("SDL: RemoveAllSubscriptionsFromSdl(): %s\n", err.Error()) } else { diff --git a/pkg/control/sdl_e2SubsDb_test.go b/pkg/control/sdl_e2SubsDb_test.go index 2deb4b5..3175cc9 100644 --- a/pkg/control/sdl_e2SubsDb_test.go +++ b/pkg/control/sdl_e2SubsDb_test.go @@ -463,13 +463,17 @@ func TestRemoveAllSubscriptionsFromSdlFail(t *testing.T) { t.Log("TEST: All subscription removed from db") } -func (m *Mock) Set(pairs ...interface{}) error { +func (m *Mock) Set(ns string, pairs ...interface{}) error { var key string var val string m.marshalLock.Lock() defer m.marshalLock.Unlock() + if ns != e2SubSdlNs { + return fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } + if sdlShouldReturnError == true { return GetSdlError() } @@ -507,8 +511,13 @@ func (m *Mock) Set(pairs ...interface{}) error { return nil } -func (m *Mock) Get(keys []string) (map[string]interface{}, error) { +func (m *Mock) Get(ns string, keys []string) (map[string]interface{}, error) { retMap := make(map[string]interface{}) + + if ns != e2SubSdlNs { + return nil, fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } + if len(keys) == 0 { return nil, fmt.Errorf("Get() error: len(key) == 0\n") } @@ -527,7 +536,11 @@ func (m *Mock) Get(keys []string) (map[string]interface{}, error) { return retMap, nil } -func (m *Mock) GetAll() ([]string, error) { +func (m *Mock) GetAll(ns string) ([]string, error) { + + if ns != e2SubSdlNs { + return nil, fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } if sdlShouldReturnError == true { return nil, GetSdlError() @@ -540,7 +553,12 @@ func (m *Mock) GetAll() ([]string, error) { return keys, nil } -func (m *Mock) Remove(keys []string) error { +func (m *Mock) Remove(ns string, keys []string) error { + + if ns != e2SubSdlNs { + return fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } + if len(keys) == 0 { return fmt.Errorf("Remove() error: len(key) == 0\n") } @@ -560,7 +578,11 @@ func (m *Mock) Remove(keys []string) error { return nil } -func (m *Mock) RemoveAll() error { +func (m *Mock) RemoveAll(ns string) error { + + if ns != e2SubSdlNs { + return fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } for key := range m.e2SubsDb { subId64, err := strconv.ParseUint(key, 10, 64) diff --git a/pkg/control/sdl_restSubsDb.go b/pkg/control/sdl_restSubsDb.go index f9d837b..e9a7d2f 100644 --- a/pkg/control/sdl_restSubsDb.go +++ b/pkg/control/sdl_restSubsDb.go @@ -27,6 +27,8 @@ import ( "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" ) +const restSubSdlNs = "submgr_restSubsDb" + type RESTSubscriptionInfo struct { XAppRmrEndPoint string Meid string @@ -38,7 +40,7 @@ type RESTSubscriptionInfo struct { } func CreateRESTSdl() Sdlnterface { - return sdl.NewSdlInstance("submgr_restSubsDb", sdl.NewDatabase()) + return sdl.NewSyncStorage() } func (c *Control) WriteRESTSubscriptionToSdl(restSubId string, restSubs *RESTSubscription) error { @@ -57,7 +59,7 @@ func (c *Control) WriteRESTSubscriptionToSdl(restSubId string, restSubs *RESTSub return fmt.Errorf("SDL: WriteSubscriptionToSdl() json.Marshal error: %s", err.Error()) } - if err = c.restSubsDb.Set(restSubId, jsonData); err != nil { + if err = c.restSubsDb.Set(restSubSdlNs, restSubId, jsonData); err != nil { c.UpdateCounter(cSDLWriteFailure) return fmt.Errorf("SDL: WriteSubscriptionToSdl(): %s", err.Error()) } else { @@ -70,7 +72,7 @@ func (c *Control) ReadRESTSubscriptionFromSdl(restSubId string) (*RESTSubscripti // This function is now just for testing purpose key := restSubId - retMap, err := c.restSubsDb.Get([]string{key}) + retMap, err := c.restSubsDb.Get(restSubSdlNs, []string{key}) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, fmt.Errorf("SDL: ReadSubscriptionFromSdl(): %s", err.Error()) @@ -116,7 +118,7 @@ func (c *Control) CreateRESTSubscription(restSubscriptionInfo *RESTSubscriptionI func (c *Control) RemoveRESTSubscriptionFromSdl(restSubId string) error { key := restSubId - if err := c.restSubsDb.Remove([]string{key}); err != nil { + if err := c.restSubsDb.Remove(restSubSdlNs, []string{key}); err != nil { return fmt.Errorf("SDL: RemoveSubscriptionfromSdl(): %s\n", err.Error()) } else { xapp.Logger.Debug("SDL: Subscription removed from restSubsDb. restSubId = %v", restSubId) @@ -128,7 +130,7 @@ func (c *Control) ReadAllRESTSubscriptionsFromSdl() (map[string]*RESTSubscriptio retMap := make(map[string]*RESTSubscription) // Get all keys - keys, err := c.restSubsDb.GetAll() + keys, err := c.restSubsDb.GetAll(restSubSdlNs) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), GetAll(). Error while reading REST subscriptions keys from DBAAS %s\n", err.Error()) @@ -139,7 +141,7 @@ func (c *Control) ReadAllRESTSubscriptionsFromSdl() (map[string]*RESTSubscriptio } // Get all subscriptionInfos - iRESTSubscriptionMap, err := c.restSubsDb.Get(keys) + iRESTSubscriptionMap, err := c.restSubsDb.Get(restSubSdlNs, keys) if err != nil { c.UpdateCounter(cSDLReadFailure) return nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl(), Get(): Error while reading REST subscriptions from DBAAS %s\n", err.Error()) @@ -166,11 +168,11 @@ func (c *Control) ReadAllRESTSubscriptionsFromSdl() (map[string]*RESTSubscriptio func (c *Control) RemoveAllRESTSubscriptionsFromSdl() error { - if err := c.restSubsDb.RemoveAll(); err != nil { + if err := c.restSubsDb.RemoveAll(restSubSdlNs); err != nil { c.UpdateCounter(cSDLRemoveFailure) return fmt.Errorf("SDL: RemoveAllSubscriptionsFromSdl(): %s\n", err.Error()) } else { - xapp.Logger.Debug("SDL: All subscriptions removed from e2SubsDb") + xapp.Logger.Debug("SDL: All subscriptions removed from restSubsDb") } return nil } diff --git a/pkg/control/sdl_restSubsDb_test.go b/pkg/control/sdl_restSubsDb_test.go index 12bf1eb..273a15e 100644 --- a/pkg/control/sdl_restSubsDb_test.go +++ b/pkg/control/sdl_restSubsDb_test.go @@ -369,13 +369,17 @@ func TestRemoveAllRESTSubscriptionsFromSdlFail(t *testing.T) { t.Log("TEST: All subscription removed from db") } -func (m *RestSubsDbMock) Set(pairs ...interface{}) error { +func (m *RestSubsDbMock) Set(ns string, pairs ...interface{}) error { var key string var val string m.marshalLock.Lock() defer m.marshalLock.Unlock() + if ns != restSubSdlNs { + return fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } + if sdlRestShouldReturnError == true { return GetSdlRestError() } @@ -412,8 +416,13 @@ func (m *RestSubsDbMock) Set(pairs ...interface{}) error { return nil } -func (m *RestSubsDbMock) Get(keys []string) (map[string]interface{}, error) { +func (m *RestSubsDbMock) Get(ns string, keys []string) (map[string]interface{}, error) { retMap := make(map[string]interface{}) + + if ns != restSubSdlNs { + return nil, fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } + if len(keys) == 0 { return nil, fmt.Errorf("Get() error: len(key) == 0\n") } @@ -432,7 +441,11 @@ func (m *RestSubsDbMock) Get(keys []string) (map[string]interface{}, error) { return retMap, nil } -func (m *RestSubsDbMock) GetAll() ([]string, error) { +func (m *RestSubsDbMock) GetAll(ns string) ([]string, error) { + + if ns != restSubSdlNs { + return nil, fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } if sdlRestShouldReturnError == true { return nil, GetSdlRestError() @@ -445,7 +458,12 @@ func (m *RestSubsDbMock) GetAll() ([]string, error) { return keys, nil } -func (m *RestSubsDbMock) Remove(keys []string) error { +func (m *RestSubsDbMock) Remove(ns string, keys []string) error { + + if ns != restSubSdlNs { + return fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } + if len(keys) == 0 { return fmt.Errorf("Remove() error: len(key) == 0\n") } @@ -460,7 +478,11 @@ func (m *RestSubsDbMock) Remove(keys []string) error { return nil } -func (m *RestSubsDbMock) RemoveAll() error { +func (m *RestSubsDbMock) RemoveAll(ns string) error { + + if ns != restSubSdlNs { + return fmt.Errorf("Unexpected namespace '%s' error\n", ns) + } for key := range m.restSubsDb { diff --git a/pkg/control/types.go b/pkg/control/types.go index 0123357..93cddb0 100644 --- a/pkg/control/types.go +++ b/pkg/control/types.go @@ -37,11 +37,11 @@ func (rid *RequestId) String() string { } type Sdlnterface interface { - Set(pairs ...interface{}) error - Get(keys []string) (map[string]interface{}, error) - GetAll() ([]string, error) - Remove(keys []string) error - RemoveAll() error + Set(ns string, pairs ...interface{}) error + Get(ns string, keys []string) (map[string]interface{}, error) + GetAll(ns string) ([]string, error) + Remove(ns string, keys []string) error + RemoveAll(ns string) error } type E2SubscriptionDirectives struct {