ad223fcdf2fcc4bc8ccddb9d00632908e424b883
[integration/test.git] / csit / suites / netvirt / host_route / host_route_handling.robot
1 *** Settings ***
2 Documentation     Test suite for VM based Host Route Handling
3 Suite Setup       Create Setup
4 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
5 Library           Collections
6 Library           RequestsLibrary
7 Library           SSHLibrary
8 Library           String
9 Resource          ../../../libraries/DevstackUtils.robot
10 Resource          ../../../libraries/OpenStackOperations.robot
11 Resource          ../../../libraries/VpnOperations.robot
12 Resource          ../../../variables/netvirt/Variables.robot
13 Resource          ../../../variables/Variables.robot
14
15 *** Variables ***
16 @{NETWORKS}       host_route_network_1    host_route_network_2    host_route_network_3    host_route_network_4
17 @{SUBNETS}        host_route_subnet_1    host_route_subnet_2    host_route_subnet_3    host_route_subnet_4
18 @{SUBNET_CIDR}    10.10.10.0    10.20.20.0    10.30.30.0    10.40.40.0
19 ${PREFIX24}       /24
20 @{NON_NEUTRON_DESTINATION}    5.5.5.0    6.6.6.0
21 ${NON_NEUTRON_NEXTHOP}    10.10.10.250
22
23 *** Test Cases ***
24 Verify creation of host route via openstack subnet create option
25     [Documentation]    Creating subnet host route via openstack cli and verifying in controller and openstack.
26     OpenStackOperations.Create SubNet    ${NETWORKS[${0}]}    ${SUBNETS[${0}]}    ${SUBNET_CIDR[${0}]}${PREFIX24}    --host-route destination=${SUBNET_CIDR[${2}]}${PREFIX24},gateway=${NON_NEUTRON_NEXTHOP}
27     ${SUBNET_GW_IP}    BuiltIn.Create List
28     : FOR    ${subnet}    IN    @{SUBNETS}
29     \    ${ip} =    OpenStackOperations.Get Subnet Gateway Ip    ${subnet}
30     \    Collections.Append To List    ${SUBNET_GW_IP}    ${ip}
31     BuiltIn.Set Suite Variable    ${SUBNET_GW_IP}
32     ${elements} =    BuiltIn.Create List    "destination":"${SUBNET_CIDR[${2}]}${PREFIX24}","nexthop":"${NON_NEUTRON_NEXTHOP}"
33     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Utils.Check For Elements At URI    ${SUBNETWORK_URL}    ${elements}
34     Verify Hostroutes In Subnet    ${SUBNETS[${0}]}    destination='${SUBNET_CIDR[${2}]}${PREFIX24}',\\sgateway='${NON_NEUTRON_NEXTHOP}'
35
36 Verify creation of host route via openstack subnet update option
37     [Documentation]    Creating host route using subnet update option and setting nexthop ip to subnet gateway ip. Verifying in controller and openstack.
38     OpenStackOperations.Update SubNet    ${SUBNETS[${0}]}    --host-route destination=${NON_NEUTRON_DESTINATION[${0}]}${PREFIX24},gateway=${SUBNET_GW_IP[${0}]}
39     ${elements} =    BuiltIn.Create List    "destination":"${NON_NEUTRON_DESTINATION[${0}]}${PREFIX24}","nexthop":"${SUBNET_GW_IP[${0}]}"
40     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Utils.Check For Elements At URI    ${SUBNETWORK_URL}    ${elements}
41     Verify Hostroutes In Subnet    ${SUBNETS[${0}]}    destination='${NON_NEUTRON_DESTINATION[${0}]}${PREFIX24}',\\sgateway='${SUBNET_GW_IP[${0}]}'
42
43 Verify removal of host route
44     [Documentation]    Removing subnet host routes via cli and verifying in controller and openstack
45     OpenStackOperations.Unset SubNet    ${SUBNETS[${0}]}    --host-route destination=${NON_NEUTRON_DESTINATION[${0}]}${PREFIX24},gateway=${SUBNET_GW_IP[${0}]}
46     ${elements} =    BuiltIn.Create List    "destination":"${NON_NEUTRON_DESTINATION[${0}]}${PREFIX24}","nexthop":"${SUBNET_GW_IP[${0}]}"
47     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Utils.Check For Elements Not At URI    ${SUBNETWORK_URL}    ${elements}
48     Verify No Hostroutes In Subnet    ${SUBNETS[${0}]}    destination='${NON_NEUTRON_DESTINATION[${0}]}${PREFIX24}',\\sgateway='${SUBNET_GW_IP[${0}]}'
49
50 *** Keywords ***
51 Create Setup
52     [Documentation]    Creates initial setup
53     VpnOperations.Basic Suite Setup
54     : FOR    ${network}    IN    @{NETWORKS}
55     \    OpenStackOperations.Create Network    ${network}
56     : FOR    ${i}    IN RANGE    1    4
57     \    OpenStackOperations.Create SubNet    ${NETWORKS[${i}]}    ${SUBNETS[${i}]}    ${SUBNET_CIDR[${i}]}${PREFIX24}
58
59 Verify Hostroutes In Subnet
60     [Arguments]    ${subnet_name}    @{elements}
61     [Documentation]    Show subnet with openstack request and verifies given hostroute in subnet
62     ${output} =    OpenStackOperations.Show SubNet    ${subnet_name}
63     : FOR    ${element}    IN    @{elements}
64     \    BuiltIn.Should Match Regexp    ${output}    ${element}
65
66 Verify No Hostroutes In Subnet
67     [Arguments]    ${subnet_name}    @{elements}
68     [Documentation]    Show subnet with openstack request and verifies no given hostroute in subnet
69     ${output} =    OpenStackOperations.Show SubNet    ${subnet_name}
70     : FOR    ${element}    IN    @{elements}
71     \    BuiltIn.Should Not Match Regexp    ${output}    ${element}