import (
"encoding/json"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_models"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
"net/http"
"sync"
"testing"
"time"
+
+ "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_models"
+ "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
)
//-----------------------------------------------------------------------------
teststub.TestWrapper
resultChan chan bool
nextActionOk bool
+ sleep int
}
func (msg *HttpEventWaiter) SetResult(res bool) {
return eventWaiter
}
+func (tc *testingHttpRtmgrStub) AllocNextSleep(sleep int, nextAction bool) *HttpEventWaiter {
+ eventWaiter := &HttpEventWaiter{
+ resultChan: make(chan bool),
+ nextActionOk: nextAction,
+ sleep: sleep,
+ }
+ eventWaiter.TestWrapper.Init("localhost:" + tc.port)
+ tc.NextEvent(eventWaiter)
+ return eventWaiter
+}
+
func (tc *testingHttpRtmgrStub) http_handler(w http.ResponseWriter, r *http.Request) {
tc.Lock()
defer tc.Unlock()
+ var id int32 = -1
if r.Method == http.MethodPost || r.Method == http.MethodDelete {
var req rtmgr_models.XappSubscriptionData
if err != nil {
tc.Error("%s", err.Error())
}
- tc.Info("handling SubscriptionID=%d Address=%s Port=%d", *req.SubscriptionID, *req.Address, *req.Port)
+ tc.Debug("handling SubscriptionID=%d Address=%s Port=%d", *req.SubscriptionID, *req.Address, *req.Port)
+ id = *req.SubscriptionID
}
if r.Method == http.MethodPut {
var req rtmgr_models.XappList
if err != nil {
tc.Error("%s", err.Error())
}
- tc.Info("handling put")
+ tc.Debug("handling put")
}
var code int = 0
if tc.eventWaiter.nextActionOk == false {
code = 400
}
+ if tc.eventWaiter.sleep != 0 {
+ <-time.After(time.Duration(tc.eventWaiter.sleep) * time.Millisecond)
+ tc.Debug("sleeping done, %v", id)
+ }
}
case http.MethodDelete:
code = 200
if waiter != nil {
waiter.SetResult(true)
}
- tc.Info("Method=%s Reply with code %d", r.Method, code)
+ tc.Debug("Method=%s Reply with code %d", r.Method, code)
w.WriteHeader(code)
}