[RIC-213] Add globalRicId to configuration and remove env var RIC_ID 83/2983/1
authorAmichai <amichai.sichel@intl.att.com>
Wed, 25 Mar 2020 18:42:54 +0000 (20:42 +0200)
committerAmichai <amichai.sichel@intl.att.com>
Wed, 25 Mar 2020 18:43:04 +0000 (20:43 +0200)
Change-Id: Ib3bdedff1328801182078d2e20f48968f8bca746
Signed-off-by: Amichai <amichai.sichel@intl.att.com>
Automation/Scripts/run.sh
E2Manager/build-e2mgr-ubuntu.sh
E2Manager/configuration/configuration.go
E2Manager/configuration/configuration_test.go
E2Manager/e2pdus/x2_setup_requests.go
E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler.go
E2Manager/resources/configuration.yaml

index e3fb919..5b89f94 100755 (executable)
@@ -26,8 +26,8 @@ docker pull snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/dbas
 
 docker run -d --name dbass -p 6379:6379 --env DBAAS_SERVICE_HOST=10.0.2.15  snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/dbass:1.0.0
 
-#docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env DBAAS_SERVICE_HOST=10.0.2.15 --env RIC_ID="bbbccc-abcd0e/20" --env RMR_VCTL_FILE=/tmp/rmr.verbose nexus3.o-ran-sc.org:10004/ric-plt-e2mgr:$E2M_TAG
-docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env DBAAS_SERVICE_HOST=10.0.2.15 --env RIC_ID="bbbccc-abcd0e/20" --env RMR_VCTL_FILE=/tmp/rmr.verbose snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/e2mgr:$E2M_TAG
+#docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env DBAAS_SERVICE_HOST=10.0.2.15 --env RMR_VCTL_FILE=/tmp/rmr.verbose nexus3.o-ran-sc.org:10004/ric-plt-e2mgr:$E2M_TAG
+docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env DBAAS_SERVICE_HOST=10.0.2.15 --env RMR_VCTL_FILE=/tmp/rmr.verbose snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/e2mgr:$E2M_TAG
 #docker cp e2mgr:/opt/E2Manager/router.txt .
 sleep 2
 #docker create --name e2 --env sctp=5577 --env nano=38000 --env loglevel=debug --env print=1 -p 38000:38000 nexus3.o-ran-sc.org:10004/ric-plt-e2:$E2T_TAG
@@ -60,7 +60,7 @@ if [ "$COMP" = "e2mgr" ]; then
 docker rm -f e2mgr
 #docker pull nexus3.o-ran-sc.org:10004/ric-plt-e2mgr:$E2M_TAG
 docker pull snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/e2mgr:$E2M_TAG
-#docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env RMR_RTG_SVC=10.0.2.15 --env DBAAS_SERVICE_HOST=10.0.2.15 RIC_ID="bbbccc-abcd0e/20" nexus3.o-ran-sc.org:10004/ric-plt-e2mgr:$E2M_TAG
-docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env RMR_RTG_SVC=10.0.2.15 --env DBAAS_SERVICE_HOST=10.0.2.15 RIC_ID="bbbccc-abcd0e/20" snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/e2mgr:$E2M_TAG
+#docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env RMR_RTG_SVC=10.0.2.15 --env DBAAS_SERVICE_HOST=10.0.2.15 nexus3.o-ran-sc.org:10004/ric-plt-e2mgr:$E2M_TAG
+docker run -d --name e2mgr -p 3800:3800 -p 3801:3801 --env RMR_RTG_SVC=10.0.2.15 --env DBAAS_SERVICE_HOST=10.0.2.15 snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/e2mgr:$E2M_TAG
 docker ps
 fi
\ No newline at end of file
index c496d7f..da3396a 100755 (executable)
@@ -69,7 +69,6 @@ go build -v app/main.go
 # Setting allocfreetrace=1 causes every allocation to be profiled and a
 # stack trace printed on each object's allocation and free.
 export GODEBUG=cgocheck=2,clobberfree=1,gcstoptheworld=2,allocfreetrace=0
-export RIC_ID="bbbccc-abcd0e/20"
 # Static route table is provided in git repo
 export RMR_SEED_RT=$(pwd)/router_test.txt
 # writes to coverage.txt by default
index 439d4ba..267c25a 100644 (file)
@@ -17,7 +17,6 @@
 //  This source code is part of the near-RT RIC (RAN Intelligent Controller)
 //  platform project (RICP).
 
-
 package configuration
 
 import (
@@ -37,20 +36,20 @@ type Configuration struct {
                MaxMsgSize int
        }
        RoutingManager struct {
-               BaseUrl    string
-       }
-       RicId struct {
-               PlmnId string
-               RicNearRtId string
+               BaseUrl string
        }
        NotificationResponseBuffer   int
        BigRedButtonTimeoutSec       int
        MaxConnectionAttempts        int
        MaxRnibConnectionAttempts    int
        RnibRetryIntervalMs          int
-       KeepAliveResponseTimeoutMs       int
+       KeepAliveResponseTimeoutMs   int
        KeepAliveDelayMs             int
        E2TInstanceDeletionTimeoutMs int
+       GlobalRicId                  struct {
+               PlmnId      string
+               RicNearRtId string
+       }
 }
 
 func ParseConfiguration() *Configuration {
@@ -78,6 +77,7 @@ func ParseConfiguration() *Configuration {
        config.KeepAliveResponseTimeoutMs = viper.GetInt("keepAliveResponseTimeoutMs")
        config.KeepAliveDelayMs = viper.GetInt("KeepAliveDelayMs")
        config.E2TInstanceDeletionTimeoutMs = viper.GetInt("e2tInstanceDeletionTimeoutMs")
+       config.populateGlobalRicIdConfig(viper.Sub("globalRicId"))
        return &config
 }
 
@@ -109,3 +109,11 @@ func (c *Configuration) populateRoutingManagerConfig(rmConfig *viper.Viper) {
        }
        c.RoutingManager.BaseUrl = rmConfig.GetString("baseUrl")
 }
+
+func (c *Configuration) populateGlobalRicIdConfig(globalRicIdConfig *viper.Viper) {
+       if globalRicIdConfig == nil {
+               panic(fmt.Sprintf("#configuration.populateGlobalRicIdConfig - failed to populate Global RicId configuration: The entry 'globalRicId' not found\n"))
+       }
+       c.GlobalRicId.PlmnId = globalRicIdConfig.GetString("plmnId")
+       c.GlobalRicId.RicNearRtId = globalRicIdConfig.GetString("ricNearRtId")
+}
index bbd154d..ac76d99 100644 (file)
@@ -39,6 +39,9 @@ func TestParseConfigurationSuccess(t *testing.T) {
        assert.Equal(t, 4500, config.KeepAliveResponseTimeoutMs)
        assert.Equal(t, 1500, config.KeepAliveDelayMs)
        assert.Equal(t, 15000, config.E2TInstanceDeletionTimeoutMs)
+       assert.NotNil(t, config.GlobalRicId)
+       assert.NotEmpty(t, config.GlobalRicId.PlmnId)
+       assert.NotEmpty(t, config.GlobalRicId.RicNearRtId)
 }
 
 func TestParseConfigurationFileNotFoundFailure(t *testing.T) {
@@ -74,6 +77,7 @@ func TestRmrConfigNotFoundFailure(t *testing.T) {
                "logging": map[string]interface{}{"logLevel": "info"},
                "http":    map[string]interface{}{"port": 3800},
                "routingManager":    map[string]interface{}{"baseUrl": "http://iltlv740.intl.att.com:8080/ric/v1/handles/"},
+               "globalRicId":    map[string]interface{}{"plmnId": "131014", "ricNearRtId": "556670"},
        }
        buf, err := yaml.Marshal(yamlMap)
        if err != nil {
@@ -103,6 +107,7 @@ func TestLoggingConfigNotFoundFailure(t *testing.T) {
                "rmr":  map[string]interface{}{"port": 3801, "maxMsgSize": 4096},
                "http": map[string]interface{}{"port": 3800},
                "routingManager":    map[string]interface{}{"baseUrl": "http://iltlv740.intl.att.com:8080/ric/v1/handles/"},
+               "globalRicId":    map[string]interface{}{"plmnId": "131014", "ricNearRtId": "556670"},
        }
        buf, err := yaml.Marshal(yamlMap)
        if err != nil {
@@ -133,6 +138,7 @@ func TestHttpConfigNotFoundFailure(t *testing.T) {
                "rmr":     map[string]interface{}{"port": 3801, "maxMsgSize": 4096},
                "logging": map[string]interface{}{"logLevel": "info"},
                "routingManager":    map[string]interface{}{"baseUrl": "http://iltlv740.intl.att.com:8080/ric/v1/handles/"},
+               "globalRicId":    map[string]interface{}{"plmnId": "131014", "ricNearRtId": "556670"},
        }
        buf, err := yaml.Marshal(yamlMap)
        if err != nil {
@@ -163,6 +169,7 @@ func TestRoutingManagerConfigNotFoundFailure(t *testing.T) {
                "rmr":     map[string]interface{}{"port": 3801, "maxMsgSize": 4096},
                "logging": map[string]interface{}{"logLevel": "info"},
                "http": map[string]interface{}{"port": 3800},
+               "globalRicId":    map[string]interface{}{"plmnId": "131014", "ricNearRtId": "556670"},
        }
        buf, err := yaml.Marshal(yamlMap)
        if err != nil {
@@ -175,3 +182,34 @@ func TestRoutingManagerConfigNotFoundFailure(t *testing.T) {
        assert.PanicsWithValue(t, "#configuration.populateRoutingManagerConfig - failed to populate Routing Manager configuration: The entry 'routingManager' not found\n",
                func() { ParseConfiguration() })
 }
+
+func TestGlobalRicIdConfigNotFoundFailure(t *testing.T) {
+       configPath := "../resources/configuration.yaml"
+       configPathTmp := "../resources/configuration.yaml_tmp"
+       err := os.Rename(configPath, configPathTmp)
+       if err != nil {
+               t.Errorf("#TestGlobalRicIdConfigNotFoundFailure - failed to rename configuration file: %s\n", configPath)
+       }
+       defer func() {
+               err = os.Rename(configPathTmp, configPath)
+               if err != nil {
+                       t.Errorf("#TestGlobalRicIdConfigNotFoundFailure - failed to rename configuration file: %s\n", configPath)
+               }
+       }()
+       yamlMap := map[string]interface{}{
+               "rmr":     map[string]interface{}{"port": 3801, "maxMsgSize": 4096},
+               "logging": map[string]interface{}{"logLevel": "info"},
+               "http": map[string]interface{}{"port": 3800},
+               "routingManager":    map[string]interface{}{"baseUrl": "http://iltlv740.intl.att.com:8080/ric/v1/handles/"},
+       }
+       buf, err := yaml.Marshal(yamlMap)
+       if err != nil {
+               t.Errorf("#TestGlobalRicIdConfigNotFoundFailure - failed to marshal configuration map\n")
+       }
+       err = ioutil.WriteFile("../resources/configuration.yaml", buf, 0644)
+       if err != nil {
+               t.Errorf("#TestGlobalRicIdConfigNotFoundFailure - failed to write configuration file: %s\n", configPath)
+       }
+       assert.PanicsWithValue(t, "#configuration.populateGlobalRicIdConfig - failed to populate Global RicId configuration: The entry 'globalRicId' not found\n",
+               func() { ParseConfiguration() })
+}
index deab8f3..7b91f5a 100644 (file)
@@ -29,7 +29,6 @@ import "C"
 import (
        "fmt"
        "github.com/pkg/errors"
-       "os"
        "unsafe"
 )
 
@@ -133,9 +132,7 @@ func parseRicID(ricId string) error {
 
 func init() {
        var err error
-       ricId := os.Getenv(EnvRicId)
-       //ricId="bbbccc-ffff0e/20"
-       //ricId="bbbccc-abcd0e/20"
+       ricId := "bbbccc-abcd0e/20"
        if err = parseRicID(ricId); err != nil {
                panic(err)
        }
index b35058d..907e448 100644 (file)
@@ -112,8 +112,8 @@ func (h E2SetupRequestNotificationHandler) Handle(request *models.NotificationRe
                return
        }
        successResponse := models.NewE2SetupSuccessResponseMessage()
-       successResponse.SetPlmnId(h.config.RicId.PlmnId)
-       successResponse.SetRicId(h.config.RicId.RicNearRtId)
+       successResponse.SetPlmnId(h.config.GlobalRicId.PlmnId)
+       successResponse.SetRicId(h.config.GlobalRicId.RicNearRtId)
        successResponse.SetExtractRanFunctionsIDList(setupRequest)
        responsePayload, err := xml.Marshal(successResponse)
 
index 6528db9..20805eb 100644 (file)
@@ -15,3 +15,6 @@ rnibRetryIntervalMs: 10
 keepAliveResponseTimeoutMs: 4500
 keepAliveDelayMs: 1500
 e2tInstanceDeletionTimeoutMs: 15000
+globalRicId:
+  plmnId: 131014
+  ricNearRtId: 556670