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