4 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
17 type Generator struct {
20 func (m Generator) Consume(mtype, subId, len int, payload []byte) (err error) {
21 xapp.Logger.Debug("message received - type=%d subId=%d len=%d", mtype, subId, len)
27 ack := xapp.Config.GetInt("test.waitForAck")
35 func waitForMessages() {
36 done := make(chan struct{})
45 case <-time.After(5000 * time.Millisecond):
46 xapp.Logger.Warn("Message waiting timed out!")
50 func runTests(mtype, subId, amount, msize, ack int) {
53 s := make([]byte, msize, msize)
56 for i := 0; i < amount; i++ {
57 if ok := xapp.Rmr.Send(mtype, subId, msize, s); ok {
67 // Wait until all replies are received, or timeout occurs
70 elapsed := time.Since(start)
71 xapp.Logger.Info("amount=%d|tx=%d|rx=%d|failed=%d|time=%v\n", amount, tx, rx, failed, elapsed)
75 // Start RMR and wait until engine is ready
76 go xapp.Rmr.Start(Generator{})
77 for xapp.Rmr.IsReady() == false {
78 time.Sleep(time.Duration(2) * time.Second)
82 interval := 1000000 * 1.0 / xapp.Config.GetInt("test.rate")
83 mtype := xapp.Config.GetInt("test.mtype")
84 subId := xapp.Config.GetInt("test.subId")
85 amount := xapp.Config.GetInt("test.amount")
86 size := xapp.Config.GetInt("test.size")
87 ack := xapp.Config.GetInt("test.waitForAck")
88 rounds := xapp.Config.GetInt("test.rounds")
90 // Now generate message load as per request
91 for i := 0; i < rounds; i++ {
92 runTests(mtype, subId, amount, size, ack)
94 time.Sleep(time.Duration(interval) * time.Microsecond)