Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / usc / udp / 300_Callhome_UDP / Test.robot
1 *** Settings ***
2 Documentation     Test suite for callhome DTLS channel
3 Suite Setup       Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Test Timeout      1 minute
6 Library           Collections
7 Library           OperatingSystem
8 Library           SSHLibrary
9 Library           RequestsLibrary
10 Library           json
11 Library           ../../../../libraries/Common.py
12 Variables         ../../../../variables/Variables.py
13 Resource          ../../../../libraries/UscUtils.robot
14
15 *** Test Cases ***
16 Add Channel
17     [Documentation]    Add an USC TLS callhome channel
18     ${content}    Create Dictionary    hostname=${TOOLS_SYSTEM_IP}    tcp=false    port=${ECHO_SERVER_PORT}    remote=false
19     ${channel}    Create Dictionary    channel=${content}
20     ${input}    Create Dictionary    input=${channel}
21     ${data}    json.dumps    ${input}
22     ${resp}    Post Request    session    ${REST_ADD_CHANNEL}    data=${data}
23     Log    ${resp.content}
24     Should Be Equal As Strings    ${resp.status_code}    200
25     Should Contain    ${resp.content}    Succeed to connect
26
27 Check added Channel
28     [Documentation]    Check if the channel is correct
29     ${topo}    Create Dictionary    topology-id=usc
30     ${input}    Create Dictionary    input=${topo}
31     ${data}    json.dumps    ${input}
32     ${resp}    Post Request    session    ${REST_VIEW_CHANNEL}    data=${data}
33     Log    ${resp.content}
34     Should Be Equal As Strings    ${resp.status_code}    200
35     Should Contain    ${resp.content}    "topology"
36     Should Contain    ${resp.content}    "sessions":1
37     Should Contain    ${resp.content}    "channel-type":"DTLS"
38     Should Contain    ${resp.content}    "call-home":"CallHome"
39
40 Send Messages
41     [Documentation]    Send test messages multiple times
42     ${content}    Create Dictionary    hostname=${TOOLS_SYSTEM_IP}    port=${ECHO_SERVER_PORT}    tcp=false    content=${TEST_MESSAGE}
43     ${channel}    Create Dictionary    channel=${content}
44     ${input}    Create Dictionary    input=${channel}
45     FOR    ${index}    IN RANGE    0    ${NUM_OF_MESSAGES}
46         ${data}    json.dumps    ${input}
47         ${resp}    Post Request    session    ${REST_SEND_MESSAGE}    data=${data}
48         Should Be Equal As Strings    ${resp.status_code}    200
49         Should Contain    ${resp.content}    Succeed to send request
50     END
51
52 View Bytes In and Bytes Out
53     [Documentation]    Check if the number of Bytes In and Bytes Out are correct
54     ${topo}    Create Dictionary    topology-id=usc
55     ${input}    Create Dictionary    input=${topo}
56     ${data}    json.dumps    ${input}
57     ${resp}    Post Request    session    ${REST_VIEW_CHANNEL}    data=${data}
58     Log    ${resp.content}
59     Should Be Equal As Strings    ${resp.status_code}    200
60     Should Contain    ${resp.content}    "topology"
61     ${len}    Get Length    ${TEST_MESSAGE}
62     ${totalLen}    Evaluate    ${len} * ${NUM_OF_MESSAGES}
63     Should Contain    ${resp.content}    "bytes-out":${totalLen}
64     Should Contain    ${resp.content}    "bytes-in":${totalLen}
65
66 Remove Channel
67     [Documentation]    Remove the channel
68     ${content}    Create Dictionary    hostname=${TOOLS_SYSTEM_IP}    tcp=false
69     ${channel}    Create Dictionary    channel=${content}
70     ${input}    Create Dictionary    input=${channel}
71     ${data}    json.dumps    ${input}
72     ${resp}    Post Request    session    ${REST_REMOVE_CHANNEL}    data=${data}
73     Log    ${resp.content}
74     Should Be Equal As Strings    ${resp.status_code}    200
75     Should Contain    ${resp.content}    Succeed to remove