statt 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/lib/selenium-grid/Capfile +107 -0
  2. data/lib/selenium-grid/Rakefile +190 -0
  3. data/lib/selenium-grid/build.xml +185 -0
  4. data/lib/selenium-grid/grid_configuration.yml +44 -0
  5. data/lib/selenium-grid/lib/build/common-build.xml +290 -0
  6. data/lib/selenium-grid/lib/selenium-grid-hub-1.0.5-SNAPSHOT.jar +0 -0
  7. data/lib/selenium-grid/lib/selenium-grid-hub-standalone-1.0.5-SNAPSHOT.jar +0 -0
  8. data/lib/selenium-grid/lib/selenium-grid-remote-control-1.0.5-SNAPSHOT.jar +0 -0
  9. data/lib/selenium-grid/lib/selenium-grid-remote-control-standalone-1.0.5-SNAPSHOT.jar +0 -0
  10. data/lib/selenium-grid/lib/selenium-grid-tools-1.0.5-SNAPSHOT.jar +0 -0
  11. data/lib/selenium-grid/lib/selenium-grid-tools-standalone-1.0.5-SNAPSHOT.jar +0 -0
  12. data/lib/selenium-grid/log/hub.log +66 -0
  13. data/lib/selenium-grid/project.properties +4 -0
  14. data/lib/selenium-grid/vendor/commons-logging-1.0.4.jar +0 -0
  15. data/lib/selenium-grid/vendor/selenium-java-client-driver-1.0.1.jar +0 -0
  16. data/lib/selenium-grid/vendor/selenium-server-1.0.1.jar +0 -0
  17. data/lib/statt.rb +5 -5
  18. data/lib/statt/client.rb +26 -18
  19. data/lib/statt/motor.rb +24 -8
  20. metadata +49 -24
  21. data/lib/selenium-grid/examples/ec2/lib/selenium_grid/aws/cloud.rb +0 -35
  22. data/lib/selenium-grid/examples/ec2/lib/selenium_grid/aws/ec2.rb +0 -7
  23. data/lib/selenium-grid/examples/ec2/lib/selenium_grid/aws/ec2_client.rb +0 -62
  24. data/lib/selenium-grid/examples/ec2/lib/selenium_grid/aws/hub.rb +0 -22
  25. data/lib/selenium-grid/examples/ec2/lib/selenium_grid/aws/remote_command.rb +0 -47
  26. data/lib/selenium-grid/examples/ec2/lib/selenium_grid/aws/server.rb +0 -56
  27. data/lib/selenium-grid/examples/ec2/test/unit/all_test.rb +0 -2
  28. data/lib/selenium-grid/examples/ec2/test/unit/cloud_test.rb +0 -27
  29. data/lib/selenium-grid/examples/ec2/test/unit/ec2_client_test.rb +0 -137
  30. data/lib/selenium-grid/examples/ec2/test/unit/hub_test.rb +0 -24
  31. data/lib/selenium-grid/examples/ec2/test/unit/remote_command_test.rb +0 -46
  32. data/lib/selenium-grid/examples/ec2/test/unit/server_test.rb +0 -22
  33. data/lib/selenium-grid/examples/ec2/test/unit/test_helper.rb +0 -4
  34. data/lib/selenium-grid/examples/ruby/flickr_example.rb +0 -16
  35. data/lib/selenium-grid/examples/ruby/lib/array_extension.rb +0 -13
  36. data/lib/selenium-grid/examples/ruby/lib/multi_process_behaviour_runner.rb +0 -28
  37. data/lib/selenium-grid/examples/ruby/paris_spec.rb +0 -34
  38. data/lib/selenium-grid/examples/ruby/perigord_spec.rb +0 -22
  39. data/lib/selenium-grid/examples/ruby/spec_helper.rb +0 -59
  40. data/lib/selenium-grid/sample-scripts/launch-remote-controls.rb +0 -20
@@ -0,0 +1,107 @@
1
+ # Capistrano recipes for Managing the Selenium Grid
2
+ #
3
+ # Check out http://www.capify.org/ if you are not familiar with Capistrano
4
+ #
5
+ # Typical sequence:
6
+ #
7
+ # cap -f selenium_grid_deploy.rb grid restart_all
8
+ #
9
+ # Or if you want to control all the steps:
10
+ #
11
+ # cap -f selenium_grid_deploy.rb grid start_x11
12
+ # cap -f selenium_grid_deploy.rb grid launch_hub
13
+ # cap -f selenium_grid_deploy.rb grid launch_rcs
14
+ # ...
15
+
16
+ set :repository, "http://subversion.local/repository/my-project/trunk/"
17
+ set :user, "philippe"
18
+ set :password, "verysecure"
19
+
20
+ ########### Environments ##########################
21
+
22
+ task :grid do
23
+ role :hub, "192.168.0.24"
24
+ role :rc, "192.168.0.24"
25
+ set :grid_dir, "/home/philippe/selenium-grid-0.9.1"
26
+ end
27
+
28
+ ########### Tasks ##################################
29
+
30
+ desc("Stop everything")
31
+ task :stop_all, :roles => [:rc, :hub ]do
32
+ stop_rcs rescue nil
33
+ stop_hub rescue nil
34
+ stop_x11 rescue nil
35
+ end
36
+
37
+ desc("Start everything")
38
+ task :start_all, :roles => [:rc, :hub ]do
39
+ start_x11
40
+ launch_hub
41
+ sleep 10
42
+ launch_rcs
43
+ end
44
+
45
+ desc("Restart everything")
46
+ task :restart_all, :roles => [:rc, :hub ] do
47
+ stop_all
48
+ start_all
49
+ end
50
+
51
+ desc("Stop dedicated X server")
52
+ task :stop_x11, :roles => :rc do
53
+ run "killall /usr/X11R6/bin/Xvnc"
54
+ end
55
+
56
+ desc("Start dedicated X server. Needed for remote controls.")
57
+ task :start_x11, :roles => :rc do
58
+ run "nohup rake --rakefile selenium-grid-0.9.1/Rakefile xvnc:start",
59
+ :env => { "PATH" => "/usr/X11R6/bin:/usr/local/bin:/usr/bin:/bin" }
60
+ end
61
+
62
+ desc("Display Selenium Hub Console in Firefox")
63
+ task :console, :roles => :hub do
64
+ system "firefox http://192.168.0.24:4444/console"
65
+ end
66
+
67
+ desc("Launch Selenium Hub")
68
+ task :launch_hub, :roles => :hub do
69
+ run "nohup rake --rakefile selenium-grid-0.9.1/Rakefile hub:start BACKGROUND=true",
70
+ :env => { "PATH" => "/home/philippe/Applications/jdk-6.0/bin:/home/philippe/Applications/ant-1.7.0/bin:/usr/local/bin:/usr/bin:/bin" }
71
+ end
72
+
73
+ desc("Stop Selenium Hub")
74
+ task :stop_hub, :roles => :hub do
75
+ run 'kill `lsof -t -i :4444`'
76
+ end
77
+
78
+ desc("Launch all remote controls")
79
+ task :launch_rcs, :roles => :rc do
80
+ ports = ENV['ports'] || "6000-6020"
81
+ port_range = Range.new(*ports.split("-"))
82
+ port_range.each do |port|
83
+ run remote_control_launch_command(port),
84
+ :env => {
85
+ "DISPLAY" => ":1",
86
+ "PATH" => "/home/philippe/Applications/jdk-6.0/bin:/home/philippe/Applications/ant-1.7.0/bin:/usr/lib/firefox:/usr/local/bin:/usr/bin:/bin" }
87
+ end
88
+ end
89
+
90
+ desc("Stop all remote controls")
91
+ task :stop_rcs, :roles => :rc do
92
+ ports = ENV['ports'] || "6000-6020"
93
+ run "kill `lsof -i :#{ports}`"
94
+ end
95
+
96
+ desc("View running browsers through VNC")
97
+ task :view_browsers_on_grid, :roles => :rc do
98
+ if File.exists?('/Applications/Chicken of the VNC.app/Contents/MacOS/Chicken of the VNC')
99
+ system "'/Applications/Chicken of the VNC.app/Contents/MacOS/Chicken of the VNC' --Display 1 192.168.0.24"
100
+ else
101
+ system 'vncviewer 192.168.0.24:1'
102
+ end
103
+ end
104
+
105
+ def remote_control_launch_command(port)
106
+ "nohup rake --rakefile #{grid_dir}/Rakefile rc:start --trace PORT=#{port} BACKGROUND=true"
107
+ end
@@ -0,0 +1,190 @@
1
+ #
2
+ # Rakefile managing Selenium Grid components
3
+ #
4
+ require "net/http"
5
+ require "yaml"
6
+ require File.dirname(__FILE__) + '/lib/ruby/tcp_socket_extensions'
7
+ require File.dirname(__FILE__) + '/lib/ruby/file_extensions'
8
+ require File.dirname(__FILE__) + '/lib/ruby/java/classpath'
9
+ require File.dirname(__FILE__) + '/lib/ruby/java/vm'
10
+ require File.dirname(__FILE__) + '/lib/ruby/s_grid/hub'
11
+ require File.dirname(__FILE__) + '/lib/ruby/s_grid/remote_control'
12
+
13
+ desc "Print help"
14
+ task :help do
15
+ puts <<-EOS
16
+
17
+ Rake tasks to manage a Selenium Grid on a *single* machine.
18
+
19
+ NOTE: To manage a Grid accross *multiple* machines use the
20
+ Capistrano recipes provided with Selenium Grid distribution
21
+
22
+
23
+ Start the Hub and 15 Remote Controls
24
+ ------------------------------------
25
+
26
+ rake all:start
27
+
28
+ Stop the Hub and 15 Remote Controls
29
+ -----------------------------------
30
+
31
+ rake all:stop
32
+
33
+ Restart the Hub and 15 Remote Controls
34
+ --------------------------------------
35
+
36
+ rake all:restart
37
+
38
+ Start the Hub with only 10 Remote Controls, ports 5000 to 5010
39
+ --------------------------------------------------------------
40
+
41
+ rake all:restart PORTS=5000-5010
42
+
43
+ Stop them with
44
+
45
+ rake all:stop PORTS=5000-5010
46
+
47
+ Start 5 Remote Controls with the Hub, ports 6500 to 6505
48
+ --------------------------------------------------------
49
+
50
+ rake rc:start_all PORTS=6500-6505
51
+
52
+ Start a single Remote Control on port 6666
53
+ -------------------------------------------
54
+
55
+ rake rc:start PORT=6666
56
+
57
+
58
+ EOS
59
+ end
60
+
61
+ desc "Restart all services (Hub a Remote Controls"
62
+ task :'all:restart' do
63
+ Rake::Task[:'all:stop'].execute([]) rescue nil
64
+ Rake::Task[:'all:start'].execute []
65
+ end
66
+
67
+ desc "Launch all services (Hub a Remote Controls"
68
+ task :'all:start' do
69
+ ENV['BACKGROUND'] = "true"
70
+ Rake::Task[:'hub:start'].execute []
71
+ puts "Waiting for Hub to come up..."
72
+ hub.wait_until_up_and_running
73
+ Rake::Task[:'rc:start_all'].execute []
74
+ end
75
+
76
+ desc "Stop all services (Hub a Remote Controls"
77
+ task :'all:stop' do
78
+ puts "Stopping all Selenium Grid servers..."
79
+ Rake::Task[:'rc:stop_all'].execute []
80
+ Rake::Task[:'hub:stop'].execute [] rescue nil
81
+ end
82
+
83
+ desc "Launch Hub"
84
+ task :'hub:start' do
85
+ SGrid::Hub.new.start \
86
+ :background => ("true" == ENV['BACKGROUND']),
87
+ :log_file => File.native_path(File.dirname(__FILE__) + "/log/hub.log")
88
+ end
89
+
90
+ desc "Stop Hub"
91
+ task :'hub:stop' do
92
+ puts "Shutting down Selenium Grid hub..."
93
+ hub.shutdown rescue EOFError
94
+ end
95
+
96
+ desc "Launch Remote Control"
97
+ task :'rc:start' do
98
+ port = ENV['PORT'] || 5555
99
+ remote_control(:port => port).start \
100
+ :background => ENV['BACKGROUND'],
101
+ :log_file => File.join(File.dirname(__FILE__), "log", "rc-#{port}.log")
102
+ end
103
+
104
+ desc "Stop Remote Control"
105
+ task :'rc:stop' do
106
+ remote_control.stop rescue EOFError
107
+ end
108
+
109
+ desc "Launch Remote Control"
110
+ task :'rc:start_all' do
111
+ ports = ENV['PORTS'] || "5000-5015"
112
+ port_range = Range.new(*ports.split("-"))
113
+ port_range.each do |port|
114
+ remote_control(:port => port, :background => true).start \
115
+ :background => true,
116
+ :log_file => File.join(File.dirname(__FILE__), "log", "rc-#{port}.log")
117
+ end
118
+ end
119
+
120
+ desc"Stop Remote Controls. Usage rake rc:stop PORTS=5555-5560"
121
+ task :'rc:stop_all' do
122
+ ports = ENV['PORTS'] || "5000-5015"
123
+ port_range = Range.new(*ports.split("-"))
124
+ port_range.each do |port|
125
+ begin
126
+ puts "Stopping Remote Control on port #{port}"
127
+ rc = SGrid::RemoteControl.new :host => ENV['HOST'] || "localhost",
128
+ :port => port
129
+ rc.shutdown
130
+ rescue Exception => e
131
+ STDERR.puts "Could not properly shutdown remote control #{port} : #{e}"
132
+ end
133
+ end
134
+ end
135
+
136
+ desc "Launch a Xvnc server"
137
+ task :'xvnc:start' do
138
+ sh "Xvnc :1 -alwaysshared -geometry 1280x1024 -depth 24 -desktop 'Selenium Grid' 2>&1 >#{File.join(File.dirname(__FILE__), "log", "X.log")} &"
139
+ end
140
+
141
+ desc "Fully Automated Demo (for continuous integration)"
142
+ task :'ci:demo' do
143
+ begin
144
+ Rake::Task["all:restart"].execute []
145
+ sh "ant run-demo-in-parallel" unless running_on_openqa_servers
146
+ sh "ant run-demo-in-sequence"
147
+ ensure
148
+ Rake::Task["all:stop"].execute []
149
+ end
150
+ end
151
+
152
+ desc "Fully Automated Ruby Example (for continuous integration)"
153
+ task :'ci:ruby-example' do
154
+ begin
155
+ Rake::Task["all:restart"].execute []
156
+ sh "(cd examples/ruby; rake tests:run_in_parallel)" unless running_on_openqa_servers
157
+ sh "(cd examples/ruby; rake tests:run_in_sequence)"
158
+ ensure
159
+ Rake::Task["all:stop"].execute []
160
+ end
161
+ end
162
+
163
+ def config
164
+ @config ||= YAML.load(File.read(File.dirname(__FILE__) + "/grid_configuration.yml"))
165
+ end
166
+
167
+ def hub_port
168
+ (ENV["HUB_PORT"] || config["hub"]["port"]).to_i
169
+ end
170
+
171
+ def hub
172
+ SGrid::Hub.new :port => hub_port
173
+ end
174
+
175
+ def remote_control(options={})
176
+ SGrid::RemoteControl.new(
177
+ :host => ENV['HOST'] || "localhost",
178
+ :port => (options[:port] || ENV['PORT'] || 5555),
179
+ :hub_url => (ENV['HUB_URL'] || "http://localhost:#{hub_port}"),
180
+ :shutdown_command => ENV['RC_SHUTDOWN_COMMAND'])
181
+ end
182
+
183
+ # Network is slow as hell on these VMs
184
+ def running_on_openqa_servers
185
+ begin
186
+ not `hostname -s`.grep(/(xserve|osxvm)/).empty?
187
+ rescue Exception
188
+ false
189
+ end
190
+ end
@@ -0,0 +1,185 @@
1
+ <project name="Selenium Grid Distribution" basedir=".">
2
+
3
+ <description>Selenium Grid Distribution</description>
4
+ <property file="${basedir}/project.properties"/>
5
+ <property name="version" value="SNAPSHOT"/>
6
+
7
+ <property name="webSite" value="http://images.google.com" />
8
+ <property name="seleniumHost" value="localhost" />
9
+ <property name="seleniumPort" value="4444" />
10
+ <property name="browser" value="*firefox" />
11
+ <property name="hubPollerIntervalInSeconds" value="30" />
12
+
13
+ <taskdef resource="testngtasks" classpath="${basedir}/vendor/testng-5.7-jdk15.jar"/>
14
+
15
+ <path id="remote-control.classpath">
16
+ <fileset dir="${basedir}/vendor">
17
+ <include name="selenium-server-*.jar"/>
18
+ </fileset>
19
+ <!-- Selenium Server must be first in classpath -->
20
+ <fileset dir="${basedir}/lib">
21
+ <include name="selenium-grid-remote-control-standalone-${version}*.jar"/>
22
+ </fileset>
23
+ <pathelement path="${java.class.path}/"/>
24
+ </path>
25
+
26
+ <path id="hub.classpath">
27
+ <pathelement path="${basedir}/"/>
28
+ <fileset dir="${basedir}/lib">
29
+ <include name="selenium-grid-hub-standalone-${version}*.jar"/>
30
+ </fileset>
31
+ <pathelement path="${java.class.path}/"/>
32
+ </path>
33
+
34
+ <path id="demo.classpath">
35
+ <fileset dir="${basedir}/lib">
36
+ <include name="selenium-grid-demo-standalone-${version}*.jar"/>
37
+ </fileset>
38
+ <fileset dir="${basedir}/vendor">
39
+ <include name="testng-*.jar"/>
40
+ <include name="commons-logging-*.jar"/>
41
+ </fileset>
42
+ <pathelement path="${java.class.path}/"/>
43
+ </path>
44
+
45
+ <target name="sanity-check" description="Check that the tools are been installed and configured properly">
46
+ <property environment="env"/>
47
+ <echo>${ant.version}</echo>
48
+ <condition property="ant-7">
49
+ <antversion atleast="1.7.0"/>
50
+ </condition>
51
+ <fail message="You need Ant 1.7 or newer" unless="ant-7"/>
52
+
53
+ <echo>Java ${ant.java.version}</echo>
54
+ <condition property="java-5">
55
+ <not><matches pattern="^1\.[0-4]" string="${ant.java.version}"/></not>
56
+ </condition>
57
+ <fail message="Your must use Java 1.5 or newer. You are currrenltly using '${ant.java.version}'." unless="java-5"/>
58
+
59
+ <echo/>
60
+ <echo>********************************************************************</echo>
61
+ <echo>Congratulations, your setup looks good. Have fun with Selenium Grid!</echo>
62
+ <echo>********************************************************************</echo>
63
+ <echo/>
64
+ <echo>You can launch a hub by running 'ant launch-hub'</echo>
65
+ <echo>You can launch a a remote control with 'ant -Dport=4444 launch-remote-control'</echo>
66
+ </target>
67
+
68
+ <target name="launch-hub" description="Launch Selenium Hub">
69
+ <java classname="com.thoughtworks.selenium.grid.hub.HubServer"
70
+ classpathref="hub.classpath"
71
+ fork="true"
72
+ failonerror="true" >
73
+
74
+ <sysproperty key="http.proxyHost" value="${http.proxyHost}"/>
75
+ <sysproperty key="http.proxyPort" value="${http.proxyPort}"/>
76
+ <sysproperty key="https.proxyHost" value="${https.proxyHost}"/>
77
+ <sysproperty key="https.proxyPort" value="${https.proxyPort}"/>
78
+ </java>
79
+ </target>
80
+
81
+ <property name="host" value="localhost"/>
82
+ <property name="port" value="5555"/>
83
+ <property name="hubURL" value="http://localhost:4444"/>
84
+ <property name="environment" value="*firefox"/>
85
+ <property name="seleniumArgs" value=""/>
86
+ <target name="launch-remote-control" description="Launch A Remote Control">
87
+ <java classpathref="remote-control.classpath"
88
+ classname="com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringRemoteControlLauncher"
89
+ fork="true"
90
+ failonerror="true">
91
+
92
+ <sysproperty key="http.proxyHost" value="${http.proxyHost}"/>
93
+ <sysproperty key="http.proxyPort" value="${http.proxyPort}"/>
94
+ <sysproperty key="https.proxyHost" value="${https.proxyHost}"/>
95
+ <sysproperty key="https.proxyPort" value="${https.proxyPort}"/>
96
+
97
+ <arg value="-port"/>
98
+ <arg value="${port}"/>
99
+ <arg value="-host"/>
100
+ <arg value="${host}"/>
101
+ <arg value="-hubURL"/>
102
+ <arg value="${hubURL}"/>
103
+ <arg value="-env"/>
104
+ <arg value="${environment}"/>
105
+ <arg value="-hubPollerIntervalInSeconds"/>
106
+ <arg value="${hubPollerIntervalInSeconds}"/>
107
+ <arg line="${seleniumArgs}"/>
108
+ </java>
109
+ </target>
110
+
111
+ <target name="run-demo-in-sequence" description="Run Selenium tests one by one">
112
+ <java classpathref="demo.classpath"
113
+ classname="org.testng.TestNG"
114
+ failonerror="true"
115
+
116
+ >
117
+ <sysproperty key="java.security.policy" file="${basedir}/lib/testng.policy"/>
118
+ <sysproperty key="webSite" value="${webSite}" />
119
+ <sysproperty key="seleniumHost" value="${seleniumHost}" />
120
+ <sysproperty key="seleniumPort" value="${seleniumPort}" />
121
+ <sysproperty key="browser" value="${browser}" />
122
+
123
+ <arg value="-suitename" />
124
+ <arg value="Selenium Grid Demo In Sequence" />
125
+ <arg value="-d" />
126
+ <arg value="${basedir}/target/reports" />
127
+ <arg value="-testclass"/>
128
+ <arg value="com.thoughtworks.selenium.grid.demo.WebTestForASingleBrowser"/>
129
+ </java>
130
+ </target>
131
+
132
+ <target name="run-demo-in-parallel" description="Run Selenium tests in parallel">
133
+ <java classpathref="demo.classpath"
134
+ classname="org.testng.TestNG"
135
+ failonerror="true"
136
+
137
+ >
138
+ <sysproperty key="java.security.policy" file="${basedir}/lib/testng.policy"/>
139
+ <sysproperty key="webSite" value="${webSite}" />
140
+ <sysproperty key="seleniumHost" value="${seleniumHost}" />
141
+ <sysproperty key="seleniumPort" value="${seleniumPort}" />
142
+ <sysproperty key="browser" value="${browser}" />
143
+
144
+ <arg value="-d" />
145
+ <arg value="${basedir}/target/reports" />
146
+ <arg value="-suitename" />
147
+ <arg value="Selenium Grid Demo In Parallel" />
148
+ <arg value="-parallel"/>
149
+ <arg value="methods"/>
150
+ <arg value="-threadcount"/>
151
+ <arg value="10"/>
152
+ <arg value="-testclass"/>
153
+ <arg value="com.thoughtworks.selenium.grid.demo.WebTestForASingleBrowser"/>
154
+ </java>
155
+ </target>
156
+
157
+ <target name="run-demo-for-multiple-environments"
158
+ description="Run Selenium tests in parallel for multiple environments">
159
+ <java classpathref="demo.classpath"
160
+ classname="org.testng.TestNG"
161
+ failonerror="true"
162
+
163
+ >
164
+ <sysproperty key="java.security.policy" file="${basedir}/lib/testng.policy"/>
165
+ <sysproperty key="webSite" value="${webSite}" />
166
+ <sysproperty key="seleniumHost" value="${seleniumHost}" />
167
+ <sysproperty key="seleniumPort" value="${seleniumPort}" />
168
+ <sysproperty key="firstEnvironment" value="Firefox on Windows" />
169
+ <sysproperty key="secondEnvironment" value="Firefox on Windows" />
170
+ <sysproperty key="thirdEnvironment" value="Firefox on OS X" />
171
+
172
+ <arg value="-d" />
173
+ <arg value="${basedir}/target/reports" />
174
+ <arg value="-suitename" />
175
+ <arg value="Selenium Grid Demo In Parallel For Multiple Environments" />
176
+ <arg value="-parallel"/>
177
+ <arg value="methods"/>
178
+ <arg value="-threadcount"/>
179
+ <arg value="10"/>
180
+ <arg value="-testclass"/>
181
+ <arg value="com.thoughtworks.selenium.grid.demo.WebTestInvolvingMultiEnvironments"/>
182
+ </java>
183
+ </target>
184
+
185
+ </project>