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