DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with A&AI. It handles low level stuff like managing the http request library and A&AI required fields |
| 3 | Library ExtendedSelenium2Library |
| 4 | Library StringTemplater |
| 5 | Library UUID |
| 6 | Library OperatingSystem |
| 7 | Resource ../global_properties.robot |
| 8 | Resource ../browser_setup.robot |
| 9 | |
| 10 | *** Variables *** |
| 11 | ${SNK_HOSTS_TEMPLATE} http://\${host}:\${port}/hosts/ |
| 12 | ${SNK_HOME_TEMPLATE} http://\${host}:\${port}/ |
| 13 | ${SNK_PATH} |
| 14 | ${SNK_PORT} 667 |
| 15 | ${BYTES_PER_PACKET} 29 |
| 16 | ${PACKETS_PER_SECOND_PER_STREAM} 11 |
| 17 | ${MONITOR_INTERVAL_IN_SECONDS} 4 |
| 18 | |
| 19 | *** Keywords *** |
| 20 | Get Darkstat Bytes In |
| 21 | [Documentation] Get bytes received on the passed interface for the given interval |
| 22 | [Arguments] ${host} ${interface} ${interval}=${MONITOR_INTERVAL_IN_SECONDS} |
| 23 | ${map}= Create Dictionary host=${host} port=${SNK_PORT} path=${SNK_PATH} |
| 24 | ${url}= Template String ${SNK_HOSTS_TEMPLATE} ${map} |
| 25 | Connect to Darkstat ${host} ${url} |
| 26 | Title Should Be Hosts (darkstat3 eth1) |
| 27 | ${initial_bytes}= Get Current Bytes In ${interface} |
| 28 | Sleep ${interval} |
| 29 | Go To ${url} |
| 30 | ${new_bytes}= Get Current Bytes In ${interface} |
| 31 | ${return_bytes}= Evaluate int(${new_bytes}) - int(${initial_bytes}) |
| 32 | [Return] ${return_bytes} |
| 33 | |
| 34 | Get Darkstat Packets In |
| 35 | [Documentation] Get bytes received on the passed interface for the given interval |
| 36 | [Arguments] ${host} ${interval}=${MONITOR_INTERVAL_IN_SECONDS} |
| 37 | ${map}= Create Dictionary host=${host} port=${SNK_PORT} path=${SNK_PATH} |
| 38 | ${url}= Template String ${SNK_HOME_TEMPLATE} ${map} |
| 39 | Connect to Darkstat ${host} ${url} |
| 40 | Title Should Be Graphs (darkstat3 eth1) |
| 41 | ${initial_pkts}= Get Current Packets In |
| 42 | Sleep ${interval} |
| 43 | Go To ${url} |
| 44 | ${new_pkts}= Get Current Packets In |
| 45 | ${return_pkts}= Evaluate int(${new_pkts}) - int(${initial_pkts}) |
| 46 | [Return] ${return_pkts} |
| 47 | |
| 48 | |
| 49 | Connect to Darkstat |
| 50 | [Documentation] COnnects to the Darkstat port on passed host |
| 51 | [Arguments] ${host} ${url} |
| 52 | ## Being managed by the test case |
| 53 | ##Setup Browser |
| 54 | Go To ${url} |
| 55 | Maximize Browser Window |
| 56 | Set Selenium Speed ${GLOBAL_SELENIUM_DELAY} |
| 57 | Set Browser Implicit Wait ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT} |
| 58 | Log Logging in to ${url} |
| 59 | Handle Proxy Warning |
| 60 | |
| 61 | |
| 62 | Get Current Bytes In |
| 63 | [Documentation] Retrieves packets input from given host from current Darkstats hosts page |
| 64 | [Arguments] ${interface} |
| 65 | ${bytes}= Get Text xpath=//tr[td/a[text() = '${interface}']]/td[4] |
| 66 | ${bytes}= Evaluate ${bytes.replace(',', '')} |
| 67 | [Return] ${bytes} |
| 68 | |
| 69 | Get Current Packets In |
| 70 | [Documentation] Retrieves packets input from given host from current Darkstats hosts page |
| 71 | ${bytes}= Get Text xpath=//span[@id = 'tp'] |
| 72 | ${bytes}= Evaluate ${bytes.replace(',', '')} |
| 73 | [Return] ${bytes} |
| 74 | |
| 75 | |
| 76 | Get Expected Range For Number Of Streams |
| 77 | [Documentation] Calculates the expected range of bytes for an interval for the given number of streams |
| 78 | [Arguments] ${number_of_streams} |
| 79 | ${bytes_per_second}= Evaluate ${BYTES_PER_PACKET}*(${PACKETS_PER_SECOND_PER_STREAM}*${number_of_streams}) |
| 80 | ${low_bytes}= Evaluate (${MONITOR_INTERVAL_IN_SECONDS}-1)*${bytes_per_second} |
| 81 | ${high_bytes}= Evaluate (${MONITOR_INTERVAL_IN_SECONDS}+1)*${bytes_per_second} |
| 82 | [Return] ${low_bytes} ${high_bytes} |