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