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