solutious-rudy 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/CHANGES.txt +8 -9
  2. data/README.rdoc +48 -7
  3. data/Rakefile +102 -7
  4. data/Rudyfile +28 -0
  5. data/bin/ird +162 -0
  6. data/bin/rudy +287 -93
  7. data/lib/annoy.rb +227 -0
  8. data/lib/aws_sdb/service.rb +1 -1
  9. data/lib/console.rb +20 -4
  10. data/lib/escape.rb +305 -0
  11. data/lib/rudy.rb +265 -125
  12. data/lib/rudy/aws.rb +61 -26
  13. data/lib/rudy/aws/ec2.rb +20 -296
  14. data/lib/rudy/aws/ec2/address.rb +121 -0
  15. data/lib/rudy/aws/ec2/group.rb +241 -0
  16. data/lib/rudy/aws/ec2/image.rb +46 -0
  17. data/lib/rudy/aws/ec2/instance.rb +407 -0
  18. data/lib/rudy/aws/ec2/keypair.rb +92 -0
  19. data/lib/rudy/aws/ec2/snapshot.rb +87 -0
  20. data/lib/rudy/aws/ec2/volume.rb +234 -0
  21. data/lib/rudy/aws/simpledb.rb +33 -15
  22. data/lib/rudy/cli.rb +142 -0
  23. data/lib/rudy/cli/addresses.rb +85 -0
  24. data/lib/rudy/cli/backups.rb +175 -0
  25. data/lib/rudy/{command → cli}/config.rb +18 -13
  26. data/lib/rudy/cli/deploy.rb +12 -0
  27. data/lib/rudy/cli/disks.rb +125 -0
  28. data/lib/rudy/cli/domains.rb +17 -0
  29. data/lib/rudy/cli/groups.rb +77 -0
  30. data/lib/rudy/{command → cli}/images.rb +18 -6
  31. data/lib/rudy/cli/instances.rb +142 -0
  32. data/lib/rudy/cli/keypairs.rb +47 -0
  33. data/lib/rudy/cli/manager.rb +51 -0
  34. data/lib/rudy/{command → cli}/release.rb +10 -10
  35. data/lib/rudy/cli/routines.rb +80 -0
  36. data/lib/rudy/cli/volumes.rb +121 -0
  37. data/lib/rudy/command/addresses.rb +62 -39
  38. data/lib/rudy/command/backups.rb +60 -170
  39. data/lib/rudy/command/disks-old.rb +322 -0
  40. data/lib/rudy/command/disks.rb +5 -209
  41. data/lib/rudy/command/domains.rb +34 -0
  42. data/lib/rudy/command/groups.rb +105 -48
  43. data/lib/rudy/command/instances.rb +263 -70
  44. data/lib/rudy/command/keypairs.rb +149 -0
  45. data/lib/rudy/command/manager.rb +65 -0
  46. data/lib/rudy/command/volumes.rb +110 -49
  47. data/lib/rudy/config.rb +90 -70
  48. data/lib/rudy/config/objects.rb +67 -0
  49. data/lib/rudy/huxtable.rb +253 -0
  50. data/lib/rudy/metadata/backup.rb +23 -48
  51. data/lib/rudy/metadata/disk.rb +79 -68
  52. data/lib/rudy/metadata/machine.rb +34 -0
  53. data/lib/rudy/routines.rb +54 -0
  54. data/lib/rudy/routines/disk_handler.rb +190 -0
  55. data/lib/rudy/routines/release.rb +15 -0
  56. data/lib/rudy/routines/script_runner.rb +65 -0
  57. data/lib/rudy/routines/shutdown.rb +42 -0
  58. data/lib/rudy/routines/startup.rb +48 -0
  59. data/lib/rudy/utils.rb +57 -2
  60. data/lib/storable.rb +11 -5
  61. data/lib/sysinfo.rb +274 -0
  62. data/rudy.gemspec +84 -20
  63. data/support/randomize-root-password +45 -0
  64. data/support/rudy-ec2-startup +5 -5
  65. data/support/update-ec2-ami-tools +20 -0
  66. data/test/05_config/00_setup_test.rb +24 -0
  67. data/test/05_config/30_machines_test.rb +69 -0
  68. data/test/20_sdb/00_setup_test.rb +31 -0
  69. data/test/20_sdb/10_domains_test.rb +113 -0
  70. data/test/25_ec2/00_setup_test.rb +34 -0
  71. data/test/25_ec2/10_keypairs_test.rb +33 -0
  72. data/test/25_ec2/20_groups_test.rb +139 -0
  73. data/test/25_ec2/30_addresses_test.rb +35 -0
  74. data/test/25_ec2/40_volumes_test.rb +46 -0
  75. data/test/25_ec2/50_snapshots_test.rb +69 -0
  76. data/test/26_ec2_instances/00_setup_test.rb +33 -0
  77. data/test/26_ec2_instances/10_instances_test.rb +81 -0
  78. data/test/26_ec2_instances/50_images_test.rb +13 -0
  79. data/test/30_sdb_metadata/00_setup_test.rb +28 -0
  80. data/test/30_sdb_metadata/10_disks_test.rb +99 -0
  81. data/test/30_sdb_metadata/20_backups_test.rb +102 -0
  82. data/test/50_commands/00_setup_test.rb +11 -0
  83. data/test/50_commands/10_keypairs_test.rb +79 -0
  84. data/test/50_commands/20_groups_test.rb +77 -0
  85. data/test/50_commands/40_volumes_test.rb +55 -0
  86. data/test/50_commands/50_instances_test.rb +110 -0
  87. data/test/coverage.txt +51 -0
  88. data/test/helper.rb +35 -0
  89. data/tryouts/disks.rb +55 -0
  90. data/tryouts/nested_methods.rb +36 -0
  91. data/tryouts/session_tryout.rb +48 -0
  92. metadata +94 -25
  93. data/bin/rudy-ec2 +0 -108
  94. data/lib/rudy/command/base.rb +0 -839
  95. data/lib/rudy/command/deploy.rb +0 -12
  96. data/lib/rudy/command/environment.rb +0 -74
  97. data/lib/rudy/command/machines.rb +0 -170
  98. data/lib/rudy/command/metadata.rb +0 -41
  99. data/lib/rudy/metadata.rb +0 -26
@@ -0,0 +1,35 @@
1
+
2
+ module Rudy::Test
3
+
4
+ class Case_25_EC2
5
+
6
+ context "#{name}_30 Addresses" do
7
+ should "(00) not be existing addresses" do
8
+ #p @@ec2.addresses.list
9
+ stop_test @@ec2.addresses.any?, "Destroy the existing addresses"
10
+ end
11
+
12
+ should "(01) create address" do
13
+ address = @@ec2.addresses.create
14
+ assert address.is_a?(Rudy::AWS::EC2::Address), "Did not create"
15
+ assert address.ipaddress.size > 0, "Address length is 0"
16
+ end
17
+
18
+ should "(10) list available addresses" do
19
+ assert @@ec2.addresses.any?, "No addresses"
20
+ assert @@ec2.addresses.list_as_hash.is_a?(Hash), "Not a Hash"
21
+ assert @@ec2.addresses.list.is_a?(Array), "Not an Array"
22
+ assert_equal 1, @@ec2.addresses.list.size, "More than one address"
23
+ end
24
+
25
+ should "(50) destroy address" do
26
+ assert @@ec2.addresses.any?, "No addresses"
27
+ @@ec2.addresses.list.each do |address|
28
+ assert @@ec2.addresses.destroy(address), "Did not destroy"
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,46 @@
1
+
2
+ module Rudy::Test
3
+ class Case_25_EC2
4
+
5
+ context "#{name}_40 Volumes" do
6
+
7
+ should "(00) not be existing volumes" do
8
+ volume_hash = @@ec2.volumes.list_as_hash
9
+ volume_hash.reject! { |volid, vol| !vol.available? }
10
+ stop_test !volume_hash.empty?, "Destroy the existing volumes"
11
+ end
12
+
13
+ should "(10) create volume" do
14
+ volume_size = 2
15
+ volume = @@ec2.volumes.create(volume_size, @@zone)
16
+ assert volume.is_a?(Rudy::AWS::EC2::Volume), "Not a Volume"
17
+ assert_equal @@zone, volume.zone, "Zone incorrect: #{volume.zone}"
18
+ assert_equal volume_size.to_i, volume.size.to_i, "Size incorrect: #{volume.size}"
19
+ assert volume.creating? || volume.available?, "Volume not creating or available (#{volume.status})"
20
+ end
21
+
22
+ should "(20) list volumes" do
23
+ volume_list = @@ec2.volumes.list
24
+ assert volume_list.is_a?(Array), "Not an Array"
25
+ assert volume_list.size > 0, "No Volumes in Array"
26
+
27
+ volume_hash = @@ec2.volumes.list_as_hash
28
+ assert volume_hash.is_a?(Hash), "Not a Hash"
29
+ assert volume_hash.keys.size > 0, "No Volumes in Hash"
30
+
31
+ assert_equal volume_list.size.to_i, volume_hash.keys.size.to_i, "Hash and Array not equal size"
32
+ end
33
+
34
+ should "(50) destroy volumes" do
35
+ assert @@ec2.volumes.any?, "No volumes"
36
+ volume_list = @@ec2.volumes.list
37
+ volume_list.each do |vol|
38
+ next unless vol.available?
39
+ assert @@ec2.volumes.destroy(vol.awsid), "Not destroyed (#{vol.awsid})"
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,69 @@
1
+
2
+ module Rudy::Test
3
+ class Case_25_EC2
4
+
5
+
6
+
7
+ context "#{name}_50 Snapshots" do
8
+
9
+ should "(00) be no snapshots" do
10
+ stop_test @@ec2.snapshots.any?, "Destroy existing snapshots"
11
+ end
12
+
13
+ should "(01) create a volume to work off of" do
14
+ @@volumes ||= []
15
+ @@volumes << @@ec2.volumes.create(1, @@zone)
16
+ stop_test !@@volumes.first.is_a?(Rudy::AWS::EC2::Volume), "No volume to work off of."
17
+ end
18
+
19
+ should "(01) create snapshot" do
20
+ stop_test !@@volumes.first.is_a?(Rudy::AWS::EC2::Volume), "No volume to work off of."
21
+ assert !@@volumes.first.awsid.empty?, "No volume ID"
22
+ @@ec2.snapshots.create(@@volumes.first.awsid)
23
+ end
24
+
25
+ should "(10) list snapshots" do
26
+ snap_list = @@ec2.snapshots.list
27
+ assert snap_list.is_a?(Array), "Not an Array"
28
+ assert snap_list.size > 0, "No Snapshots in Array"
29
+
30
+ snap_hash = @@ec2.snapshots.list_as_hash
31
+ assert snap_hash.is_a?(Hash), "Not an Hash"
32
+ assert snap_hash.keys.size > 0, "No Snapshots in Hash"
33
+ end
34
+
35
+ should "(20) create volume from snapshot" do
36
+ volume_size = 2
37
+ snap_list = @@ec2.snapshots.list || []
38
+ assert !snap_list.empty?, "No snapshots"
39
+
40
+ volume = @@ec2.volumes.create(volume_size, @@zone, snap_list.first.awsid)
41
+ #puts "#{volume.awsid} #{snap_list.first.awsid}"
42
+
43
+ assert volume.is_a?(Rudy::AWS::EC2::Volume), "Not a Volume"
44
+ assert_equal @@zone, volume.zone, "Zone incorrect: #{volume.zone}"
45
+ assert_equal snap_list.first.awsid, volume.snapid, "Snapshot mismatch: #{volume.snapid}"
46
+ assert_equal volume_size.to_i, volume.size.to_i, "Size incorrect: #{volume.size}"
47
+ assert volume.creating? || volume.available?, "Volume not creating or available (#{volume.status})"
48
+
49
+ @@volumes << volume # We put it here so it will be destoryed in teardown
50
+ end
51
+
52
+ should "(50) destroy snapshots" do
53
+ assert @@ec2.snapshots.any?, "No snapshots"
54
+ snap_list = @@ec2.snapshots.list
55
+ snap_list.each do |snap|
56
+ next unless snap.completed?
57
+ assert @@ec2.snapshots.destroy(snap.awsid), "Not destroyed (#{snap.awsid})"
58
+ end
59
+ end
60
+
61
+ should "(99) cleanup created volumes" do
62
+ (@@volumes || []).each do |vol|
63
+ assert @@ec2.volumes.destroy(vol), "Volume not destoryed (#{vol.awsid})"
64
+ end
65
+ end
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,33 @@
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::AWS
13
+
14
+ @@logger = STDERR #StringIO.new
15
+ @@rmach = Rudy::Instances.new(:logger => @@logger)
16
+ @@global = @@rmach.global
17
+ @@config = @@rmach.config
18
+ @@zone = @@rmach.global.zone.to_s
19
+
20
+ context "#{name}_10 Setup" do
21
+ should "(10) have class variables setup" do
22
+ stop_test !@@rmach.is_a?(Rudy::Instances), "We don't have an instance ofRudy::Instancess (#{@@rmach})"
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})"
25
+ stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
26
+ end
27
+ should "(11) be zone" do
28
+ stop_test !@@zone, "No zone"
29
+ end
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,81 @@
1
+
2
+ module Rudy::Test
3
+ class Case_26_EC2
4
+
5
+ context "#{name}_10 Instances" do
6
+
7
+ setup do
8
+ @us_ami = @@config.machines.find(:"us-east-1b", :ami)
9
+ @eu_ami = @@config.machines.find(:"eu-west-1b", :ami)
10
+ end
11
+
12
+ should "(10) create instance" do
13
+ stop_test @@ec2.instances.any?(:running), "Destroy the existing instances"
14
+ instances = @@ec2.instances.create('ami-235fba4a') # Amazon Getting Started AMI
15
+ assert instances.is_a?(Array), "Not an Array of instances"
16
+ instances.each do |instance|
17
+ Rudy.waiter(2, 120, @@logger) { @@ec2.instances.running?(instance) }
18
+ assert instance.is_a?(Rudy::AWS::EC2::Instance), "Not an Rudy::AWS::EC2::Instance object"
19
+ end
20
+ end
21
+
22
+ testnum = 20
23
+ Rudy::AWS::EC2::Instances::KNOWN_STATES.each do |state|
24
+ should "(#{testnum}) know instance is #{state}" do
25
+ instances = @@ec2.instances.list(state) || []
26
+ return skip("No instances are in #{state} state") if instances.empty?
27
+ instances.each do |inst|
28
+ assert @@ec2.instances.send("#{state}?", inst) # running?(inst)
29
+ end
30
+ end
31
+ testnum += 1
32
+ end
33
+
34
+ should "(30) list instance" do
35
+ assert @@ec2.instances.list.is_a?(Array), "Not an Array of instances"
36
+ assert @@ec2.instances.list_as_hash.is_a?(Hash), "Not a Hash of instances"
37
+ end
38
+
39
+ should "(31) console" do
40
+ @@ec2.instances.list.each do |inst|
41
+ assert @@ec2.instances.console_output(inst).is_a?(String), "No console output for (#{inst.awsid})"
42
+ end
43
+ end
44
+
45
+ should "(40) assign IP address to instance" do
46
+ assigned = 0
47
+ @@ec2.instances.list.each do |instance|
48
+ next if instance.terminated? || instance.shutting_down?
49
+ assigned += 1
50
+ address = @@ec2.addresses.create
51
+ assert @@ec2.addresses.associate(instance, address), "Did not assign"
52
+ end
53
+ assert assigned > 0, "No machine running"
54
+ end
55
+
56
+
57
+ should "(60) restart instance" do
58
+ instances = @@ec2.instances.list(:running)
59
+ instances.each do |instance|
60
+ assert @@ec2.instances.restart(instance), "Did not restart"
61
+ end
62
+ end
63
+
64
+ should "(99) destroy instance" do
65
+ Rudy.waiter(2, 60, @@logger) { @@ec2.instances.any?(:running) }
66
+ instances = @@ec2.instances.list(:running)
67
+ return skip("No running instances") unless instances
68
+ instances.each do |instance|
69
+ assert @@ec2.instances.destroy(instance), "Did not destroy"
70
+ end
71
+ end
72
+
73
+ should "(99) clean created addresses" do
74
+ (@@ec2.addresses.list || []).each do |address|
75
+ assert @@ec2.addresses.destroy(address), "Address not destroyed (#{address})"
76
+ end
77
+ end
78
+
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,13 @@
1
+ module Rudy::Test
2
+ class Case_26_EC2
3
+
4
+ context "#{name} Images" do
5
+ should "nothing" do
6
+ assert true
7
+ end
8
+
9
+ end
10
+
11
+
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
+
3
+ module Rudy::Test
4
+ class Case_30_MetaData < Test::Unit::TestCase
5
+ include Rudy::AWS
6
+
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
+
15
+ context "#{name}_00 Setup" do
16
+ should "(00) have class variables setup" do
17
+ stop_test !@@rmach.is_a?(Rudy::Instances), "We don't have an instance ofRudy::Instancess (#{@@rmach})"
18
+ stop_test !@@global.is_a?(OpenStruct), "We don't have global (#{@@global})"
19
+ stop_test !@@config.is_a?(Rudy::Config), "We don't have an instance of Rudy::Config (#{@@config})"
20
+ end
21
+ end
22
+
23
+ at_exit {
24
+ @@logger.rewind
25
+ puts @@logger.read
26
+ }
27
+ end
28
+ end
@@ -0,0 +1,99 @@
1
+ module Rudy::Test
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
15
+
16
+ context "#{name}_10 Disks" do
17
+
18
+ setup do
19
+ @ami = @@config.machines.find(@@zone.to_sym, :ami)
20
+ end
21
+
22
+ should "(00) have global setup" do
23
+ [:region, :zone, :environment, :role, :position].each do |n|
24
+ assert @@global.respond_to?(n), "No global #{n}"
25
+ end
26
+ end
27
+
28
+ should "(01) have domain" do
29
+ assert @@sdb.domains.create(Rudy::RUDY_DOMAIN), "Domain not created (#{Rudy::RUDY_DOMAIN})"
30
+ end
31
+
32
+
33
+ should "(10) create a disk object" do
34
+ disk = create_disk
35
+
36
+ disk_name = []
37
+ [:region, :zone, :environment, :role, :position].each do |n|
38
+ disk_name << @@global.send(n)
39
+ end
40
+
41
+ disk_name.shift # don't use region in disk name, but add the disk identifier and path
42
+ disk_name = [Rudy.identifier(:disk), disk_name, 'rudy', 'disk'].join(Rudy::RUDY_DELIM)
43
+
44
+ assert_equal disk_name, disk.name, "Unexpected disk name #{disk.name}"
45
+ assert disk.valid?, "Disk not valid"
46
+
47
+ disk.save
48
+ end
49
+
50
+ should "(20) list metadata" do
51
+ q = "select * from #{Rudy::RUDY_DOMAIN}"
52
+
53
+ items = @@sdb.select(q)
54
+ assert_equal Hash, items.class
55
+ assert items.size > 0, "No disks"
56
+ assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
57
+ end
58
+
59
+ should "(22) list disk metadata with select" do
60
+ q = "select * from #{Rudy::RUDY_DOMAIN} where rtype = 'disk'"
61
+ items = @@sdb.select(q)
62
+ assert_equal Hash, items.class
63
+ assert items.size > 0, "No disks"
64
+ assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
65
+ end
66
+
67
+ should "(23) list disk metadata with query" do
68
+ q = "select * from #{Rudy::RUDY_DOMAIN} where rtype = 'disk'"
69
+
70
+ items = @@sdb.query_with_attributes(Rudy::RUDY_DOMAIN, "['rtype' = 'disk']")
71
+ assert_equal Hash, items.class
72
+ assert items.size > 0, "No disks"
73
+ assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
74
+ end
75
+
76
+ should "(30) get disk metadata" do
77
+ disk_tmp = create_disk
78
+ disk = Rudy::MetaData::Disk.get(disk_tmp.name)
79
+ assert_equal Rudy::MetaData::Disk, disk.class
80
+ assert_equal @@global.zone.to_s, disk.zone.to_s
81
+ end
82
+
83
+
84
+ should "(99) destroy disk metadata" do
85
+ q = "select * from #{Rudy::RUDY_DOMAIN} where rtype = 'disk'"
86
+ items = @@sdb.select(q)
87
+ assert_equal Hash, items.class
88
+ items.keys.each do |item|
89
+ @@sdb.destroy(Rudy::RUDY_DOMAIN, item)
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+
96
+
97
+
98
+ end
99
+ end
@@ -0,0 +1,102 @@
1
+ module Rudy::Test
2
+ class Case_30_MetaData
3
+
4
+ def create_backup
5
+ back = Rudy::MetaData::Backup.new
6
+ [:region, :zone, :environment, :role, :position].each do |n|
7
+ back.send("#{n}=", @@global.send(n))
8
+ end
9
+
10
+ back.path = "/rudy/disk"
11
+ back.size = 10
12
+
13
+ back
14
+ end
15
+
16
+ def format_timestamp(dat)
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::RUDY_DELIM, hour, min, Rudy::RUDY_DELIM, sec].join
19
+ end
20
+
21
+ context "#{name}_20 Backups" do
22
+
23
+ should "(00) have global setup" do
24
+ [:region, :zone, :environment, :role, :position].each do |n|
25
+ assert @@global.respond_to?(n), "No global #{n}"
26
+ end
27
+ end
28
+
29
+ should "(01) have domain" do
30
+ #assert @@sdb.domains.create(Rudy::RUDY_DOMAIN), "Domain not created (#{Rudy::RUDY_DOMAIN})"
31
+ end
32
+
33
+
34
+ should "(10) create a backup object" do
35
+ back = create_backup
36
+
37
+ back_name = []
38
+ [:region, :zone, :environment, :role, :position].each do |n|
39
+ back_name << @@global.send(n)
40
+ end
41
+
42
+ back_time = format_timestamp(Time.now.utc)
43
+
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::RUDY_DELIM)
46
+ assert_equal back_name, back.name
47
+
48
+ assert back.valid?, "Bcakup not valid"
49
+
50
+ back.save
51
+ end
52
+
53
+ should "(20) list metadata" do
54
+ q = "select * from #{Rudy::RUDY_DOMAIN}"
55
+
56
+ items = @@sdb.select(q)
57
+ assert_equal Hash, items.class
58
+ assert items.size > 0, "No backups"
59
+ assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
60
+ end
61
+
62
+ should "(22) list backup metadata with select" do
63
+ q = "select * from #{Rudy::RUDY_DOMAIN} where rtype = 'back'"
64
+ items = @@sdb.select(q)
65
+ assert_equal Hash, items.class
66
+ assert items.size > 0, "No backups"
67
+ assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
68
+ end
69
+
70
+ should "(23) list backup metadata with query" do
71
+ q = "select * from #{Rudy::RUDY_DOMAIN} where rtype = 'back'"
72
+
73
+ items = @@sdb.query_with_attributes(Rudy::RUDY_DOMAIN, "['rtype' = 'back']")
74
+ assert_equal Hash, items.class
75
+ assert items.size > 0, "No backups"
76
+ assert_equal @@global.zone.to_s, items.values.first['zone'].first.to_s
77
+ end
78
+
79
+ should "(30) get backup metadata" do
80
+ back_tmp = create_backup
81
+ back = Rudy::MetaData::Backup.get(back_tmp.name)
82
+ assert_equal Rudy::MetaData::Backup, back.class
83
+ assert_equal @@global.zone.to_s, back.zone.to_s
84
+
85
+ end
86
+
87
+ should "(40) destroy backup metadata" do
88
+ q = "select * from #{Rudy::RUDY_DOMAIN} where rtype = 'back'"
89
+ items = @@sdb.select(q)
90
+ assert_equal Hash, items.class
91
+ items.keys.each do |item|
92
+ @@sdb.destroy(Rudy::RUDY_DOMAIN, item)
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+
99
+
100
+
101
+ end
102
+ end