| Felipe Vicens | 5020a8f | 2020-07-01 18:41:38 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2019 Tech Mahindra Limited |
| 5 | # |
| 6 | # All Rights Reserved. |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. You may obtain |
| 10 | # a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | # License for the specific language governing permissions and limitations |
| 18 | # under the License. |
| 19 | ## |
| 20 | |
| 21 | ## Change log: |
| 22 | # 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-aug-2019 : Improvement to the code, robot framework initial seed code. |
| 23 | ## |
| 24 | |
| 25 | |
| 26 | *** Variables *** |
| 27 | ${success_return_code} 0 |
| 28 | ${ns_launch_max_wait_time} 5min |
| 29 | ${ns_launch_pol_time} 30sec |
| 30 | ${ns_delete_max_wait_time} 1min |
| 31 | ${ns_delete_pol_time} 15sec |
| 32 | ${nsconfig} |
| 33 | |
| 34 | *** Keywords *** |
| 35 | Get NS List |
| 36 | [Documentation] Get ns instance list |
| 37 | |
| 38 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list |
| 39 | log ${stdout} |
| 40 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 41 | |
| 42 | |
| 43 | Get NS Instance ID |
| 44 | [Arguments] ${ns_name} |
| 45 | |
| 46 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}" | awk 'NR==4{print $4}' |
| 47 | log ${stdout} |
| 48 | [Return] ${stdout} |
| 49 | |
| 50 | |
| 51 | Verify All JUJU Applications Status |
| 52 | [Arguments] ${ns} ${api_ip} ${api_port} ${username} ${password} ${api_cert_path} |
| 53 | |
| 54 | ${juju_model}= Get NS Instance ID ${ns} |
| 55 | |
| 56 | Import Library robot_juju.JujuLibrary ${api_ip} ${api_port} ${juju_model} ${username} ${password} ${api_cert_path} |
| 57 | Assert status of applications is ${status_active} |
| 58 | |
| 59 | |
| 60 | Launch Network Services and Return |
| 61 | [Arguments] ${vim_name} ${ns_config}='' |
| 62 | [Documentation] Get Configuration parameter to create Newtork service |
| 63 | |
| 64 | Run Keyword If ${ns_config}=='' Get NS Config |
| 65 | ... ELSE Set NS Config ${ns_config} |
| 66 | Log To Console \n${nsconfig} |
| 67 | Should Not Be Empty ${nsd_ids} There are no NS descriptors to launch the NS |
| 68 | :FOR ${nsd} IN @{nsd_ids} |
| 69 | \ ${ns_name}= GENERATE NAME |
| 70 | \ Append To List ${ns_ids} ${ns_name} |
| 71 | \ Create Network Service ${nsd} ${vim_name} ${ns_name} ${nsconfig} |
| 72 | |
| 73 | |
| 74 | Set NS Config |
| 75 | [Arguments] ${ns_config} |
| 76 | [Documentation] Set NS Configuration variable |
| 77 | |
| 78 | ${nsconfig}= Get Variable Value ${ns_config} '' |
| 79 | Set Test Variable ${nsconfig} |
| 80 | |
| 81 | |
| 82 | Get NS Config |
| 83 | [Documentation] Get NS Configuration from Environment Variable |
| 84 | |
| 85 | ${nsconfig}= Get Environment Variable NS_CONFIG '' |
| 86 | Set Test Variable ${nsconfig} |
| 87 | |
| 88 | |
| 89 | Create Network Service |
| 90 | [Documentation] Create ns at osm |
| 91 | [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} |
| 92 | |
| 93 | Run Keyword If ${ns_config}!='' Create Network Service With Config ${nsd} ${vim_name} ${ns_name} ${ns_config} |
| 94 | ... ELSE Create Network Service Without Config ${nsd} ${vim_name} ${ns_name} |
| 95 | |
| 96 | WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name} |
| 97 | Check For NS Instance For Failure ${ns_name} |
| 98 | |
| 99 | |
| 100 | Create Network Service Without Config |
| 101 | [Documentation] Create ns at osm |
| 102 | [Arguments] ${nsd} ${vim_name} ${ns_name} |
| 103 | |
| 104 | ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} |
| 105 | log ${stdout} |
| 106 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 107 | |
| 108 | |
| 109 | Create Network Service With Config |
| 110 | [Documentation] Create ns at osm |
| 111 | [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} |
| 112 | |
| 113 | ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} --config ${ns_config} |
| 114 | log ${stdout} |
| 115 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 116 | |
| 117 | |
| 118 | Delete NS |
| 119 | [Documentation] Delete ns |
| 120 | [Arguments] ${ns} |
| 121 | |
| 122 | ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns} |
| 123 | log ${stdout} |
| 124 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 125 | |
| 126 | WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns} |
| 127 | |
| 128 | |
| 129 | Check For NS Instance To Configured |
| 130 | [Arguments] ${ns_name} |
| 131 | |
| 132 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}" |
| 133 | log ${stdout} |
| 134 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 135 | Should Contain Any ${stdout} READY BROKEN |
| 136 | |
| 137 | |
| 138 | Check For NS Instance For Failure |
| 139 | [Arguments] ${ns_name} |
| 140 | |
| 141 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}" |
| 142 | log ${stdout} |
| 143 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 144 | Should Not Contain ${stdout} BROKEN |
| 145 | |
| 146 | |
| 147 | Check For NS Instance To Be Delete |
| 148 | [Arguments] ${ns} |
| 149 | |
| 150 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list |
| 151 | log ${stdout} |
| 152 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 153 | Should Not Contain ${stdout} ${ns} |
| 154 | |
| 155 | |
| 156 | Force Delete NS |
| 157 | [Documentation] Forcely Delete ns |
| 158 | [Arguments] ${ns} |
| 159 | |
| 160 | ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns} |
| 161 | log ${stdout} |
| 162 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 163 | WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns} |
| 164 | |
| 165 | |
| 166 | Perform VNF Scale-in Operation |
| 167 | [Arguments] ${ns} ${vnf_member} ${scaling_group} |
| 168 | |
| 169 | ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal |
| 170 | ${scaled_vnf}= Get Scaled Vnf ${nsr} |
| 171 | log to console Scaled VNF befor scale-in operation is ${scaled_vnf} |
| 172 | ${rc} ${stdout}= Run and Return RC and Output osm vnf-scale --scale-in --scaling-group ${scaling_group} ${ns} ${vnf_member} |
| 173 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 174 | log ${stdout} |
| 175 | Sleep 1m Waiting for scale-in operation to complete |
| 176 | ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal |
| 177 | ${scaled_vnf}= Get Scaled Vnf ${nsr} |
| 178 | log to console Scaled VNF after scale-in operation is ${scaled_vnf} |
| 179 | |
| 180 | |
| 181 | Perform VNF Scale-out Operation |
| 182 | [Arguments] ${ns} ${vnf_member} ${scaling_group} |
| 183 | |
| 184 | ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal |
| 185 | ${scaled_vnf}= Get Scaled Vnf ${nsr} |
| 186 | log to console Scaled VNF befor scale-out operation is ${scaled_vnf} |
| 187 | ${rc} ${stdout}= Run and Return RC and Output osm vnf-scale --scale-out --scaling-group ${scaling_group} ${ns} ${vnf_member} |
| 188 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 189 | log ${stdout} |
| 190 | Sleep 1m Waiting for scale-out operation to complete |
| 191 | ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal |
| 192 | ${scaled_vnf}= Get Scaled Vnf ${nsr} |
| 193 | log to console Scaled VNF befor scale-out operation is ${scaled_vnf} |