Moving to ubuntu 18 and fixing UT's

Change-Id: Id4bf535bd1567d4adefed95641271e2bf6b447fe
Signed-off-by: wahidw <abdulwahid.w@nokia.com>
diff --git a/Dockerfile b/Dockerfile
index 1d64d4a..999009d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -23,7 +23,7 @@
 # a Docker tag from the string in file container-tag.yaml
 
 #FROM golang:1.12.1 as rtmgrbuild
-FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:4-u18.04-nng as rtmgrbuild
+FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:5-u18.04-nng as rtmgrbuild
 
 # Install RMr shared library
 ARG RMRVERSION=3.6.0
@@ -65,20 +65,20 @@
 COPY run_rtmgr.sh /run_rtmgr.sh
 RUN mkdir manifests
 COPY manifests/ /go/src/routing-manager/manifests
-#RUN go mod download 
-#RUN /usr/local/go/bin/go mod tidy
+COPY "uta_rtg_ric.rt" /
 ENV GOPATH /go
 
 ENV GOBIN /go/bin
 RUN go install ./cmd/rtmgr.go
 
 # UT intermediate container
-#FROM rtmgrbuild as rtmgrut
-#RUN ldconfig
-#RUN go test ./pkg/sbi ./pkg/rpe ./pkg/nbi ./pkg/sdl -f "/go/src/routing-manager/manifests/rtmgr/rtmgr-cfg.yaml" -cover -race
+FROM rtmgrbuild as rtmgrut
+RUN ldconfig
+ENV RMR_SEED_RT "/uta_rtg_ric.rt"
+RUN go test ./pkg/sbi ./pkg/rpe ./pkg/nbi ./pkg/sdl -f "/go/src/routing-manager/manifests/rtmgr/rtmgr-cfg.yaml" -cover -race
 
 # Final, executable container
-FROM ubuntu:16.04
+FROM ubuntu:18.04
 COPY --from=rtmgrbuild /go/bin/rtmgr /
 COPY --from=rtmgrbuild /run_rtmgr.sh /
 COPY --from=rtmgrbuild /usr/local/include /usr/local/include
diff --git a/RELNOTES b/RELNOTES
index 354ff2a..a4726b0 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -1,3 +1,6 @@
+### v0.5.6-1
+* Moving to ubuntu 18 and fixing UT's
+
 ### v0.5.6
 * Fix to convert service name to IP during Route update Request
 
diff --git a/container-tag.yaml b/container-tag.yaml
index 4f49c1f..92585c6 100644
--- a/container-tag.yaml
+++ b/container-tag.yaml
@@ -2,4 +2,4 @@
 # By default this file is in the docker build directory,
 # but the location can configured in the JJB template.
 ---
-tag: 0.5.6
+tag: 0.5.6-1
diff --git a/glide.lock b/glide.lock
deleted file mode 100644
index ca9041f..0000000
--- a/glide.lock
+++ /dev/null
@@ -1,120 +0,0 @@
-hash: f46d5840e1625820d08f8be64aad2627deaca8c33a33d5b90234a4212d01cf26
-updated: 2019-04-17T22:45:16.134234092+03:00
-imports:
-- name: github.com/asaskevich/govalidator
-  version: f9ffefc3facfbe0caee3fea233cbb6e8208f4541
-- name: github.com/docker/go-units
-  version: 2fb04c6466a548a03cb009c5569ee1ab1e35398e
-- name: github.com/droundy/goopt
-  version: 0b8effe182da161d81b011aba271507324ecb7ab
-- name: github.com/globalsign/mgo
-  version: eeefdecb41b842af6dc652aaea4026e8403e62df
-  subpackages:
-  - bson
-  - internal/json
-- name: github.com/go-openapi/analysis
-  version: e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014
-  subpackages:
-  - internal
-- name: github.com/go-openapi/errors
-  version: 7a7ff1b7b8020f22574411a32f28b4d168d69237
-- name: github.com/go-openapi/jsonpointer
-  version: ef5f0afec364d3b9396b7b77b43dbe26bf1f8004
-- name: github.com/go-openapi/jsonreference
-  version: 8483a886a90412cd6858df4ea3483dce9c8e35a3
-- name: github.com/go-openapi/loads
-  version: 74628589c3b94e3526a842d24f46589980f5ab22
-- name: github.com/go-openapi/runtime
-  version: 109737172424d8a656fd1199e28c9f5cc89b0cca
-  subpackages:
-  - flagext
-  - logger
-  - middleware
-  - middleware/denco
-  - middleware/header
-  - middleware/untyped
-  - security
-- name: github.com/go-openapi/spec
-  version: 53d776530bf78a11b03a7b52dd8a083086b045e5
-- name: github.com/go-openapi/strfmt
-  version: 29177d4b5db488583bb97ebc05d3842ebeda91a8
-- name: github.com/go-openapi/swag
-  version: b3e2804c8535ee0d1b89320afd98474d5b8e9e3b
-- name: github.com/go-openapi/validate
-  version: 5b1623be7460f5a3967a82c00d518048fb190f5e
-- name: github.com/gorilla/websocket
-  version: 66b9c49e59c6c48f0ffce28c2d8b8a5678502c6d
-- name: github.com/jcelliott/lumber
-  version: dd349441af25132d146d7095c6693a15431fc9b1
-- name: github.com/jessevdk/go-flags
-  version: c6ca198ec95c841fdb89fc0de7496fed11ab854e
-- name: github.com/mailru/easyjson
-  version: 1ea4449da9834f4d333f1cc461c374aea217d249
-  subpackages:
-  - buffer
-  - jlexer
-  - jwriter
-- name: github.com/Microsoft/go-winio
-  version: 1a8911d1ed007260465c3bfbbc785ac6915a0bb8
-- name: github.com/mitchellh/mapstructure
-  version: 3536a929edddb9a5b34bd6861dc4a9647cb459fe
-- name: github.com/PuerkitoBio/purell
-  version: 44968752391892e1b0d0b821ee79e9a85fa13049
-- name: github.com/PuerkitoBio/urlesc
-  version: de5bf2ad457846296e2031421a34e2568e304e35
-- name: golang.org/x/net
-  version: 1da14a5a36f220ea3f03470682b737b1dfd5de22
-  subpackages:
-  - idna
-  - netutil
-- name: golang.org/x/sys
-  version: 12500544f89f9420afe9529ba8940bf72d294972
-  subpackages:
-  - windows
-- name: golang.org/x/text
-  version: f4905fbd45b6790792202848439271c74074bbfd
-  subpackages:
-  - secure/bidirule
-  - transform
-  - unicode/bidi
-  - unicode/norm
-  - width
-- name: gopkg.in/yaml.v2
-  version: 51d6538a90f86fe93ac480b35f37b2be17fef232
-- name: nanomsg.org/go/mangos/v2
-  version: 63f66a65137b9a648ac9f7bf0160b4a4d17d7999
-  subpackages:
-  - errors
-  - internal/core
-  - protocol
-  - protocol/bus
-  - protocol/pair
-  - protocol/pub
-  - protocol/pull
-  - protocol/push
-  - protocol/rep
-  - protocol/req
-  - protocol/respondent
-  - protocol/star
-  - protocol/sub
-  - protocol/surveyor
-  - protocol/xbus
-  - protocol/xpair
-  - protocol/xpub
-  - protocol/xpull
-  - protocol/xpush
-  - protocol/xrep
-  - protocol/xstar
-  - transport
-  - transport/all
-  - transport/inproc
-  - transport/ipc
-  - transport/tcp
-  - transport/tlstcp
-  - transport/ws
-  - transport/wss
-testImports:
-- name: github.com/smartystreets/goconvey
-  version: 68dc04aab96ae4326137d6b77330c224063a927e
-  subpackages:
-  - convey
diff --git a/glide.yaml b/glide.yaml
deleted file mode 100644
index 683cbb9..0000000
--- a/glide.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-#
-#==================================================================================
-#   Copyright (c) 2019 AT&T Intellectual Property.
-#   Copyright (c) 2019 Nokia
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-#
-#   This source code is part of the near-RT RIC (RAN Intelligent Controller)
-#   platform project (RICP).
-#
-#==================================================================================
-#
-#
-#   Abstract:   Glide config for dependency management
-#   Date:	29 March 2019
-#
-package: .
-import:
-- package: github.com/Microsoft/go-winio
-  version: v0.4.12
-- package: github.com/droundy/goopt
-- package: github.com/gorilla/websocket
-  version: v1.4.0
-- package: nanomsg.org/go/mangos/v2
-  version: v2.0.2
-  subpackages:
-  - errors
-  - internal/core
-  - protocol
-  - protocol/bus
-  - protocol/pair
-  - protocol/pub
-  - protocol/pull
-  - protocol/push
-  - protocol/rep
-  - protocol/req
-  - protocol/respondent
-  - protocol/star
-  - protocol/sub
-  - protocol/surveyor
-  - protocol/xbus
-  - protocol/xpair
-  - protocol/xpub
-  - protocol/xpull
-  - protocol/xpush
-  - protocol/xrep
-  - protocol/xstar
-  - transport
-  - transport/all
-  - transport/inproc
-  - transport/ipc
-  - transport/tcp
-  - transport/tlstcp
-  - transport/ws
-  - transport/wss
-- package: github.com/go-openapi/errors
-  version: v0.19.0
-- package: github.com/go-openapi/loads
-  version: v0.19.0
-- package: github.com/go-openapi/runtime
-  version: v0.19.0
-  subpackages:
-  - flagext
-  - middleware
-  - security
-- package: github.com/go-openapi/spec
-  version: v0.19.0
-- package: github.com/go-openapi/strfmt
-  version: v0.19.0
-- package: github.com/go-openapi/swag
-  version: v0.19.0
-- package: github.com/go-openapi/validate
-  version: v0.19.0
-- package: github.com/jessevdk/go-flags
-  version: v1.4.0
-- package: github.com/jcelliott/lumber
-ignore:
-- models
-- rtmgr
-- restapi
-- nbi
-- sbi
-- rpe
-- sdl
-- appmgr_model
-- appmgr_client
-- stub
-testImport:
-- package: github.com/smartystreets/goconvey
-  subpackages:
-  - convey
diff --git a/pkg/rpe/rmr_test.go b/pkg/rpe/rmr_test.go
index da469fa..950cd99 100644
--- a/pkg/rpe/rmr_test.go
+++ b/pkg/rpe/rmr_test.go
@@ -48,7 +48,7 @@
 func TestRmrPushGeneratePolicies(t *testing.T) {
 	var rmrpush = RmrPush{}
 	var pcs rtmgr.RicComponents
-	resetTestDataset(stub.ValidEndpoints)
+	resetTestDataset(stub.ValidEndpoints1)
 	stub.ValidPlatformComponents = nil
 	rtmgr.Subs = *stub.ValidSubscriptions
 	rtmgr.PrsCfg = stub.DummyRoutes
diff --git a/pkg/sbi/nngpush.go b/pkg/sbi/nngpush.go
index 4451299..677a80c 100644
--- a/pkg/sbi/nngpush.go
+++ b/pkg/sbi/nngpush.go
@@ -28,28 +28,11 @@
 
 package sbi
 
-/*
-#include <time.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <rmr/rmr.h>
-#include <rmr/RIC_message_types.h>
-
-
-#cgo CFLAGS: -I../
-#cgo LDFLAGS: -lrmr_nng -lnng
-*/
-import "C"
-
 import (
 	"bytes"
 	"crypto/md5"
 	"errors"
 	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-	"nanomsg.org/go/mangos/v2"
-	"nanomsg.org/go/mangos/v2/protocol/push"
-	_ "nanomsg.org/go/mangos/v2/transport/all"
 	"routing-manager/pkg/rtmgr"
 	"strconv"
 	"time"
@@ -58,7 +41,6 @@
 
 type NngPush struct {
 	Sbi
-	NewSocket CreateNewNngSocketHandler
 	rcChan    chan *xapp.RMRParams
 }
 
@@ -76,38 +58,9 @@
 
 func NewNngPush() *NngPush {
 	instance := new(NngPush)
-	instance.NewSocket = createNewPushSocket
 	return instance
 }
 
-func createNewPushSocket() (NngSocket, error) {
-	xapp.Logger.Debug("Invoked: createNewPushSocket()")
-	socket, err := push.NewSocket()
-	if err != nil {
-		return nil, errors.New("can't create new push socket due to:" + err.Error())
-	}
-	socket.SetPipeEventHook(pipeEventHandler)
-	return socket, nil
-}
-
-func pipeEventHandler(event mangos.PipeEvent, pipe mangos.Pipe) {
-	xapp.Logger.Debug("Invoked: pipeEventHandler()")
-	xapp.Logger.Debug("Received pipe event for " + pipe.Address() + " address")
-	for _, ep := range rtmgr.Eps {
-		uri := DefaultNngPipelineSocketPrefix + ep.Ip + ":" + strconv.Itoa(DefaultNngPipelineSocketNumber)
-		if uri == pipe.Address() {
-			switch event {
-			case 1:
-				ep.IsReady = true
-				xapp.Logger.Debug("Endpoint " + uri + " successfully attached")
-			default:
-				ep.IsReady = false
-				xapp.Logger.Debug("Endpoint " + uri + " has been detached")
-			}
-		}
-	}
-}
-
 func (c *NngPush) Initialize(ip string) error {
 	return nil
 }
@@ -119,7 +72,6 @@
 func (c *NngPush) AddEndpoint(ep *rtmgr.Endpoint) error {
 
 	xapp.Logger.Debug("Invoked sbi.AddEndpoint")
-	xapp.Logger.Debug("args: %v", *ep)
 	endpoint := ep.Ip + ":" + strconv.Itoa(DefaultNngPipelineSocketNumber)
 	ep.Whid = int(xapp.Rmr.Openwh(endpoint))
 	if ep.Whid < 0   {
@@ -143,20 +95,6 @@
 	c.updateEndpoints(rcs, c)
 }
 
-/*
-NOTE: Asynchronous dial starts a goroutine which keep maintains the connection to the given endpoint
-*/
-func (c *NngPush) dial(ep *rtmgr.Endpoint) error {
-	xapp.Logger.Debug("Dialing to endpoint: " + ep.Uuid)
-	uri := DefaultNngPipelineSocketPrefix + ep.Ip + ":" + strconv.Itoa(DefaultNngPipelineSocketNumber)
-	options := make(map[string]interface{})
-	options[mangos.OptionDialAsynch] = true
-	if err := ep.Socket.(NngSocket).DialOptions(uri, options); err != nil {
-		return errors.New("can't dial on push socket to " + uri + " due to: " + err.Error())
-	}
-	return nil
-}
-
 func (c *NngPush) DistributeAll(policies *[]string) error {
 	xapp.Logger.Debug("Invoked: sbi.DistributeAll")
 	xapp.Logger.Debug("args: %v", *policies)
diff --git a/pkg/sbi/nngpush_test.go b/pkg/sbi/nngpush_test.go
index b17b2ca..de11e74 100644
--- a/pkg/sbi/nngpush_test.go
+++ b/pkg/sbi/nngpush_test.go
@@ -28,55 +28,31 @@
 package sbi
 
 import (
-	"errors"
+	//"errors"
 	"routing-manager/pkg/rtmgr"
 	"routing-manager/pkg/stub"
+	"time"
+	"os"
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
 	//"nanomsg.org/go/mangos/v2"
 	//_ "nanomsg.org/go/mangos/v2/transport/all"
 	//"nanomsg.org/go/mangos/v2/protocol/push"
 	"testing"
 )
 
-/*
-Returns an error free Socket instance
-*/
-func createNewStubPushSocket() (NngSocket, error) {
-	socket := stub.MangosSocket{}
-	return socket, nil
+type Consumer struct{}
+
+func (m Consumer) Consume(params *xapp.RMRParams) (err error) {
+        xapp.Sdl.Store("myKey", params.Payload)
+        return nil
 }
 
-/*
-Returns a SocketError
-*/
-func createNewStubPushSocketError() (NngSocket, error) {
-	return nil, errors.New("stub generated Create Socket error")
-}
-
-/*
-Returns a Socket which always generates error on Close()
-*/
-func createNewStubPushSocketCloseError() (NngSocket, error) {
-	socket := stub.MangosSocket{}
-	socket.GenerateSocketCloseError = true
-	return socket, nil
-}
-
-/*
-Returns a Socket which always generates error on Send()
-*/
-func createNewStubPushSocketSendError() (NngSocket, error) {
-	socket := stub.MangosSocket{}
-	socket.GenerateSocketSendError = true
-	return socket, nil
-}
-
-/*
-Returns a Socket which always generates error on Dial()
-*/
-func createNewStubPushSocketDialError() (NngSocket, error) {
-	socket := stub.MangosSocket{}
-	socket.GenerateSocketDialError = true
-	return socket, nil
+// Test cases
+func TestMain(m *testing.M) {
+        go xapp.RunWithParams(Consumer{}, false)
+        time.Sleep(time.Duration(5) * time.Second)
+        code := m.Run()
+        os.Exit(code)
 }
 
 /*
@@ -86,7 +62,7 @@
 	rtmgr.Eps = make(map[string]*rtmgr.Endpoint)
 	for _, endpoint := range testdata {
 		ep := endpoint
-		ep.Socket, _ = instance.NewSocket()
+		//ep.Socket, _ = instance.NewSocket()
 		rtmgr.Eps[ep.Uuid] = &ep
 	}
 }
@@ -96,7 +72,6 @@
 */
 func TestNngPushInitialize(t *testing.T) {
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocket
 
 	_ = nngpush.Initialize("")
 }
@@ -106,7 +81,6 @@
 */
 func TestNngPushTerminate(t *testing.T) {
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocket
 
 	_ = nngpush.Terminate()
 }
@@ -116,8 +90,7 @@
 */
 func TestNngPushUpdateEndpoints(t *testing.T) {
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocket
-	rtmgr.Eps = make(rtmgr.Endpoints)
+	resetTestPushDataset(nngpush, stub.ValidEndpoints)
 
 	nngpush.UpdateEndpoints(&stub.ValidRicComponents)
 	if rtmgr.Eps == nil {
@@ -131,50 +104,13 @@
 func TestNngPushAddEndpoint(t *testing.T) {
 	var err error
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocket
 	resetTestPushDataset(nngpush, stub.ValidEndpoints)
-
-	err = nngpush.AddEndpoint(rtmgr.Eps["10.0.0.1:0"])
+	err = nngpush.AddEndpoint(rtmgr.Eps["localhost"])
 	if err != nil {
 		t.Errorf("nngpush.AddEndpoint() return was incorrect, got: %v, want: %v.", err, "nil")
 	}
-	if rtmgr.Eps["10.0.0.1:0"].Socket == nil {
-		t.Errorf("nngpush.AddEndpoint() was incorrect, got: %v, want: %v.", nil, "Socket")
-	}
 }
 
-/*
-nngpush.AddEndpoint() is tested for Socket creating error case
-*/
-func TestNngPushAddEndpointWithSocketError(t *testing.T) {
-	var err error
-	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocketError
-	resetTestPushDataset(nngpush, stub.ValidEndpoints)
-
-	err = nngpush.AddEndpoint(rtmgr.Eps["10.0.0.1:0"])
-	if err == nil {
-		t.Errorf("nngpush.AddEndpoint() was incorrect, got: %v, want: %v.", nil, "error")
-	}
-	if rtmgr.Eps["10.0.0.1:0"].Socket != nil {
-		t.Errorf("nngpush.AddEndpoint() was incorrect, got: %v, want: %v.", rtmgr.Eps["10.0.0.1:0"].Socket, nil)
-	}
-}
-
-/*
-nngpush.AddEndpoint() is tested for Dialing error case
-*/
-func TestNngPushAddEndpointWithSocketDialError(t *testing.T) {
-	var err error
-	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocketDialError
-	resetTestPushDataset(nngpush, stub.ValidEndpoints)
-
-	err = nngpush.AddEndpoint(rtmgr.Eps["10.0.0.1:0"])
-	if err == nil {
-		t.Errorf("nngpush.AddEndpoint() was incorrect, got: %v, want: %v.", nil, "error")
-	}
-}
 
 /*
 nngpush.DistributeAll() is tested for happy path case
@@ -182,7 +118,6 @@
 func TestNngPushDistributeAll(t *testing.T) {
 	var err error
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocket
 	resetTestPushDataset(nngpush, stub.ValidEndpoints)
 
 	err = nngpush.DistributeAll(stub.ValidPolicies)
@@ -192,65 +127,42 @@
 }
 
 /*
-nngpush.DistributeAll() is tested for Sending error case
+nngpush.DistributeToEp() is tested for Sending case
 */
-func TestNngPushDistributeAllSocketSendError(t *testing.T) {
+func TestDistributeToEp(t *testing.T) {
 	var err error
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocketSendError
 	resetTestPushDataset(nngpush, stub.ValidEndpoints)
 
-	err = nngpush.DistributeAll(stub.ValidPolicies)
+	err = nngpush.DistributeToEp(stub.ValidPolicies,rtmgr.Eps["localhost"])
 	if err != nil {
-		t.Errorf("nngpush.DistributeAll(policies) was incorrect, got: %v, want: %v.", err, "nil")
+		t.Errorf("nngpush.DistributetoEp(policies) was incorrect, got: %v, want: %v.", err, "nil")
 	}
 }
 
-func TestNngPushDeleteEndpoint(t *testing.T) {
+func TestDeleteEndpoint(t *testing.T) {
 	var err error
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocket
 	resetTestPushDataset(nngpush, stub.ValidEndpoints)
 
-	err = nngpush.DeleteEndpoint(rtmgr.Eps["10.0.0.1:0"])
+	err = nngpush.DeleteEndpoint(rtmgr.Eps["localhost"])
 	if err != nil {
 		t.Errorf("nngpush.DeleteEndpoint() was incorrect, got: %v, want: %v.", err, "nil")
 	}
 }
 
-func TestNngPushDeleteEndpointWithSocketCloseError(t *testing.T) {
-	var err error
+func TestCreateEndpoint(t *testing.T) {
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocketCloseError
-	resetTestPushDataset(nngpush, stub.ValidEndpoints)
-
-	err = nngpush.DeleteEndpoint(rtmgr.Eps["10.1.1.1:0"])
-	if err == nil {
-		t.Errorf("nngpush.DeleteEndpoint() was incorrect, got: %v, want: %v.", nil, "error")
-	}
+	resetTestPushDataset(nngpush, stub.ValidEndpoints1)
+	 nngpush.CreateEndpoint("192.168.0.1:0")
+	 nngpush.CreateEndpoint("localhost:4560")
 }
-
 /*
 Initialize and send policies
 */
 func TestNngPushInitializeandsendPolicies(t *testing.T) {
         var nngpush = NngPush{}
-        _,_ = createNewPushSocket()
+	resetTestPushDataset(nngpush, stub.ValidEndpoints)
         policies := []string{"hello","welcome"}
-        nngpush.send(rtmgr.Eps["10.1.1.1:0"],&policies)
+	nngpush.send(rtmgr.Eps["localhost"],&policies)
 }
-
-/*
-func TestPipeEventHandler(t *testing.T) {
-	var sock mangos.Socket
-	var event mangos.PipeEvent
-	var pipe mangos.Pipe
-
-	var err error
-	sock, err = push.NewSocket()
-	sock.Dial("tcp://127.0.0.1:4555")
-	sock.SetPipeEventHook(pipeEventHandler)
-        pipeEventHandler(event,pipe)
-      t.Log(err)
-}
-*/
diff --git a/pkg/sbi/sbi_test.go b/pkg/sbi/sbi_test.go
index 7cb350c..68c7654 100644
--- a/pkg/sbi/sbi_test.go
+++ b/pkg/sbi/sbi_test.go
@@ -59,11 +59,19 @@
 	var err error
 	var sbi = Sbi{}
 	sbii, err := GetSbi("nngpush")
+
+	var EP = make(map[string]*rtmgr.Endpoint)
+	EP["127.0.0.2"] = &rtmgr.Endpoint{Uuid: "127.0.0.2", Name: "E2TERM", XAppType: "app1", Ip: "127.0.0.2", Port: 4562, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false}
+	rtmgr.Eps = EP
+
+	var nngpush = NngPush{}
+	nngpush.AddEndpoint(rtmgr.Eps["127.0.0.2"])
+
 	var E2map = make(map[string]rtmgr.E2TInstance)
 
-	E2map["1.2.3.4:100"] = rtmgr.E2TInstance{
+	E2map["127.0.0.2:4562"] = rtmgr.E2TInstance{
 		Name:    "E2Tinstance1",
-		Fqdn:    "1.2.3.4:100",
+		Fqdn:    "127.0.0.2:4562",
 		Ranlist: []string{"1", "2"},
 	}
 
@@ -76,12 +84,11 @@
 	var err error
 	sbii, err := GetSbi("nngpush")
 	var EP = make(map[string]*rtmgr.Endpoint)
-	EP["10.0.0.1:0"] = &rtmgr.Endpoint{Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "10.20.30.40", Port: 1234, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false}
+	EP["127.0.0.2"] = &rtmgr.Endpoint{Uuid: "127.0.0.2", Name: "E2TERM", XAppType: "app1", Ip: "127.0.0.1", Port: 4562, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false}
 	rtmgr.Eps = EP
 
 	var nngpush = NngPush{}
-	nngpush.NewSocket = createNewStubPushSocket
-	nngpush.AddEndpoint(rtmgr.Eps["10.0.0.1:0"])
+	nngpush.AddEndpoint(rtmgr.Eps["127.0.0.2"])
 
 	sbi.pruneEndpointList(sbii)
 	t.Log(err)
diff --git a/pkg/stub/stub.go b/pkg/stub/stub.go
index 87923b5..b3e5f3d 100644
--- a/pkg/stub/stub.go
+++ b/pkg/stub/stub.go
@@ -35,25 +35,18 @@
 )
 
 var ValidXApps = &[]rtmgr.XApp{
-	{Name: "app1", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "E2TERM", Status: "unknown", Ip: "10.0.0.1", Port: 0, TxMessages: []string{"HandoverPreparation", "HandoverCancel"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
-	{Name: "app2", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "SUBMAN", Status: "unknown", Ip: "192.168.0.1", Port: 0, TxMessages: []string{"HandoverCancel", "HandoverPreparation"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
-	{Name: "app3", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "E2MAN", Status: "unknown", Ip: "10.1.1.1", Port: 0, TxMessages: []string{"X2Setup"}, RxMessages: []string{"Reset", "UEContextRelease"}}}},
-	{Name: "app4", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "UEMAN", Status: "unknown", Ip: "10.2.2.1", Port: 0, TxMessages: []string{"Reset", "UEContextRelease"}, RxMessages: []string{"", ""}, Policies: []int32{1, 2}}}},
+	{Name: "app2", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "SUBMAN", Status: "unknown", Ip: "127.0.0.1", Port: 4560, TxMessages: []string{"HandoverCancel", "HandoverPreparation"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
+	{Name: "app1", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "E2TERM", Status: "unknown", Ip: "127.0.0.2", Port: 4562, TxMessages: []string{"HandoverCancel", "HandoverPreparation"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
 }
 
 var ValidPlatformComponents = &rtmgr.PlatformComponents{
-	{Name: "E2TERM", Fqdn: "e2term", Port: 4561},
-	{Name: "SUBMAN", Fqdn: "subman", Port: 4561},
-	{Name: "E2MAN", Fqdn: "e2man", Port: 4561},
-	{Name: "UEMAN", Fqdn: "ueman", Port: 4561},
+	{Name: "SUBMAN", Fqdn: "localhost", Port: 4560},
+	{Name: "E2TERM", Fqdn: "localhost1", Port: 4562},
 }
 
 var ValidEndpoints = []rtmgr.Endpoint{
-	{Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
-	{Uuid: "10.0.0.2:0", Name: "E2TERMINST", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
-	{Uuid: "192.168.0.1:0", Name: "SUBMAN", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
-	{Uuid: "10.1.1.1:0", Name: "E2MAN", XAppType: "app3", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false},
-	{Uuid: "10.2.2.1:0", Name: "UEMAN", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Policies: []int32{1, 2}, Socket: nil, IsReady: false, Keepalive: true},
+	{Uuid: "localhost", Name: "SUBMAN", XAppType: "app2", Ip: "127.0.0.1", Port: 4560, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
+	{Uuid: "localhost1", Name: "E2TERM", XAppType: "app1", Ip: "127.0.0.2", Port: 4562, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
 }
 
 var ValidE2TInstance = rtmgr.E2TInstance{
@@ -72,6 +65,14 @@
 
 var ValidPolicies = &[]string{"", ""}
 
+var ValidEndpoints1 = []rtmgr.Endpoint{
+{Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
+        {Uuid: "10.0.0.2:0", Name: "E2TERMINST", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
+        {Uuid: "192.168.0.1:0", Name: "SUBMAN", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
+        {Uuid: "10.1.1.1:0", Name: "E2MAN", XAppType: "app3", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false},
+        {Uuid: "10.2.2.1:0", Name: "UEMAN", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Policies: []int32{1, 2}, Socket: nil, IsReady: false, Keepalive: true},
+}
+
 var ValidSubscriptions = &[]rtmgr.Subscription{
 	{SubID: 1234, Fqdn: "10.0.0.1", Port: 0},
 	{SubID: 1235, Fqdn: "192.168.0.1", Port: 0},