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
6 Library OperatingSystem
7 Resource ../global_properties.robot
8 Resource ../browser_setup.robot
11 ${SNK_HOSTS_TEMPLATE} http://\${host}:\${port}/hosts/
12 ${SNK_HOME_TEMPLATE} http://\${host}:\${port}/
15 ${BYTES_PER_PACKET} 29
16 ${PACKETS_PER_SECOND_PER_STREAM} 11
17 ${MONITOR_INTERVAL_IN_SECONDS} 4
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}
30 ${new_bytes}= Get Current Bytes In ${interface}
31 ${return_bytes}= Evaluate int(${new_bytes}) - int(${initial_bytes})
32 [Return] ${return_bytes}
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
44 ${new_pkts}= Get Current Packets In
45 ${return_pkts}= Evaluate int(${new_pkts}) - int(${initial_pkts})
46 [Return] ${return_pkts}
50 [Documentation] COnnects to the Darkstat port on passed host
51 [Arguments] ${host} ${url}
52 ## Being managed by the test case
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}
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(',', '')}
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(',', '')}
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}