This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
every_enabled_application do |app, _deploy| | ||
scm = Drivers::Scm::Factory.build(app, node) | ||
appserver = Drivers::Appserver::Factory.build(app, node) | ||
framework = Drivers::Framework::Factory.build(app, node) | ||
|
||
scm.before_undeploy(self) | ||
appserver.before_undeploy(self) | ||
framework.before_undeploy(self) | ||
|
||
deploy app['shortname'] do | ||
deploy_to deploy_dir(app) | ||
user node['deployer']['user'] || 'root' | ||
group www_group | ||
|
||
appserver.notifies[:undeploy].each do |config| | ||
notifies config[:action], | ||
config[:resource].respond_to?(:call) ? config[:resource].call(app) : config[:resource], | ||
config[:timer] | ||
end | ||
|
||
action :rollback | ||
end | ||
|
||
framework.after_undeploy(self) | ||
appserver.after_undeploy(self) | ||
scm.after_undeploy(self) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
# | ||
# Cookbook Name:: opsworks_ruby | ||
# Spec:: undeploy | ||
# | ||
# Copyright (c) 2016 The Authors, All Rights Reserved. | ||
|
||
require 'spec_helper' | ||
|
||
describe 'opsworks_ruby::undeploy' do | ||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new do |solo_node| | ||
deploy = node['deploy'] | ||
deploy['dummy_project']['scm'].delete('ssh_wrapper') | ||
solo_node.set['deploy'] = deploy | ||
end.converge(described_recipe) | ||
end | ||
before do | ||
stub_search(:aws_opsworks_app, '*:*').and_return([aws_opsworks_app]) | ||
stub_search(:aws_opsworks_rds_db_instance, '*:*').and_return([aws_opsworks_rds_db_instance]) | ||
end | ||
|
||
context 'Postgresql + Git + Unicorn + Nginx' do | ||
it 'performs a rollback' do | ||
expect(chef_run).to rollback_deploy('dummy_project') | ||
expect(chef_run).to run_execute('stop unicorn') | ||
expect(chef_run).to run_execute('start unicorn') | ||
end | ||
end | ||
end |