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