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,29 @@
1
+ module VirtualMonkey
2
+ class LampRunner
3
+ include VirtualMonkey::DeploymentRunner
4
+ include VirtualMonkey::UnifiedApplication
5
+ include VirtualMonkey::Mysql
6
+
7
+ # It's not that I'm a Java fundamentalist; I merely believe that mortals should
8
+ # not be calling the following methods directly. Instead, they should use the
9
+ # TestCaseInterface methods (behavior, verify, probe) to access these functions.
10
+ # Trust me, I know what's good for you. -- Tim R.
11
+ private
12
+
13
+ def run_lamp_checks
14
+ # check that the standard unified app is responding on port 80
15
+ run_unified_application_checks(@servers, 80)
16
+
17
+ # TODO: check that running the mysql backup script succeeds
18
+ # server.spot_check_command("/etc/cron.daily/mysql-dump-backup.sh")
19
+ #
20
+ # TODO: run operational RightScript(s)
21
+ #
22
+
23
+
24
+
25
+ end
26
+
27
+
28
+ end
29
+ end
@@ -0,0 +1,172 @@
1
+ require 'ruby-debug'
2
+ module VirtualMonkey
3
+ module Mysql
4
+ include VirtualMonkey::DeploymentRunner
5
+ include VirtualMonkey::EBS
6
+ attr_accessor :scripts_to_run
7
+ attr_accessor :db_ebs_prefix
8
+
9
+ # sets the lineage for the deployment
10
+ # * kind<~String> can be "chef" or nil
11
+ def set_variation_lineage(kind = nil)
12
+ @lineage = "testlineage#{@deployment.href.split(/\//).last}"
13
+ if kind == "chef"
14
+ @deployment.set_input('db/backup/lineage', "text:#{@lineage}")
15
+ # unset all server level inputs in the deployment to ensure use of
16
+ # the setting from the deployment level
17
+ @deployment.servers_no_reload.each do |s|
18
+ s.set_input('db/backup/lineage', "text:")
19
+ end
20
+ else
21
+ @deployment.set_input('DB_LINEAGE_NAME', "text:#{@lineage}")
22
+ # unset all server level inputs in the deployment to ensure use of
23
+ # the setting from the deployment level
24
+ @deployment.servers_no_reload.each do |s|
25
+ s.set_input('DB_LINEAGE_NAME', "text:")
26
+ end
27
+ end
28
+ end
29
+
30
+ def set_variation_backup_prefix
31
+ @lineage = "text:testlineage#{rand(1000000)}"
32
+ @deployment.set_input('DB_EBS_PREFIX', @lineage)
33
+ # unset all server level inputs in the deployment to ensure use of
34
+ # the setting from the deployment level
35
+ @deployment.servers_no_reload.each do |s|
36
+ s.set_input('DB_EBS_PREFIX', "text:")
37
+ end
38
+ end
39
+
40
+ def set_variation_bucket
41
+ bucket = "text:testingcandelete#{@deployment.href.split(/\//).last}"
42
+ @deployment.set_input('remote_storage/default/container', bucket)
43
+ # unset all server level inputs in the deployment to ensure use of
44
+ # the setting from the deployment level
45
+ @deployment.servers_no_reload.each do |s|
46
+ s.set_input('remote_storage/default/container', "text:")
47
+ end
48
+ end
49
+
50
+ # creates a MySQL enabled EBS stripe on the server
51
+ # * server<~Server> the server to create stripe on
52
+ def create_stripe(server)
53
+ options = { "EBS_MOUNT_POINT" => "text:/mnt/mysql",
54
+ "EBS_STRIPE_COUNT" => "text:#{@stripe_count}",
55
+ "EBS_VOLUME_SIZE" => "text:1",
56
+ "DBAPPLICATION_USER" => "text:someuser",
57
+ "DB_MYSQLDUMP_BUCKET" => "ignore:$ignore",
58
+ "DB_MYSQLDUMP_FILENAME" => "ignore:$ignore",
59
+ "AWS_ACCESS_KEY_ID" => "ignore:$ignore",
60
+ "AWS_SECRET_ACCESS_KEY" => "ignore:$ignore",
61
+ "DB_SCHEMA_NAME" => "ignore:$ignore",
62
+ "DBAPPLICATION_PASSWORD" => "text:somepass",
63
+ "EBS_TOTAL_VOLUME_GROUP_SIZE" => "text:1",
64
+ "EBS_LINEAGE" => "text:#{@lineage}" }
65
+ audit = server.run_executable(@scripts_to_run['create_mysql_ebs_stripe'], options)
66
+ audit.wait_for_completed
67
+ end
68
+
69
+ # Performs steps necessary to bootstrap a MySQL Master server from a pristine state.
70
+ # * server<~Server> the server to use as MASTER
71
+ def config_master_from_scratch(server)
72
+ behavior(:create_stripe, server)
73
+ object_behavior(server, :spot_check_command, "service mysqld start")
74
+ #TODO the service name depends on the OS
75
+ # server.spot_check_command("service mysql start")
76
+ behavior(:run_query, "create database mynewtest", server)
77
+ behavior(:set_master_dns, server)
78
+ # This sleep is to wait for DNS to settle - must sleep
79
+ sleep 120
80
+ behavior(:run_script, "backup", server)
81
+ end
82
+
83
+ # Runs a mysql query on specified server.
84
+ # * query<~String> a SQL query string to execute
85
+ # * server<~Server> the server to run the query on
86
+ def run_query(query, server)
87
+ query_command = "echo -e \"#{query}\"| mysql"
88
+ server.spot_check_command(query_command)
89
+ end
90
+
91
+ # Sets DNS record for the Master server to point at server
92
+ # * server<~Server> the server to use as MASTER
93
+ def set_master_dns(server)
94
+ audit = server.run_executable(@scripts_to_run['master_init'])
95
+ audit.wait_for_completed
96
+ end
97
+
98
+ # Use the termination script to stop all the servers (this cleans up the volumes)
99
+ def stop_all(wait=true)
100
+ if @scripts_to_run['terminate']
101
+ options = { "DB_TERMINATE_SAFETY" => "text:off" }
102
+ @servers.each { |s| s.run_executable(@scripts_to_run['terminate'], options) unless s.state == 'stopped' }
103
+ else
104
+ @servers.each { |s| s.stop }
105
+ end
106
+
107
+ wait_for_all("stopped") if wait
108
+ # unset dns in our local cached copy..
109
+ @servers.each { |s| s.params['dns-name'] = nil }
110
+ end
111
+
112
+ # uses SharedDns to find an available set of DNS records and sets them on the deployment
113
+ def setup_dns(domain)
114
+ # TODO should we just use the ID instead of the full href?
115
+ owner=@deployment.href
116
+ @dns = SharedDns.new(domain)
117
+ raise "Unable to reserve DNS" unless @dns.reserve_dns(owner)
118
+ @dns.set_dns_inputs(@deployment)
119
+ end
120
+
121
+ # releases records back into the shared DNS pool
122
+ def release_dns
123
+ @dns.release_dns
124
+ end
125
+
126
+ def promote_server(server)
127
+ run_script("promote", server)
128
+ end
129
+
130
+ def slave_init_server(server)
131
+ run_script("slave_init", server)
132
+ end
133
+
134
+ def restore_server(server)
135
+ run_script("restore", server)
136
+ end
137
+
138
+ def create_migration_script
139
+ options = { "DB_EBS_PREFIX" => "text:regmysql",
140
+ "DB_EBS_SIZE_MULTIPLIER" => "text:1",
141
+ "EBS_STRIPE_COUNT" => "text:#{@stripe_count}" }
142
+ s_one.run_executable(@scripts_to_run['create_migrate_script'], options)
143
+ end
144
+
145
+ # These are mysql specific checks (used by mysql_runner and lamp_runner)
146
+ def run_checks
147
+ # check that mysql tmpdir is custom setup on all servers
148
+ query = "show variables like 'tmpdir'"
149
+ query_command = "echo -e \"#{query}\"| mysql"
150
+ @servers.each do |server|
151
+ server.spot_check(query_command) { |result| raise "Failure: tmpdir was unset#{result}" unless result.include?("/mnt/mysqltmp") }
152
+ end
153
+ end
154
+
155
+ # check that mysql can handle 5000 concurrent connections (file limits, etc.)
156
+ def run_mysqlslap_check
157
+ @servers.each do |server|
158
+ result = server.spot_check_command("mysqlslap --concurrency=5000 --iterations=10 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --csv=/tmp/mysqlslap_q1000_innodb.csv --engine=innodb --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --number-of-queries=1000 --user=root")
159
+ raise "FATAL: mysqlslap check failed" unless result[:output].empty?
160
+ end
161
+ end
162
+
163
+ # check that ulimit has been set correctly
164
+ # XXX: DEPRECATED
165
+ def ulimit_check
166
+ @servers.each do |server|
167
+ result = server.spot_check_command("su - mysql -s /bin/bash -c \"ulimit -n\"")
168
+ raise "FATAL: ulimit wasn't set correctly" unless result[:output].to_i >= 1024
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,108 @@
1
+ module VirtualMonkey
2
+ class MysqlRunner
3
+ include VirtualMonkey::DeploymentRunner
4
+ include VirtualMonkey::EBS
5
+ include VirtualMonkey::Mysql
6
+ attr_accessor :scripts_to_run
7
+ attr_accessor :db_ebs_prefix
8
+
9
+ # It's not that I'm a Java fundamentalist; I merely believe that mortals should
10
+ # not be calling the following methods directly. Instead, they should use the
11
+ # TestCaseInterface methods (behavior, verify, probe) to access these functions.
12
+ # Trust me, I know what's good for you. -- Tim R.
13
+ private
14
+
15
+ def run_promotion_operations
16
+ behavior(:config_master_from_scratch, s_one)
17
+ object_behavior(s_one, :relaunch)
18
+ s_one.dns_name = nil
19
+ behavior(:wait_for_snapshots)
20
+ # need to wait for ebs snapshot, otherwise this could easily fail
21
+ behavior(:restore_server, s_two)
22
+ object_behavior(s_one, :wait_for_operational_with_dns)
23
+ behavior(:wait_for_snapshots)
24
+ behavior(:slave_init_server, s_one)
25
+ behavior(:promote_server, s_one)
26
+ end
27
+
28
+ def run_reboot_operations
29
+ # Duplicate code here because we need to wait between the master and the slave time
30
+ #reboot_all(true) # serially_reboot = true
31
+ @servers.each do |s|
32
+ object_behavior(s, :reboot, true)
33
+ object_behavior(s, :wait_for_state, "operational")
34
+ end
35
+ behavior(:wait_for_all, "operational")
36
+ behavior(:run_reboot_checks)
37
+ end
38
+
39
+ # This is where we perform multiple checks on the deployment after a reboot.
40
+ def run_reboot_checks
41
+ # one simple check we can do is the backup. Backup can fail if anything is amiss
42
+ @servers.each do |server|
43
+ behavior(:run_script, "backup", server)
44
+ end
45
+ end
46
+
47
+
48
+ # lookup all the RightScripts that we will want to run
49
+ def lookup_scripts
50
+ #TODO fix this so epoch is not hard coded.
51
+ puts "WE ARE HARDCODING THE TOOL BOX NAMES TO USE 11H1.b1"
52
+ scripts = [
53
+ [ 'restore', 'restore and become' ],
54
+ [ 'slave_init', 'slave init' ],
55
+ [ 'promote', 'EBS promote to master' ],
56
+ [ 'backup', 'EBS backup' ],
57
+ [ 'terminate', 'TERMINATE SERVER' ]
58
+ ]
59
+ ebs_toolbox_scripts = [
60
+ [ 'create_stripe' , 'EBS stripe volume create - 11H1.b1' ]
61
+ ]
62
+ mysql_toolbox_scripts = [
63
+ [ 'create_mysql_ebs_stripe' , 'DB Create MySQL EBS stripe volume - 11H1.b1' ],
64
+ [ 'create_migrate_script' , 'DB EBS create migrate script from MySQL EBS v1' ]
65
+ ]
66
+ st = ServerTemplate.find(s_two.server_template_href)
67
+ lookup_scripts_table(st,scripts)
68
+ @scripts_to_run['master_init'] = RightScript.new('href' => "/api/acct/2901/right_scripts/195053")
69
+ #This does not work - does not create the same type as call above does.
70
+ #@scripts_to_run['master_init'] = RightScript.find_by("name") { |n| n =~ /DB register master \-ONLY FOR TESTING/ }
71
+ raise "Did not find script" unless @scripts_to_run['master_init']
72
+
73
+ tbx = ServerTemplate.find_by(:nickname) { |n| n =~ /EBS Stripe Toolbox - 11H1.b1/ }
74
+ raise "Did not find toolbox template" unless tbx[0]
75
+ # Use the HEAD revision.
76
+ lookup_scripts_table(tbx[0],ebs_toolbox_scripts)
77
+ # @scripts_to_run['create_stripe'] = RightScript.new('href' => "/api/acct/2901/right_scripts/198381")
78
+ #TODO - does not account for 5.0/5.1 toolbox differences
79
+ puts "USING MySQL 5.0 toolbox"
80
+ tbx = ServerTemplate.find_by(:nickname) { |n| n =~ /Database Manager with MySQL 5.0 Toolbox - 11H1.b1/ }
81
+ raise "Did not find toolbox template" unless tbx[0]
82
+ lookup_scripts_table(tbx[0],mysql_toolbox_scripts)
83
+ # @scripts_to_run['create_mysql_ebs_stripe'] = RightScript.new('href' => "/api/acct/2901/right_scripts/212492")
84
+ # @scripts_to_run['create_migrate_script'] = tbx[0].executables.detect { |ex| ex.name =~ /DB EBS create migrate script from MySQL EBS v1 master/ }
85
+ raise "FATAL: Need 2 MySQL servers in the deployment" unless @servers.size == 2
86
+ end
87
+
88
+ def migrate_slave
89
+ s_one.settings
90
+ object_behavior(s_one, :spot_check_command, "/tmp/init_slave.sh")
91
+ behavior(:run_script, "backup", s_one)
92
+ end
93
+
94
+ def launch_v2_slave
95
+ s_two.settings
96
+ behavior(:wait_for_snapshots)
97
+ behavior(:run_script, "slave_init", s_two)
98
+ end
99
+
100
+ def run_restore_with_timestamp_override
101
+ object_behavior(s_one, :relaunch)
102
+ s_one.dns_name = nil
103
+ s_one.wait_for_operational_with_dns
104
+ audit = object_behavior(s_one, :run_executable, @scripts_to_run['restore'], { "OPT_DB_RESTORE_TIMESTAMP_OVERRIDE" => "text:#{find_snapshot_timestamp}" } )
105
+ audit.wait_for_completed
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,51 @@
1
+ module VirtualMonkey
2
+ class MysqlToolboxRunner
3
+ include VirtualMonkey::DeploymentRunner
4
+ include VirtualMonkey::EBS
5
+ include VirtualMonkey::Mysql
6
+ attr_accessor :scripts_to_run
7
+
8
+ # It's not that I'm a Java fundamentalist; I merely believe that mortals should
9
+ # not be calling the following methods directly. Instead, they should use the
10
+ # TestCaseInterface methods (behavior, verify, probe) to access these functions.
11
+ # Trust me, I know what's good for you. -- Tim R.
12
+ private
13
+
14
+ def lookup_scripts
15
+ scripts_mysql = [
16
+ [ 'promote', 'EBS promote to master' ],
17
+ [ 'backup', 'EBS backup' ],
18
+ [ 'terminate', 'TERMINATE SERVER' ]
19
+ ]
20
+ scripts_my_toolbox = [
21
+ [ 'create_backup_scripts', 'EBS create backup scripts' ],
22
+ [ 'enable_network', 'DB MySQL Enable Networking' ],
23
+ [ 'create_migrate_script', 'DB EBS create migrate script from MySQL EBS v1' ],
24
+ [ 'create_mysql_ebs_stripe', 'DB Create MySQL EBS stripe' ],
25
+ [ 'grow_volume', 'DB EBS slave init and grow stripe volume' ],
26
+ [ 'restore', 'DB EBS restore stripe volume' ]
27
+ ]
28
+ st = ServerTemplate.find(s_one.server_template_href)
29
+ lookup_scripts_table(st,scripts_mysql)
30
+ # hardwired script! (this is an 'anyscript' that users typically use to setup the master dns)
31
+ # This a special version of the register that uses MASTER_DB_DNSID instead of a test DNSID
32
+ # This is identical to "DB register master" However it is not part of the template.
33
+ # @scripts_to_run['master_init'] = RightScript.find_by("name") { |n| n =~ /DB register master \-ONLY FOR TESTING/ }
34
+ @scripts_to_run['master_init'] = RightScript.new('href' => "/api/acct/2901/right_scripts/195053")
35
+ raise "Did not find script" unless @scripts_to_run['master_init']
36
+
37
+ # @scripts_to_run['master_init'] = RightScript.new('href' => "/api/acct/2901/right_scripts/195053")
38
+ #TODO - this is hardcoded for 5.0 toolbox - need to deal with issue that we have two
39
+ #toolboxes and their names are going to change
40
+ tbx = ServerTemplate.find_by(:nickname) { |n| n =~ /Database Manager with MySQL 5.0 Toolbox - 11H1.b1/ }
41
+ raise "FATAL: could not find toolbox" unless tbx
42
+ # Use the HEAD revision.
43
+ st = tbx[0]
44
+ lookup_scripts_table(st,scripts_my_toolbox)
45
+ end
46
+
47
+ def create_master
48
+ config_master_from_scratch(s_one)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,46 @@
1
+ require "rubygems"
2
+ require "right_aws"
3
+
4
+ module VirtualMonkey
5
+ class PatchRunner
6
+ include VirtualMonkey::DeploymentRunner
7
+
8
+
9
+ # It's not that I'm a Java fundamentalist; I merely believe that mortals should
10
+ # not be calling the following methods directly. Instead, they should use the
11
+ # TestCaseInterface methods (behavior, verify, probe) to access these functions.
12
+ # Trust me, I know what's good for you. -- Tim R.
13
+ private
14
+
15
+ def initialize(args)
16
+ super(args)
17
+ end
18
+
19
+ # Grab the scripts we plan to excersize
20
+ def lookup_scripts
21
+ scripts = [
22
+ [ 'test_patch', 'TEST' ]
23
+ ]
24
+ server = @servers.first
25
+ server.settings
26
+ st = ServerTemplate.find(server.server_template_href)
27
+ lookup_scripts_table(st,scripts)
28
+ end
29
+
30
+ def set_user_data(value)
31
+ @servers.each do |server|
32
+ server.settings
33
+ server.ec2_user_data = value
34
+ server.save
35
+ end
36
+ end
37
+
38
+ # run the patch test script
39
+ def run_patch_test
40
+ @servers.each do |server|
41
+ run_script('test_patch', server)
42
+ end
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,6 @@
1
+ module VirtualMonkey
2
+ class PhpAioTrialChefRunner
3
+ include VirtualMonkey::DeploymentRunner
4
+ include VirtualMonkey::ApplicationFrontend
5
+ end
6
+ end
@@ -0,0 +1,69 @@
1
+ module VirtualMonkey
2
+ class PhpChefRunner
3
+ include VirtualMonkey::DeploymentRunner
4
+ include VirtualMonkey::ApplicationFrontend
5
+
6
+ # It's not that I'm a Java fundamentalist; I merely believe that mortals should
7
+ # not be calling the following methods directly. Instead, they should use the
8
+ # TestCaseInterface methods (behavior, verify, probe) to access these functions.
9
+ # Trust me, I know what's good for you. -- Tim R.
10
+ private
11
+
12
+ def set_lb_hostname
13
+ @deployment.set_input("lb_haproxy/host", get_lb_hostname_input)
14
+ end
15
+
16
+ # sets the MASTER_DB_DNSNAME to this machine's ip address
17
+ def set_master_db_dnsname
18
+ the_name = get_tester_ip_addr
19
+ @deployment.set_input("php/db_dns_name", the_name)
20
+ end
21
+
22
+ def frontend_checks
23
+ behavior(:detect_os)
24
+
25
+ behavior(:run_unified_application_checks, fe_servers, 80)
26
+
27
+ # check that all application servers exist in the haproxy config file on all fe_servers
28
+ server_ips = Array.new
29
+ app_servers.each { |app| server_ips << app['private-ip-address'] }
30
+ fe_servers.each do |fe|
31
+ fe.settings
32
+ haproxy_config = object_behavior(fe, :spot_check_command, 'cat /home/haproxy/rightscale_lb.cfg | grep server')
33
+ server_ips.each { |ip| haproxy_config.to_s.include?(ip).should == true }
34
+ end
35
+
36
+ # restart haproxy and check that it succeeds
37
+ fe_servers.each_with_index do |server,i|
38
+ response = object_behavior(server, :spot_check_command?, 'service haproxy stop')
39
+ raise "Haproxy stop command failed" unless response
40
+
41
+ stopped = false
42
+ count = 0
43
+ until response || count > 3 do
44
+ response = object_behavior(server, :spot_check_command, server.haproxy_check)
45
+ stopped = response.include?("not running")
46
+ break if stopped
47
+ count += 1
48
+ sleep 10
49
+ end
50
+
51
+ response = object_behavior(server, :spot_check_command?, 'service haproxy start')
52
+ raise "Haproxy start failed" unless response
53
+ end
54
+ end
55
+
56
+ def lookup_scripts
57
+ @scripts_to_run = {}
58
+ st = ServerTemplate.find(fe_servers.first.server_template_href)
59
+ @scripts_to_run["attach"] = st.executables.detect { |d| d.recipe == "lb_haproxy::do_attach_request" }
60
+ end
61
+
62
+ def cross_connect_frontends
63
+ statuses = Array.new
64
+ @servers.each { |s| statuses << s.run_executable(@scripts_to_run['attach']) }
65
+ statuses.each_with_index { |s,i| s.wait_for_completed }
66
+ end
67
+
68
+ end
69
+ end