solutious-rudy 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +19 -1
- data/README.rdoc +66 -35
- data/Rakefile +1 -0
- data/Rudyfile +97 -6
- data/bin/ird +7 -4
- data/bin/rudy +120 -212
- data/bin/rudy-ec2 +240 -0
- data/bin/rudy-s3 +76 -0
- data/bin/rudy-sdb +67 -0
- data/lib/annoy.rb +61 -18
- data/lib/console.rb +10 -5
- data/lib/rudy/aws/ec2/address.rb +76 -40
- data/lib/rudy/aws/ec2/group.rb +138 -78
- data/lib/rudy/aws/ec2/image.rb +134 -12
- data/lib/rudy/aws/ec2/instance.rb +116 -89
- data/lib/rudy/aws/ec2/keypair.rb +26 -14
- data/lib/rudy/aws/ec2/snapshot.rb +23 -12
- data/lib/rudy/aws/ec2/volume.rb +198 -202
- data/lib/rudy/aws/ec2/zone.rb +77 -0
- data/lib/rudy/aws/ec2.rb +56 -25
- data/lib/rudy/aws/s3.rb +54 -0
- data/lib/rudy/aws/sdb/error.rb +46 -0
- data/lib/rudy/aws/sdb.rb +298 -0
- data/lib/rudy/aws.rb +29 -57
- data/lib/rudy/{metadata/backup.rb → backup.rb} +8 -8
- data/lib/rudy/cli/aws/ec2/addresses.rb +105 -0
- data/lib/rudy/cli/aws/ec2/candy.rb +208 -0
- data/lib/rudy/cli/aws/ec2/groups.rb +121 -0
- data/lib/rudy/cli/aws/ec2/images.rb +196 -0
- data/lib/rudy/cli/aws/ec2/instances.rb +194 -0
- data/lib/rudy/cli/aws/ec2/keypairs.rb +53 -0
- data/lib/rudy/cli/aws/ec2/snapshots.rb +49 -0
- data/lib/rudy/cli/aws/ec2/volumes.rb +104 -0
- data/lib/rudy/cli/aws/ec2/zones.rb +22 -0
- data/lib/rudy/cli/aws/s3/buckets.rb +50 -0
- data/lib/rudy/cli/aws/s3/store.rb +22 -0
- data/lib/rudy/cli/aws/sdb/domains.rb +41 -0
- data/lib/rudy/cli/{deploy.rb → candy.rb} +2 -6
- data/lib/rudy/cli/config.rb +25 -20
- data/lib/rudy/cli/disks.rb +18 -108
- data/lib/rudy/cli/machines.rb +94 -0
- data/lib/rudy/cli/routines.rb +47 -70
- data/lib/rudy/cli.rb +104 -89
- data/lib/rudy/config/objects.rb +5 -43
- data/lib/rudy/config.rb +8 -24
- data/lib/rudy/disks.rb +248 -0
- data/lib/rudy/global.rb +121 -0
- data/lib/rudy/huxtable.rb +232 -147
- data/lib/rudy/machines.rb +245 -0
- data/lib/rudy/metadata.rb +136 -0
- data/lib/rudy/routines/helpers/diskhelper.rb +101 -0
- data/lib/rudy/routines/helpers/scripthelper.rb +91 -0
- data/lib/rudy/routines/release.rb +27 -8
- data/lib/rudy/routines/shutdown.rb +47 -32
- data/lib/rudy/routines/startup.rb +47 -37
- data/lib/rudy/routines.rb +30 -37
- data/lib/rudy/scm/svn.rb +1 -1
- data/lib/rudy/utils.rb +262 -4
- data/lib/rudy.rb +76 -248
- data/lib/storable.rb +19 -16
- data/lib/sysinfo.rb +1 -1
- data/rudy.gemspec +88 -68
- data/support/rudy-ec2-startup +5 -5
- data/test/05_config/00_setup_test.rb +3 -7
- data/test/20_sdb/00_setup_test.rb +2 -17
- data/test/20_sdb/10_domains_test.rb +18 -16
- data/test/25_ec2/00_setup_test.rb +5 -10
- data/test/25_ec2/10_keypairs_test.rb +13 -5
- data/test/25_ec2/20_groups_test.rb +48 -56
- data/test/25_ec2/30_addresses_test.rb +13 -10
- data/test/25_ec2/40_volumes_test.rb +11 -8
- data/test/25_ec2/50_snapshots_test.rb +17 -12
- data/test/26_ec2_instances/00_setup_test.rb +3 -8
- data/test/26_ec2_instances/10_instances_test.rb +21 -19
- data/test/30_sdb_metadata/00_setup_test.rb +2 -9
- data/test/30_sdb_metadata/10_disks_test.rb +47 -37
- data/test/30_sdb_metadata/20_backups_test.rb +9 -9
- data/test/helper.rb +5 -3
- data/vendor/highline-1.5.1/CHANGELOG +222 -0
- data/vendor/highline-1.5.1/INSTALL +35 -0
- data/vendor/highline-1.5.1/LICENSE +7 -0
- data/vendor/highline-1.5.1/README +63 -0
- data/vendor/highline-1.5.1/Rakefile +82 -0
- data/vendor/highline-1.5.1/TODO +6 -0
- data/vendor/highline-1.5.1/examples/ansi_colors.rb +38 -0
- data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +18 -0
- data/vendor/highline-1.5.1/examples/basic_usage.rb +75 -0
- data/vendor/highline-1.5.1/examples/color_scheme.rb +32 -0
- data/vendor/highline-1.5.1/examples/limit.rb +12 -0
- data/vendor/highline-1.5.1/examples/menus.rb +65 -0
- data/vendor/highline-1.5.1/examples/overwrite.rb +19 -0
- data/vendor/highline-1.5.1/examples/page_and_wrap.rb +322 -0
- data/vendor/highline-1.5.1/examples/password.rb +7 -0
- data/vendor/highline-1.5.1/examples/trapping_eof.rb +22 -0
- data/vendor/highline-1.5.1/examples/using_readline.rb +17 -0
- data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +120 -0
- data/vendor/highline-1.5.1/lib/highline/compatibility.rb +17 -0
- data/vendor/highline-1.5.1/lib/highline/import.rb +43 -0
- data/vendor/highline-1.5.1/lib/highline/menu.rb +395 -0
- data/vendor/highline-1.5.1/lib/highline/question.rb +463 -0
- data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +193 -0
- data/vendor/highline-1.5.1/lib/highline.rb +758 -0
- data/vendor/highline-1.5.1/setup.rb +1360 -0
- data/vendor/highline-1.5.1/test/tc_color_scheme.rb +56 -0
- data/vendor/highline-1.5.1/test/tc_highline.rb +823 -0
- data/vendor/highline-1.5.1/test/tc_import.rb +54 -0
- data/vendor/highline-1.5.1/test/tc_menu.rb +429 -0
- data/vendor/highline-1.5.1/test/ts_all.rb +15 -0
- metadata +81 -69
- data/lib/aws_sdb/error.rb +0 -42
- data/lib/aws_sdb/service.rb +0 -215
- data/lib/aws_sdb.rb +0 -3
- data/lib/rudy/aws/simpledb.rb +0 -71
- data/lib/rudy/cli/addresses.rb +0 -85
- data/lib/rudy/cli/backups.rb +0 -175
- data/lib/rudy/cli/domains.rb +0 -17
- data/lib/rudy/cli/groups.rb +0 -77
- data/lib/rudy/cli/images.rb +0 -111
- data/lib/rudy/cli/instances.rb +0 -142
- data/lib/rudy/cli/keypairs.rb +0 -47
- data/lib/rudy/cli/manager.rb +0 -51
- data/lib/rudy/cli/release.rb +0 -174
- data/lib/rudy/cli/volumes.rb +0 -121
- data/lib/rudy/command/addresses.rb +0 -69
- data/lib/rudy/command/backups.rb +0 -65
- data/lib/rudy/command/disks-old.rb +0 -322
- data/lib/rudy/command/disks.rb +0 -9
- data/lib/rudy/command/domains.rb +0 -34
- data/lib/rudy/command/groups.rb +0 -118
- data/lib/rudy/command/instances.rb +0 -278
- data/lib/rudy/command/keypairs.rb +0 -149
- data/lib/rudy/command/manager.rb +0 -65
- data/lib/rudy/command/volumes.rb +0 -127
- data/lib/rudy/metadata/disk.rb +0 -149
- data/lib/rudy/metadata/machine.rb +0 -34
- data/lib/rudy/routines/disk_handler.rb +0 -190
- data/lib/rudy/routines/script_runner.rb +0 -65
- data/test/50_commands/00_setup_test.rb +0 -11
- data/test/50_commands/10_keypairs_test.rb +0 -79
- data/test/50_commands/20_groups_test.rb +0 -77
- data/test/50_commands/40_volumes_test.rb +0 -55
- data/test/50_commands/50_instances_test.rb +0 -110
- data/tryouts/console_tryout.rb +0 -91
- data/tryouts/disks.rb +0 -55
- data/tryouts/nested_methods.rb +0 -36
- data/tryouts/session_tryout.rb +0 -46
@@ -4,28 +4,31 @@ module Rudy::Test
|
|
4
4
|
class Case_25_EC2
|
5
5
|
|
6
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
|
+
|
7
11
|
should "(00) not be existing addresses" do
|
8
|
-
|
9
|
-
stop_test @@ec2.addresses.any?, "Destroy the existing addresses"
|
12
|
+
stop_test @ec2add.any?, "Destroy the existing addresses"
|
10
13
|
end
|
11
14
|
|
12
15
|
should "(01) create address" do
|
13
|
-
address =
|
16
|
+
address = @ec2add.create
|
14
17
|
assert address.is_a?(Rudy::AWS::EC2::Address), "Did not create"
|
15
18
|
assert address.ipaddress.size > 0, "Address length is 0"
|
16
19
|
end
|
17
20
|
|
18
21
|
should "(10) list available addresses" do
|
19
|
-
assert
|
20
|
-
assert
|
21
|
-
assert
|
22
|
-
assert_equal 1,
|
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"
|
23
26
|
end
|
24
27
|
|
25
28
|
should "(50) destroy address" do
|
26
|
-
assert
|
27
|
-
|
28
|
-
assert
|
29
|
+
assert @ec2add.any?, "No addresses"
|
30
|
+
@ec2add.list.each do |address|
|
31
|
+
assert @ec2add.destroy(address), "Did not destroy"
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
@@ -3,16 +3,19 @@ module Rudy::Test
|
|
3
3
|
class Case_25_EC2
|
4
4
|
|
5
5
|
context "#{name}_40 Volumes" do
|
6
|
-
|
6
|
+
setup do
|
7
|
+
@ec2vol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
|
8
|
+
end
|
9
|
+
|
7
10
|
should "(00) not be existing volumes" do
|
8
|
-
volume_hash =
|
11
|
+
volume_hash = @ec2vol.list_as_hash
|
9
12
|
volume_hash.reject! { |volid, vol| !vol.available? }
|
10
13
|
stop_test !volume_hash.empty?, "Destroy the existing volumes"
|
11
14
|
end
|
12
15
|
|
13
16
|
should "(10) create volume" do
|
14
17
|
volume_size = 2
|
15
|
-
volume =
|
18
|
+
volume = @ec2vol.create(volume_size, @@zone)
|
16
19
|
assert volume.is_a?(Rudy::AWS::EC2::Volume), "Not a Volume"
|
17
20
|
assert_equal @@zone, volume.zone, "Zone incorrect: #{volume.zone}"
|
18
21
|
assert_equal volume_size.to_i, volume.size.to_i, "Size incorrect: #{volume.size}"
|
@@ -20,11 +23,11 @@ module Rudy::Test
|
|
20
23
|
end
|
21
24
|
|
22
25
|
should "(20) list volumes" do
|
23
|
-
volume_list =
|
26
|
+
volume_list = @ec2vol.list
|
24
27
|
assert volume_list.is_a?(Array), "Not an Array"
|
25
28
|
assert volume_list.size > 0, "No Volumes in Array"
|
26
29
|
|
27
|
-
volume_hash =
|
30
|
+
volume_hash = @ec2vol.list_as_hash
|
28
31
|
assert volume_hash.is_a?(Hash), "Not a Hash"
|
29
32
|
assert volume_hash.keys.size > 0, "No Volumes in Hash"
|
30
33
|
|
@@ -32,11 +35,11 @@ module Rudy::Test
|
|
32
35
|
end
|
33
36
|
|
34
37
|
should "(50) destroy volumes" do
|
35
|
-
assert
|
36
|
-
volume_list =
|
38
|
+
assert @ec2vol.any?, "No volumes"
|
39
|
+
volume_list = @ec2vol.list
|
37
40
|
volume_list.each do |vol|
|
38
41
|
next unless vol.available?
|
39
|
-
assert
|
42
|
+
assert @ec2vol.destroy(vol.awsid), "Not destroyed (#{vol.awsid})"
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -5,39 +5,44 @@ module Rudy::Test
|
|
5
5
|
|
6
6
|
|
7
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
|
+
|
8
13
|
|
9
14
|
should "(00) be no snapshots" do
|
10
|
-
stop_test
|
15
|
+
stop_test @ec2snap.any?, "Destroy existing snapshots"
|
11
16
|
end
|
12
17
|
|
13
18
|
should "(01) create a volume to work off of" do
|
14
19
|
@@volumes ||= []
|
15
|
-
@@volumes <<
|
20
|
+
@@volumes << @ec2vol.create(1, @@zone)
|
16
21
|
stop_test !@@volumes.first.is_a?(Rudy::AWS::EC2::Volume), "No volume to work off of."
|
17
22
|
end
|
18
23
|
|
19
24
|
should "(01) create snapshot" do
|
20
25
|
stop_test !@@volumes.first.is_a?(Rudy::AWS::EC2::Volume), "No volume to work off of."
|
21
26
|
assert !@@volumes.first.awsid.empty?, "No volume ID"
|
22
|
-
|
27
|
+
@ec2snap.create(@@volumes.first.awsid)
|
23
28
|
end
|
24
29
|
|
25
30
|
should "(10) list snapshots" do
|
26
|
-
snap_list =
|
31
|
+
snap_list = @ec2snap.list
|
27
32
|
assert snap_list.is_a?(Array), "Not an Array"
|
28
33
|
assert snap_list.size > 0, "No Snapshots in Array"
|
29
34
|
|
30
|
-
snap_hash =
|
35
|
+
snap_hash = @ec2snap.list_as_hash
|
31
36
|
assert snap_hash.is_a?(Hash), "Not an Hash"
|
32
37
|
assert snap_hash.keys.size > 0, "No Snapshots in Hash"
|
33
38
|
end
|
34
39
|
|
35
40
|
should "(20) create volume from snapshot" do
|
36
41
|
volume_size = 2
|
37
|
-
snap_list =
|
42
|
+
snap_list = @ec2snap.list || []
|
38
43
|
assert !snap_list.empty?, "No snapshots"
|
39
44
|
|
40
|
-
volume =
|
45
|
+
volume = @ec2vol.create(volume_size, @@zone, snap_list.first.awsid)
|
41
46
|
#puts "#{volume.awsid} #{snap_list.first.awsid}"
|
42
47
|
|
43
48
|
assert volume.is_a?(Rudy::AWS::EC2::Volume), "Not a Volume"
|
@@ -49,18 +54,18 @@ module Rudy::Test
|
|
49
54
|
@@volumes << volume # We put it here so it will be destoryed in teardown
|
50
55
|
end
|
51
56
|
|
52
|
-
should "(
|
53
|
-
assert
|
54
|
-
snap_list =
|
57
|
+
should "(90) destroy snapshots" do
|
58
|
+
assert @ec2snap.any?, "No snapshots"
|
59
|
+
snap_list = @ec2snap.list
|
55
60
|
snap_list.each do |snap|
|
56
61
|
next unless snap.completed?
|
57
|
-
assert
|
62
|
+
assert @ec2snap.destroy(snap.awsid), "Not destroyed (#{snap.awsid})"
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
61
66
|
should "(99) cleanup created volumes" do
|
62
67
|
(@@volumes || []).each do |vol|
|
63
|
-
assert
|
68
|
+
assert @ec2vol.destroy(vol), "Volume not destoryed (#{vol.awsid})"
|
64
69
|
end
|
65
70
|
end
|
66
71
|
end
|
@@ -9,19 +9,14 @@ module Rudy::Test
|
|
9
9
|
# DO NOT RUN THIS TEST ON A PRODUCTION AWS ACCOUNT!!
|
10
10
|
#
|
11
11
|
class Case_26_EC2 < Test::Unit::TestCase
|
12
|
-
include Rudy::
|
12
|
+
include Rudy::Huxtable
|
13
13
|
|
14
14
|
@@logger = STDERR #StringIO.new
|
15
|
-
@@
|
16
|
-
@@global = @@rmach.global
|
17
|
-
@@config = @@rmach.config
|
18
|
-
@@zone = @@rmach.global.zone.to_s
|
15
|
+
@@zone = @@global.zone.to_s
|
19
16
|
|
20
17
|
context "#{name}_10 Setup" do
|
21
18
|
should "(10) have class variables setup" do
|
22
|
-
stop_test !@@
|
23
|
-
stop_test !@@ec2.is_a?(Rudy::AWS::EC2), "We don't have an instance of Rudy::AWS::EC2 (#{@@ec2})"
|
24
|
-
stop_test !@@global.is_a?(OpenStruct), "We don't have global (#{@@global})"
|
19
|
+
stop_test !@@global.is_a?(Rudy::Global), "We don't have Rudy::Global (#{@@global})"
|
25
20
|
stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
|
26
21
|
end
|
27
22
|
should "(11) be zone" do
|
@@ -5,16 +5,18 @@ module Rudy::Test
|
|
5
5
|
context "#{name}_10 Instances" do
|
6
6
|
|
7
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)
|
8
10
|
@us_ami = @@config.machines.find(:"us-east-1b", :ami)
|
9
11
|
@eu_ami = @@config.machines.find(:"eu-west-1b", :ami)
|
10
12
|
end
|
11
13
|
|
12
14
|
should "(10) create instance" do
|
13
|
-
stop_test
|
14
|
-
instances =
|
15
|
+
stop_test @ec2inst.any?(:running), "Destroy the existing instances"
|
16
|
+
instances = @ec2inst.create(:ami => 'ami-235fba4a', :group => "default") # Amazon Getting Started AMI
|
15
17
|
assert instances.is_a?(Array), "Not an Array of instances"
|
16
18
|
instances.each do |instance|
|
17
|
-
Rudy.waiter(2, 120, @@logger) {
|
19
|
+
Rudy::Utils.waiter(2, 120, @@logger) { @ec2inst.running?(instance) }
|
18
20
|
assert instance.is_a?(Rudy::AWS::EC2::Instance), "Not an Rudy::AWS::EC2::Instance object"
|
19
21
|
end
|
20
22
|
end
|
@@ -22,57 +24,57 @@ module Rudy::Test
|
|
22
24
|
testnum = 20
|
23
25
|
Rudy::AWS::EC2::Instances::KNOWN_STATES.each do |state|
|
24
26
|
should "(#{testnum}) know instance is #{state}" do
|
25
|
-
instances =
|
27
|
+
instances = @ec2inst.list(state) || []
|
26
28
|
return skip("No instances are in #{state} state") if instances.empty?
|
27
29
|
instances.each do |inst|
|
28
|
-
assert
|
30
|
+
assert @ec2inst.send("#{state}?", inst) # running?(inst)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
testnum += 1
|
32
34
|
end
|
33
35
|
|
34
36
|
should "(30) list instance" do
|
35
|
-
assert
|
36
|
-
assert
|
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"
|
37
39
|
end
|
38
40
|
|
39
41
|
should "(31) console" do
|
40
|
-
|
41
|
-
assert
|
42
|
+
@ec2inst.list.each do |inst|
|
43
|
+
assert @ec2inst.console_output(inst).is_a?(String), "No console output for (#{inst.awsid})"
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
47
|
should "(40) assign IP address to instance" do
|
46
48
|
assigned = 0
|
47
|
-
|
49
|
+
@ec2inst.list.each do |instance|
|
48
50
|
next if instance.terminated? || instance.shutting_down?
|
49
51
|
assigned += 1
|
50
|
-
address =
|
51
|
-
assert
|
52
|
+
address = @ec2add.create
|
53
|
+
assert @ec2add.associate(address, instance), "Did not assign"
|
52
54
|
end
|
53
55
|
assert assigned > 0, "No machine running"
|
54
56
|
end
|
55
57
|
|
56
58
|
|
57
59
|
should "(60) restart instance" do
|
58
|
-
instances =
|
60
|
+
instances = @ec2inst.list(:running)
|
59
61
|
instances.each do |instance|
|
60
|
-
assert
|
62
|
+
assert @ec2inst.restart(instance), "Did not restart"
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
66
|
should "(99) destroy instance" do
|
65
|
-
|
66
|
-
instances =
|
67
|
+
assert @ec2inst.any?(:running), "No instances running"
|
68
|
+
instances = @ec2inst.list(:running)
|
67
69
|
return skip("No running instances") unless instances
|
68
70
|
instances.each do |instance|
|
69
|
-
assert
|
71
|
+
assert @ec2inst.destroy(instance), "Did not destroy"
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
75
|
should "(99) clean created addresses" do
|
74
|
-
(
|
75
|
-
assert
|
76
|
+
(@ec2add.list || []).each do |address|
|
77
|
+
assert @ec2add.destroy(address), "Address not destroyed (#{address})"
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
@@ -2,20 +2,13 @@ require File.join(File.dirname(__FILE__), '..', 'helper')
|
|
2
2
|
|
3
3
|
module Rudy::Test
|
4
4
|
class Case_30_MetaData < Test::Unit::TestCase
|
5
|
-
include Rudy::
|
5
|
+
include Rudy::Huxtable
|
6
6
|
|
7
7
|
@@logger = StringIO.new
|
8
|
-
@@rmach = Rudy::Instances.new(:logger => @@logger)
|
9
|
-
@@global = @@rmach.global
|
10
|
-
@@config = @@rmach.config
|
11
|
-
@@zone = @@rmach.global.zone.to_s
|
12
|
-
|
13
|
-
|
14
8
|
|
15
9
|
context "#{name}_00 Setup" do
|
16
10
|
should "(00) have class variables setup" do
|
17
|
-
stop_test !@@
|
18
|
-
stop_test !@@global.is_a?(OpenStruct), "We don't have global (#{@@global})"
|
11
|
+
stop_test !@@global.is_a?(Rudy::Global), "We don't have global (#{@@global})"
|
19
12
|
stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
|
20
13
|
end
|
21
14
|
end
|
@@ -1,24 +1,15 @@
|
|
1
1
|
module Rudy::Test
|
2
2
|
class Case_30_MetaData
|
3
|
-
|
4
|
-
def create_disk
|
5
|
-
disk = Rudy::MetaData::Disk.new
|
6
|
-
[:region, :zone, :environment, :role, :position].each do |n|
|
7
|
-
disk.send("#{n}=", @@global.send(n))
|
8
|
-
end
|
9
|
-
|
10
|
-
disk.path = "/rudy/disk"
|
11
|
-
disk.size = 10
|
12
|
-
disk.device = "/dev/sdh"
|
13
|
-
disk
|
14
|
-
end
|
3
|
+
|
15
4
|
|
16
5
|
context "#{name}_10 Disks" do
|
17
6
|
|
18
7
|
setup do
|
19
|
-
@
|
8
|
+
@sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
|
9
|
+
#@ami = @@config.machines.find(@@zone.to_sym, :ami)
|
20
10
|
end
|
21
11
|
|
12
|
+
|
22
13
|
should "(00) have global setup" do
|
23
14
|
[:region, :zone, :environment, :role, :position].each do |n|
|
24
15
|
assert @@global.respond_to?(n), "No global #{n}"
|
@@ -26,70 +17,89 @@ module Rudy::Test
|
|
26
17
|
end
|
27
18
|
|
28
19
|
should "(01) have domain" do
|
29
|
-
assert
|
20
|
+
assert @sdb.create_domain(Rudy::DOMAIN), "Domain not created (#{Rudy::DOMAIN})"
|
30
21
|
end
|
31
22
|
|
32
23
|
|
33
24
|
should "(10) create a disk object" do
|
34
|
-
disk =
|
25
|
+
disk = Rudy::Disk.new('/rudy/disk', 1, '/dev/sdh')
|
35
26
|
|
36
|
-
|
37
|
-
[:
|
38
|
-
|
27
|
+
disk_name_elements = []
|
28
|
+
[:zone, :environment, :role, :position].each do |n|
|
29
|
+
disk_name_elements << @@global.send(n)
|
39
30
|
end
|
40
31
|
|
41
|
-
|
42
|
-
disk_name = [
|
32
|
+
# disk-us-east-1b-stage-app-01-rudy-disk
|
33
|
+
disk_name = ['disk', disk_name_elements, 'rudy', 'disk'].join(Rudy::DELIM)
|
43
34
|
|
44
35
|
assert_equal disk_name, disk.name, "Unexpected disk name #{disk.name}"
|
45
36
|
assert disk.valid?, "Disk not valid"
|
46
37
|
|
47
|
-
disk.save
|
48
38
|
end
|
49
39
|
|
50
|
-
should "(
|
51
|
-
|
40
|
+
should "(11) save a disk object" do
|
41
|
+
disk = Rudy::Disk.new('/rudy/disk', 1, '/dev/sdh')
|
42
|
+
assert disk.is_a?(Rudy::Disk), "Not a Rudy::Disk (#{disk})"
|
43
|
+
assert disk.save, "Did not save #{disk.name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
should "(20) list metadata with select" do
|
47
|
+
q = "select * from #{Rudy::DOMAIN}"
|
52
48
|
|
53
|
-
items =
|
49
|
+
items = @sdb.select(q)
|
50
|
+
#p items
|
54
51
|
assert_equal Hash, items.class
|
55
52
|
assert items.size > 0, "No disks"
|
56
53
|
assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
|
57
54
|
end
|
58
55
|
|
59
56
|
should "(22) list disk metadata with select" do
|
60
|
-
q = "select * from #{Rudy::
|
61
|
-
items =
|
57
|
+
q = "select * from #{Rudy::DOMAIN} where rtype = 'disk'"
|
58
|
+
items = @sdb.select(q)
|
62
59
|
assert_equal Hash, items.class
|
63
60
|
assert items.size > 0, "No disks"
|
64
61
|
assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
|
65
62
|
end
|
66
63
|
|
67
64
|
should "(23) list disk metadata with query" do
|
68
|
-
q = "select * from #{Rudy::
|
65
|
+
q = "select * from #{Rudy::DOMAIN} where rtype = 'disk'"
|
69
66
|
|
70
|
-
items =
|
67
|
+
items = @sdb.query_with_attributes(Rudy::DOMAIN, "['rtype' = 'disk']")
|
71
68
|
assert_equal Hash, items.class
|
72
69
|
assert items.size > 0, "No disks"
|
73
70
|
assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
|
74
71
|
end
|
75
72
|
|
76
|
-
should "(30) get disk
|
77
|
-
disk_tmp =
|
78
|
-
|
79
|
-
|
80
|
-
assert_equal
|
73
|
+
should "(30) get disk from Rudy::Disks, modify, and save" do
|
74
|
+
disk_tmp = Rudy::Disk.new('/rudy/disk', 1, '/dev/sdh')
|
75
|
+
rdisk = Rudy::Disks.new
|
76
|
+
disk_orig = rdisk.get(disk_tmp.name)
|
77
|
+
assert_equal Rudy::Disk, disk_orig.class, "Not a Rudy::Disk #{disk_orig}"
|
78
|
+
assert_equal @@global.zone.to_s, disk_orig.zone.to_s, "Unexpected zone #{disk_orig.zone}"
|
79
|
+
sleep 1
|
80
|
+
disk_orig.size = 2
|
81
|
+
assert disk_orig.save, "Did not save #{disk_orig.name}"
|
82
|
+
disk_new = rdisk.get(disk_orig.name)
|
83
|
+
assert_equal disk_orig.size, disk_new.size, "Different size #{disk_new.size}"
|
84
|
+
assert disk_new.destroy, "Did not destroy #{disk_new.name}"
|
81
85
|
end
|
82
86
|
|
83
87
|
|
84
|
-
|
85
|
-
|
86
|
-
|
88
|
+
xshould "(90) destroy all disk metadata" do
|
89
|
+
# disabled b/c there are disks at this point. Previous tests delete them.
|
90
|
+
q = "select * from #{Rudy::DOMAIN} where rtype = 'disk'"
|
91
|
+
items = @sdb.select(q)
|
92
|
+
p items
|
87
93
|
assert_equal Hash, items.class
|
88
94
|
items.keys.each do |item|
|
89
|
-
|
95
|
+
@sdb.destroy(Rudy::DOMAIN, item)
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|
99
|
+
should "(99) destroy domain" do
|
100
|
+
assert @sdb.destroy_domain(Rudy::DOMAIN), "Domain not destroyed (#{Rudy::DOMAIN})"
|
101
|
+
end
|
102
|
+
|
93
103
|
end
|
94
104
|
|
95
105
|
|
@@ -15,7 +15,7 @@ module Rudy::Test
|
|
15
15
|
|
16
16
|
def format_timestamp(dat)
|
17
17
|
mon, day, hour, min, sec = [dat.mon, dat.day, dat.hour, dat.min, dat.sec].collect { |v| v.to_s.rjust(2, "0") }
|
18
|
-
[dat.year, mon, day, Rudy::
|
18
|
+
[dat.year, mon, day, Rudy::DELIM, hour, min, Rudy::DELIM, sec].join
|
19
19
|
end
|
20
20
|
|
21
21
|
context "#{name}_20 Backups" do
|
@@ -27,7 +27,7 @@ module Rudy::Test
|
|
27
27
|
end
|
28
28
|
|
29
29
|
should "(01) have domain" do
|
30
|
-
#assert @@sdb.domains.create(Rudy::
|
30
|
+
#assert @@sdb.domains.create(Rudy::DOMAIN), "Domain not created (#{Rudy::DOMAIN})"
|
31
31
|
end
|
32
32
|
|
33
33
|
|
@@ -42,7 +42,7 @@ module Rudy::Test
|
|
42
42
|
back_time = format_timestamp(Time.now.utc)
|
43
43
|
|
44
44
|
back_name.shift # don't use region in backup name, but add the backup identifier and path
|
45
|
-
back_name = ['back', back_name, 'rudy', 'disk', back_time].join(Rudy::
|
45
|
+
back_name = ['back', back_name, 'rudy', 'disk', back_time].join(Rudy::DELIM)
|
46
46
|
assert_equal back_name, back.name
|
47
47
|
|
48
48
|
assert back.valid?, "Bcakup not valid"
|
@@ -51,7 +51,7 @@ module Rudy::Test
|
|
51
51
|
end
|
52
52
|
|
53
53
|
should "(20) list metadata" do
|
54
|
-
q = "select * from #{Rudy::
|
54
|
+
q = "select * from #{Rudy::DOMAIN}"
|
55
55
|
|
56
56
|
items = @@sdb.select(q)
|
57
57
|
assert_equal Hash, items.class
|
@@ -60,7 +60,7 @@ module Rudy::Test
|
|
60
60
|
end
|
61
61
|
|
62
62
|
should "(22) list backup metadata with select" do
|
63
|
-
q = "select * from #{Rudy::
|
63
|
+
q = "select * from #{Rudy::DOMAIN} where rtype = 'back'"
|
64
64
|
items = @@sdb.select(q)
|
65
65
|
assert_equal Hash, items.class
|
66
66
|
assert items.size > 0, "No backups"
|
@@ -68,9 +68,9 @@ module Rudy::Test
|
|
68
68
|
end
|
69
69
|
|
70
70
|
should "(23) list backup metadata with query" do
|
71
|
-
q = "select * from #{Rudy::
|
71
|
+
q = "select * from #{Rudy::DOMAIN} where rtype = 'back'"
|
72
72
|
|
73
|
-
items = @@sdb.query_with_attributes(Rudy::
|
73
|
+
items = @@sdb.query_with_attributes(Rudy::DOMAIN, "['rtype' = 'back']")
|
74
74
|
assert_equal Hash, items.class
|
75
75
|
assert items.size > 0, "No backups"
|
76
76
|
assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
|
@@ -85,11 +85,11 @@ module Rudy::Test
|
|
85
85
|
end
|
86
86
|
|
87
87
|
should "(40) destroy backup metadata" do
|
88
|
-
q = "select * from #{Rudy::
|
88
|
+
q = "select * from #{Rudy::DOMAIN} where rtype = 'back'"
|
89
89
|
items = @@sdb.select(q)
|
90
90
|
assert_equal Hash, items.class
|
91
91
|
items.keys.each do |item|
|
92
|
-
@@sdb.destroy(Rudy::
|
92
|
+
@@sdb.destroy(Rudy::DOMAIN, item)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
data/test/helper.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
|
2
2
|
libdir = File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
-
|
4
|
-
|
3
|
+
$:.unshift libdir
|
4
|
+
%w{amazon-ec2 drydock caesars rye}.each { |dir| $: << File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
|
5
|
+
|
6
|
+
require 'rubygems'
|
5
7
|
require 'test/unit'
|
6
8
|
require 'shoulda'
|
7
9
|
|
8
10
|
require 'rudy'
|
9
11
|
|
10
12
|
|
11
|
-
puts Rudy.banner("THIS IS RUBY #{RUBY_VERSION}")
|
13
|
+
puts Rudy::Utils.banner("THIS IS RUBY #{RUBY_VERSION}")
|
12
14
|
|
13
15
|
# +should_stop+ should the test be stopped?
|
14
16
|
# +str+ The message to print when +should_stop+ is true
|