Add openflowport as a parameter to cbench command line
[integration/test.git] / csit / suites / openflowplugin / Performance / 010_Cbench.robot
1 *** Settings ***
2 Documentation     Cbench Latency and Throughput tests can be run from an external
3 ...               cbench.
4 ...               If cbench is run with a medium number of switches or higher (e.g. 32+)
5 ...               the normal openflow operations seem to break.
6 ...               BUG: https://bugs.opendaylight.org/show_bug.cgi?id=2897
7 Suite Setup       Cbench Suite Setup
8 Test Teardown     Log Results As Zero If Cbench Timed Out
9 Force Tags        cbench
10 Library           String
11 Library           Process
12 Resource          ../../../libraries/Utils.robot
13 Resource          ../../../libraries/KarafKeywords.robot
14
15 *** Variables ***
16 ${throughput_threshold}    30000
17 ${latency_threshold}    10000
18 ${switch_count}    16
19 ${duration_in_secs}    10
20 ${loops}          10
21 ${num_of_unique_macs}    100
22 ${start_delay}    5000
23 ${test_delay}     0
24 ${of_port}        6633
25 ${cbench_system}    ${TOOLS_SYSTEM_IP}
26 ${cbench_executable}    /usr/local/bin/cbench
27 ${throughput_results_file}    throughput.csv
28 ${latency_results_file}    latency.csv
29
30 *** Testcases ***
31 Cbench Latency Test
32     [Documentation]    cbench executed in default latency mode. Test parameters have defaults, but can be overridden
33     ...    on the pybot command line
34     [Tags]    latency
35     [Timeout]    ${test_timeout}
36     Log    Cbench tests using ${loops} iterations of ${duration_in_secs} second tests. Switch Count: ${switch_count}. Unique MACS to cycle: ${num_of_unique_macs}
37     Run Cbench And Log Results    -m ${duration_in_ms} -M ${num_of_unique_macs} -s ${switch_count} -l ${loops} -D ${start_delay} -p ${of_port}    ${latency_threshold}    ${latency_results_file}
38     # We have to give some time for the controller to recover. See bug 6176.
39     Sleep    ${test_delay}
40
41 Cbench Throughput Test
42     [Documentation]    cbench executed in throughput mode (-t). Test parameters have defaults, but can be overridden
43     ...    on the pybot command line
44     [Tags]    throughput
45     [Timeout]    ${test_timeout}
46     Log    Cbench tests using ${loops} iterations of ${duration_in_secs} second tests. Switch Count: ${switch_count}. Unique MACS to cycle: ${num_of_unique_macs}
47     Run Cbench And Log Results    -t -m ${duration_in_ms} -M ${num_of_unique_macs} -s ${switch_count} -l ${loops} -D ${start_delay} -p ${of_port}    ${throughput_threshold}    ${throughput_results_file}
48     # We have to give some time for the controller to recover. See bug 6176.
49     Sleep    ${test_delay}
50
51 Rerun Latency Test To Check Bug 6176
52     [Documentation]    cbench executed in latency mode to see if controller is healthy
53     [Tags]    latency
54     [Timeout]    ${test_timeout}
55     Log    Cbench tests using ${loops} iterations of ${duration_in_secs} second tests. Switch Count: ${switch_count}. Unique MACS to cycle: ${num_of_unique_macs}
56     Run Cbench And Log Results    -m ${duration_in_ms} -M ${num_of_unique_macs} -s ${switch_count} -l ${loops} -D ${start_delay} -p ${of_port}    ${latency_threshold}    bug.csv
57     # We have to give some time for the controller to recover. See bug 6176.
58     Sleep    ${test_delay}
59     [Teardown]    Report_Failure_Due_To_Bug    6176
60
61 *** Keywords ***
62 Run Cbench And Log Results
63     [Arguments]    ${cbench_args}    ${average_threshold}    ${output_filename}=results.csv
64     ##If the cbench command fails to return, the keyword to run it will time out.    The test tear
65     ##down can catch this problem and log the results as zero.    However, we need to know which
66     ##file to log to, so setting it as a suite variable here.
67     Set Suite Variable    ${output_filename}
68     ${output}=    Run Keyword If    "${cbench_system}" == "localhost"    Run    ${cbench_executable} -c ${ODL_SYSTEM_IP} ${cbench_args}
69     ...    ELSE    Run Command On Remote System    ${cbench_system}    ${cbench_executable} -c ${ODL_SYSTEM_IP} ${cbench_args}    prompt_timeout=${test_timeout}
70     Log    ${output}
71     Should Contain    ${output}    RESULT
72     ${result_line}=    Get Lines Containing String    ${output}    RESULT
73     @{results_list}=    Split String    ${result_line}
74     Log    ${results_list[5]}
75     Log    ${results_list[7]}
76     @{result_name_list}=    Split String    ${results_list[5]}    /
77     @{result_value_list}=    Split String    ${results_list[7]}    /
78     ${num_stats}=    Get Length    ${result_name_list}
79     : FOR    ${i}    IN RANGE    0    ${num_stats}
80     \    Log    ${result_name_list[${i}]} :: ${result_value_list[${i}]}
81     ${min}=    Set Variable    ${result_value_list[${0}]}
82     ${max}=    Set Variable    ${result_value_list[${1}]}
83     ${average}=    Set Variable    ${result_value_list[${2}]}
84     ${stdev}=    Set Variable    ${result_value_list[${3}]}
85     ${date}=    Get Time    d,m,s
86     Log    CBench Result: ${date},${cbench_args},${min},${max},${average},${stdev}
87     Log Results And Determine Status    ${min}    ${max}    ${average}    ${average_threshold}    ${output_filename}
88
89 Cbench Suite Setup
90     Wait Until Keyword Succeeds    3x    1s    KarafKeywords.Issue Command On Karaf Console    log:set ERROR
91     Append To File    ${latency_results_file}    LATENCY_MIN,LATENCY_MAX,LATENCY_AVERAGE\n
92     Append To File    ${throughput_results_file}    THROUGHPUT_MIN,THROUGHPUT_MAX,THROUGHPUT_AVERAGE\n
93     ${duration_in_ms}    Evaluate    ${duration_in_secs} * 1000
94     Set Suite Variable    ${duration_in_ms}
95     ##Setting the test timeout dynamically in case larger values on command line override default
96     ${test_timeout}    Evaluate    (${loops} * ${duration_in_secs}) * 1.5
97     Set Suite Variable    ${test_timeout}
98     Run Keyword If    "${cbench_system}" == "localhost"    OperatingSystem.File Should Exist    ${cbench_executable}
99     ...    ELSE    Verify File Exists On Remote System    ${cbench_system}    ${cbench_executable}
100     Should Be True    ${loops} >= 2    If number of loops is less than 2, cbench will not run
101     Verify Feature Is Installed    odl-openflowplugin-drop-test
102     Issue Command On Karaf Console    dropallpacketsrpc on
103
104 Log Results And Determine Status
105     [Arguments]    ${min}    ${max}    ${average}    ${threshold}    ${output_file}
106     Append To File    ${output_file}    ${min},${max},${average}\n
107     Should Be True    ${average} > ${threshold}    ${average} flow_mods per/sec did not exceed threshold of ${threshold}
108
109 Log Results As Zero If Cbench Timed Out
110     Run Keyword If Timeout Occurred    Log Results And Determine Status    0    0    0    0    ${output_filename}