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