# The Jenkins job uses this string for the tag in the image name
# for example nexus3.o-ran-sc.org:10004/my-image-name:my-tag
---
-tag: '0.4.1'
+tag: '0.4.3'
func Init() {
loadConfig()
Logger = logger.NewLogger("appmgr")
- Logger.SetMdc("xm", "0.4.1")
+ Logger.SetMdc("xm", "0.4.3")
}
return
}
-func (h *Helm) GetEndpointInfo(name string) (ip string, port int) {
+func (h *Helm) GetEndpointInfo(name string) (svc string, port int) {
+ port = 4560 // Default
ns := h.cm.GetNamespace("")
- args := fmt.Sprintf(" get endpoints -o=jsonpath='{.subsets[*].addresses[*].ip}' service-%s-%s-rmr -n %s", ns, name, ns)
+ args := fmt.Sprintf(" get service -n ricxapp service-%s-%s-rmr -o json", ns, name)
out, err := util.KubectlExec(args)
if err != nil {
- return
+ return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), 4560
}
- appmgr.Logger.Info("Endpoint IP address of %s: %s", name, string(out))
- return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), 4560
+ appmgr.Logger.Debug("Endpoint IP address of %s: %s", name, string(out))
+
+ v, err := h.cm.ParseJson(string(out))
+ if err != nil {
+ return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), 4560
+ }
+
+ for _, p := range v.GetArray("spec", "ports") {
+ if string(p.GetStringBytes("name")) == "rmrdata" {
+ port = int(p.GetInt("port"))
+ break
+ }
+ }
+ appmgr.Logger.Info("service-%s-%s-rmr.%s %d", ns, name, ns, port)
+
+ return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), port
}
func (h *Helm) GetNames(out string) (names []string, err error) {
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) {
func TestHelmStatus(t *testing.T) {
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 {
}
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)
}
}
r := v.Val.(SubscriptionInfo).req
if *r.Data.TargetURL == *sr.Data.TargetURL && r.Data.EventType == sr.Data.EventType {
appmgr.Logger.Info("Similar subscription already exists!")
- return &models.SubscriptionResponse{}
+ resp := v.Val.(SubscriptionInfo).resp
+ return &resp
}
}
func TestAddSubscriptionExists(t *testing.T) {
resp := rh.AddSubscription(CreateSubscription(models.EventTypeCreated, int64(5), int64(10), "http://localhost:8087/xapps_hook"))
assert.Equal(t, resp.Version, int64(0))
- assert.Equal(t, resp.EventType, models.EventType(""))
+ assert.Equal(t, resp.EventType, models.EventTypeCreated)
}
func TestDeletesubscriptionSuccess(t *testing.T) {