Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
| 2 | # |
| 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 |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 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. |
| 14 | |
| 15 | *** Settings *** |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 16 | Suite Setup Setup |
| 17 | Test Timeout 10 minutes |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 18 | Documentation Validates external connectivity from Cord-Tester Container through VSG Subscriber |
| 19 | Library OperatingSystem |
| 20 | Library SSHLibrary |
| 21 | Library /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/utils.py |
| 22 | Library /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/onosUtils.py |
| 23 | Library /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/openstackUtils.py |
| 24 | Resource /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/utils.robot |
| 25 | |
| 26 | *** Variables *** |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 27 | ${pod} qct-pod1.yml |
| 28 | ${vsg_data_file} /opt/cord/test/cord-tester/src/test/cord-api/Tests/data/Ch_VoltTenant.json |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 29 | |
| 30 | *** Test Cases *** |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 31 | Validate Instances are ACTIVE |
| 32 | [Documentation] Validates that all instances are ACTIVE |
| 33 | Wait Until Keyword Succeeds 300s 5s Instances ACTIVE |
| 34 | |
| 35 | Validate Connectivity to All VSGs via Mgmt Interface |
| 36 | [Documentation] Validates that all given vsg instances are reachable through the mgmt interfaces |
| 37 | ##Loop through nova ids, get mgmt ips + compute nodes, ssh into compute node, and validate ping to mgmt_ip |
| 38 | : FOR ${nova_id} IN @{nova_ids} |
| 39 | \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}' |
| 40 | \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}' |
| 41 | \ ${ping_result}= Run ssh ubuntu@${node} ping -c 1 ${mgmt_ip} |
| 42 | \ Should Contain ${ping_result} 64 bytes from ${mgmt_ip} |
| 43 | \ Should Not Contain ${ping_result} 100% packet loss |
| 44 | |
| 45 | Validate VSG External Connectivity |
| 46 | [Documentation] Validates that the given vsg instances have external connectivity |
| 47 | : FOR ${nova_id} IN @{nova_ids} |
| 48 | \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}' |
| 49 | \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}' |
| 50 | \ Wait Until Keyword Succeeds 300s 5s Validate Ext Connectivity ${node} ${mgmt_ip} |
| 51 | |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 52 | Configure X-Connects for 3 Subscribers |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 53 | [Documentation] Configures the cross connect on the fabric switch with s-tags for the subscribers created via control-plane tests on the correct ports |
| 54 | [Tags] xconnect |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 55 | ${netcfg_init}= onosUtils.onos_command_execute onos-fabric 8101 netcfg |
| 56 | Log ${netcfg_init} |
| 57 | Run http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/network/configuration/ |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 58 | Sleep 5 |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 59 | Run http -a onos:rocks POST http://onos-fabric:8181/onos/v1/network/configuration/ < /opt/cord/test/cord-tester/src/test/setup/${netcfg_file} |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 60 | Sleep 5 |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 61 | Run http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 62 | Sleep 5 |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 63 | Run http -a onos:rocks POST http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active |
| 64 | Sleep 5 |
| 65 | ${netcfg}= onosUtils.onos_command_execute onos-fabric 8101 netcfg |
| 66 | Log ${netcfg} |
| 67 | Should Contain ${netcfg} vsg-1 |
| 68 | Should Contain ${netcfg} vsg-2 |
| 69 | Should Contain ${netcfg} vsg-3 |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 70 | Should Contain ${netcfg} "vlan" : ${s_tags[0]} |
| 71 | Should Contain ${netcfg} "vlan" : ${s_tags[1]} |
| 72 | Should Contain ${netcfg} "vlan" : ${s_tags[2]} |
| 73 | |
| 74 | Validate VSG External Connectivity Again |
| 75 | [Documentation] Validates that the given vsg instances have external connectivity even after onos-fabric has been re-configured |
| 76 | : FOR ${nova_id} IN @{nova_ids} |
| 77 | \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}' |
| 78 | \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}' |
| 79 | \ Wait Until Keyword Succeeds 300s 5s Validate Ext Connectivity ${node} ${mgmt_ip} |
| 80 | |
| 81 | Validate VCPE Containers |
| 82 | [Documentation] Validates that vcpes containers are up in each vsg instance |
| 83 | : FOR ${nova_id} IN @{nova_ids} |
| 84 | \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}' |
| 85 | \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}' |
| 86 | \ Wait Until Keyword Succeeds 800s 5s Validate VCPE Container is Up ${node} ${mgmt_ip} |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 87 | |
| 88 | Get VSG Subscriber and Tags |
| 89 | [Documentation] Retrieves compute node connected on leaf-1 and s/c tags for that particular subscriber |
| 90 | ${cmd}= Set Variable cordvtn-nodes | grep 10.6.1 |
| 91 | ${cnode}= onosUtils.onos_command_execute onos-cord 8102 ${cmd} |
| 92 | @{cnode_on_leaf_1}= Split String ${cnode} |
| 93 | ${novalist}= Run . /opt/cord_profile/admin-openrc.sh; nova list --all-tenants | awk '{print $2}' | grep '[a-z]' |
| 94 | Log ${novalist} |
| 95 | @{nova_ids}= Split To Lines ${novalist} |
| 96 | : FOR ${nova_id} IN @{nova_ids} |
| 97 | \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}' |
| 98 | \ Run Keyword If '${node}' == '${cnode_on_leaf_1[0]}' Exit For Loop |
| 99 | ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}' |
| 100 | ## Get s/c tags for vsg |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 101 | ${result}= Run ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu ${cnode_on_leaf_1[0]}" ubuntu@${mgmt_ip} "sudo docker ps|grep 'vsg\\|vcpe'" | awk '{print $10}' |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 102 | @{tags}= Split String ${result} - |
| 103 | ${s_tag}= Set Variable ${tags[1]} |
| 104 | ${c_tag}= Set Variable ${tags[2]} |
| 105 | Set Suite Variable ${s_tag} |
| 106 | Set Suite Variable ${c_tag} |
| 107 | |
| 108 | Execute Dataplane Test |
| 109 | [Documentation] Configures interfaces on cord-tester container to connect to vsg instance and validates traffic |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 110 | [Tags] dataplane |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 111 | ${i_num}= Set Variable If |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 112 | ... '${s_tag}' == '${s_tags[0]}' 1 |
| 113 | ... '${s_tag}' == '${s_tags[1]}' 2 |
| 114 | ... '${s_tag}' == '${s_tags[2]}' 3 |
Kailash Khalasi | ecf3014 | 2018-01-24 15:16:45 -0800 | [diff] [blame] | 115 | ${output}= Run docker exec cord-tester1 bash -c "sudo echo 'nameserver 192.168.0.1' > /etc/resolv.conf" |
| 116 | ${output}= Run docker exec cord-tester1 bash -c "sudo dhclient vcpe${i_num}.${s_tag}.${c_tag}" |
| 117 | Sleep 5 |
| 118 | ${output}= Run docker exec cord-tester1 bash -c "sudo route add default gw 192.168.0.1 vcpe${i_num}.${s_tag}.${c_tag}" |
| 119 | ${output}= Run docker exec cord-tester1 bash -c "ping -c 3 -I vcpe${i_num}.${s_tag}.${c_tag} 8.8.8.8" |
| 120 | Log To Console \n ${output} |
| 121 | Should Contain ${output} 64 bytes from 8.8.8.8 |
Kailash Khalasi | 9b31109 | 2018-02-08 11:26:37 -0800 | [diff] [blame^] | 122 | Should Not Contain ${output} 100% packet loss |
| 123 | |
| 124 | *** Keywords *** |
| 125 | Setup |
| 126 | [Documentation] Gets global vars for test suite |
| 127 | @{s_tags}= Create List |
| 128 | @{c_tags}= Create List |
| 129 | ${netcfg_file}= Set Variable If |
| 130 | ... '${pod}' == 'qct-pod1.yml' qct_fabric_test_netcfg.json |
| 131 | ... '${pod}' == 'flex-pod1.yml' flex_fabric_test_netcfg.json |
| 132 | ... '${pod}' == 'calix-pod1.yml' calix_fabric_test_netcfg.json |
| 133 | Set Suite Variable ${netcfg_file} |
| 134 | ${voltList} = utils.jsonToList ${vsg_data_file} voltSubscriberInfo |
| 135 | Set Suite Variable ${vlist} ${voltList} |
| 136 | ${voltTenantList} = Get Variable Value ${vlist} |
| 137 | ${vsg_count}= Get Length ${vlist} |
| 138 | Set Suite Variable ${vsg_count} |
| 139 | : FOR ${INDEX} IN RANGE 0 ${vsg_count} |
| 140 | \ ${voltTenantDict}= utils.listToDict ${voltTenantList} ${INDEX} |
| 141 | \ ${voltDict}= Get From Dictionary ${voltTenantDict} voltTenant |
| 142 | \ ${s_tag}= Get From Dictionary ${voltDict} s_tag |
| 143 | \ ${c_tag}= Get From Dictionary ${voltDict} c_tag |
| 144 | \ Append To List ${s_tags} ${s_tag} |
| 145 | \ Append To List ${c_tags} ${c_tag} |
| 146 | @{nova_ids}= Wait Until Keyword Succeeds 120s 5s Validate Number of VSGs ${vsg_count} |
| 147 | Set Suite Variable @{nova_ids} |
| 148 | Set Suite Variable ${s_tags} |
| 149 | Set Suite Variable ${c_tags} |
| 150 | |
| 151 | Validate Number of VSGs |
| 152 | [Arguments] ${count} |
| 153 | ${novalist}= Run . /opt/cord_profile/admin-openrc.sh; nova list --all-tenants | awk '{print $2}' | grep '[a-z]' |
| 154 | Log ${novalist} |
| 155 | @{nova_ids}= Split To Lines ${novalist} |
| 156 | ${vsgCount}= Get Length ${nova_ids} |
| 157 | Should Be Equal ${vsgCount} ${count} |
| 158 | [Return] @{nova_ids} |
| 159 | |
| 160 | Instances ACTIVE |
| 161 | : FOR ${nova_id} IN @{nova_ids} |
| 162 | \ ${status}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep status | awk '{print $4}' |
| 163 | \ Should Be Equal ${status} ACTIVE |
| 164 | |
| 165 | Validate Ext Connectivity |
| 166 | [Arguments] ${compute_node} ${vsg_ip} |
| 167 | ${ping_ext_result}= Run ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu ${compute_node}" ubuntu@${vsg_ip} "ping -c 3 8.8.8.8" |
| 168 | Should Contain ${ping_ext_result} 64 bytes from 8.8.8.8 |
| 169 | Should Not Contain ${ping_ext_result} 100% packet loss |
| 170 | |
| 171 | Validate VCPE Container is Up |
| 172 | [Arguments] ${compute_node} ${vsg_ip} |
| 173 | ${docker_containers}= Run ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu ${compute_node}" ubuntu@${vsg_ip} sudo docker ps | wc -l |
| 174 | Should Not Contain ${docker_containers} 0 |