refactor dhcp function
[integration/test.git] / csit / suites / openstack / clustering / 02_l3_tests.robot
index 272558cbfcb0c0314a97075a9bc1459fc3971bfb..401784025dd9464f8eeadbd72f31ff4876c81b72 100644 (file)
@@ -1,27 +1,28 @@
 *** Settings ***
 Documentation     Test suite to check connectivity in L3 using routers.
-Suite Setup       Devstack Suite Setup Tests    source_pwd=yes
+Suite Setup       Devstack Suite Setup    source_pwd=yes
 Suite Teardown    Close All Connections
-Test Teardown     Run Keywords    Show Debugs    ${NET_1_VM_IPS}
-...               AND    Show Debugs    ${NET_2_VM_IPS}
-...               AND    Get OvsDebugInfo
+Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+Test Teardown     Get Test Teardown Debugs
 Library           SSHLibrary
 Library           OperatingSystem
 Library           RequestsLibrary
+Library           Collections
 Resource          ../../../libraries/Utils.robot
 Resource          ../../../libraries/OpenStackOperations.robot
 Resource          ../../../libraries/DevstackUtils.robot
+Resource          ../../../libraries/OVSDB.robot
+Resource          ../../../libraries/ClusterOvsdb.robot
 Resource          ../../../libraries/ClusterManagement.robot
+Resource          ../../../libraries/SetupUtils.robot
+Variables         ../../../variables/Variables.py
 
 *** Variables ***
 @{NETWORKS_NAME}    l3_net_1    l3_net_2
 @{SUBNETS_NAME}    l3_sub_net_1    l3_sub_net_2
 @{NET_1_VM_INSTANCES}    VmInstance1_net_1    VmInstance2_net_1    VmInstance3_net_1
 @{NET_2_VM_INSTANCES}    VmInstance1_net_2    VmInstance2_net_2    VmInstance3_net_2
-@{NET_1_VM_IPS}    90.0.0.3    90.0.0.4    90.0.0.5
-@{NET_2_VM_IPS}    100.0.0.3    100.0.0.4    100.0.0.5
 @{GATEWAY_IPS}    90.0.0.1    100.0.0.1
-@{DHCP_IPS}       90.0.0.2    100.0.0.2
 @{SUBNETS_RANGE}    90.0.0.0/24    100.0.0.0/24
 @{odl_1_and_2_down}    ${1}    ${2}
 @{odl_2_and_3_down}    ${2}    ${3}
@@ -50,8 +51,7 @@ Take Down ODL1
 
 Create Vm Instances For l3_net_1
     [Documentation]    Create Four Vm instances using flavor and image names for a network.
-    OpenStackOperations.Create Vm Instances    l3_net_1    ${NET_1_VM_INSTANCES}     sg=csit
-    [Teardown]    OpenStackOperations.Show Debugs    ${NET_1_VM_INSTANCES}
+    OpenStackOperations.Create Vm Instances    l3_net_1    ${NET_1_VM_INSTANCES}    sg=csit
 
 Bring Up ODL1
     [Documentation]    Bring up ODL1 again
@@ -63,8 +63,38 @@ Take Down ODL2
 
 Create Vm Instances For l3_net_2
     [Documentation]    Create Four Vm instances using flavor and image names for a network.
-    OpenStackOperations.Create Vm Instances    l3_net_2    ${NET_2_VM_INSTANCES}     sg=csit
-    [Teardown]    Show Debugs    ${NET_2_VM_INSTANCES}
+    OpenStackOperations.Create Vm Instances    l3_net_2    ${NET_2_VM_INSTANCES}    sg=csit
+
+Check Vm Instances Have Ip Address
+    [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
+    ...    We are polling first and longest on the last VM created assuming that if it's received it's address
+    ...    already the other instances should have theirs already or at least shortly thereafter.
+    # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
+    # for dhcp addresses
+    : FOR    ${vm}    IN    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
+    \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
+    ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
+    ...    true    @{NET_1_VM_INSTANCES}
+    ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
+    ...    true    @{NET_2_VM_INSTANCES}
+    ${NET2_L3_VM_IPS}    ${NET2_DHCP_IP}    Collect VM IP Addresses    false    @{NET_2_VM_INSTANCES}
+    ${NET1_L3_VM_IPS}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{NET_1_VM_INSTANCES}
+    ${VM_INSTANCES}=    Collections.Combine Lists    ${NET_1_VM_INSTANCES}    ${NET_2_VM_INSTANCES}
+    ${VM_IPS}=    Collections.Combine Lists    ${NET1_L3_VM_IPS}    ${NET2_L3_VM_IPS}
+    ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
+    : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
+    \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
+    \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
+    Set Suite Variable    ${NET1_L3_VM_IPS}
+    Set Suite Variable    ${NET2_L3_VM_IPS}
+    Set Suite Variable    ${NET1_DHCP_IP}
+    Set Suite Variable    ${NET2_DHCP_IP}
+    Should Not Contain    ${NET1_L3_VM_IPS}    None
+    Should Not Contain    ${NET2_L3_VM_IPS}    None
+    Should Not Contain    ${NET1_DHCP_IP}    None
+    Should Not Contain    ${NET2_DHCP_IP}    None
+    [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
+    ...    AND    Get Test Teardown Debugs
 
 Bring Up ODL2
     [Documentation]    Bring up ODL2 again
@@ -77,6 +107,7 @@ Take Down ODL3
 Create Router router_2
     [Documentation]    Create Router and Add Interface to the subnets. this fails sometimes.
     OpenStackOperations.Create Router    router_2
+    [Teardown]    Report_Failure_Due_To_Bug    6117
 
 Create Router router_3
     [Documentation]    Create Router and Add Interface to the subnets.
@@ -99,64 +130,53 @@ Bring Up ODL3
 
 Ping Vm Instance1 In l3_net_2 From l3_net_1
     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
-    Get OvsDebugInfo
-    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET_2_VM_IPS}[0]
+    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[0]
 
 Ping Vm Instance2 In l3_net_2 From l3_net_1
     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
-    Get OvsDebugInfo
-    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET_2_VM_IPS}[1]
+    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[1]
 
 Ping Vm Instance3 In l3_net_2 From l3_net_1
     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
-    Get OvsDebugInfo
-    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET_2_VM_IPS}[2]
+    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[2]
 
 Ping Vm Instance1 In l3_net_1 From l3_net_2
     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
-    Get OvsDebugInfo
-    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET_1_VM_IPS}[0]
+    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[0]
 
 Ping Vm Instance2 In l3_net_1 From l3_net_2
     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
-    Get OvsDebugInfo
-    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET_1_VM_IPS}[1]
+    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[1]
 
 Ping Vm Instance3 In l3_net_1 From l3_net_2
     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
-    Get OvsDebugInfo
-    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET_1_VM_IPS}[2]
+    OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[2]
 
 Take Down ODL1 and ODL2
     [Documentation]    Kill the karaf in First and Second Controller
     ClusterManagement.Kill Members From List Or All    ${odl_1_and_2_down}
+    [Teardown]    Get OvsDebugInfo
 
 Connectivity Tests From Vm Instance1 In l3_net_1
-    [Documentation]    Logging to the vm instance using generated key pair.
-    ${dst_ip_list}=    Create List    @{NET_1_VM_IPS}[1]    @{DHCP_IPS}[0]    @{NET_1_VM_IPS}[2]
+    [Documentation]    ssh to the VM instance and test operations.
+    ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
     Log    ${dst_ip_list}
-    ${other_dst_ip_list}=    Create List    @{NET_2_VM_IPS}[0]    @{DHCP_IPS}[1]    @{NET_2_VM_IPS}[2]    @{NET_2_VM_IPS}[1]
-    Log    ${other_dst_ip_list}
-    Get OvsDebugInfo
-    OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET_1_VM_IPS}[0]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+    OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[0]    ${dst_ip_list}
+    [Teardown]    Get OvsDebugInfo
 
 Connectivity Tests From Vm Instance2 In l3_net_1
-    [Documentation]    Logging to the vm instance using generated key pair.
-    ${dst_ip_list}=    Create List    @{NET_1_VM_IPS}[0]    @{DHCP_IPS}[0]    @{NET_1_VM_IPS}[2]
+    [Documentation]    ssh to the VM instance and test operations.
+    ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
     Log    ${dst_ip_list}
-    ${other_dst_ip_list}=    Create List    @{NET_2_VM_IPS}[0]    @{DHCP_IPS}[1]    @{NET_2_VM_IPS}[2]
-    Log    ${other_dst_ip_list}
-    Get OvsDebugInfo
-    OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET_1_VM_IPS}[1]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+    OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[1]    ${dst_ip_list}
+    [Teardown]    Get OvsDebugInfo
 
 Connectivity Tests From Vm Instance3 In l3_net_1
-    [Documentation]    Logging to the vm instance using generated key pair.
-    ${dst_ip_list}=    Create List    @{NET_1_VM_IPS}[0]    @{DHCP_IPS}[0]    @{NET_1_VM_IPS}[1]
+    [Documentation]    ssh to the VM instance and test operations.
+    ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
     Log    ${dst_ip_list}
-    ${other_dst_ip_list}=    Create List    @{NET_2_VM_IPS}[0]    @{DHCP_IPS}[1]    @{NET_2_VM_IPS}[2]
-    Log    ${other_dst_ip_list}
-    Get OvsDebugInfo
-    OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET_1_VM_IPS}[2]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+    OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[2]    ${dst_ip_list}
+    [Teardown]    Get OvsDebugInfo
 
 Bring Up ODL1 and ODL2
     [Documentation]    Bring up ODL1 and ODL2 again
@@ -165,33 +185,28 @@ Bring Up ODL1 and ODL2
 Take Down ODL2 and ODL3
     [Documentation]    Kill the karaf in First and Second Controller
     ClusterManagement.Kill Members From List Or All    ${odl_2_and_3_down}
+    [Teardown]    Get OvsDebugInfo
 
 Connectivity Tests From Vm Instance1 In l3_net_2
-    [Documentation]    Logging to the vm instance using generated key pair.
-    ${dst_ip_list}=    Create List    @{NET_2_VM_IPS}[1]    @{DHCP_IPS}[1]    @{NET_2_VM_IPS}[2]
+    [Documentation]    ssh to the VM instance and test operations.
+    ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
     Log    ${dst_ip_list}
-    ${other_dst_ip_list}=    Create List    @{NET_1_VM_IPS}[0]    @{DHCP_IPS}[0]    @{NET_1_VM_IPS}[1]    @{NET_1_VM_IPS}[2]
-    Log    ${other_dst_ip_list}
-    Get OvsDebugInfo
-    OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET_2_VM_IPS}[0]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+    OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[0]    ${dst_ip_list}
+    [Teardown]    Get OvsDebugInfo
 
 Connectivity Tests From Vm Instance2 In l3_net_2
-    [Documentation]    Logging to the vm instance using generated key pair.
-    ${dst_ip_list}=    Create List    @{NET_2_VM_IPS}[0]    @{DHCP_IPS}[1]    @{NET_2_VM_IPS}[2]
+    [Documentation]    ssh to the VM instance and test operations.
+    ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
     Log    ${dst_ip_list}
-    ${other_dst_ip_list}=    Create List    @{NET_1_VM_IPS}[0]    @{DHCP_IPS}[0]    @{NET_1_VM_IPS}[1]    @{NET_1_VM_IPS}[2]
-    Log    ${other_dst_ip_list}
-    Get OvsDebugInfo
-    OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET_2_VM_IPS}[1]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+    OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[1]    ${dst_ip_list}
+    [Teardown]    Get OvsDebugInfo
 
 Connectivity Tests From Vm Instance3 In l3_net_2
-    [Documentation]    Logging to the vm instance using generated key pair.
-    ${dst_ip_list}=    Create List    @{NET_2_VM_IPS}[0]    @{DHCP_IPS}[1]    @{NET_2_VM_IPS}[1]
+    [Documentation]    ssh to the VM instance and test operations.
+    ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
     Log    ${dst_ip_list}
-    ${other_dst_ip_list}=    Create List    @{NET_1_VM_IPS}[0]    @{DHCP_IPS}[0]    @{NET_1_VM_IPS}[1]    @{NET_1_VM_IPS}[2]
-    Log    ${other_dst_ip_list}
-    Get OvsDebugInfo
-    OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET_2_VM_IPS}[2]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+    OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[2]    ${dst_ip_list}
+    [Teardown]    Get OvsDebugInfo
 
 Bring Up ODL2 and ODL3
     [Documentation]    Bring up ODL2 and ODL3 again.