Update Robot Framework format - step 7
[integration/test.git] / csit / suites / groupbasedpolicy / GBP / Devstack / 02__neutron-mapper_test.robot
1 *** Settings ***
2 Documentation       Testing of Group Based Policy Neutron-Mapper
3
4 Library             SSHLibrary
5 Library             OperatingSystem
6 Library             RequestsLibrary
7 Library             String
8 Resource            Variables.robot
9 Resource            ../../../../variables/gbp/Constants.robot
10 Resource            ../../../../libraries/Utils.robot
11 Resource            ../../../../libraries/GBP/RestconfUtils.robot
12 Resource            ../../../../libraries/GBP/AssertionUtils.robot
13 Resource            ../../../../libraries/DevstackUtils.robot
14 Resource            ../../../../libraries/OpenStackOperations.robot
15
16 Suite Setup         Devstack Suite Setup
17 Suite Teardown      Clean Suite
18
19
20 *** Variables ***
21 ${NETWORK_NAME}         net123
22 ${SUBNET_NAME}          subnet123
23 ${CLIENT_SG}            client_sg
24 ${SERVER_SG}            server_sg
25 ${TENANTS_CONF_PATH}    restconf/config/policy:tenants
26 ${CLIENT_PORT_IP}       10.0.0.5
27 ${SERVER_PORT_IP}       10.0.0.6
28 ${CLIENT_PORT_NAME}     client
29 ${SERVER_PORT_NAME}     server
30 ${REMOTE_IP_PREFIX}     10.0.0.0/24
31 ${SUBNET_IP_PREFIX}     10.0.0.0/24
32 ${ROUTER_NAME}          router123
33 ${TENANT_ID}            ${EMPTY}
34 ${SUBNET_ID}            ${EMPTY}
35 ${FLOOD_DOMAIN_ID}      ${EMPTY}
36 ${BRIDGE_DOMAIN_ID}     ${EMPTY}
37 ${L3_CONTEXT_ID}        ${EMPTY}
38 ${GROUP_RULE_ID}        ${EMPTY}
39 ${CLIENT_MAC_ADDR}      ${EMPTY}
40 ${SERVER_MAC_ADDR}      ${EMPTY}
41 ${CLIENT_SG_ID}         ${EMPTY}
42 ${SERVER_SG_ID}         ${EMPTY}
43 ${ROUTER_ID}            ${EMPTY}
44
45
46 *** Test Cases ***
47 Test Resolve Tenant ID
48     [Documentation]    Test reading tenant id from default security group
49     ${tenant_id}    Get Tenant ID From Security Group
50     ${tenant_id}    To Uuid    ${tenant_id}
51     Should Match Regexp    ${tenant_id}    ${UUID_PATTERN}
52     Set Global Variable    ${TENANT_ID}    ${tenant_id}
53
54 Test Create Network
55     [Documentation]    Create sec group and verify data generated in GBP
56     ${uuid}    Create Network    net123    verbose=FALSE
57     ${l2_fd_id}    Should Match Regexp    ${uuid}    ${UUID_PATTERN}
58     ${l2_fd_path}    Get L2 Flood Domain Path    ${TENANT_ID}    ${l2_fd_id}
59     ${l2_fd}    Get Data From URI    session    ${l2_fd_path}    headers=${headers}
60     ${l2_bd_id}    Assert L2-Flood-Domain    ${l2_fd}    ${NETWORK_NAME}
61     ${l2_bd_path}    Get L2 Bridge Domain Path    ${TENANT_ID}    ${l2_bd_id}
62     ${l2_bd}    Get Data From URI    session    ${l2_bd_path}    headers=${headers}
63     ${l3_ctx_id}    Assert L2-Bridge-Domain    ${l2_bd}    ${NETWORK_NAME}
64     ${l3_ctx_path}    Get L3 Context Path    ${TENANT_ID}    ${l3_ctx_id}
65     ${l3_ctx}    Get Data From URI    session    ${l3_ctx_path}    headers=${headers}
66     Assert L3-Context    ${l3_ctx}    ${NETWORK_NAME}
67     Set Global Variable    ${FLOOD_DOMAIN_ID}    ${l2_fd_id}
68     Set Global Variable    ${BRIDGE_DOMAIN_ID}    ${l2_bd_id}
69     Set Global Variable    ${L3_CONTEXT_ID}    ${l3_ctx_id}
70
71
72 *** Keywords ***
73 Create Neutron Entity And Return ID
74     [Documentation]    Designed for creating neutron entities and returing their IDs.
75     [Arguments]    ${cmd}    ${pattern}=${UUID_PATTERN}
76     ${output}    Write Commands Until Prompt    ${cmd} | grep -w id | awk '{print $4}'
77     Should Not Be Empty    ${output}
78     ${id}    Should Match Regexp    ${output}    ${pattern}
79     RETURN    ${id}
80
81 To Uuid
82     [Documentation]    Insert dashes if missing to generate proper UUID string.
83     [Arguments]    ${init_string}
84     Should Match Regexp    ${init_string}    ${UUID_NO_DASHES}
85     ${first}    Get Substring    ${init_string}    0    8
86     ${second}    Get Substring    ${init_string}    8    12
87     ${third}    Get Substring    ${init_string}    12    16
88     ${fourth}    Get Substring    ${init_string}    16    20
89     ${fifth}    Get Substring    ${init_string}    20    32
90     RETURN    ${first}-${second}-${third}-${fourth}-${fifth}
91
92 Clean Suite
93     [Documentation]    Clears Openstack. This is also helpful when debugging tests locally.
94     ${output}    Write Commands Until Prompt    neutron net-delete net123
95     Should Match Regexp    ${output}    Deleted|Removed
96     Delete All Sessions