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.
Files changed (52) hide show
  1. data/CHANGES.txt +21 -8
  2. data/README.rdoc +43 -1
  3. data/Rudyfile +28 -27
  4. data/bin/rudy +8 -15
  5. data/lib/rudy.rb +2 -2
  6. data/lib/rudy/cli/routines.rb +4 -20
  7. data/lib/rudy/config.rb +1 -0
  8. data/lib/rudy/config/objects.rb +29 -33
  9. data/lib/rudy/huxtable.rb +9 -1
  10. data/lib/rudy/routines.rb +113 -96
  11. data/lib/rudy/routines/helper.rb +3 -3
  12. data/lib/rudy/routines/helpers/dependshelper.rb +1 -1
  13. data/lib/rudy/routines/helpers/diskhelper.rb +3 -3
  14. data/lib/rudy/routines/helpers/scripthelper.rb +41 -39
  15. data/lib/rudy/routines/helpers/userhelper.rb +5 -5
  16. data/lib/rudy/routines/passthrough.rb +11 -11
  17. data/lib/rudy/routines/startup.rb +1 -1
  18. data/rudy.gemspec +4 -37
  19. metadata +5 -38
  20. data/examples/README.md +0 -10
  21. data/examples/debian-sinatra-passenger/commands.rb +0 -19
  22. data/examples/debian-sinatra-passenger/machines.rb +0 -32
  23. data/examples/debian-sinatra-passenger/routines.rb +0 -30
  24. data/examples/debian-sinatra-thin/commands.rb +0 -17
  25. data/examples/debian-sinatra-thin/machines.rb +0 -35
  26. data/examples/debian-sinatra-thin/routines.rb +0 -72
  27. data/lib/rudy/routines/helpers/scmhelper.rb +0 -39
  28. data/lib/rudy/routines/release.rb +0 -48
  29. data/lib/rudy/scm.rb +0 -75
  30. data/lib/rudy/scm/git.rb +0 -217
  31. data/lib/rudy/scm/svn.rb +0 -110
  32. data/test/01_mixins/10_hash_test.rb +0 -25
  33. data/test/10_config/00_setup_test.rb +0 -20
  34. data/test/10_config/30_machines_test.rb +0 -69
  35. data/test/15_scm/00_setup_test.rb +0 -20
  36. data/test/15_scm/20_git_test.rb +0 -61
  37. data/test/20_sdb/00_setup_test.rb +0 -16
  38. data/test/20_sdb/10_domains_test.rb +0 -115
  39. data/test/25_ec2/00_setup_test.rb +0 -29
  40. data/test/25_ec2/10_keypairs_test.rb +0 -41
  41. data/test/25_ec2/20_groups_test.rb +0 -131
  42. data/test/25_ec2/30_addresses_test.rb +0 -38
  43. data/test/25_ec2/40_volumes_test.rb +0 -49
  44. data/test/25_ec2/50_snapshots_test.rb +0 -74
  45. data/test/26_ec2_instances/00_setup_test.rb +0 -28
  46. data/test/26_ec2_instances/10_instances_test.rb +0 -83
  47. data/test/26_ec2_instances/50_images_test.rb +0 -13
  48. data/test/30_sdb_metadata/00_setup_test.rb +0 -21
  49. data/test/30_sdb_metadata/10_disks_test.rb +0 -109
  50. data/test/30_sdb_metadata/20_backups_test.rb +0 -102
  51. data/test/coverage.txt +0 -51
  52. data/test/helper.rb +0 -36
@@ -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
@@ -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
@@ -1,41 +0,0 @@
1
-
2
- module Rudy::Test
3
-
4
- class Case_25_EC2
5
-
6
- context "#{name}_10 KeyPairs" do
7
- setup do
8
- @@test_name ||= 'test-' << Rudy::Utils.strand
9
- @ec2key = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
10
- #@ami = @@config.machines.find(@@zone.to_sym, :ami)
11
- end
12
-
13
-
14
- should "(10) create keypair" do
15
- keypair = @ec2key.create(@@test_name)
16
- assert keypair.is_a?(Rudy::AWS::EC2::KeyPair), "Not a KeyPair"
17
- assert !keypair.name.empty?, "No name"
18
- assert !keypair.fingerprint.empty?, "No fingerprint"
19
- assert !keypair.private_key.empty?, "No private key"
20
- end
21
-
22
- should "(20) list keypairs" do
23
- keypairs = @ec2key.list || []
24
- assert keypairs.size > 0, "No keypairs"
25
- end
26
-
27
- should "(21) get specific keypair" do
28
- assert @ec2key.get(@@test_name).is_a?(Rudy::AWS::EC2::KeyPair), "Not a KeyPair (#{@@test_name})"
29
- end
30
-
31
- should "(50) destroy keypairs" do
32
- keypairs = @ec2key.list || []
33
- assert keypairs.size > 0, "No keypairs"
34
- keypairs.each do |kp|
35
- @ec2key.destroy(kp.name)
36
- end
37
- end
38
- end
39
-
40
- end
41
- end
@@ -1,131 +0,0 @@
1
-
2
- module Rudy::Test
3
-
4
- class Case_25_EC2
5
-
6
- def get_groups
7
- # Ruby 1.8 throws an undefined method error when this is at the
8
- # bottom of the class
9
- group_list = @ec2group.list_as_hash
10
- # "default" cannot be deleted so we exempt it
11
- group_list.reject { |gname,group| gname == "default" }
12
- end
13
-
14
-
15
- context "#{name}_20 Groups" do
16
- setup do
17
- @ec2group = Rudy::AWS::EC2::Groups.new(@@global.accesskey, @@global.secretkey, @@global.region)
18
- @accountnum = @@config.accounts.aws.accountnum
19
- end
20
-
21
- should "(00) not be existing groups" do
22
-
23
- group_list = get_groups
24
- stop_test !group_list.empty?, "Destroy the existing groups (#{group_list.keys.join(', ')})"
25
- stop_test !@accountnum, "Need an account number for group authorization"
26
- end
27
-
28
- should "(01) create group with name" do
29
- group_list = get_groups
30
- test_name ||= 'test-' << Rudy::Utils.strand
31
- str = Rudy::Utils.strand
32
- group = @ec2group.create(test_name)
33
- assert group.is_a?(Rudy::AWS::EC2::Group), "Not a Group object (#{group.class.to_s})"
34
- assert_equal group.name, test_name, "Group name not set"
35
- assert_equal group.description, "Security Group #{test_name}", "Group description not 'Security Group #{test_name}'"
36
- assert @ec2group.exists?(test_name), "Group #{test_name} doesn't exist"
37
- end
38
-
39
- should "(02) create group with name and description" do
40
- test_name ||= 'test-' << Rudy::Utils.strand
41
- str = Rudy::Utils.strand
42
- desc = "Description for #{test_name}"
43
- group = @ec2group.create(test_name, desc)
44
- assert group.is_a?(Rudy::AWS::EC2::Group), "Not a Group object"
45
- assert_equal group.name, test_name, "Group name not set"
46
- assert_equal group.description, desc, "Group description not set"
47
- assert @ec2group.exists?(test_name), "Group #{test_name} doesn't exist"
48
- end
49
-
50
- should "(10) list available groups" do
51
- group_list = @ec2group.list
52
- assert group_list.is_a?(Array), "Group list is not an Array"
53
-
54
- group_list_hash = @ec2group.list_as_hash
55
- assert group_list_hash.is_a?(Hash), "Group list is not an Hash"
56
-
57
- group_list.each do |group|
58
- assert group.is_a?(Rudy::AWS::EC2::Group), "Not a group"
59
- end
60
- end
61
-
62
- should "(20) authorize/revoke group rules for address" do
63
- external_ip_address = Rudy::Utils::external_ip_address
64
- external_ip_address ||= '192.168.0.1/32'
65
-
66
- test_name ||= 'test-' << Rudy::Utils.strand
67
-
68
- group = @ec2group.create(test_name)
69
- protocols = ['tcp', 'udp']
70
- addresses = [external_ip_address]
71
- ports = [[3100,3150],[3200,3250]]
72
-
73
- ret = @ec2group.authorize(test_name, addresses, ports, protocols)
74
- assert ret, "Authorize did not return true"
75
-
76
- group = @ec2group.get(test_name)
77
-
78
- assert group.is_a?(Rudy::AWS::EC2::Group), "Not a group (#{group})"
79
- assert group.addresses.is_a?(Hash), "Addresses is not a hash (#{group.addresses})"
80
-
81
- group.addresses.each_pair do |address,rules|
82
- assert rules.is_a?(Array), "Not an Array"
83
- assert_equal 7, rules.size, "Not 7 rules"
84
- puts "TODO: Check port ranges"
85
- end
86
-
87
- ret = @ec2group.revoke(test_name, addresses, ports, protocols)
88
- assert ret, "Revoke did not return true"
89
- sleep 1 # Wait for eventual consistency
90
- group = @ec2group.get(test_name)
91
- assert group.addresses.is_a?(Hash), "Addresses is not a hash"
92
- assert group.addresses.empty?, "Some addresses not revoked #{group.addresses.to_s}"
93
- end
94
-
95
-
96
- should "(21) authorize/revoke group permissions for account/group" do
97
- test_name ||= 'test-' << Rudy::Utils.strand
98
- group = @ec2group.create(test_name)
99
- should_have = "#{@accountnum}:#{test_name}"
100
-
101
- ret = @ec2group.authorize_group(test_name, test_name, @accountnum)
102
- assert ret, "Authorize failed (#{should_have})"
103
- group = @ec2group.get(test_name)
104
- assert group.is_a?(Rudy::AWS::EC2::Group), "Not a Group object"
105
- assert group.groups.is_a?(Hash), "Groups is not a Hash (#{group.groups.class})"
106
- assert_equal should_have, group.groups.keys.first, "Authorized group is not #{should_have}"
107
- # TODO: Check port ranges
108
-
109
- ret = @ec2group.revoke_group(test_name, test_name, @accountnum)
110
- assert ret, "Revoke failed (#{should_have})"
111
- group = @ec2group.get(test_name)
112
- assert group.is_a?(Rudy::AWS::EC2::Group), "Not a Group object"
113
- assert group.groups.is_a?(Hash), "Groups is not a Hash (#{group.groups.class})"
114
- assert !group.groups.has_key?(should_have), "Still authorized for #{should_have}"
115
- end
116
-
117
-
118
- should "(50) destroy groups" do
119
- group_list = get_groups
120
- assert !group_list.empty?, "No groups"
121
- group_list.each_pair do |gname,group|
122
- assert @ec2group.destroy(group.name), "Not destroyed (#{group.name})"
123
- end
124
- end
125
-
126
-
127
- end
128
-
129
-
130
- end
131
- end