Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add specs for the seed data interface

  • Loading branch information...
commit 424369fc2553d4ed346777baf48018a28128ce8c 1 parent 22f2226
@movitto movitto authored
Showing with 164 additions and 0 deletions.
  1. +24 −0 Gemfile
  2. +5 −0 Rakefile
  3. +135 −0 spec/seed_data_spec.rb
View
24 Gemfile
@@ -0,0 +1,24 @@
+source 'http://rubygems.org'
+
+gem 'rails'
+
+gem 'sqlite3', :require => 'sqlite3'
+
+gem 'authlogic'
+gem 'deltacloud-client', :require => 'deltacloud'
+gem 'sass'
+gem 'haml'
+gem 'will_paginate'
+gem 'nokogiri'
+gem 'compass'
+gem 'compass-960-plugin', :require => 'ninesixty'
+gem 'simple-navigation'
+gem 'typhoeus'
+gem 'rest-client'
+#gem 'rack-restful_submit'
+gem 'uuidtools'
+gem 'pg'
+gem 'thin'
+gem 'json'
+gem 'railties'
+gem 'rspec'
View
5 Rakefile
@@ -38,6 +38,11 @@ Spec::Rake::SpecTask.new(:cleanup_spec) do |t|
t.spec_files = FileList['spec/cleanup_spec.rb']
end
+desc "Run seed spec tests locally"
+Spec::Rake::SpecTask.new(:seed_spec) do |t|
+ t.spec_files = FileList['spec/seed_data_spec.rb']
+end
+
begin
require 'rake/remotespectask'
View
135 spec/seed_data_spec.rb
@@ -0,0 +1,135 @@
+require 'spec_helper'
+
+require 'fileutils'
+require 'curb'
+
+# FIXME should verify agaist ec2 somehow (perhaps using the mock_ec2 driver?)
+
+describe "aeolus-configure seed data api" do
+ before(:all) do
+ # !!! need to comment out "#Defaults requiretty" via visudo for this to work remotely
+ # also need to make sure the user this will be running as has passwordless sudo access
+
+ `sudo /usr/sbin/aeolus-cleanup`
+ $?.exitstatus.should == 0
+
+ `sudo /usr/sbin/aeolus-configure`
+ $?.exitstatus.should == 0
+
+ ENV['RAILS_ENV'] = 'production'
+ $: << "#{CONDUCTOR_PATH}/dutils"
+ require "dutils"
+ end
+
+ after(:each) do
+ remove_puppet_manifest
+ end
+
+ SPEC_MANIFEST = '/tmp/aeolus-spec.pp'
+
+ def create_puppet_manifest(content)
+ File.open(SPEC_MANIFEST, 'w') { |f| f.write content }
+ end
+
+ def remove_puppet_manifest
+ FileUtils.rm SPEC_MANIFEST if File.exist? SPEC_MANIFEST
+ end
+
+ def run_puppet_manifest
+ `sudo puppet #{SPEC_MANIFEST} --modulepath=/usr/share/aeolus-configure/modules/`
+ end
+
+ REQUEST_PREREQS = "$enable_https = true\n"+
+ "include aeolus::conductor\n" +
+ "aeolus::conductor::site_admin{'admin': email => 'dcuser@aeolusproject.org', password => 'password', first_name => 'aeolus', last_name => 'user'}\n" +
+ "aeolus::conductor::login{'admin': password => 'password', require => Aeolus::Conductor::Site_admin['admin']}\n"
+
+ it "should allow provider creation and deletion" do
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::provider{'mock3010': type => 'mock', port => 3010, require => Aeolus::Conductor::Login['admin'] }\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Provider['mock3010'] }")
+
+ run_puppet_manifest
+ $?.exitstatus.should == 0
+ Provider.find(:first, :conditions => ['name = ?', 'mock3010']).should_not be_nil, "provider mock3010 should not be nil"
+ # TODO actually verify service is running
+ remove_puppet_manifest
+
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::deltacloud::disabled{'mock3010': }\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Deltacloud::Disabled['mock3010'] }")
+ run_puppet_manifest
+ $?.exitstatus.should == 0
+ #Provider.find(:first, :conditions => ['name = ?', 'mock3010']).should be_nil, "provider mock3010 should be nil"
+ # TODO actually verify service is down
+ remove_puppet_manifest
+ end
+
+ it "should allow new provider account creation" do
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::provider{'mock3020': type => 'mock', port => 3020, require => Aeolus::Conductor::Login['admin'] }\n" +
+ "aeolus::conductor::provider::account{'mockuser3020': provider => 'mock3020', type => 'mock', username => 'mockuser', password => 'mockpassword', require => Aeolus::Provider['mock3020'] }\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Conductor::Provider::Account['mockuser3020'] }\n")
+ run_puppet_manifest
+ $?.exitstatus.should == 0
+ p = Provider.find(:first, :conditions => ['name = ?', 'mock3020'])
+ pa = p.provider_accounts.first
+ pa.credentials.size.should == 2
+ pa.credentials[0].value.should == "mockuser"
+ pa.credentials[1].value.should == "mockpassword"
+ remove_puppet_manifest
+
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::deltacloud::disabled{'mock3020':}\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Deltacloud::Disabled['mock3020'] }\n")
+ run_puppet_manifest
+ end
+
+ it "should allow new hwp creation" do
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::conductor::hwp{'hwp123': memory => '512', cpu => '1', storage => '', architecture => 'x86_64', require => Aeolus::Conductor::Login['admin'] }\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Conductor::Hwp['hwp123'] }\n")
+ run_puppet_manifest
+ $?.exitstatus.should == 0
+ HardwareProfile.find(:first, :conditions => ['name = ?', 'hwp123']).should_not be_nil, "hwp123 should not be nil"
+ remove_puppet_manifest
+
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::deltacloud::disabled{'mock3020': }\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Deltacloud::Disabled['mock3020'] }\n")
+ run_puppet_manifest
+ end
+
+ it "should allow new image creation" do
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::provider{'mock3030': type => 'mock', port => 3030, require => Aeolus::Conductor::Login['admin'] }\n" +
+ "aeolus::conductor::provider::account{'mockuser3030': provider => 'mock3030', type => 'mock', username => 'mockuser', password => 'mockpassword', require => Aeolus::Provider['mock3030'] }\n" +
+ "aeolus::conductor::hwp{'hwp234': memory => '512', cpu => '1', storage => '', architecture => 'x86_64', require => Aeolus::Conductor::Login['admin'] }" +
+ "aeolus::image{image543: target => 'mock', template => 'examples/custom_repo.tdl', provider => 'mock3030',\n" +
+ " require => [Aeolus::Conductor::Provider::Account['mockuser3030'], Aeolus::Conductor::Hwp['hwp234']] }\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Image['image543'] }\n")
+ run_puppet_manifest
+ $?.exitstatus.should == 0
+
+ # verify deployable
+ File.exist?('/var/www/html/deployables/image543.xml').should be_true
+ (File.read('/var/www/html/deployables/image543.xml') =~ /.*image id='([a-fA-F0-9\-]*)'.*/).should be_true
+ build = $1
+
+ # verify image in iwhd
+ r = Curl::Easy.http_get 'http://localhost:9090/images'
+ (r.body_str =~ /.*<key>#{build}<\/key>.*/).should be_true
+
+ # verify deployment and instance in conductor
+ # TODO verify instance is in 'running' state
+ Deployment.find(:first, :conditions => ['name = ?', 'image543']).should_not be_nil
+ Instance.find(:first, :conditions => ['name = ?', 'image543/image543']).should_not be_nil
+
+ remove_puppet_manifest
+
+ create_puppet_manifest(REQUEST_PREREQS +
+ "aeolus::deltacloud::disabled{'mock3030': }\n" +
+ "aeolus::conductor::logout{'admin': require => Aeolus::Deltacloud::Disabled['mock3030'] }\n")
+ run_puppet_manifest
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.