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 Tests for the Measurement Campaign XApp
18 Resource ../resources/xapps/mcxapp_properties.robot
19 Resource ../resources/global_properties.robot
22 Library KubernetesEntity ${GLOBAL_XAPP_NAMESPACE}
25 ${deploymentName} = ${GLOBAL_XAPP_NAMESPACE}-mcxapp
26 ${listenerContainerName} = mc-xapp-listener
27 ${listenerStatRegex} = ^[0-9]+\\s*\\[STAT\\]\\s*\\(mcl\\)
28 ${recentListenerDrops} = last 60s.*drops\\s*=\\s*[1-9]
29 ${recentListenerErrors} = last 60s.*errs\\s*=\\s*[1-9]
32 MC XApp Should Be Available
33 [Tags] etetests xapptests mcxapptests
34 ${deploy} = Deployment ${deploymentName}
35 ${status} = Most Recent Availability Condition @{deploy.status.conditions}
36 Should Be Equal As Strings ${status} True ignore_case=True
38 MC XApp Listener Should Not Be Dropping Messages
39 [Tags] etetests xapptests mcxapptests
40 ${log} = Most Recent Container Log ${listenerContainerName} ${listenerStatRegex}
41 Should Not Contain Match ${log} ${recentListenerDrops}
43 MC XApp Listener Should Not Be Producing Errors
44 [Tags] etetests xapptests mcxapptests
45 ${log} = Most Recent Container Log ${listenerContainerName} ${listenerStatRegex}
46 Should Not Contain Match ${log} ${recentListenerErrors}
48 Writer Should Be Successfully Sending Statistics
49 [Tags] etetests xapptests mcxapptests
50 Set Test Variable ${finalStatus} PASS
51 :FOR ${stat} IN @{GLOBAL_MCXAPP_WRITER_STATISTICS}
52 \ ${statRE} = Regexp Escape ${stat}
53 \ ${log} = Most Recent Container Log
54 ... ${GLOBAL_MCXAPP_WRITER_NAME}
55 ... ^${statRE}:\\s+successful\\s+ves\\s+posts\\.*
56 \ ${status} ${u} = Run Keyword And Ignore Error
57 ... Should Contain Match ${log} regexp=${writerVesSuccesses}
58 \ ${finalStatus} = Set Variable If "${status}" == "FAIL"
61 \ Run Keyword If "${status}" == "FAIL"
62 ... Log No messages have been sent to VES for ${stat}
63 \ ${status} ${u} = Run Keyword And Ignore Error
64 ... Should Not Contain Match ${log} regexp=${writerVesErrors}
65 \ ${finalStatus} = Set Variable If "${status}" == "FAIL"
68 \ Run Keyword If "${status}" == "FAIL"
69 ... Log ${stat} is producing errors logging to VES
70 Run Keyword If "${finalStatus}" == "FAIL"
71 ... Fail One or more statistics is not being succesfully logged
74 Most Recent Availability Condition
75 # this makes the probably-unsafe assumption that the conditions are ordered
77 [Arguments] @{Conditions}
78 ${status} = Set Variable 'False'
79 :FOR ${Condition} IN @{Conditions}
80 \ ${status} = Set Variable If '${Condition.type}' == 'Available' ${Condition.status} ${status}
84 [Arguments] ${list} ${regex}
85 ${matches} = Get Matches ${list} regexp=${regex}
86 Should Not Be Empty ${matches} No log entries matching ${regex}
87 ${match} = Get From List ${matches} -1
90 Most Recent Container Log
91 [Arguments] ${container}=${EMPTY} ${regex}=${EMPTY}
92 ${pods} = Retrieve Pods For Deployment ${deploymentName}
94 :FOR ${pod} IN @{pods}
95 \ ${log} = Retrieve Log For Pod ${pod} ${container}
96 \ Should Not Be Empty ${log} No log entries for ${pod}/${container}
97 \ ${line} = Run Keyword If "${regex}" != "${EMPTY}"
98 ... Most Recent Match ${log} ${regex}
100 ... Get From List ${log} -1
101 \ Append To List ${logs} ${line}