IPv6: refactor Collect VM IPv6 SLAAC Addresses 41/59941/29
authorValentina Krasnobaeva <valentina.krasnobaeva@6wind.com>
Tue, 4 Jul 2017 16:42:51 +0000 (18:42 +0200)
committerJamo Luhrsen <jluhrsen@redhat.com>
Wed, 3 Jan 2018 00:45:54 +0000 (00:45 +0000)
Make Collect VM IPv6 SLAAC Addresses test more reliable: at first it
will take IPv6 address, which was saved for given VM in neutron
database, after that it will try to connect to VM at this address and
check an output of ip -6 a command.

Update arguments for 'Collect VM IPv6 SLAAC Addresses' call in
netvirt/vpnservice/vpn_basic_ipv6.robot test suite.

Change-Id: I4a1df2bd97372e60f361ffd5442b945a1cc528db
Signed-off-by: Valentina Krasnobaeva <valentina.krasnobaeva@6wind.com>
csit/libraries/OpenStackOperations.robot
csit/suites/netvirt/vpnservice/vpn_basic_ipv6.robot

index 3f521cd9504434a043d265e5dc37d7b2c4f6b1f6..21380901ce8026c683fae3129c6c6ddbc5057006 100644 (file)
@@ -390,23 +390,27 @@ Get VM IPs
     [Return]    @{vm_ips}    ${ips_and_console_log[1]}
 
 Collect VM IPv6 SLAAC Addresses
-    [Arguments]    ${fail_on_none}    ${prefix}    @{vm_list}
-    [Documentation]    Using the console-log on the provided ${vm_list} to search for the string "inet6" which
-    ...    correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
-    ${ip_list}    Create List    @{EMPTY}
+    [Arguments]    ${fail_on_none}    ${vm_list}    ${network}    ${subnet}
+    [Documentation]    For each VM parse output of "openstack server show" to get its IPv6 address from Neutron DB.
+    ...    Then try to connect to each VM by SSH and execute there "ip -6 a" command. This double-check allows to
+    ...    obtain and compare IP info (Neutron DB vs dnsmasque/ODL DHCP) and to test L2 connectivity as well.
+    ...    Returns an empty list if no IPv6 addresses found or if SSH connection fails.
+    ...    Otherwise, returns a list of IPv6 addresses.
+    ${ipv6_list}    Create List    @{EMPTY}
     : FOR    ${vm}    IN    @{vm_list}
-    \    Log    ${vm}
-    \    ${rc}    ${vm_ip_line}=    Run And Return Rc And Output    openstack console log show ${vm} | grep -i "inet6"
-    \    Log    ${vm_ip_line}
-    \    Log    ${rc}
-    \    @{vm_ip_list}    Get Regexp Matches    ${vm_ip_line}    ${prefix}
-    \    ${vm_ip_length}    Get Length    ${vm_ip_list}
-    \    Run Keyword If    ${vm_ip_length}>0    Append To List    ${ip_list}    @{vm_ip_list}[0]
-    \    ...    ELSE    Append To List    ${ip_list}    None
-    \    Log    ${ip_list}
-    Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${ip_list}    None
-    Log    ${ip_list}
-    [Return]    ${ip_list}
+    \    ${rc}    ${output}=    Run And Return Rc And Output    openstack server show ${vm} -f shell
+    \    Log    ${output}
+    \    Should Be True    '${rc}' == '0'
+    \    ${pattern}=    Replace String    ${subnet}    ::/64    (:[a-f0-9]{,4}){,4}
+    \    @{vm_ipv6}=    Get Regexp Matches    ${output}    ${pattern}
+    \    ${vm_ip_length}    Get Length    ${vm_ipv6}[0]
+    \    ${ipv6_data_from_vm}=    Run Keyword If    ${vm_ip_length}>0    Execute Command on VM Instance    ${network}    ${vm_ipv6[0]}
+    \    ...    ip -6 a
+    \    @{ipv6}=    Get Regexp Matches    ${ipv6_data_from_vm}    ${pattern}
+    \    ${ipv6_addr_list_length}    Get Length    @{ipv6}
+    \    Run Keyword If    ${ipv6_addr_list_length}>0    Append To List    ${ipv6_list}    ${ipv6[0]}
+    \    ...    ELSE    Append To List    ${ipv6_list}    None
+    [Return]    ${ipv6_list}
 
 View Vm Console
     [Arguments]    ${vm_instance_names}
index 30c3b3a16f0888e3e0286c33e187a2ba5ee40081..ba02bbde191970a685b9bdd2c0a5d0e0fc3c00f5 100644 (file)
@@ -97,12 +97,12 @@ Create Nova VMs
     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate    ${NETWORKS}    ${SUBNET_CIDRS}
     ${prefix_net10} =    Replace String    @{SUBNET_CIDRS}[0]    ::/64    (:[a-f0-9]{,4}){,4}
     ${status}    ${message}    Run Keyword And Ignore Error    BuiltIn.Wait Until Keyword Succeeds    3x    60s    OpenStackOperations.Collect VM IPv6 SLAAC Addresses
-    ...    true    ${prefix_net10}    @{NET_1_VMS}
+    ...    fail_on_none=true    vm_list=${NET_1_VMS}    network=@{NETWORKS}[0]    subnet=${prefix_net10}
     ${prefix_net20} =    Replace String    @{SUBNET_CIDRS}[1]    ::/64    (:[a-f0-9]{,4}){,4}
     ${status}    ${message}    Run Keyword And Ignore Error    BuiltIn.Wait Until Keyword Succeeds    3x    60s    OpenStackOperations.Collect VM IPv6 SLAAC Addresses
-    ...    true    ${prefix_net20}    @{NET_2_VMS}
-    ${VM_IP_NET10} =    OpenStackOperations.Collect VM IPv6 SLAAC Addresses    false    ${prefix_net10}    @{NET_1_VMS}
-    ${VM_IP_NET20} =    OpenStackOperations.Collect VM IPv6 SLAAC Addresses    false    ${prefix_net20}    @{NET_2_VMS}
+    ...    fail_on_none=true    vm_list=${NET_2_VMS}    network=@{NETWORKS}[1]    subnet=${prefix_net20}
+    ${VM_IP_NET10} =    OpenStackOperations.Collect VM IPv6 SLAAC Addresses    fail_on_none=false    vm_list=${NET_1_VMS}    network=@{NETWORKS}[0]    subnet=${prefix_net10}
+    ${VM_IP_NET20} =    OpenStackOperations.Collect VM IPv6 SLAAC Addresses    fail_on_none=false    vm_list=${NET_2_VMS}    network=@{NETWORKS}[1]    subnet=${prefix_net20}
     ${VM_INSTANCES} =    Collections.Combine Lists    ${NET_1_VMS}    ${NET_2_VMS}
     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET10}    ${VM_IP_NET20}
     ${LOOP_COUNT}    BuiltIn.Get Length    ${NET_1_VMS}