Fix race condition in UT cases
Change-Id: Ida3bcf39cfdca2f4e7359a8b8ec2e83692d16d4c
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
diff --git a/cmd/vesmgr/vesmgr.go b/cmd/vesmgr/vesmgr.go
index 4906d28..5086098 100755
--- a/cmd/vesmgr/vesmgr.go
+++ b/cmd/vesmgr/vesmgr.go
@@ -23,12 +23,12 @@
import (
"errors"
+ "fmt"
"io/ioutil"
"net"
"net/http"
"os"
"time"
- "fmt"
mdcloggo "gerrit.o-ran-sc.org/r/com/golog.git"
)
@@ -126,11 +126,11 @@
if ok {
logger.Info("Using appmgrdomain %s", appmgrDomain)
} else {
- pltnamespace := os.Getenv("PLT_NAMESPACE")
- if pltnamespace == "" {
- pltnamespace = "ricplt"
- }
- appmgrDomain = fmt.Sprintf("service-%s-appmgr-http.%s.svc.cluster.local",pltnamespace, pltnamespace)
+ pltnamespace := os.Getenv("PLT_NAMESPACE")
+ if pltnamespace == "" {
+ pltnamespace = "ricplt"
+ }
+ appmgrDomain = fmt.Sprintf("service-%s-appmgr-http.%s.svc.cluster.local", pltnamespace, pltnamespace)
logger.Info("Using default appmgrdomain %s", appmgrDomain)
}
vesmgr.chXAppSubscriptions = make(chan subscriptionNotification)
diff --git a/cmd/vesmgr/vesmgr_queryxappconfig_test.go b/cmd/vesmgr/vesmgr_queryxappconfig_test.go
old mode 100644
new mode 100755
index 8cc3ad4..11e7531
--- a/cmd/vesmgr/vesmgr_queryxappconfig_test.go
+++ b/cmd/vesmgr/vesmgr_queryxappconfig_test.go
@@ -27,6 +27,7 @@
"net/http"
"net/url"
"os"
+ "sync"
"testing"
"time"
@@ -39,6 +40,7 @@
suite.Suite
listener net.Listener
xAppMgrFunc do
+ mu sync.Mutex
}
// suite setup creates the HTTP server
@@ -56,7 +58,9 @@
http.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
+ suite.mu.Lock()
suite.xAppMgrFunc(w)
+ suite.mu.Unlock()
}
})
http.Serve(listener, nil)