virtualmonkey 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/.document +5 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +77 -0
  4. data/Rakefile +51 -0
  5. data/VERSION +1 -0
  6. data/bin/grinder +102 -0
  7. data/bin/mcicp +46 -0
  8. data/bin/monkey +12 -0
  9. data/bin/vary_instance_types +59 -0
  10. data/config/cloud_variables/all_clouds.json +30 -0
  11. data/config/cloud_variables/east.json +9 -0
  12. data/config/cloud_variables/rackspace.json +7 -0
  13. data/config/cloud_variables/west.json +9 -0
  14. data/config/common_inputs/apache_haproxy.json +27 -0
  15. data/config/common_inputs/base.json +5 -0
  16. data/config/common_inputs/ebs_toolbox.json +10 -0
  17. data/config/common_inputs/haproxy.json +15 -0
  18. data/config/common_inputs/lamp.json +30 -0
  19. data/config/common_inputs/mysql.json +24 -0
  20. data/config/common_inputs/none.json +4 -0
  21. data/config/common_inputs/php.json +25 -0
  22. data/config/common_inputs/php_aio_trial_chef_alpha.json +3 -0
  23. data/config/common_inputs/php_app_fe_chef.json +12 -0
  24. data/config/common_inputs/php_elb.json +12 -0
  25. data/config/common_inputs/qstart.json +5 -0
  26. data/config/common_inputs/rails.json +31 -0
  27. data/config/common_inputs/rails_aio_demo_chef_alpha.json +3 -0
  28. data/config/common_inputs/rails_aio_developer_chef_alpha.json +10 -0
  29. data/config/common_inputs/rsgrid.json +10 -0
  30. data/config/common_inputs/tomcat.json +15 -0
  31. data/config/common_inputs/windows_blog_engine.json +3 -0
  32. data/config/common_inputs/windows_net_aio.json +14 -0
  33. data/config/troop/11H1/backup/base.json +10 -0
  34. data/config/troop/11H1/backup/lamp_mysql_50.json +10 -0
  35. data/config/troop/11H1/backup/lamp_mysql_51.json +10 -0
  36. data/config/troop/11H1/backup/loadbalancer-php.json +13 -0
  37. data/config/troop/11H1/backup/loadbalancer.json +14 -0
  38. data/config/troop/11H1/backup/loadbalancer_rails.json +13 -0
  39. data/config/troop/11H1/backup/loadbalancer_tomcat6.json +13 -0
  40. data/config/troop/11H1/backup/mysql50.json +11 -0
  41. data/config/troop/11H1/backup/mysql50_toolbox.json +12 -0
  42. data/config/troop/11H1/backup/mysql51.json +11 -0
  43. data/config/troop/11H1/backup/mysql51_toolbox.json +12 -0
  44. data/config/troop/11H1/backup/php_elb.json +11 -0
  45. data/config/troop/11H1/base.json +10 -0
  46. data/config/troop/11H1/ebs_toolbox.json +12 -0
  47. data/config/troop/11H1/lamp_mysql_50.json +10 -0
  48. data/config/troop/11H1/lamp_mysql_51.json +10 -0
  49. data/config/troop/11H1/loadbalancer-php.json +13 -0
  50. data/config/troop/11H1/loadbalancer.json +17 -0
  51. data/config/troop/11H1/loadbalancer_rails.json +13 -0
  52. data/config/troop/11H1/loadbalancer_tomcat6.json +13 -0
  53. data/config/troop/11H1/mysql50.json +11 -0
  54. data/config/troop/11H1/mysql50_toolbox.json +12 -0
  55. data/config/troop/11H1/mysql51.json +11 -0
  56. data/config/troop/11H1/mysql51_awsdns.json +11 -0
  57. data/config/troop/11H1/mysql51_debug.json +11 -0
  58. data/config/troop/11H1/mysql51_toolbox.json +12 -0
  59. data/config/troop/11H1/php.json +13 -0
  60. data/config/troop/11H1/php_elb.json +11 -0
  61. data/config/troop/11H1/rails.json +13 -0
  62. data/config/troop/11H1/tomcat6.json +13 -0
  63. data/config/troop/chef_quickstart.json +10 -0
  64. data/config/troop/just_elb +10 -0
  65. data/config/troop/lamp_v4.json +10 -0
  66. data/config/troop/patch_test.json +10 -0
  67. data/config/troop/rightlink.json +10 -0
  68. data/config/troop/simple_fail.json +11 -0
  69. data/config/troop/simple_pass.json +11 -0
  70. data/config/troop/windows_blog_engine.json +10 -0
  71. data/config/troop/windows_net_aio.json +10 -0
  72. data/config/troop/windows_quick_start.json +10 -0
  73. data/features/base.rb +31 -0
  74. data/features/db_toolbox.rb +59 -0
  75. data/features/ebs_toolbox.rb +62 -0
  76. data/features/lamp.rb +33 -0
  77. data/features/lb-apache-haproxy.rb +49 -0
  78. data/features/mysql_5.x_v2_v4_from_scratch.rb +71 -0
  79. data/features/mysql_5.x_v2_v4_from_scratch_awsdns.rb +71 -0
  80. data/features/mysql_5.x_v2_v4_from_scratch_dyndns.rb +71 -0
  81. data/features/mysql_v1_upgrade_v2.rb +54 -0
  82. data/features/old_cuke_features/Rakefile +121 -0
  83. data/features/old_cuke_features/Steps-TODO +31 -0
  84. data/features/old_cuke_features/app_state.feature +25 -0
  85. data/features/old_cuke_features/app_test.feature +24 -0
  86. data/features/old_cuke_features/base.feature +16 -0
  87. data/features/old_cuke_features/chef_quickstart.feature +11 -0
  88. data/features/old_cuke_features/db_toolbox.feature +38 -0
  89. data/features/old_cuke_features/ebs_toolbox.feature +39 -0
  90. data/features/old_cuke_features/elb_create_delete.feature +41 -0
  91. data/features/old_cuke_features/elb_generic.feature +27 -0
  92. data/features/old_cuke_features/fe_app_checks.feature +21 -0
  93. data/features/old_cuke_features/just-start.feature +13 -0
  94. data/features/old_cuke_features/lamp.feature +15 -0
  95. data/features/old_cuke_features/lb-apache-haproxy.feature +27 -0
  96. data/features/old_cuke_features/mysql_5.x_v2_v4_from_scratch.feature +33 -0
  97. data/features/old_cuke_features/mysql_5.x_v2_v4_from_scratch_awsdns.feature +33 -0
  98. data/features/old_cuke_features/mysql_5.x_v2_v4_from_scratch_dyndns.feature +33 -0
  99. data/features/old_cuke_features/mysql_chef_premium.feature +27 -0
  100. data/features/old_cuke_features/mysql_chef_premium_from_scratch.feature +37 -0
  101. data/features/old_cuke_features/mysql_v1_upgrade_v2.feature +42 -0
  102. data/features/old_cuke_features/php.feature +27 -0
  103. data/features/old_cuke_features/php_aio_trial_chef_alpha.feature +11 -0
  104. data/features/old_cuke_features/php_chef.feature +21 -0
  105. data/features/old_cuke_features/php_elb.feature +41 -0
  106. data/features/old_cuke_features/rails.feature +26 -0
  107. data/features/old_cuke_features/rails_aio_developer_chef.feature +17 -0
  108. data/features/old_cuke_features/reboot.feature +23 -0
  109. data/features/old_cuke_features/rightlink.feature +19 -0
  110. data/features/old_cuke_features/rsgrid.feature +19 -0
  111. data/features/old_cuke_features/simple.feature +8 -0
  112. data/features/old_cuke_features/simple_fail.feature +9 -0
  113. data/features/old_cuke_features/start-stop.feature +13 -0
  114. data/features/old_cuke_features/step_definitions/app.rb +21 -0
  115. data/features/old_cuke_features/step_definitions/deployment_steps.rb +112 -0
  116. data/features/old_cuke_features/step_definitions/ebs.rb +36 -0
  117. data/features/old_cuke_features/step_definitions/elb.rb +35 -0
  118. data/features/old_cuke_features/step_definitions/lb.rb +22 -0
  119. data/features/old_cuke_features/step_definitions/mysql_steps.rb +84 -0
  120. data/features/old_cuke_features/terminate.feature +7 -0
  121. data/features/old_cuke_features/tomcat6-tests-TODO +29 -0
  122. data/features/old_cuke_features/tomcat6.feature +27 -0
  123. data/features/patch_test.rb +33 -0
  124. data/features/php.rb +54 -0
  125. data/features/php_elb.rb +78 -0
  126. data/features/rails.rb +54 -0
  127. data/features/start_only.rb +26 -0
  128. data/features/tomcat6.rb +54 -0
  129. data/lib/virtualmonkey.rb +28 -0
  130. data/lib/virtualmonkey/application.rb +75 -0
  131. data/lib/virtualmonkey/application_frontend.rb +42 -0
  132. data/lib/virtualmonkey/command.rb +39 -0
  133. data/lib/virtualmonkey/command/clone.rb +50 -0
  134. data/lib/virtualmonkey/command/create.rb +21 -0
  135. data/lib/virtualmonkey/command/destroy.rb +51 -0
  136. data/lib/virtualmonkey/command/list.rb +10 -0
  137. data/lib/virtualmonkey/command/run.rb +76 -0
  138. data/lib/virtualmonkey/command/troop.rb +146 -0
  139. data/lib/virtualmonkey/cuke_monk.rb +184 -0
  140. data/lib/virtualmonkey/deployment_monk.rb +132 -0
  141. data/lib/virtualmonkey/deployment_runner.rb +333 -0
  142. data/lib/virtualmonkey/ebs.rb +161 -0
  143. data/lib/virtualmonkey/ebs_runner.rb +59 -0
  144. data/lib/virtualmonkey/elb_runner.rb +194 -0
  145. data/lib/virtualmonkey/fe_app_runner.rb +7 -0
  146. data/lib/virtualmonkey/file_locations.rb +7 -0
  147. data/lib/virtualmonkey/frontend.rb +124 -0
  148. data/lib/virtualmonkey/http_checks.rb +33 -0
  149. data/lib/virtualmonkey/index.html.erb +109 -0
  150. data/lib/virtualmonkey/lamp_runner.rb +29 -0
  151. data/lib/virtualmonkey/mysql.rb +172 -0
  152. data/lib/virtualmonkey/mysql_runner.rb +108 -0
  153. data/lib/virtualmonkey/mysql_toolbox_runner.rb +51 -0
  154. data/lib/virtualmonkey/patch_runner.rb +46 -0
  155. data/lib/virtualmonkey/php_aio_trial_chef_runner.rb +6 -0
  156. data/lib/virtualmonkey/php_chef_runner.rb +69 -0
  157. data/lib/virtualmonkey/rails_aio_developer_chef_runner.rb +8 -0
  158. data/lib/virtualmonkey/shared_dns.rb +67 -0
  159. data/lib/virtualmonkey/simple.rb +5 -0
  160. data/lib/virtualmonkey/simple_runner.rb +6 -0
  161. data/lib/virtualmonkey/test_case_interface.rb +151 -0
  162. data/lib/virtualmonkey/unified_application.rb +40 -0
  163. data/spec/bug3518.rb +16 -0
  164. data/spec/concurrent_writes_spec.rb +26 -0
  165. data/spec/cuke_job_spec.rb +26 -0
  166. data/spec/ek.rb +28 -0
  167. data/spec/little_ruby.rb +20 -0
  168. data/spec/mini.rb +25 -0
  169. data/spec/monitoring.rb +13 -0
  170. data/spec/release_aws_dns.rb +5 -0
  171. data/spec/release_dns.rb +5 -0
  172. data/spec/release_dyndns.rb +5 -0
  173. data/spec/shared_resources_spec.rb +25 -0
  174. data/spec/spec.opts +1 -0
  175. data/spec/spec_helper.rb +11 -0
  176. data/spec/virtualmonkey_spec.rb +7 -0
  177. data/virtualmonkey.gemspec +265 -0
  178. metadata +428 -0
@@ -0,0 +1,8 @@
1
+ module VirtualMonkey
2
+ class RailsAioDeveloperChefRunner
3
+ include VirtualMonkey::DeploymentRunner
4
+ include VirtualMonkey::ApplicationFrontend
5
+
6
+ end
7
+ end
8
+
@@ -0,0 +1,67 @@
1
+ class SharedDns
2
+ attr_accessor :reservation
3
+ attr_accessor :owner
4
+
5
+ def initialize(domain = "virtualmonkey_shared_resources")
6
+ @sdb = Fog::AWS::SimpleDB.new(:aws_access_key_id => Fog.credentials[:aws_access_key_id_test], :aws_secret_access_key => Fog.credentials[:aws_secret_access_key_test])
7
+ @domain = domain
8
+ @reservation = nil
9
+ end
10
+
11
+ # set dns inputs on a deployment to match the current reservation
12
+ # * deployment<~Deployment> the deployment to set inputs on
13
+ def set_dns_inputs(deployment)
14
+ sdb_result = @sdb.get_attributes(@domain, @reservation)
15
+
16
+ set_these = sdb_result.body['Attributes'].reject {|k,v| k == 'owner'}
17
+ set_these.each do |key,val|
18
+ deployment.set_input(key, val.to_s)
19
+ deployment.servers.each { |s| s.set_input(key, "text:") }
20
+ end
21
+ end
22
+
23
+ def reserve_dns(owner, timeout = 0)
24
+ puts "Checking DNS reservation for #{owner}"
25
+ result = @sdb.select("SELECT * from #{@domain} where owner = '#{owner}'")
26
+ puts "Reusing DNS reservation" unless result.body["Items"].empty?
27
+ if result.body["Items"].empty?
28
+ result = @sdb.select("SELECT * from #{@domain} where owner = 'available'")
29
+ return false if result.body["Items"].empty?
30
+ puts "Aquired new DNS reservation"
31
+ item_name = result.body["Items"].keys.first
32
+ response = @sdb.put_attributes(@domain, item_name, {'owner' => owner}, :expect => {'owner' => "available"}, :replace => ['owner'])
33
+ end
34
+ @owner = owner
35
+ @reservation = result.body["Items"].keys.first
36
+ rescue Excon::Errors::ServiceUnavailable
37
+ puts "Resuce: ServiceUnavailable"
38
+ retry_reservation(owner, timeout)
39
+ rescue Excon::Errors::Conflict
40
+ puts "Resuce: Conflict"
41
+ retry_reservation(owner, timeout)
42
+ end
43
+
44
+ def retry_reservation(owner, timeout)
45
+ STDOUT.flush
46
+ if timeout > 20
47
+ return false
48
+ end
49
+ sleep(5)
50
+ reserve_dns(owner, timeout + 1)
51
+ end
52
+
53
+ def release_all
54
+ result = @sdb.select("SELECT * from #{@domain}")
55
+ result.body['Items'].keys.each do |item_name|
56
+ @sdb.put_attributes(@domain, item_name, {"owner" => "available"}, :replace => ["owner"])
57
+ end
58
+ end
59
+
60
+ def release_dns(res = @reservation)
61
+ raise "FATAL: could not release dns because there was no @reservation" unless res
62
+ @sdb.put_attributes(@domain, res, {"owner" => "available"}, :replace => ["owner"])
63
+ @reservation = nil
64
+ end
65
+ end
66
+
67
+
@@ -0,0 +1,5 @@
1
+ module VirtualMonkey
2
+ module Simple
3
+
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module VirtualMonkey
2
+ class SimpleRunner
3
+ include VirtualMonkey::DeploymentRunner
4
+ include VirtualMonkey::Simple
5
+ end
6
+ end
@@ -0,0 +1,151 @@
1
+ module VirtualMonkey
2
+ module TestCaseInterface
3
+ def set_var(sym, *args)
4
+ behavior(sym, *args)
5
+ end
6
+
7
+ def behavior(sym, *args)
8
+ begin
9
+ rerun_test
10
+ #pre-command
11
+ populate_settings unless @populated
12
+ #command
13
+ result = __send__(sym, *args)
14
+ #post-command
15
+ continue_test
16
+ rescue Exception => e
17
+ dev_mode?(e)
18
+ end while @rerun_last_command.pop
19
+ result
20
+ end
21
+
22
+ def verify(method, expectation, *args)
23
+ if expectation =~ /((exception)|(error)|(fatal)|(fail))/i
24
+ expect = "fail"
25
+ error_msg = expectation.split(":")[1..-1].join(":")
26
+ elsif expectation =~ /((success)|(succeed)|(pass))/i
27
+ expect = "pass"
28
+ elsif expectation =~ /nil/i
29
+ expect = "nil"
30
+ else
31
+ raise 'Syntax Error: verify expects a "pass", "fail", or "nil"'
32
+ end
33
+
34
+ begin
35
+ rerun_test
36
+ result = __send__(command, *args)
37
+ if expect != "pass" and not (result == nil and expect == "nil")
38
+ raise "FATAL: Failed verification"
39
+ end
40
+ continue_test
41
+ rescue Exception => e
42
+ if not ("#{e}" =~ /#{error_msg}/ and expect == "fail")
43
+ dev_mode?(e)
44
+ end
45
+ end while @rerun_last_command.pop
46
+ end
47
+
48
+ def probe(server, command, &block)
49
+ # run command on servers matching "server" over ssh
50
+ result = ""
51
+ @servers.select { |s| s.nickname =~ /#{server}/ }.each { |s|
52
+ begin
53
+ rerun_test
54
+ result_temp = s.spot_check_command(command)
55
+ if not yield(result_temp[:output])
56
+ raise "FATAL: Server #{s.nickname} failed probe. Got #{result_temp[:output]}"
57
+ end
58
+ continue_test
59
+ rescue Exception => e
60
+ dev_mode?(e)
61
+ end while @rerun_last_command.pop
62
+ result += result_temp[:output]
63
+ }
64
+ end
65
+
66
+ private
67
+
68
+ def dev_mode?(e)
69
+ if not ENV['MONKEY_NO_DEBUG'] =~ /true/i
70
+ puts e
71
+ puts "Pausing for debugging..."
72
+ debugger
73
+ else
74
+ exception_handle(e)
75
+ end
76
+ end
77
+
78
+ def exception_handle(e)
79
+ puts "ATTENTION: Using default exception_handle(e). This can be overridden in mixin classes."
80
+ if e.message =~ /Insufficient capacity/
81
+ puts "Got \"#{e.message}\". Retrying...."
82
+ sleep 60
83
+ else
84
+ raise e
85
+ end
86
+ end
87
+
88
+ def help
89
+ puts "Here are some of the wrapper methods that may be of use to you in your debugging quest:\n"
90
+ puts "behavior(sym, *args): Pass the method name (as a symbol or string) and the optional arguments"
91
+ puts " that you wish to pass to that method; behavior() will call that method"
92
+ puts " with those arguments while handling nested exceptions, retries, and"
93
+ puts " debugger calls.\n"
94
+ puts " Examples:"
95
+ puts " behavior(:launch_all)"
96
+ puts " behavior(:launch_set, 'Load Balancer')\n"
97
+ puts "verify(sym, expectation_string, *args): Pass the method name (as a symbol or string), the expected"
98
+ puts " result, and any arguments to pass to that method. The"
99
+ puts " expectation_string should consist of 'Error: MyRegex',"
100
+ puts " 'Pass', or 'nil'. 'Error: MyRegex' tells verify() that it"
101
+ puts " should expect an exception to be raised, and the message "
102
+ puts " or exception name should match /MyRegex/. 'Pass' tells"
103
+ puts " verify() that it should expect the method to return normally,"
104
+ puts " and 'nil' tells verify() that it should expect the method to"
105
+ puts " return nil.\n"
106
+ puts " Example:"
107
+ puts " verify(:launch_all, 'Error: execution expired')\n"
108
+ puts "probe(server_regex, shell_command, &block): Provides a one-line interface for running a command on"
109
+ puts " a set of servers and verifying their output. The block"
110
+ puts " should take one argument, the output string from one of"
111
+ puts " the servers, and return true or false based on however"
112
+ puts " the developer wants to verify correctness.\n"
113
+ puts " Examples:"
114
+ puts " probe('.*', 'ls') { |s| puts s }"
115
+ puts " probe('.*', 'uname -a') { |s| s =~ /x64/ }\n"
116
+ puts "continue_test: Disables the retry loop that reruns the last command (the current command that you're"
117
+ puts " debugging.\n"
118
+ puts "help: Prints this help message."
119
+ end
120
+
121
+ def populate_settings
122
+ @servers.each { |s| s.settings }
123
+ lookup_scripts
124
+ @populated = 1
125
+ end
126
+
127
+ def object_behavior(obj, sym, *args)
128
+ begin
129
+ rerun_test
130
+ #pre-command
131
+ populate_settings unless @populated
132
+ #command
133
+ result = obj.__send__(sym, *args)
134
+ #post-command
135
+ continue_test
136
+ rescue Exception => e
137
+ dev_mode?(e)
138
+ end while @rerun_last_command.pop
139
+ result
140
+ end
141
+
142
+ def rerun_test
143
+ @rerun_last_command.push(true)
144
+ end
145
+
146
+ def continue_test
147
+ @rerun_last_command.pop
148
+ @rerun_last_command.push(false)
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,40 @@
1
+ module VirtualMonkey
2
+ module UnifiedApplication
3
+ # returns true if the http response contains the expected_string
4
+ # * url<~String> url to perform http request
5
+ # * expected_string<~String> regex compatible string used to match against the response output
6
+ def test_http_response(expected_string, url, port)
7
+ cmd = "curl -s #{url} 2> /dev/null "
8
+ puts cmd
9
+ timeout=300
10
+ begin
11
+ status = Timeout::timeout(timeout) do
12
+ while true
13
+ response = `#{cmd}`
14
+ break if response.include?(expected_string)
15
+ puts "Retrying..."
16
+ sleep 5
17
+ end
18
+ end
19
+ rescue Timeout::Error => e
20
+ raise "ERROR: Query failed after #{timeout/60} minutes."
21
+ end
22
+ end
23
+
24
+ def run_unified_application_checks(run_on=@servers, port=8000)
25
+ run_on.each do |server|
26
+ behavior(:run_unified_application_check, server.dns_name, port)
27
+ end
28
+ end
29
+
30
+ # this is where ALL the generic application server checks live, this could get rather long but for now it's a single method with a sequence of checks
31
+ def run_unified_application_check(dns_name, port=8000)
32
+ url_base = "#{dns_name}:#{port}"
33
+ behavior(:test_http_response, "html serving succeeded", "#{url_base}/index.html", port)
34
+ behavior(:test_http_response, "configuration=succeeded", "#{url_base}/appserver/", port)
35
+ behavior(:test_http_response, "I am in the db", "#{url_base}/dbread/", port)
36
+ behavior(:test_http_response, "hostname=", "#{url_base}/serverid/", port)
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,16 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "bug #3518" do
4
+ before(:all) do
5
+ raise "for this spec to run, you must have a mysql deployment nickname in $DEPLOYMENT variable" unless ENV['DEPLOYMENT']
6
+ @runner = VirtualMonkey::MysqlRunner.new(ENV['DEPLOYMENT'])
7
+ @runner.lookup_scripts
8
+ @runner.setup_dns
9
+ end
10
+ it "disables binlogs on the old master after promote" do
11
+ @runner.run_promotion_operations
12
+ oldmaster = @runner.servers.last
13
+ oldmaster.settings
14
+ puts "oldmaster is #{oldmaster.dns_name}"
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ require File.join(File.dirname(__FILE__), "spec_helper")
2
+ require 'ruby-debug'
3
+
4
+ describe SharedDns, "Using sdb to store shared resources" do
5
+ it "should perform concurrent reads and writes" do
6
+ unique_record = "blah#{rand(10000000)}"
7
+
8
+ reservations = Array.new
9
+ 18.times do |i|
10
+ reservations[i] = SharedDns.new
11
+ end
12
+
13
+ reservations[0].release_all
14
+
15
+ mythreads = Array.new
16
+ reservations.each do |x|
17
+ mythreads << Thread.new do
18
+ x.reserve_dns
19
+ # all reservations should succeed
20
+ x.should_not == false
21
+ puts "reserved #{x.reservation}"
22
+ STDOUT.flush
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe CukeMonk do
4
+ it "checks a job status" do
5
+ EM.run {
6
+ cm = CukeMonk.new
7
+ cm.run_test("NODEPLOY", "simple.feature")
8
+ cm.run_test("NODEPLOY", "simple.feature")
9
+ cm.run_test("NODEPLOY", "simple.feature")
10
+
11
+ EM.add_periodic_timer(1) {
12
+ cm.show_jobs
13
+ }
14
+
15
+ donetime = EM.add_periodic_timer(1) {
16
+ donetime.cancel
17
+ puts "All done? #{cm.all_done?}"
18
+ if cm.all_done?
19
+ EM.stop
20
+ end
21
+ }
22
+
23
+
24
+ }
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require "ruby-debug"
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+
5
+ describe "Messing with spec" do
6
+ before(:all) do
7
+ raise "for this spec to run, you must have a mysql deployment nickname in $DEPLOYMENT variable" unless ENV['DEPLOYMENT']
8
+ @runner = VirtualMonkey::MysqlRunner.new(ENV['DEPLOYMENT'])
9
+ @runner.lookup_scripts
10
+ @runner.lineage='testlineage3049'
11
+ @runner.stripe_count=1
12
+ # @runner.set_variation_lineage
13
+ @master = @runner.servers.first
14
+ @master.start
15
+ @master.wait_for_operational_with_dns
16
+ @master.settings
17
+ puts "master is #{@master.dns_name}"
18
+ # @runner.config_master_from_scratch(master)
19
+ # @runner.setup_dns
20
+
21
+ end
22
+ it "wait for master snapshot to complete - no pending snapshots for master lineage" do
23
+ # take the lineage name, find all snapshots and verify that none are in the pending state.
24
+ @runner.run_script("backup", @master)
25
+ @runner.wait_for_snapshots
26
+ debugger
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'virtualmonkey'
3
+
4
+ @sdb = Fog::AWS::SimpleDB.new(:aws_access_key_id => Fog.credentials[:aws_access_key_id_test], :aws_secret_access_key => Fog.credentials[:aws_secret_access_key_test])
5
+
6
+ @domain="virtualmonkey_awsdns"
7
+
8
+ 29.times do |num|
9
+ item_name="awsdns#{num}"
10
+ attributes=
11
+ {"SLAVE_DB_DNSID"=>["text:Z3AINKOIEY1X3X:testslave#{num}.aws.rightscale.com"],
12
+ "MASTER_DB_DNSID"=>["text:Z3AINKOIEY1X3X:test#{num}.aws.rightscale.com"],
13
+ "DNS_USER"=>["cred:AWS_ACCESS_KEY_ID_TEST"],
14
+ "DNS_PASSWORD"=>["cred:AWS_SECRET_ACCESS_KEY_TEST"],
15
+ "DNS_PROVIDER"=>["text:AwsDNS"],
16
+ "owner"=>["available"],
17
+ "MASTER_DB_DNSNAME"=>["text:test#{num}.aws.rightscale.com"]}
18
+ response = @sdb.put_attributes(@domain, item_name, attributes)
19
+ end
20
+
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require "ruby-debug"
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+
5
+ describe "Messing with spec" do
6
+ before(:all) do
7
+ raise "for this spec to run, you must have a mysql deployment nickname in $DEPLOYMENT variable" unless ENV['DEPLOYMENT']
8
+ @runner = VirtualMonkey::MysqlRunner.new(ENV['DEPLOYMENT'])
9
+ @runner
10
+ @runner.lookup_scripts
11
+ @snapshot_lineage_prefix='testlineage3049'
12
+ # @runner.setup_dns
13
+
14
+ end
15
+ it "wait for master snapshot to complete - no pending snapshots for master lineage" do
16
+ # take the lineage name, find all snapshots and verify that none are in the pending state.
17
+ snapshots =Ec2EbsSnapshot.find_by_cloud_id(3).select { |n| n.nickname =~ /#{@snapshot_lineage_prefix}.*$/ }
18
+ status= snapshots.map &:aws_status
19
+ puts status.join ","
20
+ puts "we got completed snapshots" if status.include?("completed")
21
+ puts "we got pending snapshots" if status.include?("pending")
22
+ debugger
23
+ puts x
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'rubygems'
4
+ require 'virtualmonkey'
5
+
6
+ dep=VirtualMonkey::SimpleRunner.new(ENV['DEPLOYMENT'])
7
+ s= dep.servers.first
8
+ s.monitoring
9
+ mon=s.get_sketchy_data({'start'=>-180,'end'=>"-20",'plugin_name'=>"df",'plugin_type'=>"df-mnt"})
10
+ data=mon['data']
11
+ free=data['free']
12
+ raise "No df free data" unless free.length > 0
13
+ raise "DF not free" unless free[0]