Giving the right library for Report_Failure_Due_To_Bug_Found keyword
[integration/test.git] / csit / libraries / UscUtils.robot
1 *** Settings ***
2 Library           Collections
3 Library           SSHLibrary
4 Library           UtilLibrary.py
5 Resource          Utils.robot
6
7 *** Variables ***
8 ${REST_VIEW_CHANNEL}    /restconf/operations/usc-channel:view-channel
9 ${REST_ADD_CHANNEL}    /restconf/operations/usc-channel:add-channel
10 ${REST_REMOVE_CHANNEL}    /restconf/operations/usc-channel:remove-channel
11 ${REST_SEND_MESSAGE}    /restconf/operations/usc-channel:send-message
12 ${NAV_USC_TOOLS}    cd ~/usc-tools
13 ${CLONE_USC_TOOLS}    [ -f ~/usc-tools/UscAgent.jar ] && echo "The usc-tools does exist. (17/17), done." || git clone https://github.com/victorxu99/usc-tools.git ~/usc-tools
14 ${USC_AGENT_IP}    192.168.56.51
15 ${ECHO_SERVER_PORT}    2007
16 @{LIST_ECHO_SERVER_PORT}    2007    2008    2009
17 ${TEST_MESSAGE}    This is a test message.
18 ${NUM_OF_MESSAGES}    100
19 ${AgentTcp}       java -jar UscAgent.jar -t true
20 ${AgentUdp}       java -jar UscAgent.jar -t false
21 ${AgentTcpCallhome}    java -jar UscAgent.jar -t true -c true -h 192.168.56.20
22 ${AgentUdpCallhome}    java -jar UscAgent.jar -t false -c true -h 192.168.56.20
23 ${EchoServerTcp}    java -jar EchoServer.jar -t true -p 2007
24 ${EchoServerUdp}    java -jar EchoServer.jar -t false -p 2007
25
26 *** Keywords ***
27 Download Tools
28     [Documentation]    Download UscAgent and EchoServer before any system
29     ...    is run.
30     Log    Download tools begin ...
31     ${tools_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
32     Set Suite Variable    ${tools_conn_id}
33     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
34     Write    ${CLONE_USC_TOOLS}
35     Read Until    (17/17), done.
36     Log    Download tools ended.
37
38 Close Download Connection
39     [Documentation]    Close Download Connection
40     Log    Close Download Connection
41     Switch Connection    ${tools_conn_id}
42     Write    exit
43     Close Connection
44
45 Start TCP
46     [Documentation]    Basic setup/cleanup work that can be done safely before any system
47     ...    is run.
48     Log    Start USC test VM for TCP
49     ${agent_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
50     Set Suite Variable    ${agent_conn_id}
51     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
52     Write    ${NAV_USC_TOOLS}
53     Write    ${AgentTcp}
54     Read
55     ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
56     Set Suite Variable    ${echo_conn_id}
57     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
58     Write    ${NAV_USC_TOOLS}
59     Write    ${EchoServerTcp}
60     Read Until    initialized
61
62 Start UDP
63     [Documentation]    Basic setup/cleanup work that can be done safely before any system
64     ...    is run.
65     Log    Start USC test VM for UDP
66     ${agent_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
67     Set Suite Variable    ${agent_conn_id}
68     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
69     Write    ${NAV_USC_TOOLS}
70     Write    ${AgentUdp}
71     Read
72     ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
73     Set Suite Variable    ${echo_conn_id}
74     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
75     Write    ${NAV_USC_TOOLS}
76     Write    ${EchoServerUdp}
77     Read Until    initialized
78
79 Start CALLHOME_TCP
80     [Documentation]    Basic setup/cleanup work that can be done safely before any system
81     ...    is run.
82     Log    Start USC test VM for CALLHOME_TCP
83     ${agent_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
84     Set Suite Variable    ${agent_conn_id}
85     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
86     Write    ${NAV_USC_TOOLS}
87     Write    ${AgentTcpCallhome}
88     Read
89     ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
90     Set Suite Variable    ${echo_conn_id}
91     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
92     Write    ${NAV_USC_TOOLS}
93     Write    ${EchoServerTcp}
94     Read Until    initialized
95
96 Start CALLHOME_UDP
97     [Documentation]    Basic setup/cleanup work that can be done safely before any system
98     ...    is run.
99     Log    Start USC test VM for CALLHOME_UDP
100     ${agent_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
101     Set Suite Variable    ${agent_conn_id}
102     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
103     Write    ${NAV_USC_TOOLS}
104     Write    ${AgentUdpCallhome}
105     Read
106     ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
107     Set Suite Variable    ${echo_conn_id}
108     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
109     Write    ${NAV_USC_TOOLS}
110     Write    ${EchoServerUdp}
111     Read Until    initialized
112
113 Start Fallback_TCP
114     [Documentation]    Basic setup/cleanup work that can be done safely before any system
115     ...    is run.
116     Log    Start USC test VM for Fallback_TCP
117     ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
118     Set Suite Variable    ${echo_conn_id}
119     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
120     Write    ${NAV_USC_TOOLS}
121     Write    ${EchoServerTcp}
122     Read Until    initialized
123
124 Start Fallback_UDP
125     [Documentation]    Basic setup/cleanup work that can be done safely before any system
126     ...    is run.
127     Log    Start USC test VM for Fallback_TCP
128     ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
129     Set Suite Variable    ${echo_conn_id}
130     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
131     Write    ${NAV_USC_TOOLS}
132     Write    ${EchoServerUdp}
133     Read Until    initialized
134
135 Start Multiple_Sessions_TCP
136     [Documentation]    Basic setup/cleanup work that can be done safely before any system
137     ...    is run.
138     Log    Start USC test VM for Multiple_Sessions_TCP
139     ${agent_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
140     Set Suite Variable    ${agent_conn_id}
141     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
142     Write    ${NAV_USC_TOOLS}
143     Write    ${AgentTcp}
144     Read
145     ${L1}    Create List
146     : FOR    ${port_index}    IN    @{LIST_ECHO_SERVER_PORT}
147     \    Log    ${port_index}
148     \    ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
149     \    Append To List    ${L1}    ${echo_conn_id}
150     \    Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
151     \    Write    ${NAV_USC_TOOLS}
152     \    Write    java -jar EchoServer.jar -t true -p ${port_index}
153     \    Read Until    initialized
154     Set Suite Variable    ${L1}
155
156 Start Multiple_Sessions_UDP
157     [Documentation]    Basic setup/cleanup work that can be done safely before any system
158     ...    is run.
159     Log    Start USC test VM for Multiple_Sessions_UDP
160     ${agent_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
161     Set Suite Variable    ${agent_conn_id}
162     Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
163     Write    ${NAV_USC_TOOLS}
164     Write    ${AgentUdp}
165     Read
166     ${L1}    Create List
167     : FOR    ${port_index}    IN    @{LIST_ECHO_SERVER_PORT}
168     \    Log    ${port_index}
169     \    ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
170     \    Append To List    ${L1}    ${echo_conn_id}
171     \    Flexible Mininet Login    user=${TOOLS_SYSTEM_USER}    password=${TOOLS_SYSTEM_PASSWORD}
172     \    Write    ${NAV_USC_TOOLS}
173     \    Write    java -jar EchoServer.jar -t false -p ${port_index}
174     \    Read Until    initialized
175     Set Suite Variable    ${L1}
176
177 Stop Agent_Echo
178     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
179     ...    tests
180     Log    Stop USC test VM for Agent_Echo
181     Switch Connection    ${agent_conn_id}
182     Read
183     Write_Bare_Ctrl_C
184     Write    exit
185     Close Connection
186     Switch Connection    ${echo_conn_id}
187     Read
188     Write_Bare_Ctrl_C
189     Write    exit
190     Close Connection
191
192 Stop Echo
193     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
194     ...    tests
195     Log    Stop USC test VM for Echo
196     Switch Connection    ${echo_conn_id}
197     Read
198     Write_Bare_Ctrl_C
199     Write    exit
200     Close Connection
201
202 Stop One_Agent_Multiple_Echo
203     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
204     ...    tests
205     Log    Stop USC test VM for One_Agent_Multiple_Echo
206     Switch Connection    ${agent_conn_id}
207     Read
208     Write_Bare_Ctrl_C
209     Write    exit
210     Close Connection
211     : FOR    ${echo_conn_id}    IN    @{L1}
212     \    Switch Connection    ${echo_conn_id}
213     \    Read
214     \    Write_Bare_Ctrl_C
215     \    Write    exit
216     \    Close Connection