From: Martyn Taylor mtaylor@redhat.com
--- Rakefile | 7 +++++++ spec/spec.opts | 4 ++++ spec/spec_helper.rb | 3 +++ 3 files changed, 14 insertions(+), 0 deletions(-) create mode 100644 spec/spec.opts create mode 100644 spec/spec_helper.rb
diff --git a/Rakefile b/Rakefile index cc529d8..5ad69f5 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,8 @@ require 'rake/clean' require 'rake/rpmtask' require 'rake/yumtask' +require 'rubygems' +require 'spec/rake/spectask'
CURRENT_DIR = File.dirname(__FILE__) RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild" @@ -26,3 +28,8 @@ Rake::YumTask.new(YUM_REPO) do |repo| repo.rpms << rpm_task.rpm_file end
+desc "Run remote spec tests, SSH options: hostname=<hostname> username=<username> password=<password>" +Spec::Rake::SpecTask.new do |t, args| + t.spec_files = FileList['spec/**/*_spec.rb'] +end + diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..391705b --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,4 @@ +--colour +--format progress +--loadby mtime +--reverse diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..a9cd152 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,3 @@ +require 'rubygems' +require 'spec' +require 'spec/autorun'
From: Martyn Taylor mtaylor@redhat.com
Tests run over SSH to remote installation of aeolus-configure
example: rake spec hostname="testing" username="root" password="password"
Options: hostname - default localhost username - default root password - no default
You can avoid passing password as an argument by adding your ssh public key to the authorized_hosts file on your test machine
will be ignored, and an empty message aborts the commit. --- spec/verify_install_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) create mode 100644 spec/verify_install_spec.rb
diff --git a/spec/verify_install_spec.rb b/spec/verify_install_spec.rb new file mode 100644 index 0000000..1ea5d27 --- /dev/null +++ b/spec/verify_install_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' +require 'net/ssh' + +describe "aeolus-configure install" do + before(:each) do + @username = "#{ENV['username']}".empty? ? "root" : "#{ENV['username']}" + @hostname = "#{ENV['hostname']}".empty? ? "localhost" : "#{ENV['hostname']}" + @password = "#{ENV['password']}".empty? ? nil : "#{ENV['password']}" + end + + it "should install all aeolus packages" do + stdout = "" + Net::SSH.start(@hostname, @username, :password => @password) do |ssh| + ssh.exec!("rpm -qa | grep aeolus") do |channel, stream, data| + stdout << data if stream == :stdout + end + end + stdout.include?("aeolus-conductor-doc").should == true + stdout.include?("aeolus-conductor").should == true + stdout.include?("aeolus-conductor-daemons").should == true + stdout.include?("aeolus-configure").should == true + end + + it "should start all aeolus services" do + stdout = "" + Net::SSH.start(@hostname, @username, :password => @password) do |ssh| + ["aeolus-conductor", "aeolus-conductor", "iwhd", "conductor-dbomatic", "conductor-condor_refreshd", "postgresql"].each do |service| + ssh.exec!("/etc/init.d/" + service + " status") do |channel, stream, data| + stdout << data if stream == :stdout + end + stdout.include?("is running").should == true + stdout = "" + end + end + end +end
ACK with a small note about the commit message (inline)
Thomas
On 03/09/2011 12:31 PM, mtaylor@redhat.com wrote:
From: Martyn Taylormtaylor@redhat.com
Tests run over SSH to remote installation of aeolus-configure
example: rake spec hostname="testing" username="root" password="password"
Options: hostname - default localhost username - default root password - no default
You can avoid passing password as an argument by adding your ssh public key to the authorized_hosts file on your test machine
will be ignored, and an empty message aborts the commit.
This line ^ looks like it was was left here by accident.
spec/verify_install_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) create mode 100644 spec/verify_install_spec.rb
diff --git a/spec/verify_install_spec.rb b/spec/verify_install_spec.rb new file mode 100644 index 0000000..1ea5d27 --- /dev/null +++ b/spec/verify_install_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' +require 'net/ssh'
+describe "aeolus-configure install" do
- before(:each) do
- @username = "#{ENV['username']}".empty? ? "root" : "#{ENV['username']}"
- @hostname = "#{ENV['hostname']}".empty? ? "localhost" : "#{ENV['hostname']}"
- @password = "#{ENV['password']}".empty? ? nil : "#{ENV['password']}"
- end
- it "should install all aeolus packages" do
- stdout = ""
- Net::SSH.start(@hostname, @username, :password => @password) do |ssh|
ssh.exec!("rpm -qa | grep aeolus") do |channel, stream, data|
stdout<< data if stream == :stdout
end
- end
- stdout.include?("aeolus-conductor-doc").should == true
- stdout.include?("aeolus-conductor").should == true
- stdout.include?("aeolus-conductor-daemons").should == true
- stdout.include?("aeolus-configure").should == true
- end
- it "should start all aeolus services" do
- stdout = ""
- Net::SSH.start(@hostname, @username, :password => @password) do |ssh|
["aeolus-conductor", "aeolus-conductor", "iwhd", "conductor-dbomatic", "conductor-condor_refreshd", "postgresql"].each do |service|
ssh.exec!("/etc/init.d/" + service + " status") do |channel, stream, data|
stdout<< data if stream == :stdout
end
stdout.include?("is running").should == true
stdout = ""
end
- end
- end
+end
On 03/09/2011 06:31 AM, mtaylor@redhat.com wrote:
<snip>
+++ b/spec/verify_install_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' +require 'net/ssh'
+describe "aeolus-configure install" do
- before(:each) do
- @username = "#{ENV['username']}".empty? ? "root" : "#{ENV['username']}"
- @hostname = "#{ENV['hostname']}".empty? ? "localhost" : "#{ENV['hostname']}"
- @password = "#{ENV['password']}".empty? ? nil : "#{ENV['password']}"
- end
- it "should install all aeolus packages" do
- stdout = ""
- Net::SSH.start(@hostname, @username, :password => @password) do |ssh|
ssh.exec!("rpm -qa | grep aeolus") do |channel, stream, data|
stdout<< data if stream == :stdout
end
- end
- stdout.include?("aeolus-conductor-doc").should == true
- stdout.include?("aeolus-conductor").should == true
- stdout.include?("aeolus-conductor-daemons").should == true
- stdout.include?("aeolus-configure").should == true
- end
Hey sorry for the delay, was just able to look at this. I'm wondering if this is the best way to go, eg create a ssh session in each test case and the remotely execute commands, capturing and parsing the output.
Rather it might make sense to implement the spec suite as we would normally, executing all the operations against the local system, and provide a means via our build system to copy all the tests to a remote host and execute the spec suite there via ssh/scp. Or we could create a aeolus-configure-test rpm providing the test cases which can be installed and run on a remote system.
Also organization-wise, I'm thinking we might want to break the spec suite into multiple files, one for each aeolus component, eg conductor_spec.rb, deltacloud_spec.rb, iwhd_spec.rb, etc. Each verifying the intended component has been properly setup. We can have an aeolus_spec.rb containing the integration tests which don't fit in any one module. NBD this can be easily changed at any point.
Thoughts?
-Mo
Hey Martyn,
I nit inline, otherwise ACK.
Thomas
On 03/09/2011 12:31 PM, mtaylor@redhat.com wrote:
From: Martyn Taylormtaylor@redhat.com
Rakefile | 7 +++++++ spec/spec.opts | 4 ++++ spec/spec_helper.rb | 3 +++ 3 files changed, 14 insertions(+), 0 deletions(-) create mode 100644 spec/spec.opts create mode 100644 spec/spec_helper.rb
diff --git a/Rakefile b/Rakefile index cc529d8..5ad69f5 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,8 @@ require 'rake/clean' require 'rake/rpmtask' require 'rake/yumtask' +require 'rubygems' +require 'spec/rake/spectask'
CURRENT_DIR = File.dirname(__FILE__) RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild" @@ -26,3 +28,8 @@ Rake::YumTask.new(YUM_REPO) do |repo| repo.rpms<< rpm_task.rpm_file end
+desc "Run remote spec tests, SSH options: hostname=<hostname> username=<username> password=<password>" +Spec::Rake::SpecTask.new do |t, args|
- t.spec_files = FileList['spec/**/*_spec.rb']
+end
Trailing whitespace ^
diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..391705b --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,4 @@ +--colour +--format progress +--loadby mtime +--reverse diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..a9cd152 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,3 @@ +require 'rubygems' +require 'spec' +require 'spec/autorun'
aeolus-devel@lists.fedorahosted.org