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