solutious-rudy 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGES.txt +9 -3
  2. data/README.rdoc +43 -1
  3. data/Rudyfile +15 -0
  4. data/bin/rudy +0 -12
  5. data/examples/debian-sinatra-thin/routines.rb +1 -1
  6. data/lib/rudy.rb +1 -1
  7. data/lib/rudy/routines.rb +4 -1
  8. data/lib/rudy/routines/helper.rb +1 -1
  9. data/lib/rudy/routines/helpers/dependshelper.rb +1 -1
  10. data/lib/rudy/routines/helpers/diskhelper.rb +3 -3
  11. data/lib/rudy/routines/helpers/scripthelper.rb +11 -14
  12. data/lib/rudy/routines/helpers/userhelper.rb +3 -3
  13. data/lib/rudy/routines/passthrough.rb +3 -3
  14. data/lib/rudy/scm.rb +1 -1
  15. data/lib/rudy/scm/git.rb +4 -4
  16. data/rudy.gemspec +1 -24
  17. metadata +1 -24
  18. data/lib/rudy/routines/helpers/scmhelper.rb +0 -39
  19. data/lib/rudy/routines/release.rb +0 -48
  20. data/test/01_mixins/10_hash_test.rb +0 -25
  21. data/test/10_config/00_setup_test.rb +0 -20
  22. data/test/10_config/30_machines_test.rb +0 -69
  23. data/test/15_scm/00_setup_test.rb +0 -20
  24. data/test/15_scm/20_git_test.rb +0 -61
  25. data/test/20_sdb/00_setup_test.rb +0 -16
  26. data/test/20_sdb/10_domains_test.rb +0 -115
  27. data/test/25_ec2/00_setup_test.rb +0 -29
  28. data/test/25_ec2/10_keypairs_test.rb +0 -41
  29. data/test/25_ec2/20_groups_test.rb +0 -131
  30. data/test/25_ec2/30_addresses_test.rb +0 -38
  31. data/test/25_ec2/40_volumes_test.rb +0 -49
  32. data/test/25_ec2/50_snapshots_test.rb +0 -74
  33. data/test/26_ec2_instances/00_setup_test.rb +0 -28
  34. data/test/26_ec2_instances/10_instances_test.rb +0 -83
  35. data/test/26_ec2_instances/50_images_test.rb +0 -13
  36. data/test/30_sdb_metadata/00_setup_test.rb +0 -21
  37. data/test/30_sdb_metadata/10_disks_test.rb +0 -109
  38. data/test/30_sdb_metadata/20_backups_test.rb +0 -102
  39. data/test/coverage.txt +0 -51
  40. data/test/helper.rb +0 -36
@@ -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
@@ -1,38 +0,0 @@
1
-
2
- module Rudy::Test
3
-
4
- class Case_25_EC2
5
-
6
- context "#{name}_30 Addresses" do
7
- setup do
8
- @ec2add = Rudy::AWS::EC2::Addresses.new(@@global.accesskey, @@global.secretkey, @@global.region)
9
- end
10
-
11
- should "(00) not be existing addresses" do
12
- stop_test @ec2add.any?, "Destroy the existing addresses"
13
- end
14
-
15
- should "(01) create address" do
16
- address = @ec2add.create
17
- assert address.is_a?(Rudy::AWS::EC2::Address), "Did not create"
18
- assert address.ipaddress.size > 0, "Address length is 0"
19
- end
20
-
21
- should "(10) list available addresses" do
22
- assert @ec2add.any?, "No addresses"
23
- assert @ec2add.list_as_hash.is_a?(Hash), "Not a Hash"
24
- assert @ec2add.list.is_a?(Array), "Not an Array"
25
- assert_equal 1, @ec2add.list.size, "More than one address"
26
- end
27
-
28
- should "(50) destroy address" do
29
- assert @ec2add.any?, "No addresses"
30
- @ec2add.list.each do |address|
31
- assert @ec2add.destroy(address), "Did not destroy"
32
- end
33
- end
34
-
35
- end
36
-
37
- end
38
- end
@@ -1,49 +0,0 @@
1
-
2
- module Rudy::Test
3
- class Case_25_EC2
4
-
5
- context "#{name}_40 Volumes" do
6
- setup do
7
- @ec2vol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
8
- end
9
-
10
- should "(00) not be existing volumes" do
11
- volume_hash = @ec2vol.list_as_hash
12
- volume_hash.reject! { |volid, vol| !vol.available? }
13
- stop_test !volume_hash.empty?, "Destroy the existing volumes"
14
- end
15
-
16
- should "(10) create volume" do
17
- volume_size = 2
18
- volume = @ec2vol.create(volume_size, @@zone)
19
- assert volume.is_a?(Rudy::AWS::EC2::Volume), "Not a Volume"
20
- assert_equal @@zone, volume.zone, "Zone incorrect: #{volume.zone}"
21
- assert_equal volume_size.to_i, volume.size.to_i, "Size incorrect: #{volume.size}"
22
- assert volume.creating? || volume.available?, "Volume not creating or available (#{volume.status})"
23
- end
24
-
25
- should "(20) list volumes" do
26
- volume_list = @ec2vol.list
27
- assert volume_list.is_a?(Array), "Not an Array"
28
- assert volume_list.size > 0, "No Volumes in Array"
29
-
30
- volume_hash = @ec2vol.list_as_hash
31
- assert volume_hash.is_a?(Hash), "Not a Hash"
32
- assert volume_hash.keys.size > 0, "No Volumes in Hash"
33
-
34
- assert_equal volume_list.size.to_i, volume_hash.keys.size.to_i, "Hash and Array not equal size"
35
- end
36
-
37
- should "(50) destroy volumes" do
38
- assert @ec2vol.any?, "No volumes"
39
- volume_list = @ec2vol.list
40
- volume_list.each do |vol|
41
- next unless vol.available?
42
- assert @ec2vol.destroy(vol.awsid), "Not destroyed (#{vol.awsid})"
43
- end
44
- end
45
-
46
- end
47
-
48
- end
49
- end
@@ -1,74 +0,0 @@
1
-
2
- module Rudy::Test
3
- class Case_25_EC2
4
-
5
-
6
-
7
- context "#{name}_50 Snapshots" do
8
- setup do
9
- @ec2vol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
10
- @ec2snap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
- end
12
-
13
-
14
- should "(00) be no snapshots" do
15
- stop_test @ec2snap.any?, "Destroy existing snapshots"
16
- end
17
-
18
- should "(01) create a volume to work off of" do
19
- @@volumes ||= []
20
- @@volumes << @ec2vol.create(1, @@zone)
21
- stop_test !@@volumes.first.is_a?(Rudy::AWS::EC2::Volume), "No volume to work off of."
22
- end
23
-
24
- should "(01) create snapshot" do
25
- stop_test !@@volumes.first.is_a?(Rudy::AWS::EC2::Volume), "No volume to work off of."
26
- assert !@@volumes.first.awsid.empty?, "No volume ID"
27
- @ec2snap.create(@@volumes.first.awsid)
28
- end
29
-
30
- should "(10) list snapshots" do
31
- snap_list = @ec2snap.list
32
- assert snap_list.is_a?(Array), "Not an Array"
33
- assert snap_list.size > 0, "No Snapshots in Array"
34
-
35
- snap_hash = @ec2snap.list_as_hash
36
- assert snap_hash.is_a?(Hash), "Not an Hash"
37
- assert snap_hash.keys.size > 0, "No Snapshots in Hash"
38
- end
39
-
40
- should "(20) create volume from snapshot" do
41
- volume_size = 2
42
- snap_list = @ec2snap.list || []
43
- assert !snap_list.empty?, "No snapshots"
44
-
45
- volume = @ec2vol.create(volume_size, @@zone, snap_list.first.awsid)
46
- #puts "#{volume.awsid} #{snap_list.first.awsid}"
47
-
48
- assert volume.is_a?(Rudy::AWS::EC2::Volume), "Not a Volume"
49
- assert_equal @@zone, volume.zone, "Zone incorrect: #{volume.zone}"
50
- assert_equal snap_list.first.awsid, volume.snapid, "Snapshot mismatch: #{volume.snapid}"
51
- assert_equal volume_size.to_i, volume.size.to_i, "Size incorrect: #{volume.size}"
52
- assert volume.creating? || volume.available?, "Volume not creating or available (#{volume.status})"
53
-
54
- @@volumes << volume # We put it here so it will be destoryed in teardown
55
- end
56
-
57
- should "(90) destroy snapshots" do
58
- assert @ec2snap.any?, "No snapshots"
59
- snap_list = @ec2snap.list
60
- snap_list.each do |snap|
61
- next unless snap.completed?
62
- assert @ec2snap.destroy(snap.awsid), "Not destroyed (#{snap.awsid})"
63
- end
64
- end
65
-
66
- should "(99) cleanup created volumes" do
67
- (@@volumes || []).each do |vol|
68
- assert @ec2vol.destroy(vol), "Volume not destoryed (#{vol.awsid})"
69
- end
70
- end
71
- end
72
-
73
- end
74
- end
@@ -1,28 +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_26_EC2 < Test::Unit::TestCase
12
- include Rudy::Huxtable
13
-
14
- @@logger = STDERR #StringIO.new
15
- @@zone = @@global.zone.to_s
16
-
17
- context "#{name}_10 Setup" do
18
- should "(10) have class variables setup" do
19
- stop_test !@@global.is_a?(Rudy::Global), "We don't have Rudy::Global (#{@@global})"
20
- stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
21
- end
22
- should "(11) be zone" do
23
- stop_test !@@zone, "No zone"
24
- end
25
- end
26
- end
27
-
28
- end
@@ -1,83 +0,0 @@
1
-
2
- module Rudy::Test
3
- class Case_26_EC2
4
-
5
- context "#{name}_10 Instances" do
6
-
7
- setup do
8
- @ec2inst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
9
- @ec2add = Rudy::AWS::EC2::Addresses.new(@@global.accesskey, @@global.secretkey, @@global.region)
10
- @us_ami = @@config.machines.find(:"us-east-1b", :ami)
11
- @eu_ami = @@config.machines.find(:"eu-west-1b", :ami)
12
- end
13
-
14
- should "(10) create instance" do
15
- stop_test @ec2inst.any?(:running), "Destroy the existing instances"
16
- instances = @ec2inst.create(:ami => 'ami-235fba4a', :group => "default") # Amazon Getting Started AMI
17
- assert instances.is_a?(Array), "Not an Array of instances"
18
- instances.each do |instance|
19
- Rudy::Utils.waiter(2, 120, @@logger) { @ec2inst.running?(instance) }
20
- assert instance.is_a?(Rudy::AWS::EC2::Instance), "Not an Rudy::AWS::EC2::Instance object"
21
- end
22
- end
23
-
24
- testnum = 20
25
- Rudy::AWS::EC2::Instances::KNOWN_STATES.each do |state|
26
- should "(#{testnum}) know instance is #{state}" do
27
- instances = @ec2inst.list(state) || []
28
- return skip("No instances are in #{state} state") if instances.empty?
29
- instances.each do |inst|
30
- assert @ec2inst.send("#{state}?", inst) # running?(inst)
31
- end
32
- end
33
- testnum += 1
34
- end
35
-
36
- should "(30) list instance" do
37
- assert @ec2inst.list.is_a?(Array), "Not an Array of instances"
38
- assert @ec2inst.list_as_hash.is_a?(Hash), "Not a Hash of instances"
39
- end
40
-
41
- should "(31) console" do
42
- @ec2inst.list.each do |inst|
43
- assert @ec2inst.console_output(inst).is_a?(String), "No console output for (#{inst.awsid})"
44
- end
45
- end
46
-
47
- should "(40) assign IP address to instance" do
48
- assigned = 0
49
- @ec2inst.list.each do |instance|
50
- next if instance.terminated? || instance.shutting_down?
51
- assigned += 1
52
- address = @ec2add.create
53
- assert @ec2add.associate(address, instance), "Did not assign"
54
- end
55
- assert assigned > 0, "No machine running"
56
- end
57
-
58
-
59
- should "(60) restart instance" do
60
- instances = @ec2inst.list(:running)
61
- instances.each do |instance|
62
- assert @ec2inst.restart(instance), "Did not restart"
63
- end
64
- end
65
-
66
- should "(99) destroy instance" do
67
- assert @ec2inst.any?(:running), "No instances running"
68
- instances = @ec2inst.list(:running)
69
- return skip("No running instances") unless instances
70
- instances.each do |instance|
71
- assert @ec2inst.destroy(instance), "Did not destroy"
72
- end
73
- end
74
-
75
- should "(99) clean created addresses" do
76
- (@ec2add.list || []).each do |address|
77
- assert @ec2add.destroy(address), "Address not destroyed (#{address})"
78
- end
79
- end
80
-
81
- end
82
- end
83
- end