f32e088a78ea2deca0469b06ffa988db35730f21
[integration/test.git] / csit / suites / l2gw / __init__.robot
1 *** Settings ***
2 Documentation     Test suite for HWVTEP Setup
3 Suite Setup       Start Suite
4 Suite Teardown    Stop Suite
5 Library           SSHLibrary
6 Library           Collections
7 Resource          ../../variables/Variables.robot
8 Resource          ../../libraries/Utils.robot
9 Resource          ../../libraries/DevstackUtils.robot
10 Resource          ../../libraries/KarafKeywords.robot
11 Resource          ../../variables/l2gw/Variables.robot
12
13 *** Variables ***
14
15 *** Keywords ***
16 Start Suite
17     [Documentation]    Suite Setup to configure HWVTEP Emulator for L2 Gateway Testcase Verification.
18     ${hwvtep_conn_id}=    Create And Set Hwvtep Connection Id    ${HWVTEP_IP}
19     Set Suite Variable    ${hwvtep_conn_id}
20     Hwvtep Cleanup    ${hwvtep_conn_id}    ${HWVTEP_BRIDGE}
21     Namespace Cleanup
22     Hwvtep Initiate    ${hwvtep_conn_id}    ${HWVTEP_IP}    ${HWVTEP_BRIDGE}
23     Namespace Intiate Hwvtep1
24     Wait Until Keyword Succeeds    30s    1s    Hwvtep Validation
25
26 Stop Suite
27     [Documentation]    Stop Suite to cleanup Hwvtep configuration
28     Hwvtep Cleanup    ${hwvtep_conn_id}    ${HWVTEP_BRIDGE}
29     Namespace Cleanup
30     Switch Connection    ${hwvtep_conn_id}
31     Close Connection
32
33 Hwvtep Cleanup
34     [Arguments]    ${conn_id}    ${hwvtep_bridge}
35     [Documentation]    Cleanup any existing VTEP, VSWITCHD or OVSDB processes.
36     Switch Connection    ${conn_id}
37     Write Commands Until Prompt    ${DEL_OVS_BRIDGE} ${hwvtep_bridge}    30s
38     Write Commands Until Prompt    ${KILL_VTEP_PROC}    30s
39     Write Commands Until Prompt    ${KILL_VSWITCHD_PROC}    30s
40     Write Commands Until Prompt    ${KILL_OVSDB_PROC}    30s
41     ${stdout}=    Write Commands Until Prompt    ${GREP_OVS}    30s
42     Log    ${stdout}
43     Write Commands Until Prompt    ${REM_OVSDB}    30s
44     Write Commands Until Prompt    ${REM_VTEPDB}    30s
45
46 Namespace Cleanup
47     [Documentation]    Cleanup the existing namespaces and ports.
48     Switch Connection    ${hwvtep_conn_id}
49     ${stdout}=    Write Commands Until Prompt    ${IP_LINK}    30s
50     Log    ${stdout}
51     Write Commands Until Prompt    ${IP_LINK_DEL} ${NS_PORT1}    30s
52     Write Commands Until Prompt    ${IP_LINK_DEL} ${NS_PORT2}    30s
53     ${stdout}=    Write Commands Until Prompt    ${NETNS}    30s
54     Log    ${stdout}
55     Write Commands Until Prompt    ${NETNS_DEL} ${HWVTEP_NS1}    30s
56     Write Commands Until Prompt    ${NETNS_DEL} ${HWVTEP_NS2}    30s
57     ${stdout}=    Write Commands Until Prompt    ${IP_LINK}    30s
58     Log    ${stdout}
59
60 Hwvtep Initiate
61     [Arguments]    ${conn_id}    ${hwvtep_ip}    ${hwvtep_bridge}
62     [Documentation]    Configure the Hwvtep Emulation
63     Switch Connection    ${conn_id}
64     Write Commands Until Prompt    ${CREATE_OVSDB}    30s
65     Write Commands Until Prompt    ${CREATE VTEP}    30s
66     Write Commands Until Prompt    ${START_OVSDB_SERVER}    30s
67     ${stdout}=    Write Commands Until Prompt    ${GREP_OVS}    30s
68     Log    ${stdout}
69     Write Commands Until Prompt    ${INIT_VSCTL}    30s
70     Write Commands Until Prompt    ${DETACH_VSWITCHD}    30s
71     Write Commands Until Prompt    ${CREATE_OVS_BRIDGE} ${hwvtep_bridge}    30s
72     ${stdout}=    Write Commands Until Prompt    ${OVS_SHOW}    30s
73     Log    ${stdout}
74     Write Commands Until Prompt    ${ADD_VTEP_PS} ${hwvtep_bridge}    30s
75     Write Commands Until Prompt    ${SET_VTEP_PS} ${hwvtep_bridge} tunnel_ips=${hwvtep_ip}    30s
76     Write Commands Until Prompt    ${START_OVSVTEP} ${hwvtep_bridge}    30s
77     ${stdout}=    Write Commands Until Prompt    ${GREP_OVS}    30s
78     Log    ${stdout}
79
80 Namespace Intiate Hwvtep1
81     [Documentation]    Create and configure the namespace, bridges and ports.
82     Switch Connection    ${hwvtep_conn_id}
83     Create Configure Namespace    ${HWVTEP_NS1}    ${NS_PORT1}    ${NS_TAP1}    ${HWVTEP_BRIDGE}
84     Create Configure Namespace    ${HWVTEP_NS2}    ${NS_PORT2}    ${NS2_TAP1}    ${HWVTEP_BRIDGE}
85
86 Create Configure Namespace
87     [Arguments]    ${ns_name}    ${ns_port_name}    ${tap_port_name}    ${hwvtep_bridge}
88     Write Commands Until Prompt    ${NETNS_ADD} ${ns_name}    30s
89     Write Commands Until Prompt    ${IP_LINK_ADD} ${tap_port_name} type veth peer name ${ns_port_name}    30s
90     Write Commands Until Prompt    ${CREATE_OVS_PORT} ${hwvtep_bridge} ${ns_port_name}    30s
91     Write Commands Until Prompt    ${IP_LINK_SET} ${tap_port_name} netns ${ns_name}    30s
92     Write Commands Until Prompt    ${NETNS_EXEC} ${ns_name} ${IPLINK_SET} ${tap_port_name} up    30s
93     Write Commands Until Prompt    sudo ${IPLINK_SET} ${ns_port_name} up    30s
94     ${stdout}=    Write Commands Until Prompt    ${NETNS_EXEC} ${ns_name} ${IFCONF}    30s
95     Log    ${stdout}
96
97 Hwvtep Validation
98     [Documentation]    Initial validation of the Hwvtep Configuration to confirm Phyisical_Switch table entries
99     Switch Connection    ${hwvtep_conn_id}
100     ${stdout}=    Write Commands Until Prompt    ${VTEP LIST} ${PHYSICAL_SWITCH_TABLE}    30s
101     Should Contain    ${stdout}    ${HWVTEP_BRIDGE}
102     Should Contain    ${stdout}    ${HWVTEP_IP}
103     ${stdout}=    Write Commands Until Prompt    ${VTEP LIST} ${PHYSICAL_PORT_TABLE}    30s
104     Should Contain    ${stdout}    ${NS_PORT1}
105     Should Contain    ${stdout}    ${NS_PORT2}
106
107 Create And Set Hwvtep Connection Id
108     [Arguments]    ${hwvtep_ip}
109     [Documentation]    To create connection and return connection id for hwvtep_ip received
110     ${conn_id}=    SSHLibrary.Open Connection    ${hwvtep_ip}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
111     Log    ${conn_id}
112     Flexible SSH Login    ${DEFAULT_USER}    ${DEFAULT_PASSWORD}
113     [Return]    ${conn_id}