1 # Copyright (c) 2019 AT&T Intellectual Property.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 Documentation Tools for interacting with the MC XApp
18 Resource /robot/resources/global_properties.robot
19 Resource /robot/resources/mcxapp_properties.robot
23 Library KubernetesEntity ${GLOBAL_XAPP_NAMESPACE}
27 ${listenerStatSubstring} (mcl) mtype=
28 ${listenerStatRegex} ^\\s*([0-9]+)\\s+\\[STAT\\]\\s+\\(mcl\\)\\s+mtype=([^\\s]+)\\s+total\\s+writes=([0-9]+)\\s+total\\s+drops=([0-9]+);.*writes=([0-9]+)\\s+drops=([0-9]+)
31 Retrieve Listener Message Counts
32 ${pods} = Retrieve Pods For Deployment ${MCDeployment}
33 # for now, i'm just going to completely ignore the possibility
34 # of multiple MC XApp pods. that seems safe, i think.
35 ${pod} = Get From List ${pods} 0
36 ${log} = Retrieve Log For Pod ${pod} tail=500
37 ${statLogs} = Get Matches ${log} glob=*${listenerStatSubstring}*
38 ${stats} = Parse Listener Statistics ${statLogs}
41 Parse Listener Statistics
42 [Arguments] ${logLines}
43 # while it's almost certainly safe to assume the log
44 # lines are sorted by timestamp, it's not something i'm
45 # going to take for granted.
46 ${stats} = Create Dictionary
47 FOR ${statLine} IN @{logLines}
48 ${match} ${ts} ${mtype} ${tWrites} ${tDrops} ${rWrites} ${rDrops} =
49 ... Should Match Regexp ${statLine} ${listenerStatRegex}
50 ${stat} = Create Dictionary
52 ... totalWrites=${tWrites}
53 ... totalDrops=${tDrops}
54 ... recentWrites=${rWrites}
55 ... recentDrops=${rDrops}
56 ${s} ${d} = Run Keyword And Ignore Error
57 ... Get From Dictionary ${stats} ${mtype}
58 ${prevTS} = Run Keyword If "${s}" == "PASS"
59 ... Get From Dictionary ${d} timestamp
62 Run Keyword If ${ts} > ${prevTS}
63 ... Set To Dictionary ${stats} ${mtype} ${stat}