2 Python invocation of several parallel publish-notifications RPCs.
10 def publish_notifications(host, grprefix, duration, rate, nrpairs=1):
11 """Invoke publish notification rpcs and verify the response.
13 :param host: ip address of odl node
15 :param grprefix: prefix identifier for publisher/listener pair
16 :type grprefix: string
17 :param duration: publishing notification duration in seconds
19 :param rate: events rate per second
21 :param nrpairs: number of publisher/listener pairs, id suffix is counted from it
24 def _publ_notifications(rqueue, url, grid, duration, rate):
25 dtmpl = string.Template('''<input xmlns="tag:opendaylight.org,2017:controller:yang:lowlevel:control">
27 <seconds>$DURATION</seconds>
28 <notifications-per-second>$RATE</notifications-per-second>
30 data = dtmpl.substitute({'ID': grid, 'DURATION': duration, 'RATE': rate})
32 resp = requests.post(url=url, headers={'Content-Type': 'application/xml'},
33 data=data, auth=('admin', 'admin'), timeout=int(duration)+60)
34 except Exception as exc:
38 resqueue = Queue.Queue()
40 url = 'http://{}:8181/restconf/operations/odl-mdsal-lowlevel-control:publish-notifications'.format(host)
41 for i in range(nrpairs):
42 t = threading.Thread(target=_publ_notifications,
43 args=(resqueue, url, '{}{}'.format(grprefix, i+1), duration, rate))
51 for i in range(nrpairs):
53 assert resp.status_code == 200