Create add operation perf results in lisp
[integration/test.git] / csit / suites / lispflowmapping / performance / 010_Southbound_MapRequest.robot
1 *** Settings ***
2 Documentation     Test suite to determine the southbound Map-Request serving rate
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 Variables         ../../../variables/Variables.py
12
13 *** Variables ***
14 ${MAPPINGS}       10000
15 ${LISP_SCAPY}     https://raw.githubusercontent.com/intouch/py-lispnetworking/master/lisp.py
16 ${TOOLS_DIR}      ${CURDIR}/../../../../tools/odl-lispflowmapping-performance-tests/
17 ${PCAP_CREATOR}    ${TOOLS_DIR}/create_map_request_pcap.py
18 ${MAPPING_BLASTER}    ${TOOLS_DIR}/mapping_blaster.py
19 ${REPLAY_PPS}     100000
20 ${REPLAY_CNT}     1000
21 ${REPLAY_FILE}    encapsulated-map-requests-sequential.pcap
22 ${RESULTS_FILE}    results.csv
23
24 *** Test Cases ***
25 Add Simple IPv4 Mappings
26     ${start_date}=    Get Current Date
27     Run Process With Logging And Status Check    ${MAPPING_BLASTER}    --host    ${CONTROLLER}    --mappings    ${MAPPINGS}
28     ${end_date}=    Get Current Date
29     ${add_seconds}=    Subtract Date From Date    ${end_date}    ${start_date}
30     Log    ${add_seconds}
31     Set Suite Variable    ${add_seconds}
32
33 Generate Test Traffic
34     Reset Stats
35     ${result}=    Run Process With Logging And Status Check    /usr/local/bin/udpreplay    --pps    ${REPLAY_PPS}    --repeat    ${REPLAY_CNT}
36     ...    --host    ${CONTROLLER}    --port    4342    ${REPLAY_FILE}
37     ${partial}=    Fetch From Left    ${result.stdout}    s =
38     Log    ${partial}
39     ${get_seconds}=    Fetch From Right    ${partial}    ${SPACE}
40     ${get_seconds}=    Convert To Number    ${get_seconds}
41     Log    ${get_seconds}
42     Set Suite Variable    ${get_seconds}
43
44 Compute And Export MapReply Rate
45     ${rpcs}=    Evaluate    ${MAPPINGS}/${add_seconds}
46     ${txmrep}=    Get Transmitted Map-Requests Stats
47     ${pps}=    Evaluate    ${txmrep}/${get_seconds}
48     Log    ${pps}
49     Create File    ${RESULTS_FILE}    store/s,replies/s\n
50     Append To File    ${RESULTS_FILE}    ${rpcs},${pps}\n
51
52 *** Keywords ***
53 Reset Stats
54     ${resp}=    RequestsLibrary.Post    session    ${LFM_SB_RPC_API}:reset-stats
55     Log    ${resp.content}
56     Should Be Equal As Strings    ${resp.status_code}    200
57
58 Get Transmitted Map-Requests Stats
59     ${resp}=    RequestsLibrary.Post    session    ${LFM_SB_RPC_API}:get-stats
60     Log    ${resp.content}
61     ${output}=    Get From Dictionary    ${resp.json()}    output
62     ${stats}=    Get From Dictionary    ${output}    control-message-stats
63     ${ctrlmsg}=    Get From Dictionary    ${stats}    control-message
64     ${replies}=    Get From List    ${ctrlmsg}    2
65     ${txmrep}=    Get From Dictionary    ${replies}    tx-count
66     ${txmrep}=    Convert To Integer    ${txmrep}
67     Log    ${txmrep}
68     [Return]    ${txmrep}
69
70 Prepare Environment
71     Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
72     Run Process With Logging And Status Check    wget    -P    ${TOOLS_DIR}    ${LISP_SCAPY}
73     Run Process With Logging And Status Check    ${PCAP_CREATOR}    --requests    ${MAPPINGS}
74
75 Destroy Environment
76     Delete All Sessions
77     Remove File    ${TOOLS_DIR}/lisp.py*
78     Remove File    ${REPLAY_FILE}