engineyard-serverside 2.8.0.pre → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) hide show
  1. checksums.yaml +7 -0
  2. data/bin/engineyard-serverside-execute-service-hook +1 -1
  3. data/features/hook/running-a-deploy-hook.feature +277 -0
  4. data/features/hook/step_definitions/running-a-deploy-hook-steps.rb +200 -0
  5. data/features/step_definitions/command_steps.rb +8 -0
  6. data/features/step_definitions/version_steps.rb +5 -0
  7. data/features/support/env.rb +63 -0
  8. data/features/support/error_codes.rb +17 -0
  9. data/features/support/fs_helpers.rb +82 -0
  10. data/features/support/output_helpers.rb +7 -0
  11. data/features/support/runner.rb +41 -0
  12. data/features/version.feature +7 -0
  13. data/lib/engineyard-serverside.rb +2 -5
  14. data/lib/engineyard-serverside/callbacks/collection/base.rb +12 -5
  15. data/lib/engineyard-serverside/callbacks/distributor.rb +2 -7
  16. data/lib/engineyard-serverside/callbacks/executor/executable.rb +2 -0
  17. data/lib/engineyard-serverside/cli/app.rb +6 -0
  18. data/lib/engineyard-serverside/cli/workflows/calling_deploy_hooks.rb +1 -2
  19. data/lib/engineyard-serverside/configuration.rb +3 -3
  20. data/lib/engineyard-serverside/deploy.rb +4 -8
  21. data/lib/engineyard-serverside/shell.rb +38 -10
  22. data/lib/engineyard-serverside/version.rb +1 -1
  23. data/spec/engineyard-serverside/callbacks/collection/combined_spec.rb +232 -0
  24. data/spec/engineyard-serverside/callbacks/collection/deploy_hooks_spec.rb +170 -0
  25. data/spec/engineyard-serverside/callbacks/collection/service_hooks/collection_spec.rb +171 -0
  26. data/spec/engineyard-serverside/callbacks/collection/service_hooks/combined_spec.rb +174 -0
  27. data/spec/engineyard-serverside/callbacks/collection/service_hooks_spec.rb +31 -0
  28. data/spec/engineyard-serverside/callbacks/collection_spec.rb +49 -0
  29. data/spec/engineyard-serverside/callbacks/distributor/remote_spec.rb +135 -0
  30. data/spec/engineyard-serverside/callbacks/distributor/viability_filter_spec.rb +208 -0
  31. data/spec/engineyard-serverside/callbacks/distributor_spec.rb +43 -0
  32. data/spec/engineyard-serverside/callbacks/executor/executable_spec.rb +386 -0
  33. data/spec/engineyard-serverside/callbacks/executor/ruby/context_spec.rb +538 -0
  34. data/spec/engineyard-serverside/callbacks/executor/ruby/executor_spec.rb +313 -0
  35. data/spec/engineyard-serverside/callbacks/executor/ruby_spec.rb +35 -0
  36. data/spec/engineyard-serverside/callbacks/executor_spec.rb +45 -0
  37. data/spec/engineyard-serverside/callbacks_spec.rb +31 -0
  38. data/spec/engineyard-serverside/cli/workflows/base_spec.rb +237 -0
  39. data/spec/engineyard-serverside/cli/workflows/calling_deploy_hooks_spec.rb +65 -0
  40. data/spec/engineyard-serverside/cli/workflows/deploying_applications_spec.rb +61 -0
  41. data/spec/engineyard-serverside/cli/workflows/disabling_maintenance_spec.rb +61 -0
  42. data/spec/engineyard-serverside/cli/workflows/enabling_maintenance_spec.rb +61 -0
  43. data/spec/engineyard-serverside/cli/workflows/helpers_spec.rb +64 -0
  44. data/spec/engineyard-serverside/cli/workflows/rolling_back_applications_spec.rb +61 -0
  45. data/spec/engineyard-serverside/cli/workflows/showing_maintenance_status_spec.rb +60 -0
  46. data/spec/engineyard-serverside/cli/workflows_spec.rb +87 -0
  47. data/spec/engineyard-serverside/dependency_manager/base_spec.rb +139 -0
  48. data/spec/engineyard-serverside/paths_spec.rb +820 -0
  49. data/spec/engineyard-serverside/propagator_spec.rb +56 -0
  50. data/spec/engineyard-serverside/server_spec.rb +390 -0
  51. data/spec/engineyard-serverside/shell/helpers_spec.rb +98 -0
  52. data/spec/engineyard-serverside/shell/yieldio_spec.rb +33 -0
  53. data/spec/engineyard-serverside/shell_spec.rb +543 -0
  54. data/spec/engineyard-serverside/slug/distributor_spec.rb +199 -0
  55. data/spec/engineyard-serverside/slug/enabler_spec.rb +191 -0
  56. data/spec/engineyard-serverside/slug/failure_handler_spec.rb +114 -0
  57. data/spec/engineyard-serverside/slug/finalizer_spec.rb +191 -0
  58. data/spec/engineyard-serverside/slug/generator_spec.rb +82 -0
  59. data/spec/engineyard-serverside/slug/migrator_spec.rb +137 -0
  60. data/spec/engineyard-serverside/slug/restarter_spec.rb +226 -0
  61. data/spec/engineyard-serverside/slug/source/updater_spec.rb +710 -0
  62. data/spec/engineyard-serverside/slug/source_spec.rb +40 -0
  63. data/spec/engineyard-serverside/source_spec.rb +171 -0
  64. data/spec/railway_spec.rb +130 -0
  65. data/spec/result/failure_spec.rb +113 -0
  66. data/spec/result/success_spec.rb +109 -0
  67. data/spec/result_spec.rb +23 -0
  68. data/spec/spec_helper.rb +3 -349
  69. metadata +327 -602
  70. data/lib/vendor/json_pure/COPYING +0 -57
  71. data/lib/vendor/json_pure/GPL +0 -340
  72. data/lib/vendor/json_pure/README.rdoc +0 -358
  73. data/lib/vendor/json_pure/VERSION +0 -1
  74. data/lib/vendor/json_pure/lib/json.rb +0 -62
  75. data/lib/vendor/json_pure/lib/json/add/bigdecimal.rb +0 -28
  76. data/lib/vendor/json_pure/lib/json/add/complex.rb +0 -22
  77. data/lib/vendor/json_pure/lib/json/add/core.rb +0 -11
  78. data/lib/vendor/json_pure/lib/json/add/date.rb +0 -34
  79. data/lib/vendor/json_pure/lib/json/add/date_time.rb +0 -48
  80. data/lib/vendor/json_pure/lib/json/add/exception.rb +0 -31
  81. data/lib/vendor/json_pure/lib/json/add/ostruct.rb +0 -31
  82. data/lib/vendor/json_pure/lib/json/add/range.rb +0 -29
  83. data/lib/vendor/json_pure/lib/json/add/rational.rb +0 -22
  84. data/lib/vendor/json_pure/lib/json/add/regexp.rb +0 -30
  85. data/lib/vendor/json_pure/lib/json/add/struct.rb +0 -30
  86. data/lib/vendor/json_pure/lib/json/add/symbol.rb +0 -25
  87. data/lib/vendor/json_pure/lib/json/add/time.rb +0 -38
  88. data/lib/vendor/json_pure/lib/json/common.rb +0 -484
  89. data/lib/vendor/json_pure/lib/json/ext.rb +0 -21
  90. data/lib/vendor/json_pure/lib/json/generic_object.rb +0 -70
  91. data/lib/vendor/json_pure/lib/json/pure.rb +0 -21
  92. data/lib/vendor/json_pure/lib/json/pure/generator.rb +0 -522
  93. data/lib/vendor/json_pure/lib/json/pure/parser.rb +0 -359
  94. data/lib/vendor/json_pure/lib/json/version.rb +0 -8
  95. data/lib/vendor/multi_json/CHANGELOG.md +0 -121
  96. data/lib/vendor/multi_json/CONTRIBUTING.md +0 -46
  97. data/lib/vendor/multi_json/Gemfile +0 -31
  98. data/lib/vendor/multi_json/LICENSE.md +0 -20
  99. data/lib/vendor/multi_json/README.md +0 -105
  100. data/lib/vendor/multi_json/Rakefile +0 -12
  101. data/lib/vendor/multi_json/lib/multi_json.rb +0 -137
  102. data/lib/vendor/multi_json/lib/multi_json/adapters/gson.rb +0 -20
  103. data/lib/vendor/multi_json/lib/multi_json/adapters/json_common.rb +0 -35
  104. data/lib/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +0 -12
  105. data/lib/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +0 -12
  106. data/lib/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +0 -35
  107. data/lib/vendor/multi_json/lib/multi_json/adapters/oj.rb +0 -29
  108. data/lib/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +0 -58
  109. data/lib/vendor/multi_json/lib/multi_json/adapters/yajl.rb +0 -20
  110. data/lib/vendor/multi_json/lib/multi_json/vendor/okjson.rb +0 -602
  111. data/lib/vendor/multi_json/lib/multi_json/version.rb +0 -3
  112. data/lib/vendor/multi_json/spec/adapter_shared_example.rb +0 -162
  113. data/lib/vendor/multi_json/spec/helper.rb +0 -45
  114. data/lib/vendor/multi_json/spec/json_common_shared_example.rb +0 -36
  115. data/lib/vendor/multi_json/spec/multi_json_spec.rb +0 -151
  116. data/spec/archive_deploy_spec.rb +0 -53
  117. data/spec/basic_deploy_spec.rb +0 -26
  118. data/spec/bundler_deploy_spec.rb +0 -160
  119. data/spec/configuration_spec.rb +0 -206
  120. data/spec/custom_deploy_spec.rb +0 -128
  121. data/spec/deploy_hook_spec.rb +0 -378
  122. data/spec/deprecation_spec.rb +0 -23
  123. data/spec/ey_yml_customized_deploy_spec.rb +0 -99
  124. data/spec/fixtures/gitrepo.tar.gz +0 -0
  125. data/spec/fixtures/invalid_hook.rb +0 -1
  126. data/spec/fixtures/lockfiles/0.9-no-bundler +0 -111
  127. data/spec/fixtures/lockfiles/0.9-with-bundler +0 -117
  128. data/spec/fixtures/lockfiles/1.0-no-bundler +0 -54
  129. data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +0 -162
  130. data/spec/fixtures/lockfiles/1.0.18-do_mysql +0 -88
  131. data/spec/fixtures/lockfiles/1.0.18-do_postgres +0 -79
  132. data/spec/fixtures/lockfiles/1.0.18-mysql +0 -43
  133. data/spec/fixtures/lockfiles/1.0.18-mysql2 +0 -43
  134. data/spec/fixtures/lockfiles/1.0.18-pg +0 -43
  135. data/spec/fixtures/lockfiles/1.0.6-no-bundler +0 -51
  136. data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +0 -52
  137. data/spec/fixtures/lockfiles/1.0.6-with-bundler +0 -52
  138. data/spec/fixtures/lockfiles/1.15.1-no-bundler +0 -51
  139. data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +0 -112
  140. data/spec/fixtures/lockfiles/not-a-lockfile +0 -1
  141. data/spec/fixtures/repos/assets_detected/Gemfile +0 -5
  142. data/spec/fixtures/repos/assets_detected/Gemfile.lock +0 -88
  143. data/spec/fixtures/repos/assets_detected/README +0 -1
  144. data/spec/fixtures/repos/assets_detected/Rakefile +0 -5
  145. data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
  146. data/spec/fixtures/repos/assets_detected/config/application.rb +0 -5
  147. data/spec/fixtures/repos/assets_detected/config/ey.yml +0 -3
  148. data/spec/fixtures/repos/assets_disabled/Gemfile +0 -5
  149. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +0 -88
  150. data/spec/fixtures/repos/assets_disabled/README +0 -1
  151. data/spec/fixtures/repos/assets_disabled/Rakefile +0 -6
  152. data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
  153. data/spec/fixtures/repos/assets_disabled/config/application.rb +0 -5
  154. data/spec/fixtures/repos/assets_disabled/config/ey.yml +0 -3
  155. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +0 -5
  156. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +0 -88
  157. data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +0 -1
  158. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +0 -6
  159. data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
  160. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +0 -5
  161. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +0 -5
  162. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +0 -5
  163. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +0 -88
  164. data/spec/fixtures/repos/assets_disabled_utf8/README +0 -3
  165. data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +0 -5
  166. data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
  167. data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +0 -7
  168. data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +0 -3
  169. data/spec/fixtures/repos/assets_enabled_all/Gemfile +0 -5
  170. data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +0 -88
  171. data/spec/fixtures/repos/assets_enabled_all/README +0 -1
  172. data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
  173. data/spec/fixtures/repos/assets_enabled_all/config/application.rb +0 -5
  174. data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +0 -6
  175. data/spec/fixtures/repos/assets_enabled_all/script/assets +0 -5
  176. data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +0 -1
  177. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +0 -3
  178. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +0 -10
  179. data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +0 -1
  180. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +0 -8
  181. data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +0 -4
  182. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +0 -5
  183. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +0 -88
  184. data/spec/fixtures/repos/assets_enabled_util_only/README +0 -1
  185. data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +0 -6
  186. data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
  187. data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +0 -5
  188. data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +0 -6
  189. data/spec/fixtures/repos/assets_error/Gemfile +0 -5
  190. data/spec/fixtures/repos/assets_error/Gemfile.lock +0 -88
  191. data/spec/fixtures/repos/assets_error/README +0 -1
  192. data/spec/fixtures/repos/assets_error/Rakefile +0 -4
  193. data/spec/fixtures/repos/assets_error/app/assets/empty +0 -0
  194. data/spec/fixtures/repos/assets_error/config/application.rb +0 -5
  195. data/spec/fixtures/repos/assets_error/config/ey.yml +0 -4
  196. data/spec/fixtures/repos/assets_in_hook/Gemfile +0 -5
  197. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +0 -88
  198. data/spec/fixtures/repos/assets_in_hook/README +0 -2
  199. data/spec/fixtures/repos/assets_in_hook/Rakefile +0 -5
  200. data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
  201. data/spec/fixtures/repos/assets_in_hook/config/application.rb +0 -5
  202. data/spec/fixtures/repos/assets_in_hook/config/ey.yml +0 -3
  203. data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +0 -2
  204. data/spec/fixtures/repos/bundle_fails/Gemfile +0 -1
  205. data/spec/fixtures/repos/bundle_fails/README +0 -1
  206. data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +0 -1
  207. data/spec/fixtures/repos/bundler_disabled/Gemfile +0 -4
  208. data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +0 -12
  209. data/spec/fixtures/repos/bundler_disabled/README +0 -1
  210. data/spec/fixtures/repos/bundler_disabled/config/ey.yml +0 -2
  211. data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +0 -1
  212. data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +0 -1
  213. data/spec/fixtures/repos/bundler_old/Gemfile +0 -5
  214. data/spec/fixtures/repos/bundler_old/Gemfile.lock +0 -15
  215. data/spec/fixtures/repos/bundler_old/README +0 -1
  216. data/spec/fixtures/repos/default/Gemfile +0 -4
  217. data/spec/fixtures/repos/default/Gemfile.lock +0 -12
  218. data/spec/fixtures/repos/default/README +0 -5
  219. data/spec/fixtures/repos/default/ey.yml +0 -3
  220. data/spec/fixtures/repos/executable_hooks/README +0 -1
  221. data/spec/fixtures/repos/executable_hooks/deploy/before_restart +0 -72
  222. data/spec/fixtures/repos/executable_hooks_not_executable/README +0 -3
  223. data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +0 -3
  224. data/spec/fixtures/repos/ey_yml/Gemfile +0 -4
  225. data/spec/fixtures/repos/ey_yml/Gemfile.lock +0 -12
  226. data/spec/fixtures/repos/ey_yml/README +0 -1
  227. data/spec/fixtures/repos/ey_yml/config/ey.yml +0 -18
  228. data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +0 -6
  229. data/spec/fixtures/repos/ey_yml_alt/Gemfile +0 -4
  230. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +0 -12
  231. data/spec/fixtures/repos/ey_yml_alt/README +0 -1
  232. data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +0 -6
  233. data/spec/fixtures/repos/ey_yml_alt/ey.yml +0 -12
  234. data/spec/fixtures/repos/hook_fails/README +0 -1
  235. data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +0 -1
  236. data/spec/fixtures/repos/hooks/README +0 -1
  237. data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +0 -1
  238. data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +0 -1
  239. data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +0 -1
  240. data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +0 -1
  241. data/spec/fixtures/repos/hooks/deploy/after_restart.rb +0 -1
  242. data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +0 -1
  243. data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +0 -1
  244. data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +0 -1
  245. data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +0 -1
  246. data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +0 -1
  247. data/spec/fixtures/repos/hooks/deploy/before_restart.rb +0 -1
  248. data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +0 -1
  249. data/spec/fixtures/repos/multi_dep_manager/README +0 -1
  250. data/spec/fixtures/repos/multi_dep_manager/composer.json +0 -5
  251. data/spec/fixtures/repos/multi_dep_manager/composer.lock +0 -462
  252. data/spec/fixtures/repos/multi_dep_manager/package.json +0 -7
  253. data/spec/fixtures/repos/multi_dep_manager/public/index.php +0 -4
  254. data/spec/fixtures/repos/no_ey_config/Gemfile +0 -3
  255. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +0 -10
  256. data/spec/fixtures/repos/no_ey_config/README +0 -1
  257. data/spec/fixtures/repos/no_ey_config/ey.yml +0 -3
  258. data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile +0 -3
  259. data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile.lock +0 -10
  260. data/spec/fixtures/repos/no_ey_config_no_warning/README +0 -1
  261. data/spec/fixtures/repos/no_ey_config_no_warning/ey.yml +0 -5
  262. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +0 -4
  263. data/spec/fixtures/repos/no_gemfile_lock/README +0 -1
  264. data/spec/fixtures/repos/no_gemfile_lock/ey.yml +0 -3
  265. data/spec/fixtures/repos/nodejs/README +0 -1
  266. data/spec/fixtures/repos/nodejs/package.json +0 -7
  267. data/spec/fixtures/repos/not_bundled/README +0 -1
  268. data/spec/fixtures/repos/npm_disabled/README +0 -1
  269. data/spec/fixtures/repos/npm_disabled/config/ey.yml +0 -2
  270. data/spec/fixtures/repos/npm_disabled/package.json +0 -7
  271. data/spec/fixtures/repos/php_composer_disabled/README +0 -1
  272. data/spec/fixtures/repos/php_composer_disabled/composer.json +0 -5
  273. data/spec/fixtures/repos/php_composer_disabled/composer.lock +0 -462
  274. data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +0 -2
  275. data/spec/fixtures/repos/php_composer_disabled/public/index.php +0 -4
  276. data/spec/fixtures/repos/php_composer_lock/README +0 -1
  277. data/spec/fixtures/repos/php_composer_lock/composer.json +0 -5
  278. data/spec/fixtures/repos/php_composer_lock/composer.lock +0 -462
  279. data/spec/fixtures/repos/php_composer_lock/public/index.php +0 -4
  280. data/spec/fixtures/repos/php_no_composer_lock/README +0 -1
  281. data/spec/fixtures/repos/php_no_composer_lock/composer.json +0 -21
  282. data/spec/fixtures/repos/php_no_composer_lock/public/index.php +0 -4
  283. data/spec/fixtures/repos/public_system/Gemfile +0 -4
  284. data/spec/fixtures/repos/public_system/Gemfile.lock +0 -12
  285. data/spec/fixtures/repos/public_system/README +0 -5
  286. data/spec/fixtures/repos/public_system/ey.yml +0 -3
  287. data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +0 -3
  288. data/spec/fixtures/repos/sqlite3/Gemfile +0 -4
  289. data/spec/fixtures/repos/sqlite3/Gemfile.lock +0 -89
  290. data/spec/fixtures/repos/sqlite3/README +0 -1
  291. data/spec/fixtures/retwisj.war +0 -0
  292. data/spec/fixtures/valid_hook.rb +0 -1
  293. data/spec/git_strategy_spec.rb +0 -34
  294. data/spec/lockfile_parser_spec.rb +0 -126
  295. data/spec/maintenance_spec.rb +0 -44
  296. data/spec/multi_dependency_manager_spec.rb +0 -25
  297. data/spec/nodejs_deploy_spec.rb +0 -30
  298. data/spec/php_deploy_spec.rb +0 -81
  299. data/spec/platform_configure_spec.rb +0 -61
  300. data/spec/rails31_deploy_spec.rb +0 -172
  301. data/spec/restart_spec.rb +0 -43
  302. data/spec/rollback_spec.rb +0 -87
  303. data/spec/server_spec.rb +0 -70
  304. data/spec/services_deploy_spec.rb +0 -165
  305. data/spec/shell_spec.rb +0 -57
  306. data/spec/source/archive_spec.rb +0 -33
  307. data/spec/source/git_spec.rb +0 -44
  308. data/spec/sqlite3_deploy_spec.rb +0 -38
  309. data/spec/support/integration.rb +0 -103
  310. data/spec/support/source_doubles.rb +0 -28
  311. data/spec/support/timecop.rb +0 -5
  312. data/spec/symlink_spec.rb +0 -15
@@ -0,0 +1,710 @@
1
+ require 'spec_helper'
2
+
3
+ require 'engineyard-serverside/slug/source/updater'
4
+
5
+ module EY
6
+ module Serverside
7
+ module Slug
8
+ module Source
9
+
10
+ describe Updater do
11
+ let(:source_ref) {'i_am_a_reference'}
12
+ let(:source_opts) {{}}
13
+ let(:source_cache) {Object.new}
14
+ let(:source_uri) {'https://whatever'}
15
+ let(:source) {Object.new}
16
+ let(:servers) {[]}
17
+ let(:deploy_key) {"/path/to/deploy/key"}
18
+ let(:ssh_wrapper) {"/path/to/ssh/wrapper"}
19
+ let(:paths) {Object.new}
20
+ let(:config) {Object.new}
21
+ let(:shell) {Object.new}
22
+
23
+ let(:input) {
24
+ {:servers => servers, :config => config, :shell => shell}
25
+ }
26
+
27
+ let(:updater) {described_class.new(input)}
28
+
29
+ before(:each) do
30
+ allow(config).to receive(:source).and_return(source)
31
+ allow(config).to receive(:paths).and_return(paths)
32
+ allow(source).to receive(:uri).and_return(source_uri)
33
+ allow(source).to receive(:source_cache).and_return(source_cache)
34
+ allow(source).to receive(:opts).and_return(source_opts)
35
+ allow(source).to receive(:ref).and_return(source_ref)
36
+ allow(paths).to receive(:ssh_wrapper).and_return(ssh_wrapper)
37
+ allow(paths).to receive(:deploy_key).and_return(deploy_key)
38
+ allow(source_cache).to receive(:mkpath)
39
+ allow(source_cache).to receive(:to_s).and_return('source_cache')
40
+ end
41
+
42
+ it 'is a Railway' do
43
+ expect(updater).to be_a(Railway)
44
+ end
45
+
46
+ it 'has the exact steps for updating a source cache' do
47
+ steps = described_class.steps.map {|s| s[:name]}
48
+
49
+ expect(steps).to eql(
50
+ [
51
+ :create_source_cache,
52
+ :ensure_ssh_wrapper,
53
+ :determine_if_clone_needed,
54
+ :clone_if_necessary,
55
+ :prune_source_cache,
56
+ :fetch_updates,
57
+ :clean_local_branch,
58
+ :calculate_requested_revision,
59
+ :checkout_requested_revision,
60
+ :sync_submodules,
61
+ :update_submodules,
62
+ :clean_source_cache
63
+ ]
64
+ )
65
+ end
66
+
67
+ describe '#update' do
68
+ let(:update) {updater.update}
69
+
70
+ it 'calls the railway' do
71
+ expect(updater).to receive(:call).with(input)
72
+
73
+ update
74
+ end
75
+ end
76
+
77
+ describe '#create_source_cache' do
78
+ let(:create_source_cache) {
79
+ updater.send(:create_source_cache, input)
80
+ }
81
+
82
+ it 'creates the source cache on the file system' do
83
+ expect(source_cache).to receive(:mkpath)
84
+
85
+ create_source_cache
86
+ end
87
+
88
+ context 'when all is good' do
89
+ it 'is a success' do
90
+ expect(create_source_cache.success?).to eql(true)
91
+ end
92
+ end
93
+
94
+ context 'when the mkdir fails' do
95
+ before(:each) do
96
+ allow(source_cache).to receive(:mkpath).and_raise("any error")
97
+ end
98
+
99
+ it 'is a failure' do
100
+ expect(create_source_cache.failure?).to eql(true)
101
+ end
102
+
103
+ it 'has an error regarding the source cache creation failure' do
104
+ expect(create_source_cache.error[:error]).to eql("Could not create #{source_cache}")
105
+ end
106
+ end
107
+ end
108
+
109
+ describe '#ensure_ssh_wrapper' do
110
+ let(:wrapper) {updater.send(:ensure_ssh_wrapper, input)}
111
+
112
+ context 'when the wrapper already exists' do
113
+ before(:each) do
114
+ allow(File).
115
+ to receive(:executable?).
116
+ with(ssh_wrapper).
117
+ and_return(true)
118
+ end
119
+
120
+ it 'is a success' do
121
+ expect(wrapper).to be_a(Result::Success)
122
+ end
123
+
124
+ it 'does not modify its input' do
125
+ expect(wrapper.value).to eql(input)
126
+ end
127
+ end
128
+
129
+ context 'when the wrapper does not exist' do
130
+ let(:wrapper_file) {Object.new}
131
+
132
+ before(:each) do
133
+ allow(File).
134
+ to receive(:executable?).
135
+ with(ssh_wrapper).
136
+ and_return(false)
137
+
138
+ allow(File).
139
+ to receive(:open).
140
+ with(ssh_wrapper, 'w', 0700).
141
+ and_return(wrapper_file)
142
+
143
+ allow(wrapper_file).
144
+ to receive(:write)
145
+
146
+ allow(wrapper_file).
147
+ to receive(:close)
148
+ end
149
+
150
+ it 'writes the wrapper file' do
151
+ expect(File).
152
+ to receive(:open).
153
+ with(ssh_wrapper, 'w', 0700).
154
+ and_return(wrapper_file)
155
+
156
+ expect(wrapper_file).
157
+ to receive(:write)
158
+
159
+ expect(wrapper_file).
160
+ to receive(:close)
161
+
162
+ wrapper
163
+ end
164
+
165
+ context 'but writing the file raises an error' do
166
+ let(:onobro) {StandardError.new('onobro')}
167
+ before(:each) do
168
+ allow(wrapper_file).
169
+ to receive(:write).
170
+ and_raise(onobro)
171
+ end
172
+
173
+ it 'is a failure' do
174
+ expect(wrapper).to be_a(Result::Failure)
175
+ end
176
+
177
+ it 'records the error' do
178
+ expect(wrapper.error[:error]).to eql(onobro)
179
+ end
180
+ end
181
+
182
+ context 'and writing the file succeeds' do
183
+ it 'is a success' do
184
+ expect(wrapper).to be_a(Result::Success)
185
+ end
186
+
187
+ it 'does not modify its input' do
188
+ expect(wrapper.value).to eql(input)
189
+ end
190
+ end
191
+ end
192
+
193
+ end
194
+
195
+ describe '#determine_if_clone_needed' do
196
+ let(:determine) {updater.send(:determine_if_clone_needed, input)}
197
+
198
+ before(:each) do
199
+ allow(source_cache).to receive(:directory?).and_return(true)
200
+ allow(updater).to receive(:run_and_output).and_return(source_uri)
201
+ end
202
+
203
+ it 'is always a success' do
204
+ expect(determine.success?).to eql(true)
205
+ end
206
+
207
+ context 'when the source cache is not a directory' do
208
+ before(:each) do
209
+ allow(source_cache).to receive(:directory?).and_return(false)
210
+ end
211
+
212
+ it 'records that a clone is needed' do
213
+ expect(determine.value[:clone_needed]).to eql(true)
214
+ end
215
+ end
216
+
217
+ context 'when the source cache is a directory' do
218
+ context 'but its remotes do not include the source URI' do
219
+ before(:each) do
220
+ allow(updater).to receive(:run_and_output).and_return('')
221
+ end
222
+
223
+ it 'records that a clone is needed' do
224
+ expect(determine.value[:clone_needed]).to eql(true)
225
+ end
226
+ end
227
+
228
+ context 'and its remotes include the source URI' do
229
+ it 'records that a clone is not needed' do
230
+ expect(determine.value[:clone_needed]).to eql(false)
231
+ end
232
+ end
233
+ end
234
+
235
+ end
236
+
237
+ describe '#clone_if_necessary' do
238
+ let(:clone_input) {input}
239
+ let(:clone_if_necessary) {
240
+ updater.send(:clone_if_necessary, clone_input)
241
+ }
242
+
243
+ before(:each) do
244
+ allow(updater).to receive(:run_and_success?).and_return(true)
245
+ end
246
+
247
+ it 'is a result' do
248
+ expect(clone_if_necessary).to be_a(Result::Base)
249
+ end
250
+
251
+ context 'when no clone is needed' do
252
+ let(:clone_input) {input.merge(:clone_needed => false)}
253
+
254
+ it 'is skips cloning' do
255
+ expect(updater).not_to receive(:run_and_success?)
256
+
257
+ clone_if_necessary
258
+ end
259
+
260
+ it 'is a success' do
261
+ expect(clone_if_necessary.success?).to eql(true)
262
+ end
263
+
264
+ it 'does not alter its input' do
265
+ expect(clone_if_necessary.value).to eql(clone_input)
266
+ end
267
+ end
268
+
269
+ context 'when a clone is needed' do
270
+ let(:clone_input) {input.merge(:clone_needed => true)}
271
+
272
+ it 'clones the repo' do
273
+ expect(updater).to receive(:run_and_success?).and_return(true)
274
+
275
+ clone_if_necessary
276
+ end
277
+
278
+ context 'but cloning fails' do
279
+ before(:each) do
280
+ allow(updater).to receive(:run_and_success?).and_return(false)
281
+ end
282
+
283
+ it 'is a failure' do
284
+ expect(clone_if_necessary.failure?).to eql(true)
285
+ end
286
+
287
+ it 'contains an error regarding the clone failure' do
288
+ expect(clone_if_necessary.error[:error]).
289
+ to eql("Could not clone #{source_uri} to #{source_cache}")
290
+ end
291
+ end
292
+
293
+ context 'and cloning succeeds' do
294
+ it 'is a success' do
295
+ expect(clone_if_necessary.success?).to eql(true)
296
+ end
297
+
298
+ it 'does not modify its input' do
299
+ expect(clone_if_necessary.value).to eql(clone_input)
300
+ end
301
+ end
302
+ end
303
+
304
+ end
305
+
306
+ describe '#prune_source_cache' do
307
+ let(:prune) {updater.send(:prune_source_cache, input)}
308
+
309
+ before(:each) do
310
+ allow(updater).to receive(:run_and_success?).and_return(true)
311
+ end
312
+
313
+ it 'is a result' do
314
+ expect(prune).to be_a(Result::Base)
315
+ end
316
+
317
+ context 'when pruning fails' do
318
+ before(:each) do
319
+ allow(updater).to receive(:run_and_success?).and_return(false)
320
+ end
321
+
322
+ it 'is a failure' do
323
+ expect(prune.failure?).to eql(true)
324
+ end
325
+
326
+ it 'contains an error regarding the prune failure' do
327
+ expect(prune.error[:error]).
328
+ to eql("Could not prune #{source_cache}")
329
+ end
330
+ end
331
+
332
+ context 'when pruning succeeds' do
333
+ it 'is a success' do
334
+ expect(prune.success?).to eql(true)
335
+ end
336
+
337
+ it 'does not modify its input' do
338
+ expect(prune.value).to eql(input)
339
+ end
340
+ end
341
+ end
342
+
343
+ describe '#fetch_updates' do
344
+ let(:fetch) {updater.send(:fetch_updates, input)}
345
+
346
+ before(:each) do
347
+ allow(updater).to receive(:run_and_success?).and_return(true)
348
+ end
349
+
350
+ it 'is a result' do
351
+ expect(fetch).to be_a(Result::Base)
352
+ end
353
+
354
+ context 'when fetch fails' do
355
+ before(:each) do
356
+ allow(updater).to receive(:run_and_success?).and_return(false)
357
+ end
358
+
359
+ it 'is a failure' do
360
+ expect(fetch.failure?).to eql(true)
361
+ end
362
+
363
+ it 'includes an error regarding the fetch failure' do
364
+ expect(fetch.error[:error]).
365
+ to eql("Could not fetch #{source_cache}")
366
+ end
367
+ end
368
+
369
+ context 'when fetch succeeds' do
370
+ it 'is a success' do
371
+ expect(fetch.success?).to eql(true)
372
+ end
373
+
374
+ it 'does not modify its input' do
375
+ expect(fetch.value).to eql(input)
376
+ end
377
+ end
378
+ end
379
+
380
+ describe '#clean_local_branch' do
381
+ let(:clean_local_branch) {updater.send(:clean_local_branch, input)}
382
+
383
+ before(:each) do
384
+ allow(updater).to receive(:run_and_success?)
385
+ end
386
+
387
+ it 'is always a success' do
388
+ expect(clean_local_branch.success?).to eql(true)
389
+ end
390
+
391
+ it 'does not modify its input' do
392
+ expect(clean_local_branch.value).to eql(input)
393
+ end
394
+
395
+ it 'spawns a shell to clean the branch' do
396
+ git = updater.git
397
+ ref = updater.ref
398
+
399
+ expect(updater).
400
+ to receive(:run_and_success?).
401
+ with("#{git} show-branch #{ref} > /dev/null 2>&1 && #{git} branch -D #{ref} > /dev/null 2>&1")
402
+
403
+ clean_local_branch
404
+ end
405
+ end
406
+
407
+ describe '#calculate_requested_revision' do
408
+ let(:ref) {updater.ref}
409
+ let(:git) {updater.git}
410
+ let(:calculate) {updater.send(:calculate_requested_revision, input)}
411
+
412
+ before(:each) do
413
+ allow(Dir).to receive(:chdir).and_yield
414
+ allow(updater).to receive(:run_and_success?).and_return(true)
415
+ end
416
+
417
+ it 'is always a success' do
418
+ expect(calculate.success?).to eql(true)
419
+ end
420
+
421
+ it 'checks for the remote branch in the source cache' do
422
+ expect(Dir).to receive(:chdir).and_yield
423
+ expect(updater).
424
+ to receive(:run_and_success?).
425
+ with("#{git} show-branch origin/#{ref} > /dev/null 2>&1")
426
+
427
+ calculate
428
+ end
429
+
430
+ context 'when the remote branch is found' do
431
+ it 'records the remote branch as the requested branch' do
432
+ expect(calculate.value[:requested_branch]).
433
+ to eql("origin/#{ref}")
434
+ end
435
+ end
436
+
437
+ context 'when the remote branch is not found' do
438
+ before(:each) do
439
+ allow(updater).to receive(:run_and_success?).and_return(false)
440
+ end
441
+
442
+ it 'records the raw reference as the requested_branch' do
443
+ expect(calculate.value[:requested_branch]).
444
+ to eql(ref)
445
+ end
446
+ end
447
+ end
448
+
449
+ describe '#checkout_requested_revision' do
450
+ let(:ref) {updater.ref}
451
+ let(:git) {updater.git}
452
+ let(:checkout_input) {input.merge(:requested_branch => ref)}
453
+ let(:checkout) {
454
+ updater.send(:checkout_requested_revision, checkout_input)
455
+ }
456
+
457
+ before(:each) do
458
+ allow(Dir).to receive(:chdir).and_yield
459
+ allow(updater).to receive(:run_and_success?).and_return(false)
460
+ end
461
+
462
+ it 'is a result' do
463
+ expect(checkout).to be_a(Result::Base)
464
+ end
465
+
466
+ context 'when the raw checkout command fails' do
467
+ before(:each) do
468
+ allow(updater).
469
+ to receive(:run_and_success?).
470
+ with("git checkout --force --quiet '#{ref}'").
471
+ and_return(false)
472
+ end
473
+
474
+ it 'tries to run the raw reset command' do
475
+ expect(updater).
476
+ to receive(:run_and_success?).
477
+ with("git reset --hard --quiet '#{ref}'")
478
+
479
+ checkout
480
+ end
481
+
482
+ context 'and the raw reset command fails' do
483
+ before(:each) do
484
+ allow(updater).
485
+ to receive(:run_and_success?).
486
+ with("git reset --hard --quiet '#{ref}'").
487
+ and_return(false)
488
+ end
489
+
490
+ it 'is a failure' do
491
+ expect(checkout.failure?).to eql(true)
492
+ end
493
+
494
+ it 'contains an error regarding the checkout failure' do
495
+ expect(checkout.error[:error]).
496
+ to eql("Could not check out #{ref}")
497
+ end
498
+ end
499
+
500
+ context 'but the raw reset command succeeds' do
501
+ before(:each) do
502
+ allow(updater).
503
+ to receive(:run_and_success?).
504
+ with("git reset --hard --quiet '#{ref}'").
505
+ and_return(true)
506
+ end
507
+
508
+ it 'is a success' do
509
+ expect(checkout.success?).to eql(true)
510
+ end
511
+
512
+ it 'does not modify its input' do
513
+ expect(checkout.value).to eql(checkout_input)
514
+ end
515
+ end
516
+ end
517
+
518
+ context 'when the raw checkout command succeeds' do
519
+ before(:each) do
520
+ allow(updater).
521
+ to receive(:run_and_success?).
522
+ with("git checkout --force --quiet '#{ref}'").
523
+ and_return(true)
524
+ end
525
+
526
+ it 'skips the raw reset' do
527
+ expect(updater).
528
+ not_to receive(:run_and_success?).
529
+ with("git reset --hard --quiet '#{ref}'")
530
+
531
+ checkout
532
+ end
533
+
534
+ it 'is a success' do
535
+ expect(checkout.success?).to eql(true)
536
+ end
537
+
538
+ it 'does not modify its input' do
539
+ expect(checkout.value).to eql(checkout_input)
540
+ end
541
+ end
542
+
543
+ end
544
+
545
+ describe '#sync_submodules' do
546
+ let(:ref) {updater.ref}
547
+ let(:git) {updater.git}
548
+ let(:cmd) {"GIT_SSH=#{ssh_wrapper} git submodule sync"}
549
+ let(:sync) {
550
+ updater.send(:sync_submodules, input)
551
+ }
552
+
553
+ before(:each) do
554
+ allow(Dir).to receive(:chdir).and_yield
555
+ allow(updater).
556
+ to receive(:run_and_success?).
557
+ with(cmd).
558
+ and_return(false)
559
+ end
560
+
561
+ context 'when the sync command fails' do
562
+ before(:each) do
563
+ allow(updater).
564
+ to receive(:run_and_success?).
565
+ with(cmd).
566
+ and_return(false)
567
+ end
568
+
569
+ it 'is a failure' do
570
+ expect(sync.failure?).to eql(true)
571
+ end
572
+
573
+ it 'includes an error regarding the sync failure' do
574
+ expect(sync.error[:error]).to eql('Could not sync submodules')
575
+ end
576
+ end
577
+
578
+ context 'when the sync succeeds' do
579
+ before(:each) do
580
+ allow(updater).
581
+ to receive(:run_and_success?).
582
+ with(cmd).
583
+ and_return(true)
584
+ end
585
+
586
+ it 'is a success' do
587
+ expect(sync.success?).to eql(true)
588
+ end
589
+
590
+ it 'does not modify its input' do
591
+ expect(sync.value).to eql(input)
592
+ end
593
+ end
594
+
595
+ end
596
+
597
+ describe '#update_submodules' do
598
+ let(:ref) {updater.ref}
599
+ let(:git) {updater.git}
600
+ let(:cmd) {"GIT_SSH=#{ssh_wrapper} git submodule update --init --recursive"}
601
+ let(:update_submodules) {
602
+ updater.send(:update_submodules, input)
603
+ }
604
+
605
+ before(:each) do
606
+ allow(Dir).to receive(:chdir).and_yield
607
+ allow(updater).
608
+ to receive(:run_and_success?).
609
+ with(cmd).
610
+ and_return(false)
611
+ end
612
+
613
+ context 'when the update command fails' do
614
+ before(:each) do
615
+ allow(updater).
616
+ to receive(:run_and_success?).
617
+ with(cmd).
618
+ and_return(false)
619
+ end
620
+
621
+ it 'is a failure' do
622
+ expect(update_submodules.failure?).to eql(true)
623
+ end
624
+
625
+ it 'includes an error regarding the sync failure' do
626
+ expect(update_submodules.error[:error]).
627
+ to eql('Could not update submodules')
628
+ end
629
+ end
630
+
631
+ context 'when the update succeeds' do
632
+ before(:each) do
633
+ allow(updater).
634
+ to receive(:run_and_success?).
635
+ with(cmd).
636
+ and_return(true)
637
+ end
638
+
639
+ it 'is a success' do
640
+ expect(update_submodules.success?).to eql(true)
641
+ end
642
+
643
+ it 'does not modify its input' do
644
+ expect(update_submodules.value).to eql(input)
645
+ end
646
+ end
647
+
648
+ end
649
+
650
+ describe '#clean_source_cache' do
651
+ let(:ref) {updater.ref}
652
+ let(:git) {updater.git}
653
+ let(:cmd) {"git clean -dfq"}
654
+
655
+ let(:clean) {
656
+ updater.send(:clean_source_cache, input)
657
+ }
658
+
659
+ before(:each) do
660
+ allow(Dir).to receive(:chdir).and_yield
661
+ allow(updater).
662
+ to receive(:run_and_success?).
663
+ with(cmd).
664
+ and_return(false)
665
+ end
666
+
667
+ context 'when the clean command fails' do
668
+ before(:each) do
669
+ allow(updater).
670
+ to receive(:run_and_success?).
671
+ with(cmd).
672
+ and_return(false)
673
+ end
674
+
675
+ it 'is a failure' do
676
+ expect(clean.failure?).to eql(true)
677
+ end
678
+
679
+ it 'includes an error regarding the clean failure' do
680
+ expect(clean.error[:error]).
681
+ to eql('Could not clean source')
682
+ end
683
+ end
684
+
685
+ context 'when the clean succeeds' do
686
+ before(:each) do
687
+ allow(updater).
688
+ to receive(:run_and_success?).
689
+ with(cmd).
690
+ and_return(true)
691
+ end
692
+
693
+ it 'is a success' do
694
+ expect(clean.success?).to eql(true)
695
+ end
696
+
697
+ it 'does not modify its input' do
698
+ expect(clean.value).to eql(input)
699
+ end
700
+ end
701
+
702
+ end
703
+
704
+
705
+ end
706
+
707
+ end
708
+ end
709
+ end
710
+ end