1b265962b2cc9659cc4005066b34ff4dc9b1a057
[integration/test.git] / csit / suites / netvirt / upgrade / upgrade.robot
1 *** Settings ***
2 Documentation     Test suite for ODL Upgrade. It is assumed that OLD + OpenStack
3 ...               integrated environment is deployed and ready.
4 Suite Setup       OpenStackOperations.OpenStack Suite Setup
5 Suite Teardown    Upgrade Suite Teardown
6 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
7 Test Teardown     Get Test Teardown Debugs
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Library           SSHLibrary
11 Resource          ../../../libraries/ClusterManagement.robot
12 Resource          ../../../libraries/DevstackUtils.robot
13 Resource          ../../../libraries/KarafKeywords.robot
14 Resource          ../../../libraries/OpenStackOperations.robot
15 Resource          ../../../libraries/OVSDB.robot
16 Resource          ../../../libraries/SetupUtils.robot
17 Resource          ../../../libraries/Utils.robot
18
19 *** Variables ***
20 ${SECURITY_GROUP}    upgrade_sg
21 @{NETWORKS}       upgrade_net_1    upgrade_net_2
22 @{SUBNETS}        upgrade_sub_1    upgrade_sub_2
23 @{NET_1_VMS}      upgrade_net_1_vm_1    upgrade_net_1_vm_2
24 @{NET_2_VMS}      upgrade_net_2_vm_1    upgrade_net_2_vm_2
25 @{SUBNETS_RANGE}    91.0.0.0/24    92.0.0.0/24
26 ${ROUTER}         upgrade_router_1
27 ${TYPE}           tun
28 ${PASSIVE_MANAGER}    ptcp:6641:127.0.0.1
29 @{DEBUG_LOG_COMPONENTS}    org.opendaylight.ovsdb    org.opendaylight.ovsdb.lib    org.opendaylight.netvirt    org.opendaylight.genius
30 ${UPDATE_FLAG_PATH}    /restconf/config/genius-mdsalutil:config
31
32 *** Test Cases ***
33 Create Setup And Verify Instance Connectivity
34     [Documentation]    Create 2 VXLAN networks, subnets with 2 VMs each and a router. Ping all 4 VMs.
35     Create Resources
36     Check Resource Connectivity
37     DevstackUtils.Set Node Data For Control Only Node Setup
38     Dump Debug With Annotations    POST_SETUP
39
40 Stop ODL
41     ClusterManagement.Stop_Members_From_List_Or_All
42
43 Disconnect OVS
44     [Documentation]    Delete OVS manager, controller and groups and tun ports
45     : FOR    ${node}    IN    @{OS_ALL_IPS}
46     \    OVSDB.Delete OVS Manager    ${node}
47     \    OVSDB.Delete OVS Controller    ${node}
48     \    OVSDB.Delete Groups On Bridge    ${node}    ${INTEGRATION_BRIDGE}
49     \    OVSDB.Delete Ports On Bridge By Type    ${node}    ${INTEGRATION_BRIDGE}    ${TYPE}
50
51 Wipe Local Data
52     [Documentation]    Delete data/, journal/, snapshots/
53     ClusterManagement.Clean_Journals_Data_And_Snapshots_On_List_Or_All
54
55 Start ODL
56     [Documentation]    Start controller, wait for it to come "UP" and make sure netvirt is installed
57     ClusterManagement.Start_Members_From_List_Or_All    wait_for_sync=True
58     Wait Until Keyword Succeeds    100s    5s    Utils.Check Diagstatus
59     BuiltIn.Set_Suite_Variable    \${ClusterManagement__has_setup_run}    False
60     KarafKeywords.Verify_Feature_Is_Installed    odl-netvirt-openstack
61     Set Custom Component Logging To    DEBUG
62
63 Wait For Full Sync
64     [Documentation]    Wait for networking_odl to sync neutron configuration
65     Wait Until Keyword Succeeds    90s    5s    Canary Network Should Exist
66
67 Set Upgrade Flag
68     ${resp} =    RequestsLibrary.Put Request    session    ${UPDATE_FLAG_PATH}    {"config":{"upgradeInProgress":true}}
69     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
70
71 Set OVS Manager And Controller
72     [Documentation]    Set controller and manager on each OpenStack node and check that egress flows are present
73     : FOR    ${node}    IN    @{OS_ALL_IPS}
74     \    Run Command On Remote System    ${node}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT} ${PASSIVE_MANAGER}
75     Wait Until Keyword Succeeds    180s    15s    Check OVS Nodes Have Egress Flows
76
77 UnSet Upgrade Flag
78     ${resp} =    RequestsLibrary.Put Request    session    ${UPDATE_FLAG_PATH}    {"config":{"upgradeInProgress":false}}
79     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
80
81 Check Connectivity With Previously Created Resources And br-int Info
82     [Documentation]    Check that pre-existing instance connectivity still works after the new controller is brought
83     ...    up and config is sync'd
84     Dump Debug With Annotations    POST_UPGRADE
85     Wait Until Keyword Succeeds    90s    10s    Check Resource Connectivity
86
87 *** Keywords ***
88 Create Resources
89     [Documentation]    Create 2 VXLAN networks, subnets with 2 VMs each and a router. Ping all 4 VMs.
90     : FOR    ${net}    IN    @{NETWORKS}
91     \    OpenStackOperations.Create Network    ${net}
92     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    @{SUBNETS_RANGE}[0]
93     OpenStackOperations.Create SubNet    @{NETWORKS}[1]    @{SUBNETS}[1]    @{SUBNETS_RANGE}[1]
94     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
95     OpenStackOperations.Create Nano Flavor
96     : FOR    ${vm}    IN    @{NET_1_VMS}
97     \    OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    ${vm}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
98     : FOR    ${vm}    IN    @{NET_2_VMS}
99     \    OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    ${vm}    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
100     OpenStackOperations.Create Router    ${ROUTER}
101     : FOR    ${interface}    IN    @{SUBNETS}
102     \    OpenStackOperations.Add Router Interface    ${ROUTER}    ${interface}
103     @{NET1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
104     @{NET2_VM_IPS}    ${NET2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
105     BuiltIn.Set Suite Variable    @{NET1_VM_IPS}
106     BuiltIn.Set Suite Variable    @{NET2_VM_IPS}
107     BuiltIn.Should Not Contain    ${NET1_VM_IPS}    None
108     BuiltIn.Should Not Contain    ${NET2_VM_IPS}    None
109     BuiltIn.Should Not Contain    ${NET1_DHCP_IP}    None
110     BuiltIn.Should Not Contain    ${NET2_DHCP_IP}    None
111
112 Check Resource Connectivity
113     [Documentation]    Ping 2 VMs in the same net and 1 from another net.
114     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    @{NET1_VM_IPS}[0]
115     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    @{NET1_VM_IPS}[1]
116     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    @{NET2_VM_IPS}[0]
117     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    @{NET2_VM_IPS}[0]
118     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    @{NET2_VM_IPS}[1]
119     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    @{NET1_VM_IPS}[0]
120
121 Check OVS Nodes Have Egress Flows
122     [Documentation]    Loop over all openstack nodes to ensure they have the proper flows installed.
123     : FOR    ${node}    IN    @{OS_ALL_IPS}
124     \    Does OVS Have Multiple Egress Flows    ${node}
125
126 Does OVS Have Multiple Egress Flows
127     [Arguments]    ${ip}
128     [Documentation]    Verifies that at least 1 flow exists on the node for the ${EGRESS_L2_FWD_TABLE}
129     ${flows} =    Utils.Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
130     ${egress_flows} =    String.Get Lines Containing String    ${flows}    table=${EGRESS_LPORT_DISPATCHER_TABLE}
131     ${num_egress_flows} =    String.Get Line Count    ${egress_flows}
132     BuiltIn.Should Be True    ${num_egress_flows} > 1
133
134 Set Custom Component Logging To
135     [Arguments]    ${level}
136     SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    ${level}    ${DEBUG_LOG_COMPONENTS}
137     KarafKeywords.Issue_Command_On_Karaf_Console    log:list
138
139 Dump Debug With Annotations
140     [Arguments]    ${tag}
141     [Documentation]    Dump tons of debug logs for each OS node but also emit tags to make parsing easier
142     Builtin.Log    Start dumping at phase ${tag}
143     : FOR    ${node}    IN    @{OS_ALL_IPS}
144     \    ${conn_id} =    DevstackUtils.Open Connection    ${node}_CONNECTION_NAME    ${node}
145     \    Builtin.Log    Start dumping for ${node} at phase ${tag}
146     \    OpenStackOperations.Get DumpFlows And Ovsconfig    ${conn_id}
147     \    Builtin.Log    End dumping for ${node} at phase ${tag}
148     \    SSHLibrary.Close Connection
149     Builtin.Log    End dumping at phase ${tag}
150
151 Canary Network Should Exist
152     OpenStackOperations.Get Neutron Network Rest    bd8db3a8-2b30-4083-a8b3-b3fd46401142
153
154 Upgrade Suite Teardown
155     Set Custom Component Logging To    INFO
156     OpenStackOperations.OpenStack Suite Teardown