Upgrade RF syntax for v3.2 compatibility
[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     END
147     Set Suite Variable    ${L1}
148
149 Start Multiple_Sessions_UDP
150     [Documentation]    Basic setup/cleanup work that can be done safely before any system
151     ...    is run.
152     Log    Start USC test VM for Multiple_Sessions_UDP
153     ${agent_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
154     Set Suite Variable    ${agent_conn_id}
155     Flexible Mininet Login
156     Write    ${NAV_USC_TOOLS}
157     Write    ${AgentUdp}
158     Read
159     ${L1}    Create List
160     FOR    ${port_index}    IN    @{LIST_ECHO_SERVER_PORT}
161         Log    ${port_index}
162         ${echo_conn_id}=    Open Connection    ${TOOLS_SYSTEM_IP}    timeout=30s
163         Append To List    ${L1}    ${echo_conn_id}
164         Flexible Mininet Login
165         Write    ${NAV_USC_TOOLS}
166         Write    java -jar EchoServer.jar -t false -p ${port_index}
167         Read Until    initialized
168     END
169     Set Suite Variable    ${L1}
170
171 Stop Agent_Echo
172     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
173     ...    tests
174     Log    Stop USC test VM for Agent_Echo
175     Switch Connection    ${agent_conn_id}
176     Read
177     Write_Bare_Ctrl_C
178     Write    exit
179     Close Connection
180     Switch Connection    ${echo_conn_id}
181     Read
182     Write_Bare_Ctrl_C
183     Write    exit
184     Close Connection
185
186 Stop Echo
187     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
188     ...    tests
189     Log    Stop USC test VM for Echo
190     Switch Connection    ${echo_conn_id}
191     Read
192     Write_Bare_Ctrl_C
193     Write    exit
194     Close Connection
195
196 Stop One_Agent_Multiple_Echo
197     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
198     ...    tests
199     Log    Stop USC test VM for One_Agent_Multiple_Echo
200     Switch Connection    ${agent_conn_id}
201     Read
202     Write_Bare_Ctrl_C
203     Write    exit
204     Close Connection
205     FOR    ${echo_conn_id}    IN    @{L1}
206         Switch Connection    ${echo_conn_id}
207         Read
208         Write_Bare_Ctrl_C
209         Write    exit
210         Close Connection
211     END