X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcm%2Fcm_test.go;h=44a0c834fd34a7d8dab45c4b7c9133ffa90c4160;hb=HEAD;hp=b180fc98cfdeb846600f8c1d33efe292364fdbfa;hpb=d3aa5b98789c65107e5ac41fc5be11f08acf11d8;p=ric-plt%2Fappmgr.git diff --git a/pkg/cm/cm_test.go b/pkg/cm/cm_test.go index b180fc9..44a0c83 100755 --- a/pkg/cm/cm_test.go +++ b/pkg/cm/cm_test.go @@ -83,6 +83,98 @@ var kubectlConfigmapOutput = ` } } ` +var kubectlNewConfigmapOutput = ` +{ + "name": "ueec", + "version": "0.7.0", + "vendor": "Nokia", + "moId": "SEP", + "containers": [ + { + "name": "ueec", + "image": { + "registry": "ranco-dev-tools.eastus.cloudapp.azure.com:10001", + "name": "ueec-xapp", + "tag": "0.5.3" + }, + "resources": { + "limits": { + "cpu": "1", + "memory": "50Mi" + }, + "requests": { + "cpu": "1", + "memory": "100Mi" + } + } + } + ], + "livenessProbe": { + "httpGet": { + "path": "ric/v1/health/alive", + "port": 8080 + }, + "initialDelaySeconds": 5, + "periodSeconds": 15 + }, + "readinessProbe": { + "httpGet": { + "path": "ric/v1/health/ready", + "port": 8080 + }, + "initialDelaySeconds": 5, + "periodSeconds": 15 + }, + "messaging": { + "ports": [ + { + "name": "http", + "container": "ueec", + "port": 8080, + "description": "http service" + }, + { + "name": "rmr-route", + "container": "ueec", + "port": 4561, + "description": "rmr route port for ueec" + }, + { + "name": "rmr-data", + "container": "ueec", + "port": 4560, + "maxSize": 2072, + "threadType": 0, + "lowLatency": false, + "txMessages": ["RIC_X2_LOAD_INFORMATION"], + "rxMessages": ["RIC_X2_LOAD_INFORMATION"], + "policies": [11, 22, 33], + "description": "rmr data port for ueec" + } + ] + }, + "controls": { + "logger": { + "level": 3 + }, + "subscription": { + "subscriptionActive": true, + "functionId": 1, + "plmnId": "310150", + "eNBId": "202251", + "timeout": 5, + "host": "service-ricplt-submgr-http.ricplt:8088", + "clientEndpoint": "service-ricxapp-ueec-http.ricxapp:8080" + } + }, + "metrics": { + "url": "/ric/v1/metrics", + "namespace": "ricxapp" + }, + "faults": { }, + "measurements": [] +} +` var cfgData = `{ "active":true, "interfaceId": { @@ -293,6 +385,30 @@ func TestGetRtmDataSuccess(t *testing.T) { } } +func TestGetRtmDataNewSuccess(t *testing.T) { + expectedKubeCmd := []string{ + `get configmap -o jsonpath='{.data.config-file\.json}' -n ricxapp configmap-ricxapp-dummy-xapp-appconfig`, + } + expectedMsgs := appmgr.RtmData{ + TxMessages: []string{"RIC_X2_LOAD_INFORMATION"}, + RxMessages: []string{"RIC_X2_LOAD_INFORMATION"}, + Policies: []int64{11, 22, 33}, + } + + defer func() { resetKubeExecMock() }() + kubeExec = mockedKubeExec + //Fake 'kubectl get configmap' success + kubeExecRetOut = kubectlNewConfigmapOutput + + result := NewCM().GetRtmData("dummy-xapp") + if !reflect.DeepEqual(result, expectedMsgs) { + t.Errorf("GetRtmData failed: expected: %v, got: %v", expectedMsgs, result) + } + if !reflect.DeepEqual(caughtKubeExecArgs, expectedKubeCmd) { + t.Errorf("GetRtmData failed: expected: '%v', got: '%v'", expectedKubeCmd, caughtKubeExecArgs) + } +} + func TestGetRtmDataReturnsNoDataIfConfigmapGetFails(t *testing.T) { var expectedMsgs appmgr.RtmData @@ -382,6 +498,7 @@ func TestGetNamesFromHelmRepoFailure(t *testing.T) { helmExecRetOut = helmSearchOutput helmExecRetErr = errors.New("Command failed!") + EnvHelmVersion = "3" names := NewCM().GetNamesFromHelmRepo() if names != nil { t.Errorf("GetNamesFromHelmRepo failed: expected %v, got %v", expectedResult, names)