solutious-rudy 0.8.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/CHANGES.txt +55 -14
  2. data/README.rdoc +26 -34
  3. data/Rudyfile +27 -32
  4. data/bin/rudy +47 -27
  5. data/bin/rudy-ec2 +2 -16
  6. data/bin/rudy-s3 +0 -10
  7. data/bin/rudy-sdb +11 -12
  8. data/lib/rudy.rb +49 -89
  9. data/lib/rudy/aws.rb +2 -43
  10. data/lib/rudy/aws/ec2.rb +57 -20
  11. data/lib/rudy/aws/ec2/address.rb +10 -11
  12. data/lib/rudy/aws/ec2/group.rb +10 -9
  13. data/lib/rudy/aws/ec2/image.rb +8 -8
  14. data/lib/rudy/aws/ec2/instance.rb +15 -16
  15. data/lib/rudy/aws/ec2/keypair.rb +14 -19
  16. data/lib/rudy/aws/ec2/snapshot.rb +16 -9
  17. data/lib/rudy/aws/ec2/volume.rb +37 -24
  18. data/lib/rudy/aws/ec2/zone.rb +5 -4
  19. data/lib/rudy/aws/s3.rb +2 -1
  20. data/lib/rudy/aws/sdb.rb +35 -86
  21. data/lib/rudy/backups.rb +24 -0
  22. data/lib/rudy/cli.rb +5 -131
  23. data/lib/rudy/cli/aws/ec2/addresses.rb +19 -27
  24. data/lib/rudy/cli/aws/ec2/candy.rb +32 -7
  25. data/lib/rudy/cli/aws/ec2/groups.rb +9 -13
  26. data/lib/rudy/cli/aws/ec2/images.rb +5 -133
  27. data/lib/rudy/cli/aws/ec2/instances.rb +25 -25
  28. data/lib/rudy/cli/aws/ec2/keypairs.rb +7 -11
  29. data/lib/rudy/cli/aws/ec2/snapshots.rb +5 -9
  30. data/lib/rudy/cli/aws/ec2/volumes.rb +22 -23
  31. data/lib/rudy/cli/aws/ec2/zones.rb +2 -3
  32. data/lib/rudy/cli/aws/sdb/domains.rb +5 -6
  33. data/lib/rudy/cli/aws/sdb/objects.rb +33 -0
  34. data/lib/rudy/cli/aws/sdb/select.rb +23 -0
  35. data/lib/rudy/cli/backups.rb +38 -0
  36. data/lib/rudy/cli/base.rb +98 -0
  37. data/lib/rudy/cli/candy.rb +1 -2
  38. data/lib/rudy/cli/config.rb +7 -4
  39. data/lib/rudy/cli/disks.rb +6 -8
  40. data/lib/rudy/cli/execbase.rb +53 -0
  41. data/lib/rudy/cli/machines.rb +14 -18
  42. data/lib/rudy/cli/metadata.rb +24 -10
  43. data/lib/rudy/cli/routines.rb +31 -5
  44. data/lib/rudy/config.rb +17 -22
  45. data/lib/rudy/config/objects.rb +44 -30
  46. data/lib/rudy/disks.rb +25 -0
  47. data/lib/rudy/exceptions.rb +95 -0
  48. data/lib/rudy/global.rb +46 -23
  49. data/lib/rudy/guidelines.rb +3 -2
  50. data/lib/rudy/huxtable.rb +66 -57
  51. data/lib/rudy/machines.rb +41 -263
  52. data/lib/rudy/metadata.rb +212 -38
  53. data/lib/rudy/metadata/backup.rb +123 -78
  54. data/lib/rudy/metadata/disk.rb +152 -170
  55. data/lib/rudy/metadata/machine.rb +179 -0
  56. data/lib/rudy/mixins.rb +2 -1
  57. data/lib/rudy/mixins/hash.rb +3 -1
  58. data/lib/rudy/mixins/symbol.rb +8 -0
  59. data/lib/rudy/routines.rb +127 -344
  60. data/lib/rudy/routines/base.rb +226 -0
  61. data/lib/rudy/routines/handlers/base.rb +48 -0
  62. data/lib/rudy/routines/handlers/depends.rb +49 -0
  63. data/lib/rudy/routines/handlers/disks.rb +239 -0
  64. data/lib/rudy/routines/handlers/group.rb +42 -0
  65. data/lib/rudy/routines/handlers/host.rb +72 -0
  66. data/lib/rudy/routines/handlers/keypair.rb +70 -0
  67. data/lib/rudy/routines/handlers/machines.rb +15 -0
  68. data/lib/rudy/routines/handlers/script.rb +85 -0
  69. data/lib/rudy/routines/handlers/user.rb +41 -0
  70. data/lib/rudy/routines/passthrough.rb +19 -23
  71. data/lib/rudy/routines/reboot.rb +82 -51
  72. data/lib/rudy/routines/shutdown.rb +61 -14
  73. data/lib/rudy/routines/startup.rb +111 -17
  74. data/lib/rudy/utils.rb +12 -59
  75. data/rudy.gemspec +85 -25
  76. data/tryouts/01_mixins/01_hash_tryouts.rb +20 -0
  77. data/tryouts/10_require_time/10_rudy_tryouts.rb +33 -0
  78. data/tryouts/10_require_time/15_global_tryouts.rb +58 -0
  79. data/tryouts/12_config/10_load_config_tryouts.rb +43 -0
  80. data/tryouts/12_config/20_defaults_tryouts.rb +16 -0
  81. data/tryouts/12_config/30_accounts_tryouts.rb +17 -0
  82. data/tryouts/12_config/40_machines_tryouts.rb +53 -0
  83. data/tryouts/12_config/50_commands_tryouts.rb +17 -0
  84. data/tryouts/12_config/60_routines_tryouts.rb +16 -0
  85. data/tryouts/15_huxtable/10_huxtable_tryouts.rb +47 -0
  86. data/tryouts/15_huxtable/20_user_tryouts.rb +47 -0
  87. data/tryouts/20_simpledb/10_domains_tryouts.rb +36 -0
  88. data/tryouts/20_simpledb/20_objects_tryouts.rb +56 -0
  89. data/tryouts/25_ec2/10_keypairs_tryouts.rb +54 -0
  90. data/tryouts/25_ec2/20_groups_tryouts.rb +56 -0
  91. data/tryouts/25_ec2/21_groups_authorize_address_tryouts.rb +53 -0
  92. data/tryouts/25_ec2/22_groups_authorize_account_tryouts.rb +54 -0
  93. data/tryouts/25_ec2/30_addresses_tryouts.rb +42 -0
  94. data/tryouts/25_ec2/40_volumes_tryouts.rb +53 -0
  95. data/tryouts/25_ec2/50_snapshots_tryouts.rb +75 -0
  96. data/tryouts/26_ec2_instances/10_instance_tryouts.rb +107 -0
  97. data/tryouts/26_ec2_instances/50_images_tryouts.rb +7 -0
  98. data/tryouts/30_metadata/10_include_tryouts.rb +45 -0
  99. data/tryouts/30_metadata/13_object_tryouts.rb +19 -0
  100. data/tryouts/30_metadata/50_disk_tryouts.rb +115 -0
  101. data/tryouts/30_metadata/51_disk_digest_tryouts.rb +24 -0
  102. data/tryouts/30_metadata/53_disk_list_tryouts.rb +35 -0
  103. data/tryouts/30_metadata/56_disk_volume_tryouts.rb +68 -0
  104. data/tryouts/30_metadata/60_backup_tryouts.rb +101 -0
  105. data/tryouts/30_metadata/63_backup_list_tryouts.rb +38 -0
  106. data/tryouts/30_metadata/64_backup_disk_tryouts.rb +65 -0
  107. data/tryouts/30_metadata/66_backup_snapshot_tryouts.rb +76 -0
  108. data/tryouts/30_metadata/70_machine_tryouts.rb +85 -0
  109. data/tryouts/30_metadata/73_machine_list_tryouts.rb +58 -0
  110. data/tryouts/30_metadata/76_machine_instance_tryouts.rb +64 -0
  111. data/tryouts/30_metadata/77_machines_tryouts.rb +45 -0
  112. data/tryouts/40_routines/10_keypair_handler_tryouts.rb +52 -0
  113. data/tryouts/40_routines/11_group_handler_tryouts.rb +36 -0
  114. data/tryouts/80_cli/10_rudyec2_tryouts.rb +8 -0
  115. data/tryouts/80_cli/60_rudy_tryouts.rb +41 -0
  116. data/tryouts/failer +6 -0
  117. data/tryouts/misc/console_tryout.rb +91 -0
  118. data/tryouts/misc/disks_tryout.rb +48 -0
  119. data/tryouts/misc/drydock_tryout.rb +48 -0
  120. data/tryouts/misc/nested_methods.rb +103 -0
  121. data/tryouts/misc/session_tryout.rb +46 -0
  122. data/tryouts/misc/tryouts.rb +33 -0
  123. data/tryouts/misc/usage_tryout.rb +23 -0
  124. metadata +119 -31
  125. data/bin/ird +0 -153
  126. data/lib/rudy/metadata/backups.rb +0 -67
  127. data/lib/rudy/metadata/debug.rb +0 -38
  128. data/lib/rudy/metadata/disks.rb +0 -67
  129. data/lib/rudy/metadata/objectbase.rb +0 -108
  130. data/lib/rudy/routines/helper.rb +0 -76
  131. data/lib/rudy/routines/helpers/dependshelper.rb +0 -34
  132. data/lib/rudy/routines/helpers/diskhelper.rb +0 -403
  133. data/lib/rudy/routines/helpers/scripthelper.rb +0 -197
  134. data/lib/rudy/routines/helpers/userhelper.rb +0 -37
  135. data/support/rudy-ec2-startup +0 -200
@@ -0,0 +1,20 @@
1
+
2
+ group "Mixins"
3
+ library :rudy, File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
4
+
5
+ tryout "Hash" do
6
+ setup do
7
+ def one_lvl; {:empty=>1}; end
8
+ def two_lvls; {:l1 => {:empty=>1}}; end
9
+ def three_lvls; { :l1 => { :l2 => {:empty=>1, :empty=>1} } }; end
10
+ def six_lvls; {:l1 => {:l2 => {:l3 => {:l4 => {:l5 => {}, :empty=>1}, :empty=>1}}}}; end
11
+ end
12
+
13
+ dream [1, 2, 3, 6]
14
+ drill "should calculate deepest point" do
15
+ [one_lvl.deepest_point, two_lvls.deepest_point,
16
+ three_lvls.deepest_point, six_lvls.deepest_point]
17
+ end
18
+ end
19
+
20
+
@@ -0,0 +1,33 @@
1
+
2
+ group "Require-time"
3
+ library :rudy, File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
4
+
5
+ tryout "Rudy Initialization" do
6
+ setup do
7
+ end
8
+
9
+ drill "version matches gemspec", Rudy::VERSION.to_s do
10
+ require 'rubygems' unless defined?(Gem)
11
+ eval( File.read(File.join(RUDY_HOME, 'rudy.gemspec')))
12
+ @spec.version.to_s
13
+ end
14
+
15
+ drill "has sysinfo", Rudy.sysinfo, :class, SysInfo
16
+ drill "debug is disabled", Rudy.debug?, false
17
+ drill "quiet is disabled", Rudy.quiet?, false
18
+ drill "auto-yes is disabled", Rudy.yes?, false
19
+
20
+ drill "debug can be enabled", true do
21
+ Rudy.enable_debug
22
+ Rudy.debug?
23
+ end
24
+
25
+ drill "debug can be disabled", false do
26
+ Rudy.disable_debug
27
+ Rudy.debug?
28
+ end
29
+
30
+ end
31
+
32
+
33
+
@@ -0,0 +1,58 @@
1
+ rudy_lib_path = File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
2
+
3
+ group "Require-time"
4
+ library :rudy, rudy_lib_path
5
+
6
+ tryout "Initialization of Global" do
7
+ global = Rudy::Huxtable.global
8
+ drill "has global", global, :class, Rudy::Global
9
+ drill "has default region", global.region, :'us-east-1'
10
+ drill "has default zone", global.zone, :'us-east-1b'
11
+ drill "has default environment", global.environment, :stage
12
+ drill "has default role", global.role, :app
13
+ drill "default position is nil", global.position, nil
14
+ drill "default user is nil", global.user, nil
15
+ end
16
+
17
+ tryout "Global knows ENV" do
18
+
19
+ dream 'ACCESS99'
20
+ drill "reads AWS_ACCESS_KEY" do
21
+ ENV['AWS_ACCESS_KEY'] = 'ACCESS99' and Rudy::Huxtable.reset_global
22
+ Rudy::Huxtable.global.accesskey
23
+ end
24
+
25
+ dream 'SECRET33'
26
+ drill "reads AWS_SECRET_KEY before AWS_SECRET_ACCESS_KEY" do
27
+ ENV['AWS_SECRET_ACCESS_KEY'] = 'SACCESS7'
28
+ ENV['AWS_SECRET_KEY'] = 'SECRET33' and Rudy::Huxtable.reset_global
29
+ Rudy::Huxtable.global.secretkey
30
+ end
31
+
32
+ dream 'SACCESS7'
33
+ dream :class, String
34
+ drill "reads AWS_SECRET_ACCESS_KEY" do
35
+ ENV['AWS_SECRET_ACCESS_KEY'] = 'SACCESS7'
36
+ ENV['AWS_SECRET_KEY'] = nil or Rudy::Huxtable.reset_global
37
+ Rudy::Huxtable.global.secretkey
38
+ end
39
+
40
+ dream File.expand_path('CERT22')
41
+ drill "reads EC2_CERT" do
42
+ ENV['EC2_CERT'] = 'CERT22' and Rudy::Huxtable.reset_global
43
+ Rudy::Huxtable.global.cert
44
+ end
45
+
46
+ dream File.expand_path('PK100')
47
+ drill "reads EC2_PRIVATE_KEY" do
48
+ ENV['EC2_PRIVATE_KEY'] = 'PK100' and Rudy::Huxtable.reset_global
49
+ Rudy::Huxtable.global.pkey
50
+ end
51
+
52
+ end
53
+
54
+ tryout "Population of Global" do
55
+ setup do
56
+ Rudy::Huxtable.update_config
57
+ end
58
+ end
@@ -0,0 +1,43 @@
1
+
2
+ group "Config"
3
+ library :rudy, File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
4
+
5
+ tryout "Loads config files" do
6
+
7
+ drill "load configs when created", 1 do
8
+ @@config = Rudy::Config.new Rudy::CONFIG_FILE
9
+ @@config.paths.size
10
+ end
11
+
12
+ drill "has accounts", :class, Rudy::Config::Accounts do
13
+ @@config.accounts
14
+ end
15
+ drill "has defaults", :class, Rudy::Config::Defaults do
16
+ @@config.defaults
17
+ end
18
+
19
+ drill "loads additional configs", 2 do
20
+ @@config.paths << File.join(RUDY_HOME, 'Rudyfile')
21
+ @@config.refresh
22
+ @@config.paths.size
23
+ end
24
+
25
+ drill "has machines", :class, Rudy::Config::Machines do
26
+ @@config.machines
27
+ end
28
+ drill "has commands", :class, Rudy::Config::Commands do
29
+ @@config.commands
30
+ end
31
+ drill "has routines", :class, Rudy::Config::Routines do
32
+ @@config.routines
33
+ end
34
+
35
+ drill "autoloads known configs", true do
36
+ conf = Rudy::Config.new
37
+ conf.look_and_load # Needs to run before checking accounts, et al
38
+ (!conf.paths.empty? && !conf.paths.nil?)
39
+ end
40
+
41
+ end
42
+
43
+
@@ -0,0 +1,16 @@
1
+
2
+ group "Config"
3
+ library :rudy, File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
4
+
5
+ tryout "Defaults" do
6
+ setup do
7
+ @@config = Rudy::Config.new
8
+ @@config.look_and_load # looks for and loads config files
9
+ end
10
+
11
+ drill "has some defaults", ["environment", "role", "zone"].sort do
12
+ # Sorted so we can add new keys without breaking the test
13
+ @@config.defaults.keys.collect { |v| v.to_s }.sort
14
+ end
15
+
16
+ end
@@ -0,0 +1,17 @@
1
+
2
+ group "Config"
3
+ library :rudy, File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
4
+
5
+ tryout "Accounts" do
6
+ setup do
7
+ @@config = Rudy::Config.new
8
+ @@config.look_and_load # looks for and loads config files
9
+ end
10
+
11
+ dream ["accesskey", "accountnum", "cert", "name", "pkey", "secretkey"]
12
+ drill "has aws account" do
13
+ # Sorted so we can add new keys without breaking the test
14
+ @@config.accounts.aws.keys.collect { |v| v.to_s }.sort
15
+ end
16
+
17
+ end
@@ -0,0 +1,53 @@
1
+
2
+ group "Config"
3
+ library :rudy, File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
4
+
5
+ tryout "Machines" do
6
+ ## drill "Setup vars", :dream => true do
7
+ drill "Setup vars", true do
8
+ @@config = Rudy::Config.new
9
+ @@config.look_and_load # looks for and loads config files
10
+ @@reg, @@zon = @@config.defaults.region, @@config.defaults.zone
11
+ @@env, @@rol = @@config.defaults.environment, @@config.defaults.role
12
+ true
13
+ end
14
+
15
+ dream :class, Rudy::Config::Machines
16
+ dream :gibbler, "b44ba542bd2aa382cf77fa64ffc610e5e992609a"
17
+ drill "has instance of Rudy::Config::Machines" do
18
+ @@config.machines
19
+ end
20
+
21
+ drill "is not gibbled (yet)", false do
22
+ @@config.machines.gibbled?
23
+ end
24
+
25
+ drill "has example AMIs by zone", ["ami-e348af8a", "ami-6ecde51a"] do
26
+ [@@config.machines[:'us-east-1'].ami, @@config.machines[:'eu-west-1'].ami]
27
+ end
28
+
29
+ drill "can find us-east-1 AMI", 'ami-e348af8a' do
30
+ @@config.machines.find(:"us-east-1", :ami)
31
+ end
32
+ drill "can find eu-west-1 AMI", 'ami-6ecde51a' do
33
+ @@config.machines.find(:"eu-west-1", :ami)
34
+ end
35
+ drill "different default AMI for each zone", true do
36
+ eu = @@config.machines.find(:"eu-west-1", :ami)
37
+ us = @@config.machines.find(:"us-east-1", :ami)
38
+ (eu != us && !eu.nil? && !us.nil?)
39
+ end
40
+ drill "conf hash and find are equal", true do
41
+ conf = @@config.machines[@@env][@@rol]
42
+ find = @@config.machines.find(@@env, @@rol)
43
+ conf == find
44
+ end
45
+ drill "conf find and find_deferred are equal", true do
46
+ find = @@config.machines.find(@@env, @@rol)
47
+ find_def = @@config.machines.find_deferred(@@env, @@rol)
48
+ find == find_def
49
+ end
50
+
51
+
52
+ end
53
+
@@ -0,0 +1,17 @@
1
+
2
+ rudy_lib_path = File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
3
+
4
+ group "Config"
5
+ library :rudy, rudy_lib_path
6
+
7
+ tryout "Commands" do
8
+ setup do
9
+ @@config = Rudy::Config.new
10
+ @@config.look_and_load # looks for and loads config files
11
+ end
12
+
13
+ drill "is a well-formed hash", [:allow] do
14
+ @@config.commands.to_hash.keys.uniq.sort
15
+ end
16
+
17
+ end
@@ -0,0 +1,16 @@
1
+
2
+ rudy_lib_path = File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
3
+
4
+ group "Config"
5
+ library :rudy, rudy_lib_path
6
+
7
+ tryout "Routines" do
8
+ setup do
9
+ @@config = Rudy::Config.new
10
+ @@config.look_and_load # looks for and loads config files
11
+ end
12
+
13
+ xdrill "has aws account" do
14
+ end
15
+
16
+ end
@@ -0,0 +1,47 @@
1
+
2
+
3
+ group "Rudy::Huxtable"
4
+ library :rudy, 'lib'
5
+
6
+ tryout "Is well kept" do
7
+ set :oldlogger, Rudy::Huxtable.logger
8
+ setup do
9
+ #Rudy::Huxtable.update_config
10
+ end
11
+ clean do
12
+ Rudy::Huxtable.update_logger oldlogger
13
+ end
14
+
15
+ drill "has config", Rudy::Huxtable.config, :class, Rudy::Config
16
+ drill "has global", Rudy::Huxtable.global, :class, Rudy::Global
17
+ drill "has logger", Rudy::Huxtable.logger, :class, StringIO
18
+ drill "specify logger", :class, IO do
19
+ Rudy::Huxtable.update_logger STDOUT
20
+ Rudy::Huxtable.logger
21
+ end
22
+
23
+ # drill "knows where config lives", Rudy::Huxtable.config_dirname
24
+ end
25
+
26
+ tryout "Loads configuration" do
27
+
28
+ end
29
+
30
+
31
+ tryout "Knows the defaults" do
32
+ setup do
33
+ class ::Olivia # :: to define the class in the root context
34
+ include Rudy::Huxtable
35
+ end
36
+ end
37
+
38
+ drill "create olivia", 'Olivia' do
39
+ @@olivia = Olivia.new
40
+ @@olivia.class.to_s
41
+ end
42
+
43
+ drill "machine group", 'stage-app' do
44
+ @@olivia.current_machine_group
45
+ end
46
+
47
+ end
@@ -0,0 +1,47 @@
1
+
2
+
3
+ group "Rudy::Huxtable"
4
+ library :rudy, 'lib'
5
+
6
+ tryout "User related methods" do
7
+ set :user, Rudy::Utils.strand(4)
8
+ set :keydir, '/tmp'
9
+ set :global, Rudy::Huxtable.global
10
+ set :config, Rudy::Huxtable.config
11
+ setup do
12
+ Rudy.enable_debug
13
+ Rudy::Huxtable.update_config # Read config files
14
+ config.defaults[:keydir] = keydir
15
+ Rudy::Huxtable.global.zone = 'us-east-1b'
16
+ module Cousin
17
+ extend Rudy::Huxtable
18
+ end
19
+ end
20
+
21
+ drill "knows current user", :root do
22
+ Cousin.current_machine_user
23
+ end
24
+
25
+ drill "keypair path for current user", "#{keydir}/key-us-east-1b-stage-app" do
26
+ Cousin.user_keypairpath
27
+ end
28
+ drill "keypair path for arbitrary user", "#{keydir}/key-us-east-1b-stage-app-#{user}" do
29
+ Cousin.user_keypairpath user
30
+ end
31
+ drill "keypair path for root user", "#{keydir}/key-us-east-1b-stage-app" do
32
+ Cousin.user_keypairpath :root
33
+ end
34
+
35
+ drill "keypair name for current user", "key-us-east-1b-stage-app" do
36
+ Cousin.user_keypairname
37
+ end
38
+ drill "keypair name for arbitrary user", "key-us-east-1b-stage-app-#{user}" do
39
+ Cousin.user_keypairname user
40
+ end
41
+ drill "keypair name for root user", "key-us-east-1b-stage-app" do
42
+ Cousin.user_keypairname :root
43
+ end
44
+
45
+
46
+
47
+ end
@@ -0,0 +1,36 @@
1
+
2
+ library :rudy, 'lib'
3
+
4
+ group "SimpleDB"
5
+
6
+ tryouts "Domains" do
7
+ set :test_domain, 'test_' << Rudy::Utils.strand
8
+
9
+ setup do
10
+ Rudy::Huxtable.update_config
11
+ global = Rudy::Huxtable.global
12
+ akey, skey, region = global.accesskey, global.secretkey, global.region
13
+ @sdb = Rudy::AWS::SDB.new(akey, skey, region)
14
+ end
15
+
16
+ drill "create simpledb connection", :class, Rudy::AWS::SDB do
17
+ @sdb
18
+ end
19
+
20
+ drill "create a domain (#{test_domain})", true do
21
+ @sdb.create_domain test_domain
22
+ end
23
+
24
+ drill "list domains", :class, Array do
25
+ stash :domains, @sdb.list_domains
26
+ end
27
+
28
+ drill "destroy a domain (#{test_domain})", true do
29
+ @sdb.destroy_domain test_domain
30
+ end
31
+
32
+ end
33
+
34
+
35
+
36
+
@@ -0,0 +1,56 @@
1
+
2
+ library :rudy, 'lib'
3
+
4
+ group "SimpleDB"
5
+
6
+ tryouts "Objects" do
7
+
8
+ set :test_domain, 'test_' << Rudy::Utils.strand
9
+ set :produce, Hash[
10
+ 'orange' => (rand(100) * 10).to_s,
11
+ 'celery' => (rand(100) * 100).to_s,
12
+ 'grapes' => 'green'
13
+ ]
14
+
15
+
16
+ setup do
17
+ Rudy::Huxtable.update_config
18
+ global = Rudy::Huxtable.global
19
+ akey, skey, region = global.accesskey, global.secretkey, global.region
20
+ @sdb = Rudy::AWS::SDB.new(akey, skey, region)
21
+ end
22
+
23
+ drill "create test domain (#{test_domain})", true do
24
+ @sdb.create_domain test_domain
25
+ end
26
+
27
+ drill "put object", true do
28
+ stash :product1, produce
29
+ @sdb.put(test_domain, 'produce1', produce, :replace)
30
+ end
31
+
32
+ drill "get object by name", [produce.keys.sort, produce.values.sort] do
33
+ from_sdb = @sdb.get(test_domain, 'produce1')
34
+ stash :product1, from_sdb
35
+ [from_sdb.keys.sort, from_sdb.values.collect { |v| v.first }.sort ]
36
+ end
37
+
38
+ drill "select objects", :gt, 0 do
39
+ stash[:query] = "select * from #{test_domain}"
40
+ stash[:items] = @sdb.select stash[:query]
41
+ stash[:items].is_a?(Hash) && stash[:items].keys.size
42
+ end
43
+
44
+ dream true
45
+ drill "destroy objects by name" do
46
+ items = @sdb.select "select * from #{test_domain}"
47
+ items.keys.each { |name| @sdb.destroy test_domain, name }
48
+ @sdb.select("select * from #{test_domain}").nil?
49
+ end
50
+
51
+ drill "destroy test domain (#{test_domain})", true do
52
+ @sdb.destroy_domain test_domain
53
+ end
54
+
55
+ end
56
+