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