solutious-rudy 0.8.1 → 0.8.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.
- data/CHANGES.txt +9 -3
- data/README.rdoc +43 -1
- data/Rudyfile +15 -0
- data/bin/rudy +0 -12
- data/examples/debian-sinatra-thin/routines.rb +1 -1
- data/lib/rudy.rb +1 -1
- data/lib/rudy/routines.rb +4 -1
- data/lib/rudy/routines/helper.rb +1 -1
- data/lib/rudy/routines/helpers/dependshelper.rb +1 -1
- data/lib/rudy/routines/helpers/diskhelper.rb +3 -3
- data/lib/rudy/routines/helpers/scripthelper.rb +11 -14
- data/lib/rudy/routines/helpers/userhelper.rb +3 -3
- data/lib/rudy/routines/passthrough.rb +3 -3
- data/lib/rudy/scm.rb +1 -1
- data/lib/rudy/scm/git.rb +4 -4
- data/rudy.gemspec +1 -24
- metadata +1 -24
- data/lib/rudy/routines/helpers/scmhelper.rb +0 -39
- data/lib/rudy/routines/release.rb +0 -48
- data/test/01_mixins/10_hash_test.rb +0 -25
- data/test/10_config/00_setup_test.rb +0 -20
- data/test/10_config/30_machines_test.rb +0 -69
- data/test/15_scm/00_setup_test.rb +0 -20
- data/test/15_scm/20_git_test.rb +0 -61
- data/test/20_sdb/00_setup_test.rb +0 -16
- data/test/20_sdb/10_domains_test.rb +0 -115
- data/test/25_ec2/00_setup_test.rb +0 -29
- data/test/25_ec2/10_keypairs_test.rb +0 -41
- data/test/25_ec2/20_groups_test.rb +0 -131
- data/test/25_ec2/30_addresses_test.rb +0 -38
- data/test/25_ec2/40_volumes_test.rb +0 -49
- data/test/25_ec2/50_snapshots_test.rb +0 -74
- data/test/26_ec2_instances/00_setup_test.rb +0 -28
- data/test/26_ec2_instances/10_instances_test.rb +0 -83
- data/test/26_ec2_instances/50_images_test.rb +0 -13
- data/test/30_sdb_metadata/00_setup_test.rb +0 -21
- data/test/30_sdb_metadata/10_disks_test.rb +0 -109
- data/test/30_sdb_metadata/20_backups_test.rb +0 -102
- data/test/coverage.txt +0 -51
- data/test/helper.rb +0 -36
@@ -1,39 +0,0 @@
|
|
1
|
-
|
2
|
-
module Rudy; module Routines;
|
3
|
-
module SCMHelper
|
4
|
-
include Rudy::Routines::HelperBase
|
5
|
-
extend self
|
6
|
-
|
7
|
-
# Does the routine config contain SCM routines?
|
8
|
-
# Raises Rudy::Error if there is malformed configuration.
|
9
|
-
def scm?(routine)
|
10
|
-
scmnames = SUPPORTED_SCM_NAMES & routine.keys # Find intersections.
|
11
|
-
return false if scmnames.empty? # Nothing to do.
|
12
|
-
scmnames.each do |scm|
|
13
|
-
routine[scm].values.each do |t| # Each SCM should have a
|
14
|
-
raise "Bad #{scm} config" if !t.kind_of?(Hash) # Hash config. Otherwise
|
15
|
-
end # it's misconfigured.
|
16
|
-
end
|
17
|
-
true
|
18
|
-
end
|
19
|
-
|
20
|
-
def create_scm_objects(routine)
|
21
|
-
return nil unless routine
|
22
|
-
scmnames = SUPPORTED_SCM_NAMES & routine.keys
|
23
|
-
vlist = []
|
24
|
-
# Look for scm config in the routine by checking all known scm types.
|
25
|
-
# For each one we'll create an instance of the appropriate SCM class.
|
26
|
-
scmnames.each do |scm|
|
27
|
-
routine[scm].each_pair do |user,params|
|
28
|
-
klass = eval "Rudy::SCM::#{scm.to_s.upcase}"
|
29
|
-
params[:user] = user
|
30
|
-
scm = klass.new(params)
|
31
|
-
scm.raise_early_exceptions # Raises exceptions for obvious problems.
|
32
|
-
vlist << scm
|
33
|
-
end
|
34
|
-
end
|
35
|
-
vlist
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end; end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy; module Routines;
|
4
|
-
class Release < Rudy::Routines::Base
|
5
|
-
|
6
|
-
def init(*args)
|
7
|
-
@routine_name = args.first || :release # :release or :rerelease
|
8
|
-
@routine = fetch_routine_config(@routine_name)
|
9
|
-
end
|
10
|
-
|
11
|
-
def execute()
|
12
|
-
routine_separator(@routine_name)
|
13
|
-
|
14
|
-
vlist = []
|
15
|
-
|
16
|
-
# Some early version control system failing
|
17
|
-
if Rudy::Routines::SCMHelper.scm?(@routine)
|
18
|
-
vlist = Rudy::Routines::SCMHelper.create_scm_objects(@routine)
|
19
|
-
puts task_separator("CREATING RELEASE TAG#{'S' if vlist.size > 1}")
|
20
|
-
vlist.each do |scm|
|
21
|
-
scm.create_release(Rudy.sysinfo.user)
|
22
|
-
puts scm.liner_note
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
machines = generic_machine_runner(:list) do |machine,rbox|
|
27
|
-
vlist.each do |scm|
|
28
|
-
puts task_separator("CREATING REMOTE #{scm.engine.to_s.upcase} CHECKOUT")
|
29
|
-
scm.create_remote_checkout(rbox)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
machines
|
34
|
-
end
|
35
|
-
|
36
|
-
# Called by generic_machine_runner
|
37
|
-
def raise_early_exceptions
|
38
|
-
raise NoRoutine, :release unless @routine
|
39
|
-
rmach = Rudy::Machines.new
|
40
|
-
raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(:root)
|
41
|
-
raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
|
42
|
-
raise MachineGroupNotRunning, current_machine_group unless rmach.running?
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
end;end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'helper')
|
2
|
-
|
3
|
-
module Rudy::Test
|
4
|
-
|
5
|
-
class Case_01_Mixins < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def one_level; {:empty=>1}; end
|
8
|
-
def two_levels; {:l1 => {:empty=>1}}; end
|
9
|
-
def three_levels; { :l1 => { :l2 => {:empty=>1, :empty=>1} } }; end
|
10
|
-
def six_levels; {:l1 => {:l2 => {:l3 => {:l4 => {:l5 => {}, :empty=>1}, :empty=>1}}}}; end
|
11
|
-
|
12
|
-
context "#{name}_10 Hash" do
|
13
|
-
|
14
|
-
should "(10) should calculate deepest point" do
|
15
|
-
assert_equal one_level.deepest_point, 1
|
16
|
-
assert_equal two_levels.deepest_point, 2
|
17
|
-
assert_equal three_levels.deepest_point, 3
|
18
|
-
assert_equal six_levels.deepest_point, 6
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'helper')
|
2
|
-
|
3
|
-
module Rudy::Test
|
4
|
-
|
5
|
-
class Case_10_Config < Test::Unit::TestCase
|
6
|
-
include Rudy::Huxtable
|
7
|
-
|
8
|
-
@@logger = STDERR #StringIO.new
|
9
|
-
@@zone = @@global.zone.to_s
|
10
|
-
|
11
|
-
context "#{name}_00 Setup" do
|
12
|
-
should "(00) have class variables setup" do
|
13
|
-
stop_test !@@global.is_a?(Rudy::Global), "We don't have global (#{@@global})"
|
14
|
-
stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
|
2
|
-
module Rudy::Test
|
3
|
-
class Case_10_Config
|
4
|
-
|
5
|
-
context "#{name}_30 Machines" do
|
6
|
-
|
7
|
-
should "(10) have accounts.aws" do
|
8
|
-
stop_test !@@config.accounts.is_a?(Rudy::Config::Accounts), "Not an Accounts class"
|
9
|
-
|
10
|
-
stop_test @@config.accounts.aws.accountnum.nil?, "No account"
|
11
|
-
stop_test @@config.accounts.aws.accesskey.nil?, "No accesskey"
|
12
|
-
stop_test @@config.accounts.aws.secretkey.nil?, "No secretkey"
|
13
|
-
end
|
14
|
-
|
15
|
-
should "(20) have defaults" do
|
16
|
-
assert @@config.defaults.is_a?(Rudy::Config::Defaults), "Not a Defaults class"
|
17
|
-
assert !@@config.defaults.region.nil?, "No default region"
|
18
|
-
assert !@@config.defaults.zone.nil?, "No default zone"
|
19
|
-
assert !@@config.defaults.environment.nil?, "No default environment"
|
20
|
-
assert !@@config.defaults.role.nil?, "No default role"
|
21
|
-
end
|
22
|
-
|
23
|
-
should "(30) have machines" do
|
24
|
-
assert @@config.machines.is_a?(Rudy::Config::Machines), "Not a Machines class"
|
25
|
-
assert !@@config.machines.keys.empty?, "Nothing in machine config"
|
26
|
-
end
|
27
|
-
|
28
|
-
should "(31) have 2 disks" do
|
29
|
-
reg, zon = @@config.defaults.region, @@config.defaults.zone
|
30
|
-
env, rol = @@config.defaults.environment, @@config.defaults.role
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
# Disabled for 0.5.0 (routines config removed)
|
35
|
-
xshould "(40) have routines" do
|
36
|
-
assert @@config.routines.is_a?(Rudy::Config::Routines), "Not a Routines class"
|
37
|
-
end
|
38
|
-
|
39
|
-
# Disabled for 0.5.0 (most machines config removed)
|
40
|
-
xshould "(50) be able to find and find_deferred" do
|
41
|
-
reg, zon = @@config.defaults.region, @@config.defaults.zone
|
42
|
-
env, rol = @@config.defaults.environment, @@config.defaults.role
|
43
|
-
|
44
|
-
#Caesars.enable_debug
|
45
|
-
|
46
|
-
conf = @@config.machines[env][rol]
|
47
|
-
conf_find = @@config.machines.find(env, rol)
|
48
|
-
conf_find_def = @@config.machines.find_deferred(env, rol)
|
49
|
-
|
50
|
-
assert_equal conf, conf_find, "config hash and find not equal"
|
51
|
-
assert_equal conf_find_def, conf_find, "find and find_deferred not equal"
|
52
|
-
end
|
53
|
-
|
54
|
-
should "(51) find different config for each zone" do
|
55
|
-
reg, zon = @@config.defaults.region, @@config.defaults.zone
|
56
|
-
env, rol = @@config.defaults.environment, @@config.defaults.role
|
57
|
-
|
58
|
-
us_ami = @@config.machines.find(:"us-east-1b", :ami)
|
59
|
-
eu_ami = @@config.machines.find(:"eu-west-1b", :ami)
|
60
|
-
|
61
|
-
assert us_ami.is_a?(String), "No ami for us-east-1b zone"
|
62
|
-
assert eu_ami.is_a?(String), "No ami for eu-west-1b"
|
63
|
-
assert us_ami != eu_ami, "EU (#{eu_ami}) and US (#{us_ami}) AMIs are the same"
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'helper')
|
2
|
-
|
3
|
-
module Rudy::Test
|
4
|
-
|
5
|
-
class Case_15_SCM < Test::Unit::TestCase
|
6
|
-
include Rudy::Huxtable
|
7
|
-
|
8
|
-
@@logger = STDERR #StringIO.new
|
9
|
-
@@zone = @@global.zone.to_s
|
10
|
-
|
11
|
-
context "#{name}_00 Setup" do
|
12
|
-
should "(00) have class variables setup" do
|
13
|
-
stop_test !@@global.is_a?(Rudy::Global), "We don't have global (#{@@global})"
|
14
|
-
stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
data/test/15_scm/20_git_test.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
|
2
|
-
module Rudy::Test
|
3
|
-
class Case_15_SCM
|
4
|
-
|
5
|
-
def generate_rtag(username=nil)
|
6
|
-
now = Time.now
|
7
|
-
mon = now.mon.to_s.rjust(2, '0')
|
8
|
-
day = now.day.to_s.rjust(2, '0')
|
9
|
-
rev = "01"
|
10
|
-
criteria = ['rel', now.year, mon, day, rev]
|
11
|
-
criteria.insert(-2, username) if username
|
12
|
-
criteria.join(Rudy::DELIM)
|
13
|
-
end
|
14
|
-
|
15
|
-
context "#{name}_20 Git" do
|
16
|
-
setup do
|
17
|
-
@strand = Rudy::Utils.strand
|
18
|
-
@scm = Rudy::SCM::GIT.new({
|
19
|
-
:path => "/tmp/git-#{@strand}"
|
20
|
-
})
|
21
|
-
stop_test !Rudy::SCM::GIT.working_copy?, "Not in working directory"
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
should "(10) know when a tag is invalid" do
|
26
|
-
bad_tag = generate_rtag(@strand)
|
27
|
-
assert !@scm.valid_rtag?(bad_tag), "Said bad tag was valid"
|
28
|
-
end
|
29
|
-
|
30
|
-
should "(20) generate release tag name" do
|
31
|
-
rtag_should = generate_rtag(@strand)
|
32
|
-
rtag = @scm.find_next_rtag(@strand)
|
33
|
-
assert_equal rtag_should, rtag, "Bad tag"
|
34
|
-
end
|
35
|
-
|
36
|
-
should "(30) create release" do
|
37
|
-
rtag_should = generate_rtag(@strand)
|
38
|
-
rtag = @scm.create_release(@strand)
|
39
|
-
assert_equal rtag_should, rtag, "Bad tag"
|
40
|
-
assert @scm.delete_rtag(rtag), "Could not delete tag"
|
41
|
-
end
|
42
|
-
|
43
|
-
should "(31) know when a tag is valid" do
|
44
|
-
rtag = @scm.create_release(@strand)
|
45
|
-
assert @scm.valid_rtag?(rtag), "Said bad tag was invalid"
|
46
|
-
assert @scm.delete_rtag(rtag), "Could not delete tag"
|
47
|
-
end
|
48
|
-
|
49
|
-
should "(40) get remote URI" do
|
50
|
-
rtag = @scm.get_remote_uri
|
51
|
-
assert !@scm.get_remote_uri.nil? && !@scm.get_remote_uri.empty?, "No remote URI"
|
52
|
-
end
|
53
|
-
|
54
|
-
xshould "(90) raises exception when deleting a nonexistent tag" do
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'helper')
|
2
|
-
|
3
|
-
module Rudy::Test
|
4
|
-
# Expects:
|
5
|
-
# * There to be no pre-existing keypairs, addresses, etc... (except
|
6
|
-
# the default group)
|
7
|
-
# * It can destroy instances, images, etc...
|
8
|
-
#
|
9
|
-
# DO NOT RUN THIS TEST ON A PRODUCTION AWS ACCOUNT!!
|
10
|
-
#
|
11
|
-
class Case_20_AWS_SDB < Test::Unit::TestCase
|
12
|
-
include Rudy::Huxtable
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
module Rudy::Test
|
2
|
-
class Case_20_AWS_SDB
|
3
|
-
|
4
|
-
|
5
|
-
def get_domain
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
context "#{name}_10 Domains" do
|
10
|
-
|
11
|
-
setup do
|
12
|
-
@sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
|
13
|
-
@domain_list = @sdb.list_domains || []
|
14
|
-
@domain = @domain_list.first
|
15
|
-
end
|
16
|
-
|
17
|
-
should "(10) create domain" do
|
18
|
-
dname = 'test_' << Rudy::Utils.strand
|
19
|
-
assert @sdb.create_domain(dname), "Domain not created (#{dname})"
|
20
|
-
end
|
21
|
-
|
22
|
-
should "(20) list domains" do
|
23
|
-
domain_list = @sdb.list_domains
|
24
|
-
assert domain_list.is_a?(Array), "Not an Array"
|
25
|
-
assert !domain_list.empty?, "No Domains"
|
26
|
-
end
|
27
|
-
|
28
|
-
should "(30) store objects" do
|
29
|
-
|
30
|
-
assert !@domain.nil?, "No domain"
|
31
|
-
|
32
|
-
produce = lambda {
|
33
|
-
{
|
34
|
-
'orange' => rand(100) * 10,
|
35
|
-
'celery' => rand(100) * 100,
|
36
|
-
'grapes' => :green
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
@sdb.put(@domain, 'produce1', produce.call, :replace)
|
41
|
-
@sdb.put(@domain, 'produce2', produce.call, :replace)
|
42
|
-
|
43
|
-
# TODO: Need assertion here!
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
should "(40) get objects" do
|
48
|
-
assert !@domain.nil?, "No domain"
|
49
|
-
item = @sdb.get(@domain, 'produce1')
|
50
|
-
assert_equal Hash, item.class # good stuff
|
51
|
-
assert_equal ['green'], item['grapes']
|
52
|
-
end
|
53
|
-
|
54
|
-
should "(50) query objects" do
|
55
|
-
|
56
|
-
assert !@domain.nil?, "No domain"
|
57
|
-
|
58
|
-
items = @sdb.query(@domain, "[ 'grapes' = 'green' ]")
|
59
|
-
assert items.is_a?(Array), "Not an Array"
|
60
|
-
assert_equal 2, items.size, "More than 2 objects"
|
61
|
-
end
|
62
|
-
|
63
|
-
should "(51) query objects with attributes" do
|
64
|
-
|
65
|
-
assert !@domain.nil?, "No domain"
|
66
|
-
|
67
|
-
items = @sdb.query_with_attributes(@domain, "[ 'grapes' = 'green' ]")
|
68
|
-
assert items.is_a?(Hash), "Not a Hash"
|
69
|
-
assert_equal 2, items.keys.size, "More than 2 objects"
|
70
|
-
assert items['produce1']['celery'].first.to_i > 1000, "Celery less than 1000"
|
71
|
-
end
|
72
|
-
|
73
|
-
should "(60) select objects" do
|
74
|
-
assert !@domain.nil?, "No domain"
|
75
|
-
q = "select * from #{@domain}"
|
76
|
-
|
77
|
-
items = @sdb.select(q)
|
78
|
-
assert items.is_a?(Hash), "Not a Hash"
|
79
|
-
assert_equal 2, items.keys.size, "More than 2 objects"
|
80
|
-
|
81
|
-
# {"produce1"=>{"celery"=>["5200"], "grapes"=>["green"], "orange"=>["550"]}}
|
82
|
-
assert items['produce1']['celery'].first.to_i > 1000, "Celery less than 1000"
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
should "(70) destroy objects" do
|
87
|
-
assert !@domain.nil?, "No domain"
|
88
|
-
q = "select * from #{@domain}"
|
89
|
-
items = @sdb.select(q)
|
90
|
-
assert items.is_a?(Hash), "Not a Hash"
|
91
|
-
items.keys.each do |item|
|
92
|
-
assert @sdb.destroy(@domain, item), "Not destroyed (#{item})"
|
93
|
-
end
|
94
|
-
sleep 1 # Eventual consistency. Items may still appear.
|
95
|
-
q = "select * from #{@domain}"
|
96
|
-
items = @sdb.select(q)
|
97
|
-
assert items.nil?, "Some items not destroyed (#{items})"
|
98
|
-
end
|
99
|
-
|
100
|
-
should "(99) destroy domains" do
|
101
|
-
|
102
|
-
assert !@domain.nil?, "No domain"
|
103
|
-
|
104
|
-
@domain_list.each do |domain|
|
105
|
-
assert @sdb.destroy_domain(domain), "Not destroyed (#{domain})"
|
106
|
-
end
|
107
|
-
|
108
|
-
domain_list = @sdb.list_domains
|
109
|
-
assert domain_list.empty?, "Not empty"
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'helper')
|
2
|
-
|
3
|
-
module Rudy::Test
|
4
|
-
# Expects:
|
5
|
-
# * There to be no pre-existing keypairs, addresses, etc... (except
|
6
|
-
# the default group)
|
7
|
-
# * It can destroy instances, images, etc...
|
8
|
-
#
|
9
|
-
# DO NOT RUN THIS TEST ON A PRODUCTION AWS ACCOUNT!!
|
10
|
-
#
|
11
|
-
class Case_25_EC2 < Test::Unit::TestCase
|
12
|
-
include Rudy::Huxtable
|
13
|
-
|
14
|
-
@@zone = @@global.zone.to_s
|
15
|
-
|
16
|
-
|
17
|
-
context "#{name}_00 Setup" do
|
18
|
-
should "(10) have class variables setup" do
|
19
|
-
stop_test !@@global.is_a?(Rudy::Global), "We don't have global (#{@@global})"
|
20
|
-
stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
|
21
|
-
stop_test !@@global.accountnum, "No account number"
|
22
|
-
end
|
23
|
-
should "(11) be zone" do
|
24
|
-
stop_test !@@zone, "No zone"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|