Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / usc / tcp / 200_Multiple_Sessions_TCP / Test.robot
1 *** Settings ***
2 Documentation     Test suite for multiple sessions in an USC 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 *** Variables ***
15
16 *** Test Cases ***
17 Add Channel
18     [Documentation]    Add multiple USC TLS channels
19     FOR    ${port_index}    IN    @{LIST_ECHO_SERVER_PORT}
20         ${content}    Create Dictionary    hostname=${TOOLS_SYSTEM_IP}    port=${port_index}    tcp=true    remote=false
21         ${channel}    Create Dictionary    channel=${content}
22         ${input}    Create Dictionary    input=${channel}
23         ${data}    json.dumps    ${input}
24         ${resp}    Post Request    session    ${REST_ADD_CHANNEL}    data=${data}
25         Log    ${resp.content}
26         Should Be Equal As Strings    ${resp.status_code}    200
27         Should Contain    ${resp.content}    Succeed to connect
28     END
29
30 Check added Channel
31     [Documentation]    Check if the channels are correct
32     ${topo}    Create Dictionary    topology-id=usc
33     ${input}    Create Dictionary    input=${topo}
34     ${data}    json.dumps    ${input}
35     ${resp}    Post Request    session    ${REST_VIEW_CHANNEL}    data=${data}
36     Log    ${resp.content}
37     Should Be Equal As Strings    ${resp.status_code}    200
38     Should Contain    ${resp.content}    "topology"
39     ${len}    Get Length    ${LIST_ECHO_SERVER_PORT}
40     Should Contain    ${resp.content}    "sessions":${len}
41     Should Contain    ${resp.content}    "channel-type":"TLS"
42
43 Send Messages
44     [Documentation]    Send test messages multiple times
45     FOR    ${port_index}    IN    @{LIST_ECHO_SERVER_PORT}
46         ${content}    Create Dictionary    hostname=${TOOLS_SYSTEM_IP}    port=${port_index}    tcp=true    content=${TEST_MESSAGE}
47         ${channel}    Create Dictionary    channel=${content}
48         ${input}    Create Dictionary    input=${channel}
49         Send Now    ${input}
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     ${len1}    Get Length    ${LIST_ECHO_SERVER_PORT}
62     ${len2}    Get Length    ${TEST_MESSAGE}
63     ${totalLen}    Evaluate    ${len1} * ${len2} * ${NUM_OF_MESSAGES}
64     Should Contain    ${resp.content}    "bytes-out":${totalLen}
65     Should Contain    ${resp.content}    "bytes-in":${totalLen}
66
67 Remove Sessions
68     [Documentation]    Remove the channels
69     FOR    ${port_index}    IN    @{LIST_ECHO_SERVER_PORT}
70         ${content}    Create Dictionary    hostname=${TOOLS_SYSTEM_IP}    port=${port_index}    tcp=true
71         ${channel}    Create Dictionary    channel=${content}
72         ${input}    Create Dictionary    input=${channel}
73         ${data}    json.dumps    ${input}
74         ${resp}    Post Request    session    ${REST_REMOVE_SESSION}    data=${data}
75         Log    ${resp.content}
76         Should Be Equal As Strings    ${resp.status_code}    200
77         Should Contain    ${resp.content}    Succeed to remove
78     END
79
80 Remove Channel
81     [Documentation]    Remove the channels
82     ${content}    Create Dictionary    hostname=${TOOLS_SYSTEM_IP}    tcp=true
83     ${channel}    Create Dictionary    channel=${content}
84     ${input}    Create Dictionary    input=${channel}
85     ${data}    json.dumps    ${input}
86     ${resp}    Post Request    session    ${REST_REMOVE_CHANNEL}    data=${data}
87     Log    ${resp.content}
88     Should Be Equal As Strings    ${resp.status_code}    200
89     Should Contain    ${resp.content}    Succeed to remove
90
91 Check Channel
92     [Documentation]    Check if the channels are correct
93     ${topo}    Create Dictionary    topology-id=usc
94     ${input}    Create Dictionary    input=${topo}
95     ${data}    json.dumps    ${input}
96     ${resp}    Post Request    session    ${REST_VIEW_CHANNEL}    data=${data}
97     Log    ${resp.content}
98     Should Be Equal As Strings    ${resp.status_code}    200
99     Should Contain    ${resp.content}    "topology"
100
101 *** Keywords ***
102 Send Now
103     [Arguments]    ${body}
104     FOR    ${index}    IN RANGE    0    ${NUM_OF_MESSAGES}
105         ${data}    json.dumps    ${body}
106         ${resp}    Post Request    session    ${REST_SEND_MESSAGE}    data=${data}
107         Should Be Equal As Strings    ${resp.status_code}    200
108         Should Contain    ${resp.content}    Succeed to send request
109     END