Upgrade RF syntax for v3.2 compatibility
[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       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/odl-serviceutils-upgrade:upgrade-config
31 ${COMMIT_ACTIVE_BUNDLE_URI}    /restconf/operations/arbitrator-reconcile:commit-active-bundle
32 ${COMMIT_ACTIVE_BUNDLE_DIR}    ${CURDIR}/../../../variables/netvirt/commit_active_bundle
33
34 *** Test Cases ***
35 Create Setup And Verify Instance Connectivity
36     [Documentation]    Create 2 VXLAN networks, subnets with 2 VMs each and a router. Ping all 4 VMs.
37     Check Resource Connectivity
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     END
51
52 Wipe Local Data
53     [Documentation]    Delete data/, journal/, snapshots/
54     ClusterManagement.Clean_Journals_Data_And_Snapshots_On_List_Or_All
55
56 Start ODL
57     [Documentation]    Start controller, wait for it to come "UP" and make sure netvirt is installed
58     ClusterManagement.Start_Members_From_List_Or_All    wait_for_sync=True
59     Wait Until Keyword Succeeds    100s    5s    Utils.Check Diagstatus
60     BuiltIn.Set_Suite_Variable    \${ClusterManagement__has_setup_run}    False
61     KarafKeywords.Verify_Feature_Is_Installed    odl-netvirt-openstack
62     Set Custom Component Logging To    DEBUG
63
64 Wait For Full Sync
65     [Documentation]    Wait for networking_odl to sync neutron configuration
66     Wait Until Keyword Succeeds    90s    5s    Canary Network Should Exist
67
68 Set Upgrade Flag
69     ${resp} =    RequestsLibrary.Put Request    session    ${UPDATE_FLAG_PATH}    {"upgrade-config":{"upgradeInProgress":true}}
70     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
71     FOR    ${node}    IN    @{OS_ALL_IPS}
72         ${dpnid} =    OVSDB.Get DPID    ${node}
73         ${body} =    OperatingSystem.Get File    ${COMMIT_ACTIVE_BUNDLE_DIR}/data.json
74         ${body} =    Replace String    ${body}    DPNID    ${dpnid}
75         ${resp} =    RequestsLibrary.Post Request    session    ${COMMIT_ACTIVE_BUNDLE_URI}    data=${body}
76         BuiltIn.Log    ${resp.content}
77         BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
78     END
79
80 Set OVS Manager And Controller
81     [Documentation]    Set controller and manager on each OpenStack node and check that egress flows are present
82     FOR    ${node}    IN    @{OS_ALL_IPS}
83         Utils.Run Command On Remote System And Log    ${node}    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT} ${PASSIVE_MANAGER}
84     END
85     Wait Until Keyword Succeeds    180s    15s    Check OVS Nodes Have Egress Flows
86
87 UnSet Upgrade Flag
88     ${resp} =    RequestsLibrary.Put Request    session    ${UPDATE_FLAG_PATH}    {"upgrade-config":{"upgradeInProgress":false}}
89     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
90
91 Check Connectivity With Previously Created Resources And br-int Info
92     [Documentation]    Check that pre-existing instance connectivity still works after the new controller is brought
93     ...    up and config is sync'd
94     Dump Debug With Annotations    POST_UPGRADE
95     Wait Until Keyword Succeeds    90s    10s    Check Resource Connectivity
96
97 *** Keywords ***
98 Suite Setup
99     OpenStackOperations.OpenStack Suite Setup
100     Create Resources
101     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}
102     OpenStackOperations.Get Suite Debugs
103
104 Create Resources
105     [Documentation]    Create 2 VXLAN networks, subnets with 2 VMs each and a router. Ping all 4 VMs.
106     FOR    ${net}    IN    @{NETWORKS}
107         OpenStackOperations.Create Network    ${net}
108     END
109     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    @{SUBNETS_RANGE}[0]
110     OpenStackOperations.Create SubNet    @{NETWORKS}[1]    @{SUBNETS}[1]    @{SUBNETS_RANGE}[1]
111     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
112     OpenStackOperations.Create Nano Flavor
113     FOR    ${vm}    IN    @{NET_1_VMS}
114         OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    ${vm}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
115     END
116     FOR    ${vm}    IN    @{NET_2_VMS}
117         OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    ${vm}    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
118     END
119     OpenStackOperations.Create Router    ${ROUTER}
120     FOR    ${interface}    IN    @{SUBNETS}
121         OpenStackOperations.Add Router Interface    ${ROUTER}    ${interface}
122     END
123     @{NET1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
124     @{NET2_VM_IPS}    ${NET2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
125     BuiltIn.Set Suite Variable    @{NET1_VM_IPS}
126     BuiltIn.Set Suite Variable    @{NET2_VM_IPS}
127     BuiltIn.Should Not Contain    ${NET1_VM_IPS}    None
128     BuiltIn.Should Not Contain    ${NET2_VM_IPS}    None
129     BuiltIn.Should Not Contain    ${NET1_DHCP_IP}    None
130     BuiltIn.Should Not Contain    ${NET2_DHCP_IP}    None
131
132 Check Resource Connectivity
133     [Documentation]    Ping 2 VMs in the same net and 1 from another net.
134     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    @{NET1_VM_IPS}[0]
135     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    @{NET1_VM_IPS}[1]
136     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    @{NET2_VM_IPS}[0]
137     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    @{NET2_VM_IPS}[0]
138     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    @{NET2_VM_IPS}[1]
139     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    @{NET1_VM_IPS}[0]
140
141 Check OVS Nodes Have Egress Flows
142     [Documentation]    Loop over all openstack nodes to ensure they have the proper flows installed.
143     FOR    ${node}    IN    @{OS_ALL_IPS}
144         Does OVS Have Multiple Egress Flows    ${node}
145     END
146
147 Does OVS Have Multiple Egress Flows
148     [Arguments]    ${ip}
149     [Documentation]    Verifies that at least 1 flow exists on the node for the ${EGRESS_L2_FWD_TABLE}
150     ${flows} =    Utils.Run Command On Remote System And Log    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
151     ${egress_flows} =    String.Get Lines Containing String    ${flows}    table=${EGRESS_LPORT_DISPATCHER_TABLE}
152     ${num_egress_flows} =    String.Get Line Count    ${egress_flows}
153     BuiltIn.Should Be True    ${num_egress_flows} > 1
154
155 Set Custom Component Logging To
156     [Arguments]    ${level}
157     SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    ${level}    ${DEBUG_LOG_COMPONENTS}
158     KarafKeywords.Issue_Command_On_Karaf_Console    log:list
159
160 Dump Debug With Annotations
161     [Arguments]    ${tag}
162     [Documentation]    Dump tons of debug logs for each OS node but also emit tags to make parsing easier
163     Builtin.Log    Start dumping at phase ${tag}
164     FOR    ${node}    IN    @{OS_ALL_IPS}
165         ${conn_id} =    DevstackUtils.Open Connection    ${node}_CONNECTION_NAME    ${node}
166         Builtin.Log    Start dumping for ${node} at phase ${tag}
167         OpenStackOperations.Get DumpFlows And Ovsconfig    ${conn_id}
168         Builtin.Log    End dumping for ${node} at phase ${tag}
169         SSHLibrary.Close Connection
170     END
171     Builtin.Log    End dumping at phase ${tag}
172
173 Canary Network Should Exist
174     OpenStackOperations.Get Neutron Network Rest    bd8db3a8-2b30-4083-a8b3-b3fd46401142
175
176 Upgrade Suite Teardown
177     Set Custom Component Logging To    INFO
178     OpenStackOperations.OpenStack Suite Teardown