Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / lispflowmapping / performance / 010_Southbound_MapRequest.robot
1 *** Settings ***
2 Documentation       LISP southbound performance tests
3
4 Library             Collections
5 Library             DateTime
6 Library             OperatingSystem
7 Library             RequestsLibrary
8 Library             String
9 Resource            ../../../libraries/Utils.robot
10 Resource            ../../../libraries/LISPFlowMapping.robot
11 Resource            ../../../libraries/TemplatedRequests.robot
12 Variables           ../../../variables/Variables.py
13
14 Suite Setup         Prepare Environment
15 Suite Teardown      Destroy Environment
16
17
18 *** Variables ***
19 ${MAPPINGS}             10000
20 ${LISP_SCAPY}           https://raw.githubusercontent.com/ljakab/py-lispnetworking/opendaylight/lisp.py
21 ${TOOLS_DIR}            ${CURDIR}/../../../../tools/odl-lispflowmapping-performance-tests/
22 ${PCAP_CREATOR}         ${TOOLS_DIR}/create_lisp_control_plane_pcap.py
23 ${MAPPING_BLASTER}      ${TOOLS_DIR}/mapping_blaster.py
24 ${REPLAY_PPS}           100000
25 ${REPLAY_CNT}           1000
26 ${REPLAY_FILE_MREQ}     encapsulated-map-requests-sequential.pcap
27 ${REPLAY_FILE_MREG}     map-registers-sequential-no-auth.pcap
28 ${REPLAY_FILE_MRGA}     map-registers-sequential-sha1-auth.pcap
29 ${RPCS_RESULTS_FILE}    rpcs.csv
30 ${PPS_RESULTS_FILE}     pps.csv
31
32
33 *** Test Cases ***
34 Add Simple IPv4 Mappings
35     ${start_date}=    Get Current Date
36     Run Process With Logging And Status Check
37     ...    ${MAPPING_BLASTER}
38     ...    --host
39     ...    ${ODL_SYSTEM_IP}
40     ...    --mappings
41     ...    ${MAPPINGS}
42     ${end_date}=    Get Current Date
43     ${add_seconds}=    Subtract Date From Date    ${end_date}    ${start_date}
44     Log    ${add_seconds}
45     ${rpcs}=    Evaluate    int(${MAPPINGS}/${add_seconds})
46     Log    ${rpcs}
47     Append To File    ${RPCS_RESULTS_FILE}    ${rpcs}\n
48
49 Generate Map-Request Test Traffic
50     ${pps_mrep}=    Lossy Test    2    ${REPLAY_FILE_MREQ}
51     Set Suite Variable    ${pps_mrep}
52
53 Generate Map-Register Test Traffic
54     Allow Unauthenticated Map-Registers
55     ${pps_mnot}=    Lossy Test    4    ${REPLAY_FILE_MREG}
56     Set Suite Variable    ${pps_mnot}
57
58 Generate Authenticated Map-Register Test Traffic
59     Allow Authenticated Map-Registers
60     ${pps_mnot_auth}=    Lossy Test    4    ${REPLAY_FILE_MRGA}
61     Set Suite Variable    ${pps_mnot_auth}
62
63
64 *** Keywords ***
65 Clean Up
66     Clear Config Datastore
67     Clear Operational Datastore
68     Sleep    500ms
69
70 Clear Config Datastore
71     ${resp}=    RequestsLibrary.Delete Request    session    /restconf/config/odl-mappingservice:mapping-database
72     Log    ${resp.content}
73
74 Clear Operational Datastore
75     ${resp}=    RequestsLibrary.Delete Request    session    /restconf/operational/odl-mappingservice:mapping-database
76     Log    ${resp.content}
77
78 Lossy Test
79     [Documentation]    This test will send traffic at a rate that is known to be
80     ...    higher than the capacity of the LISP Flow Mapping service and count
81     ...    the reply messages. Using the test's time duration, it computes the
82     ...    average reply packet rate in packets per second
83     [Arguments]    ${lisp_type}    ${replay_file}
84     ${elapsed_time}=    Generate Test Traffic    ${REPLAY_PPS}    ${REPLAY_CNT}    ${replay_file}
85     ${odl_tx_count}=    Get Control Message Stats    ${lisp_type}    tx-count
86     ${pps}=    Evaluate    int(${odl_tx_count}/${elapsed_time})
87     Log    ${pps}
88     Clean Up
89     RETURN    ${pps}
90
91 Generate Test Traffic
92     [Arguments]    ${replay_pps}    ${replay_cnt}    ${replay_file}
93     Reset Stats
94     ${result}=    Run Process With Logging And Status Check
95     ...    /usr/local/bin/udpreplay
96     ...    --pps
97     ...    ${replay_pps}
98     ...    --repeat
99     ...    ${replay_cnt}
100     ...    --host
101     ...    ${ODL_SYSTEM_IP}
102     ...    --port
103     ...    4342
104     ...    ${replay_file}
105     ${partial}=    Fetch From Left    ${result.stdout}    s =
106     Log    ${partial}
107     ${time}=    Fetch From Right    ${partial}    ${SPACE}
108     ${time}=    Convert To Number    ${time}
109     Log    ${time}
110     RETURN    ${time}
111
112 Reset Stats
113     [Arguments]    ${status_codes}=${ALLOWED_STATUS_CODES}
114     ${resp}=    RequestsLibrary.Post Request    session    ${LFM_SB_RPC_API}:reset-stats
115     Log    ${resp.content}
116     TemplatedRequests.Check Status Code    ${resp}    ${status_codes}
117
118 Allow Unauthenticated Map-Registers
119     ${add_key}=    OperatingSystem.Get File    ${JSON_DIR}/rpc_add-key_default_no-auth.json
120     Post Log Check    ${LFM_RPC_API}:add-key    ${add_key}
121
122 Allow Authenticated Map-Registers
123     ${add_key}=    OperatingSystem.Get File    ${JSON_DIR}/rpc_add-key_default.json
124     Post Log Check    ${LFM_RPC_API}:add-key    ${add_key}
125
126 Get Control Message Stats
127     [Arguments]    ${lisp_type}    ${stat_type}
128     ${resp}=    RequestsLibrary.Post Request    session    ${LFM_SB_RPC_API}:get-stats
129     Log    ${resp.content}
130     ${output}=    Get From Dictionary    ${resp.json()}    output
131     ${stats}=    Get From Dictionary    ${output}    control-message-stats
132     ${ctrlmsg}=    Get From Dictionary    ${stats}    control-message
133     ${ctrlmsg_type}=    Get From List    ${ctrlmsg}    ${lisp_type}
134     ${msg_cnt}=    Get From Dictionary    ${ctrlmsg_type}    ${stat_type}
135     ${msg_cnt}=    Convert To Integer    ${msg_cnt}
136     Log    ${msg_cnt}
137     RETURN    ${msg_cnt}
138
139 Prepare Environment
140     Create File    ${RPCS_RESULTS_FILE}    store/s\n
141     Create File    ${PPS_RESULTS_FILE}    replies/s,notifies/s,auth_notifies/s\n
142     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
143     Run Process With Logging And Status Check    wget    -P    ${TOOLS_DIR}    ${LISP_SCAPY}
144     Run Process With Logging And Status Check    ${PCAP_CREATOR}    --requests    ${MAPPINGS}
145
146 Destroy Environment
147     Append To File    ${PPS_RESULTS_FILE}    ${pps_mrep},${pps_mnot},${pps_mnot_auth}\n
148     Delete All Sessions
149     Remove File    ${TOOLS_DIR}/lisp.py*
150     Remove File    ${REPLAY_FILE_MREQ}
151     Remove File    ${REPLAY_FILE_MREG}
152     Remove File    ${REPLAY_FILE_MRGA}