Remove code for capwap
[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
5 Library             OperatingSystem
6 Library             RequestsLibrary
7 Library             SSHLibrary
8 Resource            ../../../libraries/ClusterManagement.robot
9 Resource            ../../../libraries/DevstackUtils.robot
10 Resource            ../../../libraries/KarafKeywords.robot
11 Resource            ../../../libraries/OpenStackOperations.robot
12 Resource            ../../../libraries/OVSDB.robot
13 Resource            ../../../libraries/SetupUtils.robot
14 Resource            ../../../libraries/Utils.robot
15
16 Suite Setup         Suite Setup
17 Suite Teardown      Upgrade Suite Teardown
18 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
19 Test Teardown       Get Test Teardown Debugs
20
21
22 *** Variables ***
23 ${SECURITY_GROUP}               upgrade_sg
24 @{NETWORKS}                     upgrade_net_1    upgrade_net_2
25 @{SUBNETS}                      upgrade_sub_1    upgrade_sub_2
26 @{NET_1_VMS}                    upgrade_net_1_vm_1    upgrade_net_1_vm_2
27 @{NET_2_VMS}                    upgrade_net_2_vm_1    upgrade_net_2_vm_2
28 @{SUBNETS_RANGE}                91.0.0.0/24    92.0.0.0/24
29 ${ROUTER}                       upgrade_router_1
30 ${TYPE}                         tun
31 ${PASSIVE_MANAGER}              ptcp:6641:127.0.0.1
32 @{DEBUG_LOG_COMPONENTS}
33 ...                             org.opendaylight.ovsdb
34 ...                             org.opendaylight.ovsdb.lib
35 ...                             org.opendaylight.netvirt
36 ${UPDATE_FLAG_PATH}             /restconf/config/odl-serviceutils-upgrade:upgrade-config
37 ${GET_ACTIVE_BUNDLE_URI}        /restconf/operations/arbitrator-reconcile:get-active-bundle
38 ${COMMIT_ACTIVE_BUNDLE_URI}     /restconf/operations/arbitrator-reconcile:commit-active-bundle
39 ${COMMIT_ACTIVE_BUNDLE_DIR}     ${CURDIR}/../../../variables/netvirt/commit_active_bundle
40 ${SET_BUNDLE_TIMEOUT}           sudo ovs-vsctl set O . other_config:bundle-idle-timeout=3600
41
42
43 *** Test Cases ***
44 Create Setup And Verify Instance Connectivity
45     [Documentation]    Create 2 VXLAN networks, subnets with 2 VMs each and a router. Ping all 4 VMs.
46     Check Resource Connectivity
47
48 Stop ODL
49     ClusterManagement.Stop_Members_From_List_Or_All
50
51 Disconnect OVS
52     [Documentation]    Delete OVS manager, controller and groups and tun ports
53     FOR    ${node}    IN    @{OS_ALL_IPS}
54         OVSDB.Delete OVS Manager    ${node}
55         OVSDB.Delete OVS Controller    ${node}
56         OVSDB.Delete Groups On Bridge    ${node}    ${INTEGRATION_BRIDGE}
57         OVSDB.Delete Ports On Bridge By Type    ${node}    ${INTEGRATION_BRIDGE}    ${TYPE}
58         Utils.Run Command On Remote System    ${node}    ${SET_BUNDLE_TIMEOUT}
59     END
60
61 Wipe Local Data
62     [Documentation]    Delete data/, journal/, snapshots/
63     ClusterManagement.Clean_Journals_Data_And_Snapshots_On_List_Or_All
64
65 Start ODL
66     [Documentation]    Start controller, wait for it to come "UP" and make sure netvirt is installed
67     ClusterManagement.Start_Members_From_List_Or_All    wait_for_sync=True
68     Wait Until Keyword Succeeds    100s    5s    Utils.Check Diagstatus
69     BuiltIn.Set_Suite_Variable    \${ClusterManagement__has_setup_run}    False
70     KarafKeywords.Verify_Feature_Is_Installed    odl-netvirt-openstack
71     Set Custom Component Logging To    DEBUG
72
73 Wait For Full Sync
74     [Documentation]    Wait for networking_odl to sync neutron configuration
75     Wait Until Keyword Succeeds    90s    5s    Canary Network Should Exist
76
77 Set Upgrade Flag
78     ${resp} =    RequestsLibrary.Put Request
79     ...    session
80     ...    ${UPDATE_FLAG_PATH}
81     ...    {"upgrade-config":{"upgradeInProgress":true}}
82     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
83
84 Set OVS Manager And Controller
85     [Documentation]    Set controller and manager on each OpenStack node and check that egress flows are present
86     FOR    ${node}    IN    @{OS_ALL_IPS}
87         Utils.Run Command On Remote System And Log
88         ...    ${node}
89         ...    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT} ${PASSIVE_MANAGER}
90     END
91     Wait Until Keyword Succeeds    60s    10s    Verify Bundle Active State
92     FOR    ${node}    IN    @{OS_ALL_IPS}
93         ${dpnid} =    OVSDB.Get DPID    ${node}
94         ${dpnid} =    BuiltIn.Convert To String    ${dpnid}
95         ${body} =    OperatingSystem.Get File    ${COMMIT_ACTIVE_BUNDLE_DIR}/data.json
96         ${body} =    Replace String    ${body}    DPNID    ${dpnid}
97         ${resp} =    RequestsLibrary.Post Request    session    ${COMMIT_ACTIVE_BUNDLE_URI}    data=${body}
98         BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
99     END
100     Wait Until Keyword Succeeds    180s    15s    Check OVS Nodes Have Egress Flows
101
102 UnSet Upgrade Flag
103     ${resp} =    RequestsLibrary.Put Request
104     ...    session
105     ...    ${UPDATE_FLAG_PATH}
106     ...    {"upgrade-config":{"upgradeInProgress":false}}
107     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
108
109 Check Connectivity With Previously Created Resources And br-int Info
110     [Documentation]    Check that pre-existing instance connectivity still works after the new controller is brought
111     ...    up and config is sync'd
112     Wait Until Keyword Succeeds    90s    10s    Check Resource Connectivity
113
114
115 *** Keywords ***
116 Suite Setup
117     OpenStackOperations.OpenStack Suite Setup
118     Create Resources
119     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}
120     OpenStackOperations.Get Suite Debugs
121
122 Create Resources
123     [Documentation]    Create 2 VXLAN networks, subnets with 2 VMs each and a router. Ping all 4 VMs.
124     FOR    ${net}    IN    @{NETWORKS}
125         OpenStackOperations.Create Network    ${net}
126     END
127     OpenStackOperations.Create SubNet    ${NETWORKS}[0]    ${SUBNETS}[0]    ${SUBNETS_RANGE}[0]
128     OpenStackOperations.Create SubNet    ${NETWORKS}[1]    ${SUBNETS}[1]    ${SUBNETS_RANGE}[1]
129     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
130     OpenStackOperations.Create Nano Flavor
131     FOR    ${vm}    IN    @{NET_1_VMS}
132         OpenStackOperations.Create Vm Instance On Compute Node
133         ...    ${NETWORKS}[0]
134         ...    ${vm}
135         ...    ${OS_CMP1_HOSTNAME}
136         ...    sg=${SECURITY_GROUP}
137     END
138     FOR    ${vm}    IN    @{NET_2_VMS}
139         OpenStackOperations.Create Vm Instance On Compute Node
140         ...    ${NETWORKS}[1]
141         ...    ${vm}
142         ...    ${OS_CMP2_HOSTNAME}
143         ...    sg=${SECURITY_GROUP}
144     END
145     OpenStackOperations.Create Router    ${ROUTER}
146     FOR    ${interface}    IN    @{SUBNETS}
147         OpenStackOperations.Add Router Interface    ${ROUTER}    ${interface}
148     END
149     @{NET1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
150     @{NET2_VM_IPS}    ${NET2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
151     BuiltIn.Set Suite Variable    @{NET1_VM_IPS}
152     BuiltIn.Set Suite Variable    @{NET2_VM_IPS}
153     BuiltIn.Should Not Contain    ${NET1_VM_IPS}    None
154     BuiltIn.Should Not Contain    ${NET2_VM_IPS}    None
155     BuiltIn.Should Not Contain    ${NET1_DHCP_IP}    None
156     BuiltIn.Should Not Contain    ${NET2_DHCP_IP}    None
157
158 Check Resource Connectivity
159     [Documentation]    Ping 2 VMs in the same net and 1 from another net.
160     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    ${NET1_VM_IPS}[0]
161     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    ${NET1_VM_IPS}[1]
162     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_1    ${NET2_VM_IPS}[0]
163     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    ${NET2_VM_IPS}[0]
164     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    ${NET2_VM_IPS}[1]
165     OpenStackOperations.Ping Vm From DHCP Namespace    upgrade_net_2    ${NET1_VM_IPS}[0]
166
167 Check OVS Nodes Have Egress Flows
168     [Documentation]    Loop over all openstack nodes to ensure they have the proper flows installed.
169     FOR    ${node}    IN    @{OS_ALL_IPS}
170         Does OVS Have Multiple Egress Flows    ${node}
171     END
172
173 Does OVS Have Multiple Egress Flows
174     [Documentation]    Verifies that at least 1 flow exists on the node for the ${EGRESS_L2_FWD_TABLE}
175     [Arguments]    ${ip}
176     ${flows} =    Utils.Run Command On Remote System And Log
177     ...    ${ip}
178     ...    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
179     ${egress_flows} =    String.Get Lines Containing String    ${flows}    table=${EGRESS_LPORT_DISPATCHER_TABLE}
180     ${num_egress_flows} =    String.Get Line Count    ${egress_flows}
181     BuiltIn.Should Be True    ${num_egress_flows} > 1
182
183 Set Custom Component Logging To
184     [Arguments]    ${level}
185     SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    ${level}    ${DEBUG_LOG_COMPONENTS}
186     KarafKeywords.Issue_Command_On_Karaf_Console    log:list
187
188 Canary Network Should Exist
189     OpenStackOperations.Get Neutron Network Rest    bd8db3a8-2b30-4083-a8b3-b3fd46401142
190
191 Upgrade Suite Teardown
192     Set Custom Component Logging To    INFO
193     OpenStackOperations.OpenStack Suite Teardown
194
195 Verify Bundle Active State
196     [Documentation]    Verify if the bundle is active for the node.
197     FOR    ${node}    IN    @{OS_ALL_IPS}
198         ${dpnid} =    OVSDB.Get DPID    ${node}
199         ${dpnid} =    BuiltIn.Convert To String    ${dpnid}
200         ${body} =    OperatingSystem.Get File    ${COMMIT_ACTIVE_BUNDLE_DIR}/data.json
201         ${body} =    Replace String    ${body}    DPNID    ${dpnid}
202         ${resp} =    RequestsLibrary.Post Request    session    ${GET_ACTIVE_BUNDLE_URI}    data=${body}
203         BuiltIn.Log    ${resp.text}
204         BuiltIn.Should Contain    ${resp.text}    "result":
205         BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
206     END