Kailash Khalasi | b6e87fc | 2017-04-18 15:08:19 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Utility Synchronizer API |
| 3 | Suite Setup Suite Setup |
| 4 | Suite Teardown Suite Teardown |
| 5 | Variables ../Framework/restApi.py |
| 6 | Library Collections |
| 7 | Library String |
| 8 | Library OperatingSystem |
| 9 | Library XML |
| 10 | Library RequestsLibrary |
| 11 | Library ../Framework/utils/utils.py |
| 12 | Library ../Framework/restApi.py |
| 13 | Variables ../Properties/RestApiProperties.py |
| 14 | Resource ../Framework/utils/utils.robot |
| 15 | |
| 16 | *** Variables *** |
| 17 | ${VM_USER} admin |
| 18 | ${VM_PASS} admin |
| 19 | ${SSH_KEY} id_rsa.pub |
| 20 | ${ONOS_CORDVTN_API} http://onos-cord:8182/onos/cordvtn |
| 21 | |
| 22 | *** Test Cases *** |
| 23 | Get Compute Node Hostname + IP |
| 24 | [Documentation] Logs into ciab server and executes a 'cord prov list' on the headnode to get the compute node |
| 25 | [Tags] computenode |
| 26 | ${compute_node_hostname}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod cord prov list | grep node | awk '{print $2}' |
| 27 | ${compute_node_ip}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod cord prov list | grep node | awk '{print $4}' |
| 28 | Set Suite Variable ${compute_node_hostname} |
| 29 | set suite variable ${compute_node_ip} |
| 30 | |
| 31 | Get ONOSCORD Container ID |
| 32 | [Documentation] Logs into ciab server and extracts the onoscord container id on the headnode |
| 33 | [Tags] onoscord |
| 34 | ${onoscord_id}= Get Docker Container ID ${SERVER_IP} onoscord ${VM_USER} ${VM_PASS} |
| 35 | |
| 36 | Validate Default OVS Flow Count |
| 37 | [Documentation] Logs into the compute-node where OVS is running and validates the default flow count |
| 38 | [Tags] ovsflows |
| 39 | ${ovs_flow_count}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int | wc -l |
| 40 | ${ovs_flow_count}= Get Line ${ovs_flow_count} 0 |
| 41 | Should Be Equal As Integers ${ovs_flow_count} 42 |
| 42 | |
| 43 | Validate Default Flow Count in ONOS |
| 44 | [Documentation] Validates the number of flows pushed down by onos (should match number flow count in ovs) |
| 45 | [Tags] onosflows notready |
| 46 | Log Validating ONOS Flow Count |
| 47 | |
| 48 | Validate Current VTN Service Networks and Ports |
| 49 | [Documentation] Makes rest calls to both XOS and ONOSCORD to validate the default VTN Service Networks + Ports |
| 50 | [Tags] vtnservice |
| 51 | Validate Default CIAB Service Networks and Ports via XOS |
| 52 | ${serviceNetworks}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -X GET -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/serviceNetworks; echo |
| 53 | Validate Default CIAB Service Networks via ONOSCORD ${serviceNetworks} |
| 54 | ${servicePorts}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -X GET -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/servicePorts; echo |
| 55 | Validate Default CIAB Service Ports via ONOSCORD ${servicePorts} |
| 56 | |
| 57 | Create New VTN Service Network |
| 58 | [Documentation] Makes a POST Request from the head-node to the ONOS Cord-VTN App to create a new service network |
| 59 | [Tags] vtnservice |
| 60 | ${network_uuid}= Generate UUID |
| 61 | Set Suite Variable ${network_uuid} |
| 62 | ${networkCreation}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -s -o /dev/null -w "\%{http_code}" -X POST -u karaf:karaf -H "Content-Type: application/json" -d '{"ServiceNetwork": {"id": "${network_uuid}", "type": "PRIVATE", "name": "APITEST", "segment_id": 2221, "subnet": "2.2.2.0/24", "service_ip": "2.2.2.1", "providers": [{"id": "${public_network_id}", "bidirectional": true}]}}' http://onos-cord:8182/onos/cordvtn/serviceNetworks; echo |
| 63 | Should Be Equal As Integers ${networkCreation} 201 |
| 64 | ${new_network}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -X GET -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/serviceNetworks/${network_uuid}; echo |
| 65 | Log ${new_network} |
| 66 | ${name}= Get Json Value ${new_network} /ServiceNetwork/name |
| 67 | ${type}= Get Json Value ${new_network} /ServiceNetwork/type |
| 68 | ${segment_id}= Get Json Value ${new_network} /ServiceNetwork/segment_id |
| 69 | ${subnet}= Get Json Value ${new_network} /ServiceNetwork/subnet |
| 70 | ${service_ip}= Get Json Value ${new_network} /ServiceNetwork/service_ip |
| 71 | Should Be Equal As Strings ${name} "APITEST" |
| 72 | Should Be Equal As Strings ${type} "PRIVATE" |
| 73 | Should Be Equal As Strings ${segment_id} 2221 |
| 74 | Should Be Equal As Strings ${subnet} "2.2.2.0/24" |
| 75 | Should Be Equal As Strings ${service_ip} "2.2.2.1" |
| 76 | |
| 77 | Create New VTN Service Port |
| 78 | [Documentation] Makes a POST Request from the head-node to the ONOS Cord-VTN App to create a new service port for the newly created network |
| 79 | [Tags] vtnservice |
| 80 | ${port_uuid}= Generate UUID |
| 81 | Set Suite Variable ${port_uuid} |
| 82 | ${networkCreation}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -s -o /dev/null -w "\%{http_code}" -X POST -u karaf:karaf -H "Content-Type: application/json" -d '{"ServicePort": {"id": "${port_uuid}", "network_id": "${network_uuid}", "name": "APITESTPORT", "mac_address": "FA:16:3E:A8:A1:AA", "ip_address": "2.2.2.1", "floating_address_pairs":[{"ip_address":"3.3.3.1","mac_address":"02:42:0A:06:01:11"}]}}' http://onos-cord:8182/onos/cordvtn/servicePorts; echo |
| 83 | Should Be Equal As Integers ${networkCreation} 201 |
| 84 | ${new_port}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -X GET -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/servicePorts/${port_uuid}; echo |
| 85 | Log ${new_port} |
| 86 | ${name}= Get Json Value ${new_port} /ServicePort/name |
| 87 | ${netId}= Get Json Value ${new_port} /ServicePort/network_id |
| 88 | ${mac_address}= Get Json Value ${new_port} /ServicePort/mac_address |
| 89 | ${ip_address}= Get Json Value ${new_port} /ServicePort/ip_address |
| 90 | ${floating_pairs}= Get Json Value ${new_port} /ServicePort/floating_address_pairs |
| 91 | Should Be Equal As Strings ${name} "APITESTPORT" |
| 92 | Should Be Equal As Strings ${netId} "${network_uuid}" |
| 93 | Should Be Equal As Strings ${mac_address} "FA:16:3E:A8:A1:AA" |
| 94 | Should Be Equal As Strings ${ip_address} "2.2.2.1" |
| 95 | |
| 96 | Validate New Flows Pushed to OVS |
| 97 | [Documentation] Logs into the compute-node where OVS is running and validates the default flow count |
| 98 | [Tags] vtnservice |
| 99 | ${ovs_flow_count}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int | grep 2.2.2.0 | wc -l |
| 100 | ${ovs_flow_count}= Get Line ${ovs_flow_count} 0 |
| 101 | Should Be Equal As Integers ${ovs_flow_count} 3 |
| 102 | ${flows_added}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int |
| 103 | ${flows_added}= Get Lines Containing String ${flows_added} cookie= |
| 104 | Log ${flows_added} |
| 105 | ## Match src/dst (bi-directional) rules on new flows added |
| 106 | Should Contain ${flows_added} nw_src=2.2.2.0/24,nw_dst=10.6.1.192/26 |
| 107 | Should Contain ${flows_added} nw_src=10.6.1.192/26,nw_dst=2.2.2.0/24 |
| 108 | Should Contain ${flows_added} nw_src=2.2.2.0/24,nw_dst=10.6.1.193 |
| 109 | |
| 110 | Delete VTN Service Port |
| 111 | [Documentation] Makes a DELETE Request from the head-node to the ONOS Cord-VTN App to delete the new service port |
| 112 | [Tags] vtnservice |
| 113 | ${networkDeletion}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -s -o /dev/null -w "\%{http_code}" -X DELETE -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/servicePorts/${port_uuid}; echo |
| 114 | Should Be Equal As Integers ${networkDeletion} 204 |
| 115 | ${get_port}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -s -o /dev/null -w "\%{http_code}" -X GET -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/servicePorts/${port_uuid}; echo |
| 116 | Should Be Equal As Integers ${get_port} 404 |
| 117 | |
| 118 | Delete VTN Service Network |
| 119 | [Documentation] Makes a DELETE Request from the head-node to the ONOS Cord-VTN App to delete the created service network |
| 120 | [Tags] vtnservice |
| 121 | ${networkDeletion}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -s -o /dev/null -w "\%{http_code}" -X DELETE -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/serviceNetworks/${network_uuid}; echo |
| 122 | Should Be Equal As Integers ${networkDeletion} 204 |
| 123 | ${get_network}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod curl -s -o /dev/null -w "\%{http_code}" -X GET -u karaf:karaf -H "Content-Type: application/json" http://onos-cord:8182/onos/cordvtn/serviceNetworks/${network_uuid}; echo |
| 124 | Should Be Equal As Integers ${get_network} 404 |
| 125 | |
| 126 | Validate New Flows Removed From OVS |
| 127 | [Documentation] Validates that the flow rules added by ONOS from the network creation has been removed |
| 128 | [Tags] vtnservice |
| 129 | ${ovs_flow_count}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int | grep 2.2.2.0 | wc -l |
| 130 | ${ovs_flow_count}= Get Line ${ovs_flow_count} 0 |
| 131 | Should Be Equal As Integers ${ovs_flow_count} 0 |
| 132 | ${flows_added}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int |
| 133 | ${flows_added}= Get Lines Containing String ${flows_added} cookie= |
| 134 | Log ${flows_added} |
| 135 | ## Validate flow rules arent in the flows table |
| 136 | Should Not Contain ${flows_added} nw_src=2.2.2.0/24,nw_dst=10.6.1.192/26 |
| 137 | Should Not Contain ${flows_added} nw_src=10.6.1.192/26,nw_dst=2.2.2.0/24 |
| 138 | Should Not Contain ${flows_added} nw_src=2.2.2.0/24,nw_dst=10.6.1.193 |
| 139 | |
| 140 | *** Keywords *** |
| 141 | Suite Setup |
| 142 | ${auth} = Create List ${USER} ${PASSWD} |
| 143 | Create Session ${SERVER_IP} http://${SERVER_IP}:${SERVER_PORT} auth=${AUTH} |
| 144 | |
| 145 | Suite Teardown |
| 146 | Delete All Sessions |
| 147 | Close All Connections |
| 148 | |
| 149 | CORD Get |
| 150 | [Documentation] Make a rest call to the CORD controller |
| 151 | [Arguments] ${session} ${service} |
| 152 | ${resp}= Get Request ${session} ${service} |
| 153 | Log ${resp.content} |
| 154 | [Return] ${resp} |
| 155 | |
| 156 | Validate Default CIAB Service Networks and Ports via XOS |
| 157 | [Documentation] Using XOS API, this validates the default VTN Service Networks + Ports for a CIAB Environment |
| 158 | @{expected_types}= Create List PUBLIC PRIVATE MANAGEMENT_LOCAL VSG |
| 159 | @{expected_owner_slices}= Create List mysite_public mysite_exampleservice mysite_management mysite_vsg |
| 160 | @{expected_network_names}= Create List public management exampleservice_network mysite_vsg-access |
| 161 | @{types}= Create List |
| 162 | @{ownerSlices}= Create List |
| 163 | @{network_names}= Create List |
| 164 | ${resp}= CORD GET ${SERVER_IP} /api/service/vtn/serviceNetworks/ |
| 165 | Should Be Equal As Strings ${resp.status_code} 200 |
| 166 | ${jsondata}= To Json ${resp.content} |
| 167 | ${length}= Get Length ${jsondata['serviceNetworks']} |
| 168 | Should Be Equal As Integers ${length} 4 |
| 169 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 170 | \ ${item}= Get From List ${jsondata['serviceNetworks']} ${INDEX} |
| 171 | \ ${type}= Get From Dictionary ${item} type |
| 172 | \ ${ownerSliceName}= Get From Dictionary ${item} ownerSliceName |
| 173 | \ Append To List ${types} ${type} |
| 174 | \ Append To List ${ownerSlices} ${ownerSliceName} |
| 175 | : FOR ${value} IN @{expected_types} |
| 176 | \ List Should Contain Value ${types} ${value} |
| 177 | : FOR ${value} IN @{expected_owner_slices} |
| 178 | \ List Should Contain Value ${ownerSlices} ${value} |
| 179 | ${resp}= CORD GET ${SERVER_IP} /api/service/vtn/servicePorts/ |
| 180 | Should Be Equal As Strings ${resp.status_code} 200 |
| 181 | ${jsondata}= To Json ${resp.content} |
| 182 | ${length}= Get Length ${jsondata['servicePorts']} |
| 183 | Should Be Equal As Integers ${length} 5 |
| 184 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 185 | \ ${item}= Get From List ${jsondata['servicePorts']} ${INDEX} |
| 186 | \ ${network_name}= Get From Dictionary ${item} network_name |
| 187 | \ Append To List ${network_names} ${network_name} |
| 188 | : FOR ${value} IN @{expected_network_names} |
| 189 | \ List Should Contain Value ${network_names} ${value} |
| 190 | ${management_len}= Count Values in List ${network_names} management |
| 191 | Should Be Equal As Integers ${management_len} 2 |
| 192 | |
| 193 | Validate Default CIAB Service Networks via ONOSCORD |
| 194 | [Documentation] Validates the default VTN Service Network via ONOSCORD for a CIAB Environment |
| 195 | [Arguments] ${jsondata} |
| 196 | @{network_ids}= Create List |
| 197 | @{expected_types}= Create List PUBLIC PRIVATE MANAGEMENT_LOCAL VSG |
| 198 | @{expected_names}= Create List public exampleservice_network management mysite_vsg-access |
| 199 | @{types}= Create List |
| 200 | @{names}= Create List |
| 201 | ${jsondata}= To Json ${jsondata} |
| 202 | ${length}= Get Length ${jsondata['ServiceNetworks']} |
| 203 | Should Be Equal As Integers ${length} 4 |
| 204 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 205 | \ ${item}= Get From List ${jsondata['ServiceNetworks']} ${INDEX} |
| 206 | \ ${network_id}= Get From Dictionary ${item} id |
| 207 | \ ${type}= Get From Dictionary ${item} type |
| 208 | \ ${name}= Get From Dictionary ${item} name |
| 209 | \ Append To List ${network_ids} ${network_id} |
| 210 | \ Append To List ${types} ${type} |
| 211 | \ Append To List ${names} ${name} |
| 212 | \ Run Keyword If "${name}" == "management" Set Suite Variable ${management_network_id} ${network_id} |
| 213 | \ Run Keyword If "${name}" == "public" Set Suite Variable ${public_network_id} ${network_id} |
| 214 | : FOR ${value} IN @{expected_types} |
| 215 | \ List Should Contain Value ${types} ${value} |
| 216 | : FOR ${value} IN @{expected_names} |
| 217 | \ List Should Contain Value ${names} ${value} |
| 218 | Set Suite Variable ${network_ids} |
| 219 | |
| 220 | Validate Default CIAB Service Ports via ONOSCORD |
| 221 | [Documentation] Validates the default VTN Service Ports via ONOSCORD for a CIAB Environment |
| 222 | [Arguments] ${jsondata} |
| 223 | ${net_ids}= Create List |
| 224 | ${jsondata}= To Json ${jsondata} |
| 225 | ${length}= Get Length ${jsondata['ServicePorts']} |
| 226 | Should Be Equal As Integers ${length} 5 |
| 227 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 228 | \ ${item}= Get From List ${jsondata['ServicePorts']} ${INDEX} |
| 229 | \ ${net_id}= Get From Dictionary ${item} network_id |
| 230 | \ Append To List ${net_ids} ${net_id} |
| 231 | : FOR ${value} IN @{net_ids} |
| 232 | \ List Should Contain Value ${network_ids} ${value} |
| 233 | ${management_len}= Count Values in List ${net_ids} ${management_network_id} |
| 234 | Should Be Equal As Integers ${management_len} 2 |