X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fhelm%2Fhelm_test.go;h=109103c5413aeeaf97319d26429e2ca4b5a9e2c3;hb=45ea51f2a77c4aa22546224b4ded0d3cb03425e6;hp=9bc1226d0884aa7f6bb2856c7843fa3b5daabadb;hpb=e71a5a56e10d27e263fb380ea43a4d89f18e2f03;p=ric-plt%2Fappmgr.git diff --git a/pkg/helm/helm_test.go b/pkg/helm/helm_test.go index 9bc1226..109103c 100755 --- a/pkg/helm/helm_test.go +++ b/pkg/helm/helm_test.go @@ -25,9 +25,9 @@ import ( "strconv" "testing" - "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/appmgr" - "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/models" - "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/util" + "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/appmgr" + "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/models" + "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/util" ) var helmStatusOutput = ` @@ -73,7 +73,53 @@ Releases: Namespace: default Revision: 1 Status: DEPLOYED - Updated: Sun Mar 24 07:17:00 2019` + Updated: Sun Mar 24 07:17:00 2019 + ` + +var helmServiceOutput = `{ + "apiVersion": "v1", + "kind": "Service", + "metadata": { + "creationTimestamp": "2020-03-31T12:27:12Z", + "labels": { + "app": "ricxapp-dummy-xapp", + "chart": "dummy-xapp-0.0.4", + "heritage": "Tiller", + "release": "dummy-xapp" + }, + "name": "service-ricxapp-dummy-xapp-rmr", + "namespace": "ricxapp", + "resourceVersion": "4423380", + "selfLink": "/api/v1/namespaces/ricxapp/services/service-ricxapp-dummy-xapp-rmr", + "uid": "2254b77d-7dd6-43e0-beff-3e2a7b24c89a" + }, + "spec": { + "clusterIP": "10.98.239.107", + "ports": [ + { + "name": "rmrdata", + "port": 4560, + "protocol": "TCP", + "targetPort": "rmrdata" + }, + { + "name": "rmrroute", + "port": 4561, + "protocol": "TCP", + "targetPort": "rmrroute" + } + ], + "selector": { + "app": "ricxapp-dummy-xapp", + "release": "dummy-xapp" + }, + "sessionAffinity": "None", + "type": "ClusterIP" + }, + "status": { + "loadBalancer": {} + } +}` // Test cases func TestMain(m *testing.M) { @@ -85,9 +131,8 @@ func TestMain(m *testing.M) { } func TestHelmStatus(t *testing.T) { - //NewHelm().SetCM(&ConfigMap{}) util.KubectlExec = func(args string) (out []byte, err error) { - return []byte("10.102.184.212"), nil + return []byte(helmServiceOutput), nil } xapp, err := NewHelm().ParseStatus("dummy-xapp", helmStatusOutput) if err != nil { @@ -105,7 +150,7 @@ func TestHelmStatus(t *testing.T) { } if x.Instances[0].IP != xapp.Instances[0].IP || x.Instances[0].Port != xapp.Instances[0].Port { - t.Errorf("\n1:%v 2:%v", x.Instances[0].IP, xapp.Instances[0].IP) + t.Errorf("\n%v - %v, %v - %v", x.Instances[0].IP, xapp.Instances[0].IP, x.Instances[0].Port, xapp.Instances[0].Port) } }