blob: e3f5d22faa62a2b7eda42908b5f6386444749b09 [file] [log] [blame]
Kailash Khalasiecf30142018-01-24 15:16:45 -08001# 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 Khalasi9b311092018-02-08 11:26:37 -080016Suite Setup Setup
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -080017Suite Teardown Teardown
Kailash Khalasi9b311092018-02-08 11:26:37 -080018Test Timeout 10 minutes
Kailash Khalasiecf30142018-01-24 15:16:45 -080019Documentation Validates external connectivity from Cord-Tester Container through VSG Subscriber
20Library OperatingSystem
21Library SSHLibrary
22Library /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/utils.py
23Library /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/onosUtils.py
24Library /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/openstackUtils.py
25Resource /opt/cord/test/cord-tester/src/test/cord-api/Framework/utils/utils.robot
26
27*** Variables ***
Kailash Khalasi9b311092018-02-08 11:26:37 -080028${pod} qct-pod1.yml
Kailash Khalasid34f58a2018-03-01 21:27:17 -080029${vsg_data_file} /opt/cord/test/cord-tester/src/test/cord-api/Tests/data/Ch_Subscriber.json
Kailash Khalasiecf30142018-01-24 15:16:45 -080030
31*** Test Cases ***
Kailash Khalasi9b311092018-02-08 11:26:37 -080032Validate Instances are ACTIVE
33 [Documentation] Validates that all instances are ACTIVE
34 Wait Until Keyword Succeeds 300s 5s Instances ACTIVE
35
36Validate Connectivity to All VSGs via Mgmt Interface
37 [Documentation] Validates that all given vsg instances are reachable through the mgmt interfaces
38 ##Loop through nova ids, get mgmt ips + compute nodes, ssh into compute node, and validate ping to mgmt_ip
39 : FOR ${nova_id} IN @{nova_ids}
40 \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}'
41 \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}'
42 \ ${ping_result}= Run ssh ubuntu@${node} ping -c 1 ${mgmt_ip}
43 \ Should Contain ${ping_result} 64 bytes from ${mgmt_ip}
44 \ Should Not Contain ${ping_result} 100% packet loss
45
46Validate VSG External Connectivity
47 [Documentation] Validates that the given vsg instances have external connectivity
48 : FOR ${nova_id} IN @{nova_ids}
49 \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}'
50 \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}'
51 \ Wait Until Keyword Succeeds 300s 5s Validate Ext Connectivity ${node} ${mgmt_ip}
52
Kailash Khalasiecf30142018-01-24 15:16:45 -080053Configure X-Connects for 3 Subscribers
Kailash Khalasi9b311092018-02-08 11:26:37 -080054 [Documentation] Configures the cross connect on the fabric switch with s-tags for the subscribers created via control-plane tests on the correct ports
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -080055 [Tags] xconnect dataplane
Kailash Khalasiecf30142018-01-24 15:16:45 -080056 ${netcfg_init}= onosUtils.onos_command_execute onos-fabric 8101 netcfg
57 Log ${netcfg_init}
58 Run http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/network/configuration/
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -080059 Sleep 15
Kailash Khalasiecf30142018-01-24 15:16:45 -080060 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 Khalasi29ffe5e2018-02-09 13:34:31 -080061 Sleep 15
Kailash Khalasiecf30142018-01-24 15:16:45 -080062 Run http -a onos:rocks DELETE http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -080063 Sleep 15
Kailash Khalasiecf30142018-01-24 15:16:45 -080064 Run http -a onos:rocks POST http://onos-fabric:8181/onos/v1/applications/org.onosproject.segmentrouting/active
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -080065 Sleep 15
Kailash Khalasiecf30142018-01-24 15:16:45 -080066 ${netcfg}= onosUtils.onos_command_execute onos-fabric 8101 netcfg
67 Log ${netcfg}
68 Should Contain ${netcfg} vsg-1
69 Should Contain ${netcfg} vsg-2
70 Should Contain ${netcfg} vsg-3
Kailash Khalasi9b311092018-02-08 11:26:37 -080071 Should Contain ${netcfg} "vlan" : ${s_tags[0]}
72 Should Contain ${netcfg} "vlan" : ${s_tags[1]}
73 Should Contain ${netcfg} "vlan" : ${s_tags[2]}
74
75Validate VSG External Connectivity Again
76 [Documentation] Validates that the given vsg instances have external connectivity even after onos-fabric has been re-configured
77 : FOR ${nova_id} IN @{nova_ids}
78 \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}'
79 \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}'
80 \ Wait Until Keyword Succeeds 300s 5s Validate Ext Connectivity ${node} ${mgmt_ip}
81
82Validate VCPE Containers
83 [Documentation] Validates that vcpes containers are up in each vsg instance
84 : FOR ${nova_id} IN @{nova_ids}
85 \ ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}'
86 \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}'
87 \ Wait Until Keyword Succeeds 800s 5s Validate VCPE Container is Up ${node} ${mgmt_ip}
Kailash Khalasiecf30142018-01-24 15:16:45 -080088
89Get VSG Subscriber and Tags
90 [Documentation] Retrieves compute node connected on leaf-1 and s/c tags for that particular subscriber
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -080091 [Tags] dataplane
Kailash Khalasiecf30142018-01-24 15:16:45 -080092 ${cmd}= Set Variable cordvtn-nodes | grep 10.6.1
93 ${cnode}= onosUtils.onos_command_execute onos-cord 8102 ${cmd}
94 @{cnode_on_leaf_1}= Split String ${cnode}
95 ${novalist}= Run . /opt/cord_profile/admin-openrc.sh; nova list --all-tenants | awk '{print $2}' | grep '[a-z]'
96 Log ${novalist}
97 @{nova_ids}= Split To Lines ${novalist}
98 : FOR ${nova_id} IN @{nova_ids}
99 \ ${node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}'
100 \ Run Keyword If '${node}' == '${cnode_on_leaf_1[0]}' Exit For Loop
101 ${mgmt_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}'
102 ## Get s/c tags for vsg
Kailash Khalasi9b311092018-02-08 11:26:37 -0800103 ${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 Khalasiecf30142018-01-24 15:16:45 -0800104 @{tags}= Split String ${result} -
105 ${s_tag}= Set Variable ${tags[1]}
106 ${c_tag}= Set Variable ${tags[2]}
107 Set Suite Variable ${s_tag}
108 Set Suite Variable ${c_tag}
109
110Execute Dataplane Test
111 [Documentation] Configures interfaces on cord-tester container to connect to vsg instance and validates traffic
Kailash Khalasi9b311092018-02-08 11:26:37 -0800112 [Tags] dataplane
Kailash Khalasiecf30142018-01-24 15:16:45 -0800113 ${i_num}= Set Variable If
Kailash Khalasi9b311092018-02-08 11:26:37 -0800114 ... '${s_tag}' == '${s_tags[0]}' 1
115 ... '${s_tag}' == '${s_tags[1]}' 2
116 ... '${s_tag}' == '${s_tags[2]}' 3
Kailash Khalasiecf30142018-01-24 15:16:45 -0800117 ${output}= Run docker exec cord-tester1 bash -c "sudo echo 'nameserver 192.168.0.1' > /etc/resolv.conf"
118 ${output}= Run docker exec cord-tester1 bash -c "sudo dhclient vcpe${i_num}.${s_tag}.${c_tag}"
119 Sleep 5
120 ${output}= Run docker exec cord-tester1 bash -c "sudo route add default gw 192.168.0.1 vcpe${i_num}.${s_tag}.${c_tag}"
121 ${output}= Run docker exec cord-tester1 bash -c "ping -c 3 -I vcpe${i_num}.${s_tag}.${c_tag} 8.8.8.8"
122 Log To Console \n ${output}
123 Should Contain ${output} 64 bytes from 8.8.8.8
Kailash Khalasi9b311092018-02-08 11:26:37 -0800124 Should Not Contain ${output} 100% packet loss
125
126*** Keywords ***
127Setup
128 [Documentation] Gets global vars for test suite
129 @{s_tags}= Create List
130 @{c_tags}= Create List
131 ${netcfg_file}= Set Variable If
132 ... '${pod}' == 'qct-pod1.yml' qct_fabric_test_netcfg.json
133 ... '${pod}' == 'flex-pod1.yml' flex_fabric_test_netcfg.json
134 ... '${pod}' == 'calix-pod1.yml' calix_fabric_test_netcfg.json
135 Set Suite Variable ${netcfg_file}
Kailash Khalasid34f58a2018-03-01 21:27:17 -0800136 ${subscriberList} = utils.jsonToList ${vsg_data_file} SubscriberInfo
137 Set Suite Variable ${slist} ${subscriberList}
138 ${voltTenantList} = Get Variable Value ${slist}
139 ${vsg_count}= Get Length ${slist}
Kailash Khalasi9b311092018-02-08 11:26:37 -0800140 Set Suite Variable ${vsg_count}
141 : FOR ${INDEX} IN RANGE 0 ${vsg_count}
Kailash Khalasid34f58a2018-03-01 21:27:17 -0800142 \ ${s_tag}= Get From Dictionary ${slist[${INDEX}]} s_tag
143 \ ${c_tag}= Get From Dictionary ${slist[${INDEX}]} c_tag
Kailash Khalasi9b311092018-02-08 11:26:37 -0800144 \ 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
Kailash Khalasi29ffe5e2018-02-09 13:34:31 -0800151Teardown
152 ${cmd}= Set Variable log:display
153 ${onos_logs}= onosUtils.onos_command_execute onos-fabric 8101 ${cmd}
154 Log ${onos_logs}
155
Kailash Khalasi9b311092018-02-08 11:26:37 -0800156Validate Number of VSGs
157 [Arguments] ${count}
158 ${novalist}= Run . /opt/cord_profile/admin-openrc.sh; nova list --all-tenants | awk '{print $2}' | grep '[a-z]'
159 Log ${novalist}
160 @{nova_ids}= Split To Lines ${novalist}
161 ${vsgCount}= Get Length ${nova_ids}
162 Should Be Equal ${vsgCount} ${count}
163 [Return] @{nova_ids}
164
165Instances ACTIVE
166 : FOR ${nova_id} IN @{nova_ids}
167 \ ${status}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep status | awk '{print $4}'
168 \ Should Be Equal ${status} ACTIVE
169
170Validate Ext Connectivity
171 [Arguments] ${compute_node} ${vsg_ip}
172 ${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"
173 Should Contain ${ping_ext_result} 64 bytes from 8.8.8.8
174 Should Not Contain ${ping_ext_result} 100% packet loss
175
176Validate VCPE Container is Up
177 [Arguments] ${compute_node} ${vsg_ip}
178 ${docker_containers}= Run ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu ${compute_node}" ubuntu@${vsg_ip} sudo docker ps | wc -l
Kailash Khalasid34f58a2018-03-01 21:27:17 -0800179 Should Not Contain ${docker_containers} 0