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