engineyard-serverside 2.8.0.pre4 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +13 -5
  2. data/features/hook/running-a-deploy-hook.feature +277 -0
  3. data/features/hook/step_definitions/running-a-deploy-hook-steps.rb +200 -0
  4. data/features/step_definitions/command_steps.rb +8 -0
  5. data/features/step_definitions/version_steps.rb +5 -0
  6. data/features/support/env.rb +63 -0
  7. data/features/support/error_codes.rb +17 -0
  8. data/features/support/fs_helpers.rb +82 -0
  9. data/features/support/output_helpers.rb +7 -0
  10. data/features/support/runner.rb +41 -0
  11. data/features/version.feature +7 -0
  12. data/lib/engineyard-serverside/cli/app.rb +6 -0
  13. data/lib/engineyard-serverside/configuration.rb +3 -3
  14. data/lib/engineyard-serverside/deploy.rb +2 -1
  15. data/lib/engineyard-serverside/propagator.rb +1 -1
  16. data/lib/engineyard-serverside/shell.rb +38 -10
  17. data/lib/engineyard-serverside/version.rb +1 -1
  18. data/lib/engineyard-serverside.rb +2 -5
  19. data/spec/engineyard-serverside/callbacks/collection/combined_spec.rb +232 -0
  20. data/spec/engineyard-serverside/callbacks/collection/deploy_hooks_spec.rb +170 -0
  21. data/spec/engineyard-serverside/callbacks/collection/service_hooks/collection_spec.rb +171 -0
  22. data/spec/engineyard-serverside/callbacks/collection/service_hooks/combined_spec.rb +174 -0
  23. data/spec/engineyard-serverside/callbacks/collection/service_hooks_spec.rb +31 -0
  24. data/spec/engineyard-serverside/callbacks/collection_spec.rb +49 -0
  25. data/spec/engineyard-serverside/callbacks/distributor/remote_spec.rb +135 -0
  26. data/spec/engineyard-serverside/callbacks/distributor/viability_filter_spec.rb +208 -0
  27. data/spec/engineyard-serverside/callbacks/distributor_spec.rb +43 -0
  28. data/spec/engineyard-serverside/callbacks/executor/executable_spec.rb +386 -0
  29. data/spec/engineyard-serverside/callbacks/executor/ruby/context_spec.rb +538 -0
  30. data/spec/engineyard-serverside/callbacks/executor/ruby/executor_spec.rb +313 -0
  31. data/spec/engineyard-serverside/callbacks/executor/ruby_spec.rb +35 -0
  32. data/spec/engineyard-serverside/callbacks/executor_spec.rb +45 -0
  33. data/spec/engineyard-serverside/callbacks_spec.rb +31 -0
  34. data/spec/engineyard-serverside/cli/workflows/base_spec.rb +237 -0
  35. data/spec/engineyard-serverside/cli/workflows/calling_deploy_hooks_spec.rb +65 -0
  36. data/spec/engineyard-serverside/cli/workflows/deploying_applications_spec.rb +61 -0
  37. data/spec/engineyard-serverside/cli/workflows/disabling_maintenance_spec.rb +61 -0
  38. data/spec/engineyard-serverside/cli/workflows/enabling_maintenance_spec.rb +61 -0
  39. data/spec/engineyard-serverside/cli/workflows/helpers_spec.rb +64 -0
  40. data/spec/engineyard-serverside/cli/workflows/rolling_back_applications_spec.rb +61 -0
  41. data/spec/engineyard-serverside/cli/workflows/showing_maintenance_status_spec.rb +60 -0
  42. data/spec/engineyard-serverside/cli/workflows_spec.rb +87 -0
  43. data/spec/engineyard-serverside/dependency_manager/base_spec.rb +139 -0
  44. data/spec/engineyard-serverside/paths_spec.rb +820 -0
  45. data/spec/engineyard-serverside/propagator_spec.rb +56 -0
  46. data/spec/engineyard-serverside/server_spec.rb +390 -0
  47. data/spec/engineyard-serverside/shell/helpers_spec.rb +98 -0
  48. data/spec/engineyard-serverside/shell/yieldio_spec.rb +33 -0
  49. data/spec/engineyard-serverside/shell_spec.rb +543 -0
  50. data/spec/engineyard-serverside/slug/distributor_spec.rb +199 -0
  51. data/spec/engineyard-serverside/slug/enabler_spec.rb +191 -0
  52. data/spec/engineyard-serverside/slug/failure_handler_spec.rb +114 -0
  53. data/spec/engineyard-serverside/slug/finalizer_spec.rb +191 -0
  54. data/spec/engineyard-serverside/slug/generator_spec.rb +82 -0
  55. data/spec/engineyard-serverside/slug/migrator_spec.rb +137 -0
  56. data/spec/engineyard-serverside/slug/restarter_spec.rb +226 -0
  57. data/spec/engineyard-serverside/slug/source/updater_spec.rb +710 -0
  58. data/spec/engineyard-serverside/slug/source_spec.rb +40 -0
  59. data/spec/engineyard-serverside/source_spec.rb +171 -0
  60. data/spec/railway_spec.rb +130 -0
  61. data/spec/result/failure_spec.rb +113 -0
  62. data/spec/result/success_spec.rb +109 -0
  63. data/spec/result_spec.rb +23 -0
  64. data/spec/spec_helper.rb +3 -349
  65. metadata +189 -490
  66. data/lib/vendor/json_pure/COPYING +0 -57
  67. data/lib/vendor/json_pure/GPL +0 -340
  68. data/lib/vendor/json_pure/README.rdoc +0 -358
  69. data/lib/vendor/json_pure/VERSION +0 -1
  70. data/lib/vendor/json_pure/lib/json/add/bigdecimal.rb +0 -28
  71. data/lib/vendor/json_pure/lib/json/add/complex.rb +0 -22
  72. data/lib/vendor/json_pure/lib/json/add/core.rb +0 -11
  73. data/lib/vendor/json_pure/lib/json/add/date.rb +0 -34
  74. data/lib/vendor/json_pure/lib/json/add/date_time.rb +0 -48
  75. data/lib/vendor/json_pure/lib/json/add/exception.rb +0 -31
  76. data/lib/vendor/json_pure/lib/json/add/ostruct.rb +0 -31
  77. data/lib/vendor/json_pure/lib/json/add/range.rb +0 -29
  78. data/lib/vendor/json_pure/lib/json/add/rational.rb +0 -22
  79. data/lib/vendor/json_pure/lib/json/add/regexp.rb +0 -30
  80. data/lib/vendor/json_pure/lib/json/add/struct.rb +0 -30
  81. data/lib/vendor/json_pure/lib/json/add/symbol.rb +0 -25
  82. data/lib/vendor/json_pure/lib/json/add/time.rb +0 -38
  83. data/lib/vendor/json_pure/lib/json/common.rb +0 -484
  84. data/lib/vendor/json_pure/lib/json/ext.rb +0 -21
  85. data/lib/vendor/json_pure/lib/json/generic_object.rb +0 -70
  86. data/lib/vendor/json_pure/lib/json/pure/generator.rb +0 -522
  87. data/lib/vendor/json_pure/lib/json/pure/parser.rb +0 -359
  88. data/lib/vendor/json_pure/lib/json/pure.rb +0 -21
  89. data/lib/vendor/json_pure/lib/json/version.rb +0 -8
  90. data/lib/vendor/json_pure/lib/json.rb +0 -62
  91. data/lib/vendor/multi_json/CHANGELOG.md +0 -121
  92. data/lib/vendor/multi_json/CONTRIBUTING.md +0 -46
  93. data/lib/vendor/multi_json/Gemfile +0 -31
  94. data/lib/vendor/multi_json/LICENSE.md +0 -20
  95. data/lib/vendor/multi_json/README.md +0 -105
  96. data/lib/vendor/multi_json/Rakefile +0 -12
  97. data/lib/vendor/multi_json/lib/multi_json/adapters/gson.rb +0 -20
  98. data/lib/vendor/multi_json/lib/multi_json/adapters/json_common.rb +0 -35
  99. data/lib/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +0 -12
  100. data/lib/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +0 -12
  101. data/lib/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +0 -35
  102. data/lib/vendor/multi_json/lib/multi_json/adapters/oj.rb +0 -29
  103. data/lib/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +0 -58
  104. data/lib/vendor/multi_json/lib/multi_json/adapters/yajl.rb +0 -20
  105. data/lib/vendor/multi_json/lib/multi_json/vendor/okjson.rb +0 -602
  106. data/lib/vendor/multi_json/lib/multi_json/version.rb +0 -3
  107. data/lib/vendor/multi_json/lib/multi_json.rb +0 -137
  108. data/lib/vendor/multi_json/spec/adapter_shared_example.rb +0 -162
  109. data/lib/vendor/multi_json/spec/helper.rb +0 -45
  110. data/lib/vendor/multi_json/spec/json_common_shared_example.rb +0 -36
  111. data/lib/vendor/multi_json/spec/multi_json_spec.rb +0 -151
  112. data/spec/archive_deploy_spec.rb +0 -53
  113. data/spec/basic_deploy_spec.rb +0 -26
  114. data/spec/bundler_deploy_spec.rb +0 -160
  115. data/spec/configuration_spec.rb +0 -206
  116. data/spec/custom_deploy_spec.rb +0 -128
  117. data/spec/deploy_hook_spec.rb +0 -378
  118. data/spec/deprecation_spec.rb +0 -23
  119. data/spec/ey_yml_customized_deploy_spec.rb +0 -99
  120. data/spec/fixtures/gitrepo.tar.gz +0 -0
  121. data/spec/fixtures/invalid_hook.rb +0 -1
  122. data/spec/fixtures/lockfiles/0.9-no-bundler +0 -111
  123. data/spec/fixtures/lockfiles/0.9-with-bundler +0 -117
  124. data/spec/fixtures/lockfiles/1.0-no-bundler +0 -54
  125. data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +0 -162
  126. data/spec/fixtures/lockfiles/1.0.18-do_mysql +0 -88
  127. data/spec/fixtures/lockfiles/1.0.18-do_postgres +0 -79
  128. data/spec/fixtures/lockfiles/1.0.18-mysql +0 -43
  129. data/spec/fixtures/lockfiles/1.0.18-mysql2 +0 -43
  130. data/spec/fixtures/lockfiles/1.0.18-pg +0 -43
  131. data/spec/fixtures/lockfiles/1.0.6-no-bundler +0 -51
  132. data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +0 -52
  133. data/spec/fixtures/lockfiles/1.0.6-with-bundler +0 -52
  134. data/spec/fixtures/lockfiles/1.15.1-no-bundler +0 -51
  135. data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +0 -112
  136. data/spec/fixtures/lockfiles/not-a-lockfile +0 -1
  137. data/spec/fixtures/repos/assets_detected/Gemfile +0 -5
  138. data/spec/fixtures/repos/assets_detected/Gemfile.lock +0 -88
  139. data/spec/fixtures/repos/assets_detected/README +0 -1
  140. data/spec/fixtures/repos/assets_detected/Rakefile +0 -5
  141. data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
  142. data/spec/fixtures/repos/assets_detected/config/application.rb +0 -5
  143. data/spec/fixtures/repos/assets_detected/config/ey.yml +0 -3
  144. data/spec/fixtures/repos/assets_disabled/Gemfile +0 -5
  145. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +0 -88
  146. data/spec/fixtures/repos/assets_disabled/README +0 -1
  147. data/spec/fixtures/repos/assets_disabled/Rakefile +0 -6
  148. data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
  149. data/spec/fixtures/repos/assets_disabled/config/application.rb +0 -5
  150. data/spec/fixtures/repos/assets_disabled/config/ey.yml +0 -3
  151. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +0 -5
  152. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +0 -88
  153. data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +0 -1
  154. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +0 -6
  155. data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
  156. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +0 -5
  157. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +0 -5
  158. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +0 -5
  159. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +0 -88
  160. data/spec/fixtures/repos/assets_disabled_utf8/README +0 -3
  161. data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +0 -5
  162. data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
  163. data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +0 -7
  164. data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +0 -3
  165. data/spec/fixtures/repos/assets_enabled_all/Gemfile +0 -5
  166. data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +0 -88
  167. data/spec/fixtures/repos/assets_enabled_all/README +0 -1
  168. data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
  169. data/spec/fixtures/repos/assets_enabled_all/config/application.rb +0 -5
  170. data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +0 -6
  171. data/spec/fixtures/repos/assets_enabled_all/script/assets +0 -5
  172. data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +0 -1
  173. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +0 -3
  174. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +0 -10
  175. data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +0 -1
  176. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +0 -8
  177. data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +0 -4
  178. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +0 -5
  179. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +0 -88
  180. data/spec/fixtures/repos/assets_enabled_util_only/README +0 -1
  181. data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +0 -6
  182. data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
  183. data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +0 -5
  184. data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +0 -6
  185. data/spec/fixtures/repos/assets_error/Gemfile +0 -5
  186. data/spec/fixtures/repos/assets_error/Gemfile.lock +0 -88
  187. data/spec/fixtures/repos/assets_error/README +0 -1
  188. data/spec/fixtures/repos/assets_error/Rakefile +0 -4
  189. data/spec/fixtures/repos/assets_error/app/assets/empty +0 -0
  190. data/spec/fixtures/repos/assets_error/config/application.rb +0 -5
  191. data/spec/fixtures/repos/assets_error/config/ey.yml +0 -4
  192. data/spec/fixtures/repos/assets_in_hook/Gemfile +0 -5
  193. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +0 -88
  194. data/spec/fixtures/repos/assets_in_hook/README +0 -2
  195. data/spec/fixtures/repos/assets_in_hook/Rakefile +0 -5
  196. data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
  197. data/spec/fixtures/repos/assets_in_hook/config/application.rb +0 -5
  198. data/spec/fixtures/repos/assets_in_hook/config/ey.yml +0 -3
  199. data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +0 -2
  200. data/spec/fixtures/repos/bundle_fails/Gemfile +0 -1
  201. data/spec/fixtures/repos/bundle_fails/README +0 -1
  202. data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +0 -1
  203. data/spec/fixtures/repos/bundler_disabled/Gemfile +0 -4
  204. data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +0 -12
  205. data/spec/fixtures/repos/bundler_disabled/README +0 -1
  206. data/spec/fixtures/repos/bundler_disabled/config/ey.yml +0 -2
  207. data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +0 -1
  208. data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +0 -1
  209. data/spec/fixtures/repos/bundler_old/Gemfile +0 -5
  210. data/spec/fixtures/repos/bundler_old/Gemfile.lock +0 -15
  211. data/spec/fixtures/repos/bundler_old/README +0 -1
  212. data/spec/fixtures/repos/default/Gemfile +0 -4
  213. data/spec/fixtures/repos/default/Gemfile.lock +0 -12
  214. data/spec/fixtures/repos/default/README +0 -5
  215. data/spec/fixtures/repos/default/ey.yml +0 -3
  216. data/spec/fixtures/repos/executable_hooks/README +0 -1
  217. data/spec/fixtures/repos/executable_hooks/deploy/before_restart +0 -72
  218. data/spec/fixtures/repos/executable_hooks_not_executable/README +0 -3
  219. data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +0 -3
  220. data/spec/fixtures/repos/ey_yml/Gemfile +0 -4
  221. data/spec/fixtures/repos/ey_yml/Gemfile.lock +0 -12
  222. data/spec/fixtures/repos/ey_yml/README +0 -1
  223. data/spec/fixtures/repos/ey_yml/config/ey.yml +0 -18
  224. data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +0 -6
  225. data/spec/fixtures/repos/ey_yml_alt/Gemfile +0 -4
  226. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +0 -12
  227. data/spec/fixtures/repos/ey_yml_alt/README +0 -1
  228. data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +0 -6
  229. data/spec/fixtures/repos/ey_yml_alt/ey.yml +0 -12
  230. data/spec/fixtures/repos/hook_fails/README +0 -1
  231. data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +0 -1
  232. data/spec/fixtures/repos/hooks/README +0 -1
  233. data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +0 -1
  234. data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +0 -1
  235. data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +0 -1
  236. data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +0 -1
  237. data/spec/fixtures/repos/hooks/deploy/after_restart.rb +0 -1
  238. data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +0 -1
  239. data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +0 -1
  240. data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +0 -1
  241. data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +0 -1
  242. data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +0 -1
  243. data/spec/fixtures/repos/hooks/deploy/before_restart.rb +0 -1
  244. data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +0 -1
  245. data/spec/fixtures/repos/multi_dep_manager/README +0 -1
  246. data/spec/fixtures/repos/multi_dep_manager/composer.json +0 -5
  247. data/spec/fixtures/repos/multi_dep_manager/composer.lock +0 -462
  248. data/spec/fixtures/repos/multi_dep_manager/package.json +0 -7
  249. data/spec/fixtures/repos/multi_dep_manager/public/index.php +0 -4
  250. data/spec/fixtures/repos/no_ey_config/Gemfile +0 -3
  251. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +0 -10
  252. data/spec/fixtures/repos/no_ey_config/README +0 -1
  253. data/spec/fixtures/repos/no_ey_config/ey.yml +0 -3
  254. data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile +0 -3
  255. data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile.lock +0 -10
  256. data/spec/fixtures/repos/no_ey_config_no_warning/README +0 -1
  257. data/spec/fixtures/repos/no_ey_config_no_warning/ey.yml +0 -5
  258. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +0 -4
  259. data/spec/fixtures/repos/no_gemfile_lock/README +0 -1
  260. data/spec/fixtures/repos/no_gemfile_lock/ey.yml +0 -3
  261. data/spec/fixtures/repos/nodejs/README +0 -1
  262. data/spec/fixtures/repos/nodejs/package.json +0 -7
  263. data/spec/fixtures/repos/not_bundled/README +0 -1
  264. data/spec/fixtures/repos/npm_disabled/README +0 -1
  265. data/spec/fixtures/repos/npm_disabled/config/ey.yml +0 -2
  266. data/spec/fixtures/repos/npm_disabled/package.json +0 -7
  267. data/spec/fixtures/repos/php_composer_disabled/README +0 -1
  268. data/spec/fixtures/repos/php_composer_disabled/composer.json +0 -5
  269. data/spec/fixtures/repos/php_composer_disabled/composer.lock +0 -462
  270. data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +0 -2
  271. data/spec/fixtures/repos/php_composer_disabled/public/index.php +0 -4
  272. data/spec/fixtures/repos/php_composer_lock/README +0 -1
  273. data/spec/fixtures/repos/php_composer_lock/composer.json +0 -5
  274. data/spec/fixtures/repos/php_composer_lock/composer.lock +0 -462
  275. data/spec/fixtures/repos/php_composer_lock/public/index.php +0 -4
  276. data/spec/fixtures/repos/php_no_composer_lock/README +0 -1
  277. data/spec/fixtures/repos/php_no_composer_lock/composer.json +0 -21
  278. data/spec/fixtures/repos/php_no_composer_lock/public/index.php +0 -4
  279. data/spec/fixtures/repos/public_system/Gemfile +0 -4
  280. data/spec/fixtures/repos/public_system/Gemfile.lock +0 -12
  281. data/spec/fixtures/repos/public_system/README +0 -5
  282. data/spec/fixtures/repos/public_system/ey.yml +0 -3
  283. data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +0 -3
  284. data/spec/fixtures/repos/sqlite3/Gemfile +0 -4
  285. data/spec/fixtures/repos/sqlite3/Gemfile.lock +0 -89
  286. data/spec/fixtures/repos/sqlite3/README +0 -1
  287. data/spec/fixtures/retwisj.war +0 -0
  288. data/spec/fixtures/valid_hook.rb +0 -1
  289. data/spec/git_strategy_spec.rb +0 -34
  290. data/spec/lockfile_parser_spec.rb +0 -126
  291. data/spec/maintenance_spec.rb +0 -44
  292. data/spec/multi_dependency_manager_spec.rb +0 -25
  293. data/spec/nodejs_deploy_spec.rb +0 -30
  294. data/spec/php_deploy_spec.rb +0 -81
  295. data/spec/platform_configure_spec.rb +0 -61
  296. data/spec/rails31_deploy_spec.rb +0 -172
  297. data/spec/restart_spec.rb +0 -43
  298. data/spec/rollback_spec.rb +0 -87
  299. data/spec/server_spec.rb +0 -70
  300. data/spec/services_deploy_spec.rb +0 -165
  301. data/spec/shell_spec.rb +0 -57
  302. data/spec/source/archive_spec.rb +0 -33
  303. data/spec/source/git_spec.rb +0 -44
  304. data/spec/sqlite3_deploy_spec.rb +0 -38
  305. data/spec/support/integration.rb +0 -103
  306. data/spec/support/source_doubles.rb +0 -28
  307. data/spec/support/timecop.rb +0 -5
  308. data/spec/symlink_spec.rb +0 -15
@@ -0,0 +1,208 @@
1
+ require 'spec_helper'
2
+
3
+ require 'pathname'
4
+
5
+ require 'railway'
6
+ require 'engineyard-serverside/callbacks/distributor/viability_filter'
7
+
8
+ module EY
9
+ module Serverside
10
+ module Callbacks
11
+ module Distributor
12
+
13
+ describe ViabilityFilter do
14
+ let(:shell) {Object.new}
15
+ let(:ruby_hook) {Object.new}
16
+ let(:executable_hook) {Object.new}
17
+ let(:executable_path) {Object.new}
18
+ let(:hooks) {[ruby_hook, executable_hook]}
19
+ let(:callback_name) {:some_callback}
20
+
21
+ let(:filter) {described_class.new}
22
+
23
+ before(:each) do
24
+ allow(ruby_hook).to receive(:flavor).and_return(:ruby)
25
+ allow(executable_hook).to receive(:flavor).and_return(:executable)
26
+ hooks.each do |hook|
27
+ allow(hook).to receive(:callback_name).and_return(callback_name)
28
+ end
29
+
30
+ allow(executable_hook).to receive(:path).and_return(executable_path)
31
+ allow(executable_path).to receive(:executable?).and_return(false)
32
+
33
+ allow(shell).to receive(:warning)
34
+ end
35
+
36
+ it 'is a Railway' do
37
+ expect(filter).to be_a(Railway)
38
+ end
39
+
40
+ it 'has the exact steps for filtering hooks' do
41
+ steps = described_class.steps.map {|s| s[:name]}
42
+
43
+ expect(steps).to eql(
44
+ [
45
+ :normalize_input,
46
+ :check_ruby_candidates,
47
+ :check_executable_candidates,
48
+ :calculate_callback_name
49
+ ]
50
+ )
51
+ end
52
+
53
+ describe '#normalize_input' do
54
+ let(:candidates) {hooks}
55
+
56
+ let(:input) {
57
+ {
58
+ :candidates => candidates,
59
+ :shell => shell
60
+ }
61
+ }
62
+
63
+ let(:result) {filter.normalize_input(input)}
64
+
65
+ it 'is always a success' do
66
+ expect(filter.normalize_input).to be_a(Result::Success)
67
+ end
68
+
69
+ it 'adds a viable array to the input hash' do
70
+ expect(result.value[:viable]).to be_a(Array)
71
+ end
72
+
73
+ context 'when given a non-array candidate' do
74
+ let(:candidates) {ruby_hook}
75
+
76
+ it 'converts the candidate to an array' do
77
+ expect(result.value[:candidates]).to eql([ruby_hook])
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#check_ruby_candidates' do
83
+ let(:input) {
84
+ {
85
+ :candidates => hooks,
86
+ :shell => shell,
87
+ :viable => []
88
+ }
89
+ }
90
+
91
+ let(:result) {filter.check_ruby_candidates(input)}
92
+
93
+ it 'adds all ruby hooks to the viable array' do
94
+ expect(result.value[:viable]).to include(ruby_hook)
95
+ end
96
+
97
+ it 'ignores non-ruby hooks' do
98
+ expect(result.value[:viable]).not_to include(executable_hook)
99
+ end
100
+
101
+ it 'does not alter the candidates' do
102
+ expect(result.value[:candidates]).to eql(hooks)
103
+ end
104
+ end
105
+
106
+ describe '#check_executable_candidates' do
107
+ let(:input) {
108
+ {
109
+ :candidates => hooks,
110
+ :shell => shell,
111
+ :viable => []
112
+ }
113
+ }
114
+
115
+ let(:result) {filter.check_executable_candidates(input)}
116
+
117
+ it 'ignores ruby hooks' do
118
+ expect(result.value[:viable]).not_to include(ruby_hook)
119
+ end
120
+
121
+ it 'does not alter the candidates' do
122
+ expect(result.value[:candidates]).to eql(hooks)
123
+ end
124
+
125
+ context 'with a hook that has the executable bit' do
126
+ before(:each) do
127
+ allow(executable_path).to receive(:executable?).and_return(true)
128
+ end
129
+
130
+ it 'adds that hook to the viable array' do
131
+ expect(result.value[:viable]).to include(executable_hook)
132
+ end
133
+ end
134
+
135
+ context 'with a hook that lacks the executable bit' do
136
+ before(:each) do
137
+ allow(executable_path).to receive(:executable?).and_return(false)
138
+ end
139
+
140
+ it 'warns the user that the hook is being skipped' do
141
+ expect(shell).
142
+ to receive(:warning).
143
+ with(
144
+ "Skipping possible deploy hook #{executable_hook} because it is not executable."
145
+ )
146
+
147
+ result
148
+ end
149
+
150
+ it 'omits that hook from the viable array' do
151
+ expect(result.value[:viable]).not_to include(executable_hook)
152
+ end
153
+ end
154
+ end
155
+
156
+ describe '#calculate_callback_name' do
157
+ let(:viable) {hooks}
158
+
159
+ let(:input) {
160
+ {
161
+ :candidates => hooks,
162
+ :shell => shell,
163
+ :viable => viable
164
+ }
165
+ }
166
+
167
+ let(:result) {filter.calculate_callback_name(input)}
168
+
169
+ context 'with viable hooks' do
170
+ let(:viable) {hooks}
171
+
172
+ it 'is a Success' do
173
+ expect(result).to be_a(Result::Success)
174
+ end
175
+
176
+ it 'has a callback name value' do
177
+ expect(result.value).to eql(callback_name)
178
+ end
179
+ end
180
+
181
+ context 'with no viable hooks' do
182
+ let(:viable) {[]}
183
+
184
+ it 'is a Failure' do
185
+ expect(result).to be_a(Result::Failure)
186
+ end
187
+
188
+ it 'includes a failure reason' do
189
+ expect(result.error[:reason]).to eql(:no_viable_hooks)
190
+ end
191
+
192
+ it 'does not modify the viable array' do
193
+ expect(result.error[:candidates]).to eql(hooks)
194
+ end
195
+
196
+ it 'does not modify the candidates array' do
197
+ expect(result.error[:viable]).to eql(viable)
198
+ end
199
+ end
200
+ end
201
+
202
+ end
203
+
204
+ end
205
+ end
206
+ end
207
+ end
208
+
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ require 'pathname'
4
+
5
+ require 'result'
6
+ require 'engineyard-serverside/callbacks/distributor'
7
+
8
+ module EY
9
+ module Serverside
10
+ module Callbacks
11
+
12
+ describe Distributor do
13
+
14
+ describe '.distribute' do
15
+ let(:runner) {Object.new}
16
+ let(:shell) {Object.new}
17
+ let(:hook_name) {:some_hook}
18
+ let(:failure) {Result::Failure.new({})}
19
+ let(:success) {Result::Success.new(hook_name)}
20
+
21
+ let(:result) {described_class.distribute(runner, hook_name)}
22
+
23
+ before(:each) do
24
+ allow(described_class::Remote).to receive(:distribute)
25
+
26
+ allow(runner).to receive(:shell).and_return(shell)
27
+ end
28
+
29
+ it 'distributes the hook remotely' do
30
+ expect(described_class::Remote).
31
+ to receive(:distribute).
32
+ with(runner, hook_name)
33
+
34
+ result
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,386 @@
1
+ require 'spec_helper'
2
+ require 'escape'
3
+
4
+ require 'result'
5
+
6
+ require 'engineyard-serverside/callbacks/executor/executable'
7
+
8
+ module EY
9
+ module Serverside
10
+ module Callbacks
11
+ module Executor
12
+
13
+ describe Executable do
14
+ let(:config) {Object.new}
15
+ let(:shell) {Object.new}
16
+ let(:paths) {Object.new}
17
+ let(:hook) {Object.new}
18
+ let(:short_name) {'hook'}
19
+ let(:active_release_path) {'/path/to/the/active/release'}
20
+ let(:hook_path) {'/path/to/the/dang/hook'}
21
+ let(:account_name) {'george'}
22
+ let(:app) {'tacoma'}
23
+ let(:env_name) {'gracie'}
24
+ let(:framework_env) {'sausages'}
25
+ let(:current_roles) {['hamlet', 'ophelia']}
26
+ let(:current_name) {nil}
27
+ let(:config_json) {'a big ol hash'}
28
+ let(:verbose) {false}
29
+ let(:execution_success) {true}
30
+ let(:hook_string) {'hooky'}
31
+
32
+ let(:executor) {described_class.new(config, shell, hook)}
33
+
34
+ before(:each) do
35
+ allow(hook).to receive(:path).and_return(hook_path)
36
+ allow(hook).to receive(:short_name).and_return(short_name)
37
+ allow(hook).to receive(:to_s).and_return(hook_string)
38
+ allow(hook).
39
+ to receive(:respond_to?).
40
+ with(:service_name).
41
+ and_return(false)
42
+
43
+ allow(shell).to receive(:info)
44
+ allow(shell).to receive(:fatal)
45
+ allow(shell).to receive(:warning)
46
+
47
+ allow(config).to receive(:paths).and_return(paths)
48
+ allow(config).to receive(:current_roles).and_return(current_roles)
49
+ allow(config).to receive(:account_name).and_return(account_name)
50
+ allow(config).to receive(:app).and_return(app)
51
+ allow(config).to receive(:environment_name).and_return(env_name)
52
+ allow(config).to receive(:verbose).and_return(verbose)
53
+ allow(config).to receive(:current_name).and_return(current_name)
54
+ allow(config).to receive(:framework_env).and_return(framework_env)
55
+ allow(config).to receive(:to_json).and_return(config_json)
56
+ allow(config).
57
+ to receive(:framework_envs).
58
+ and_return("RACK_ENV=#{framework_env} RAILS_ENV=#{framework_env}")
59
+
60
+
61
+ allow(paths).to receive(:active_release).and_return(active_release_path)
62
+ allow(hook_path).to receive(:executable?).and_return(true)
63
+
64
+ # This is a wee bit dirty, but the easiest way to test our actual code
65
+ # here is to stub out the included Runner interface.
66
+ allow(executor).to receive(:run) do |cmd|
67
+ EY::Serverside::Spawner::Result.new(cmd, execution_success, cmd, nil)
68
+ end
69
+
70
+ # We also need to stub out the #abort method, as we don't need the
71
+ # test suite to just up and stop running when we test executor failure
72
+ # modes.
73
+ allow(executor).to receive(:abort)
74
+ end
75
+
76
+ it 'is a Railway' do
77
+ expect(executor).to be_a(Railway)
78
+ end
79
+
80
+ it 'knows how to spawn CLI processes' do
81
+ expect(executor).to be_a(Runner)
82
+ end
83
+
84
+ it 'has the exact steps for executing a Ruby hook' do
85
+ steps = described_class.steps.map {|s| s[:name]}
86
+
87
+ expect(steps).to eql(
88
+ [
89
+ :validate_hook,
90
+ :populate_environment,
91
+ :calculate_wrapper,
92
+ :run_hook
93
+ ]
94
+ )
95
+ end
96
+
97
+ describe '#validate_hook' do
98
+ let(:input) {
99
+ {}
100
+ }
101
+
102
+ let(:result) {executor.validate_hook}
103
+
104
+ context 'when the hook has the executable bit' do
105
+ before(:each) do
106
+ allow(hook_path).to receive(:executable?).and_return(true)
107
+ end
108
+
109
+ it 'is a Success' do
110
+ expect(result).to be_a(Result::Success)
111
+ end
112
+
113
+ it 'does not alter the input' do
114
+ expect(result.value).to eql(input)
115
+ end
116
+ end
117
+
118
+ context 'when the hook lacks the executable bit' do
119
+ before(:each) do
120
+ allow(hook_path).to receive(:executable?).and_return(false)
121
+ end
122
+
123
+ it 'is a Failure' do
124
+ expect(result).to be_a(Result::Failure)
125
+ end
126
+
127
+ it 'contains a reason for the failure' do
128
+ expect(result.error[:reason]).to eql(:not_executable)
129
+ end
130
+ end
131
+ end
132
+
133
+ describe '#populate_environment' do
134
+ let(:input) {{}}
135
+
136
+ let(:result) {executor.populate_environment(input)}
137
+ let(:result_env) {result.value[:environment]}
138
+
139
+ it 'is a Success' do
140
+ expect(result).to be_a(Result::Success)
141
+ end
142
+
143
+ it 'adds the environment to the input' do
144
+ expect(result_env).to be_a(String)
145
+ end
146
+
147
+ it 'includes the account name in the environment' do
148
+ escaped = Escape.shell_command([account_name])
149
+
150
+ expect(result_env).
151
+ to match(%r{EY_DEPLOY_ACCOUNT_NAME=#{escaped}})
152
+ end
153
+
154
+ it 'includes the application in the environment' do
155
+ escaped = Escape.shell_command([app])
156
+
157
+ expect(result_env).
158
+ to match(%{EY_DEPLOY_APP=#{escaped}})
159
+ end
160
+
161
+ it 'includes the JSON representation of the config in the environment' do
162
+ escaped = Escape.shell_command([config_json])
163
+
164
+ expect(result_env).
165
+ to match(%r{EY_DEPLOY_CONFIG=#{escaped}})
166
+ end
167
+
168
+ it 'includes all of the current roles in the environment' do
169
+ expect(result_env).
170
+ to match(%r{EY_DEPLOY_CURRENT_ROLES='#{current_roles.join(' ')}'})
171
+ end
172
+
173
+ context 'when the server is named' do
174
+ let(:current_name) {'frankie'}
175
+ let(:escaped) {Escape.shell_command([current_name])}
176
+
177
+ it 'includes the current server name' do
178
+ expect(result_env).
179
+ to match(%r{EY_DEPLOY_CURRENT_NAME=#{escaped}})
180
+ end
181
+ end
182
+
183
+ context 'when the server is unnamed' do
184
+ let(:current_name) {nil}
185
+
186
+ it 'omits the current server name' do
187
+ expect(result_env).
188
+ not_to match(%r{EY_DEPLOY_CURRENT_NAME})
189
+ end
190
+ end
191
+
192
+ it 'includes the environment name in the environment' do
193
+ escaped = Escape.shell_command([env_name])
194
+
195
+ expect(result_env).
196
+ to match(%r{EY_DEPLOY_ENVIRONMENT_NAME=#{escaped}})
197
+ end
198
+
199
+ it 'includes the framwork env in the environment' do
200
+ escaped = Escape.shell_command([framework_env])
201
+
202
+ expect(result_env).
203
+ to match(%r{EY_DEPLOY_FRAMEWORK_ENV=#{escaped}})
204
+ end
205
+
206
+ it 'includes the release path in the environment' do
207
+ escaped = Escape.shell_command([active_release_path])
208
+
209
+ expect(result_env).
210
+ to match(%r{EY_DEPLOY_RELEASE_PATH=#{escaped}})
211
+ end
212
+
213
+ context 'with verbosity configured' do
214
+ let(:verbose) {true}
215
+
216
+ it 'enables verbosity in the environment' do
217
+ expect(result.value[:environment]).
218
+ to match(%r{EY_DEPLOY_VERBOSE=1})
219
+ end
220
+ end
221
+
222
+ context 'without verbosity configured' do
223
+ let(:verbose) {false}
224
+
225
+ it 'disables verbosity in the environment' do
226
+ expect(result.value[:environment]).
227
+ to match(%r{EY_DEPLOY_VERBOSE=0})
228
+ end
229
+ end
230
+
231
+ context 'when any of the values involved are nil' do
232
+ let(:account_name) {nil}
233
+ let(:app) {nil}
234
+ let(:config_json) {nil}
235
+ let(:env_name) {nil}
236
+
237
+ it 'omits those env vars' do
238
+ affected = ['ACCOUNT_NAME', 'APP', 'CONFIG', 'ENVIRONMENT_NAME']
239
+
240
+ affected.each do |var|
241
+ expect(result_env).not_to match(%r{EY_DEPLOY_#{var}})
242
+ end
243
+ end
244
+
245
+ end
246
+
247
+ end
248
+
249
+ describe '#calculate_wrapper' do
250
+ let(:input) {{}}
251
+
252
+ let(:result) {executor.calculate_wrapper(input)}
253
+
254
+ it 'is a Success' do
255
+ expect(result).to be_a(Result::Success)
256
+ end
257
+
258
+ it 'adds a wrapper to the input' do
259
+ expect(result.value[:wrapper]).not_to be_nil
260
+ end
261
+
262
+ context 'when dealing with a service hook' do
263
+ before(:each) do
264
+ allow(hook).
265
+ to receive(:respond_to?).
266
+ with(:service_name).
267
+ and_return(true)
268
+ end
269
+
270
+ it 'wraps the service hook executor' do
271
+ expect(result.value[:wrapper]).to eql(About.service_hook_executor)
272
+ end
273
+ end
274
+
275
+ context 'when dealing with an app hook' do
276
+ before(:each) do
277
+ allow(hook).
278
+ to receive(:respond_to?).
279
+ with(:service_name).
280
+ and_return(false)
281
+ end
282
+
283
+ it 'wraps the app hook executor' do
284
+ expect(result.value[:wrapper]).to eql(About.hook_executor)
285
+ end
286
+ end
287
+ end
288
+
289
+ describe '#run_hook' do
290
+ let(:dummy_env) {'i am an environment'}
291
+ let(:wrapper) {'candy-bar'}
292
+ let(:input) {
293
+ {
294
+ :wrapper => wrapper,
295
+ :environment => dummy_env
296
+ }
297
+ }
298
+
299
+ let(:result) {executor.run_hook(input)}
300
+
301
+ it 'runs the proper command' do
302
+ expect(executor).
303
+ to receive(:run).
304
+ with(
305
+ "#{dummy_env} #{config.framework_envs} #{wrapper} #{short_name}"
306
+ )
307
+
308
+ result
309
+ end
310
+
311
+ context 'when the execution succeeds' do
312
+ let(:execution_success) {true}
313
+
314
+ it 'is a Success' do
315
+ expect(result).to be_a(Result::Success)
316
+ end
317
+
318
+ it 'does not alter the input' do
319
+ expect(result.value).to eql(input)
320
+ end
321
+ end
322
+
323
+ context 'when the execution fails' do
324
+ let(:execution_success) {false}
325
+
326
+ it 'is a Failure' do
327
+ expect(result).to be_a(Result::Failure)
328
+ end
329
+
330
+ it 'has exeuction failure as its reason' do
331
+ expect(result.error[:reason]).to eql(:execution_failed)
332
+ end
333
+ end
334
+ end
335
+
336
+ describe '#handle_failure' do
337
+ let(:reason) {nil}
338
+ let(:error) {
339
+ {
340
+ :reason => reason
341
+ }
342
+ }
343
+
344
+ let(:result) {executor.handle_failure(error)}
345
+
346
+ context 'when the hook is not actually executable' do
347
+ let(:reason) {:not_executable}
348
+
349
+ it 'does nothing and returns true' do
350
+ expect(result).to eql(true)
351
+ end
352
+ end
353
+
354
+ context 'when execution of the hook fails' do
355
+ let(:reason) {:execution_failed}
356
+
357
+ it 'aborts with a message about the execution failure' do
358
+ expect(executor).
359
+ to receive(:abort).
360
+ with(
361
+ "*** [Error] Hook failed to exit cleanly: #{hook_path} ***\n"
362
+ )
363
+
364
+ result
365
+ end
366
+ end
367
+
368
+ context 'when an otherwise unexpected error occurs' do
369
+ let(:reason) {nil}
370
+
371
+ it 'aborts with a message about the unknown error' do
372
+ expect(executor).
373
+ to receive(:abort).
374
+ with("*** [Error] An unknown error occurred for hook: #{hook_path} ***\n")
375
+
376
+ result
377
+ end
378
+ end
379
+ end
380
+
381
+ end
382
+
383
+ end
384
+ end
385
+ end
386
+ end