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