simple_deploy 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/CHANGELOG.md +6 -0
- data/lib/simple_deploy/aws/cloud_formation/error.rb +32 -0
- data/lib/simple_deploy/aws/cloud_formation.rb +76 -0
- data/lib/simple_deploy/aws/instance_reader.rb +59 -0
- data/lib/simple_deploy/aws/simpledb.rb +52 -0
- data/lib/simple_deploy/aws.rb +4 -0
- data/lib/simple_deploy/cli/attributes.rb +7 -18
- data/lib/simple_deploy/cli/clone.rb +9 -19
- data/lib/simple_deploy/cli/create.rb +5 -14
- data/lib/simple_deploy/cli/deploy.rb +8 -11
- data/lib/simple_deploy/cli/destroy.rb +4 -10
- data/lib/simple_deploy/cli/environments.rb +1 -1
- data/lib/simple_deploy/cli/events.rb +5 -11
- data/lib/simple_deploy/cli/execute.rb +6 -9
- data/lib/simple_deploy/cli/instances.rb +4 -9
- data/lib/simple_deploy/cli/list.rb +5 -10
- data/lib/simple_deploy/cli/outputs.rb +5 -11
- data/lib/simple_deploy/cli/parameters.rb +5 -11
- data/lib/simple_deploy/cli/protect.rb +5 -10
- data/lib/simple_deploy/cli/resources.rb +5 -11
- data/lib/simple_deploy/cli/shared.rb +6 -6
- data/lib/simple_deploy/cli/status.rb +5 -11
- data/lib/simple_deploy/cli/template.rb +8 -13
- data/lib/simple_deploy/cli/update.rb +6 -10
- data/lib/simple_deploy/configuration.rb +102 -0
- data/lib/simple_deploy/entry.rb +71 -0
- data/lib/simple_deploy/entry_lister.rb +30 -0
- data/lib/simple_deploy/exceptions.rb +8 -0
- data/lib/simple_deploy/misc/attribute_merger.rb +2 -5
- data/lib/simple_deploy/notifier/campfire.rb +15 -12
- data/lib/simple_deploy/notifier.rb +6 -11
- data/lib/simple_deploy/stack/deployment/status.rb +5 -3
- data/lib/simple_deploy/stack/deployment.rb +8 -10
- data/lib/simple_deploy/stack/execute.rb +2 -3
- data/lib/simple_deploy/stack/output_mapper.rb +1 -4
- data/lib/simple_deploy/stack/ssh.rb +4 -4
- data/lib/simple_deploy/stack/{stack_attribute_formater.rb → stack_attribute_formatter.rb} +4 -6
- data/lib/simple_deploy/stack/stack_creator.rb +46 -0
- data/lib/simple_deploy/stack/stack_destroyer.rb +19 -0
- data/lib/simple_deploy/stack/stack_formatter.rb +25 -0
- data/lib/simple_deploy/stack/stack_lister.rb +18 -0
- data/lib/simple_deploy/stack/stack_reader.rb +56 -0
- data/lib/simple_deploy/stack/stack_updater.rb +67 -0
- data/lib/simple_deploy/stack/status.rb +53 -0
- data/lib/simple_deploy/stack.rb +89 -37
- data/lib/simple_deploy/version.rb +1 -1
- data/lib/simple_deploy.rb +31 -1
- data/simple_deploy.gemspec +6 -3
- data/spec/aws/cloud_formation/error_spec.rb +50 -0
- data/spec/aws/cloud_formation_spec.rb +207 -0
- data/spec/aws/instance_reader_spec.rb +96 -0
- data/spec/aws/simpledb_spec.rb +89 -0
- data/spec/cli/attributes_spec.rb +5 -15
- data/spec/cli/clone_spec.rb +14 -27
- data/spec/cli/create_spec.rb +11 -18
- data/spec/cli/deploy_spec.rb +24 -63
- data/spec/cli/destroy_spec.rb +7 -25
- data/spec/cli/outputs_spec.rb +12 -17
- data/spec/cli/protect_spec.rb +68 -106
- data/spec/cli/shared_spec.rb +12 -15
- data/spec/cli/update_spec.rb +9 -27
- data/spec/config_spec.rb +47 -14
- data/spec/contexts/config_contexts.rb +28 -0
- data/spec/contexts/logger_contexts.rb +9 -0
- data/spec/contexts/stack_contexts.rb +40 -0
- data/spec/entry_lister_spec.rb +31 -0
- data/spec/entry_spec.rb +86 -0
- data/spec/misc/attribute_merger_spec.rb +3 -8
- data/spec/notifier/campfire_spec.rb +21 -61
- data/spec/notifier_spec.rb +18 -40
- data/spec/spec_helper.rb +10 -0
- data/spec/stack/deployment/status_spec.rb +13 -13
- data/spec/stack/deployment_spec.rb +26 -21
- data/spec/stack/execute_spec.rb +7 -3
- data/spec/stack/output_mapper_spec.rb +3 -15
- data/spec/stack/ssh_spec.rb +14 -13
- data/spec/stack/{stack_attribute_formater_spec.rb → stack_attribute_formatter_spec.rb} +19 -16
- data/spec/stack/stack_creator_spec.rb +46 -0
- data/spec/stack/stack_destroyer_spec.rb +18 -0
- data/spec/stack/stack_formatter_spec.rb +37 -0
- data/spec/stack/stack_lister_spec.rb +17 -0
- data/spec/stack/stack_reader_spec.rb +81 -0
- data/spec/stack/stack_updater_spec.rb +79 -0
- data/spec/stack/status_spec.rb +106 -0
- data/spec/stack_spec.rb +160 -133
- metadata +112 -19
- data/.rvmrc +0 -1
- data/lib/simple_deploy/config.rb +0 -87
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SimpleDeploy::Status do
|
4
|
+
include_context 'stubbed config'
|
5
|
+
include_context 'double stubbed logger'
|
6
|
+
|
7
|
+
before do
|
8
|
+
@stack_reader_mock = mock 'stack reader mock'
|
9
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
10
|
+
and_return @stack_reader_mock
|
11
|
+
@status = SimpleDeploy::Status.new :name => 'test-stack'
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
SimpleDeploy.release_config
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return true if the stack is in complete state" do
|
19
|
+
@stack_reader_mock.should_receive(:status).
|
20
|
+
and_return 'UPDATE_COMPLETE'
|
21
|
+
@status.complete?.should == true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return false if the stack is not in complete state" do
|
25
|
+
@stack_reader_mock.should_receive(:status).
|
26
|
+
and_return 'UPDATE_IN_PROGRESS'
|
27
|
+
@status.complete?.should == false
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return true if the stack is in a failed state" do
|
31
|
+
@stack_reader_mock.should_receive(:status).
|
32
|
+
and_return 'DELETE_FAILED'
|
33
|
+
@status.failed?.should == true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return false if the stack is not in a failed state" do
|
37
|
+
@stack_reader_mock.should_receive(:status).
|
38
|
+
and_return 'UPDATE_IN_PROGRESS'
|
39
|
+
@status.failed?.should == false
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return true if the stack is in an in_progress state" do
|
43
|
+
@stack_reader_mock.should_receive(:status).exactly(2).times.
|
44
|
+
and_return 'UPDATE_IN_PROGRESS'
|
45
|
+
@status.in_progress?.should == true
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return false if the stack is not in an in_progress state" do
|
49
|
+
@stack_reader_mock.should_receive(:status).exactly(2).times.
|
50
|
+
and_return 'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS'
|
51
|
+
@status.in_progress?.should == false
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return true if the stack is cleaning up" do
|
55
|
+
@stack_reader_mock.should_receive(:status).
|
56
|
+
and_return 'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS'
|
57
|
+
@status.cleanup_in_progress?.should == true
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return false if the stack is not in a cleaning up state" do
|
61
|
+
@stack_reader_mock.should_receive(:status).
|
62
|
+
and_return 'UPDATE_IN_PROGRESS'
|
63
|
+
@status.cleanup_in_progress?.should == false
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return true if the stack is in a complete state" do
|
67
|
+
@stack_reader_mock.should_receive(:status).exactly(2).times.
|
68
|
+
and_return 'UPDATE_COMPLETE'
|
69
|
+
@status.stable?.should == true
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should return true if the stack is in a failed state" do
|
73
|
+
@stack_reader_mock.should_receive(:status).exactly(3).times.
|
74
|
+
and_return 'UPDATE_FAILED'
|
75
|
+
@status.stable?.should == true
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return true if the stack is in an in progress state" do
|
79
|
+
@stack_reader_mock.should_receive(:status).exactly(2).times.
|
80
|
+
and_return 'IN_PROGRESS'
|
81
|
+
@status.stable?.should == false
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return false if the stack creation failed" do
|
85
|
+
@stack_reader_mock.should_receive(:status).exactly(3).times.
|
86
|
+
and_return 'CREATE_FAILED'
|
87
|
+
@status.stable?.should == false
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should return true when the stack is in a stable state" do
|
91
|
+
@stack_reader_mock.should_receive(:status).exactly(4).times.
|
92
|
+
and_return 'CREATE_COMPLETE'
|
93
|
+
@status.wait_for_stable.should == true
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should sleep 2 times and return false when the stack is in an unstable state" do
|
97
|
+
Kernel.stub!(:sleep)
|
98
|
+
Kernel.should_receive(:sleep).with(1)
|
99
|
+
Kernel.should_receive(:sleep).with(4)
|
100
|
+
|
101
|
+
@stack_reader_mock.should_receive(:status).exactly(11).times.
|
102
|
+
and_return 'CREATE_FAILED'
|
103
|
+
@status.wait_for_stable(2).should == false
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/spec/stack_spec.rb
CHANGED
@@ -1,91 +1,104 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe SimpleDeploy do
|
3
|
+
describe SimpleDeploy::Stack do
|
4
|
+
include_context 'double stubbed config', :access_key => 'access',
|
5
|
+
:secret_key => 'secret',
|
6
|
+
:region => 'us-west-1'
|
7
|
+
include_context 'double stubbed logger'
|
8
|
+
|
4
9
|
|
5
10
|
before do
|
6
|
-
@logger_stub = stub 'logger stub', :info => 'true', :warn => 'true'
|
7
11
|
@environment_config_mock = mock 'environment config mock'
|
8
12
|
|
9
|
-
@config_stub = stub 'config stub', :region => 'us-west-1', :logger => @logger_stub
|
10
13
|
@config_stub.stub(:environment).and_return(@environment_config_mock)
|
11
14
|
@config_stub.stub(:artifacts).and_return(['chef_repo', 'cookbooks', 'app'])
|
12
15
|
@config_stub.stub(:artifact_cloud_formation_url).and_return('CookBooksURL')
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:logger => 'my-logger',
|
20
|
-
:config => @config_stub
|
21
|
-
|
22
|
-
@main_attributes = {
|
23
|
-
'chef_repo_bucket_prefix' => 'test-prefix',
|
24
|
-
'chef_repo_domain' => 'test-domain'
|
25
|
-
}
|
26
|
-
|
27
|
-
@stack_mock = mock 'stackster stack'
|
17
|
+
@entry_mock = mock 'entry mock'
|
18
|
+
SimpleDeploy::Entry.should_receive(:new).
|
19
|
+
at_least(:once).
|
20
|
+
with(:name => 'test-stack').
|
21
|
+
and_return @entry_mock
|
28
22
|
|
29
|
-
@
|
30
|
-
|
31
|
-
{ 'CookBooksURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }
|
32
|
-
]
|
23
|
+
@stack = SimpleDeploy::Stack.new :name => 'test-stack',
|
24
|
+
:environment => 'test-env'
|
33
25
|
end
|
34
26
|
|
35
27
|
describe "creating a stack" do
|
36
28
|
before do
|
37
|
-
@
|
29
|
+
@stack_creator_mock = mock 'stack creator'
|
30
|
+
@new_attributes = [
|
31
|
+
{ 'chef_repo' => 'test123' },
|
32
|
+
{ 'chef_repo_bucket_prefix' => 'test-prefix' },
|
33
|
+
{ 'chef_repo_domain' => 'test-domain' }
|
34
|
+
]
|
35
|
+
|
36
|
+
@expected_attributes = @new_attributes +
|
37
|
+
[{ 'CookBooksURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }]
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should set the attributes using what is passed to the create command" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
@entry_mock.should_receive(:attributes).and_return({})
|
42
|
+
@entry_mock.should_receive(:set_attributes).with(@expected_attributes)
|
43
|
+
@entry_mock.should_receive(:save).and_return(true)
|
44
|
+
|
45
|
+
SimpleDeploy::StackCreator.should_receive(:new).
|
46
|
+
with(:name => 'test-stack',
|
47
|
+
:entry => @entry_mock,
|
48
|
+
:template_file => 'some_json').
|
49
|
+
and_return @stack_creator_mock
|
50
|
+
@stack_creator_mock.should_receive(:create)
|
51
|
+
|
52
|
+
@stack.create :attributes => @new_attributes, :template => 'some_json'
|
53
|
+
end
|
54
|
+
end
|
45
55
|
|
46
|
-
|
56
|
+
describe "updating a stack" do
|
57
|
+
before do
|
58
|
+
@stack_updater_mock = mock 'stack updater'
|
59
|
+
@stack_reader_mock = mock 'stack reader'
|
60
|
+
@new_attributes = [
|
47
61
|
{ 'chef_repo' => 'test123' },
|
48
62
|
{ 'chef_repo_bucket_prefix' => 'test-prefix' },
|
49
|
-
{ 'chef_repo_domain' => 'test-domain' }
|
50
|
-
{ 'CookBooksURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }
|
63
|
+
{ 'chef_repo_domain' => 'test-domain' }
|
51
64
|
]
|
52
|
-
@stack_mock.should_receive(:create).with :attributes => expecteds,
|
53
|
-
:template => 'some_json'
|
54
65
|
|
55
|
-
|
66
|
+
@expected_attributes = [
|
56
67
|
{ 'chef_repo' => 'test123' },
|
57
68
|
{ 'chef_repo_bucket_prefix' => 'test-prefix' },
|
58
|
-
{ 'chef_repo_domain' => 'test-domain' }
|
69
|
+
{ 'chef_repo_domain' => 'test-domain' },
|
70
|
+
{ 'CookBooksURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }
|
59
71
|
]
|
60
|
-
|
61
|
-
@stack.create :attributes => attributes, :template => 'some_json'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "updating a stack" do
|
66
|
-
before do
|
67
|
-
@stack_mock.stub(:attributes).and_return(@main_attributes)
|
68
72
|
end
|
69
73
|
|
70
74
|
it "should update when the deployment is not locked" do
|
71
75
|
deployment_stub = stub 'deployment', :clear_for_deployment? => true
|
72
76
|
@stack.stub(:deployment).and_return(deployment_stub)
|
73
77
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
@entry_mock.should_receive(:set_attributes).with(@expected_attributes)
|
79
|
+
@entry_mock.should_receive(:save).and_return(true)
|
80
|
+
|
81
|
+
SimpleDeploy::StackUpdater.should_receive(:new).
|
82
|
+
with(:name => 'test-stack',
|
83
|
+
:entry => @entry_mock,
|
84
|
+
:template_body => 'some_json').
|
85
|
+
and_return @stack_updater_mock
|
86
|
+
@stack_updater_mock.should_receive(:update_stack_if_parameters_changed).
|
87
|
+
and_return(true)
|
88
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
89
|
+
with(:name => 'test-stack').
|
90
|
+
and_return @stack_reader_mock
|
91
|
+
@stack_reader_mock.should_receive(:attributes).and_return({})
|
92
|
+
@stack_reader_mock.should_receive(:template).and_return('some_json')
|
93
|
+
|
94
|
+
@stack.update(:attributes => @new_attributes).should be_true
|
81
95
|
end
|
82
96
|
|
83
97
|
it "should not update when the deployment is locked and force is not set" do
|
84
98
|
deployment_stub = stub 'deployment', :clear_for_deployment? => false
|
85
99
|
@stack.stub(:deployment).and_return(deployment_stub)
|
86
100
|
|
87
|
-
SimpleDeploy::
|
88
|
-
Stackster::Stack.should_not_receive(:new)
|
101
|
+
SimpleDeploy::StackAttributeFormatter.should_not_receive(:new)
|
89
102
|
|
90
103
|
@stack.update(:attributes => { 'arg1' => 'val' }).should_not be_true
|
91
104
|
end
|
@@ -97,60 +110,79 @@ describe SimpleDeploy do
|
|
97
110
|
@stack.stub(:deployment).and_return(deployment_mock)
|
98
111
|
@stack.stub(:sleep).and_return(false)
|
99
112
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
113
|
+
@entry_mock.should_receive(:set_attributes).with(@expected_attributes)
|
114
|
+
@entry_mock.should_receive(:save).and_return(true)
|
115
|
+
|
116
|
+
SimpleDeploy::StackUpdater.should_receive(:new).
|
117
|
+
with(:name => 'test-stack',
|
118
|
+
:entry => @entry_mock,
|
119
|
+
:template_body => 'some_json').
|
120
|
+
and_return @stack_updater_mock
|
121
|
+
@stack_updater_mock.should_receive(:update_stack_if_parameters_changed).
|
122
|
+
and_return(true)
|
123
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
124
|
+
with(:name => 'test-stack').
|
125
|
+
and_return @stack_reader_mock
|
126
|
+
@stack_reader_mock.should_receive(:attributes).and_return({})
|
127
|
+
@stack_reader_mock.should_receive(:template).and_return('some_json')
|
128
|
+
|
129
|
+
@stack.update(:force => true, :attributes => @new_attributes).should be_true
|
107
130
|
end
|
108
131
|
|
109
132
|
it "should not update when the deployment is locked and force is set false" do
|
110
133
|
deployment_stub = stub 'deployment', :clear_for_deployment? => false
|
111
134
|
@stack.stub(:deployment).and_return(deployment_stub)
|
112
135
|
|
113
|
-
SimpleDeploy::
|
114
|
-
Stackster::Stack.should_not_receive(:new)
|
136
|
+
SimpleDeploy::StackAttributeFormatter.should_not_receive(:new)
|
115
137
|
|
116
138
|
@stack.update(:force => false, :attributes => { 'arg1' => 'val' }).should_not be_true
|
117
139
|
end
|
118
140
|
end
|
119
141
|
|
120
142
|
describe "destroying a stack" do
|
143
|
+
before do
|
144
|
+
@stack_reader_mock = mock 'stack reader'
|
145
|
+
@stack_destroyer_mock = mock 'stack destroyer'
|
146
|
+
end
|
147
|
+
|
121
148
|
it "should destroy if the stack is not protected" do
|
122
|
-
|
123
|
-
@stack.stub(:stack) { stack_mock }
|
149
|
+
@entry_mock.should_receive(:delete_attributes)
|
124
150
|
|
125
|
-
|
151
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
152
|
+
with(:name => 'test-stack').
|
153
|
+
and_return @stack_reader_mock
|
154
|
+
@stack_reader_mock.should_receive(:attributes).and_return('protection' => 'off')
|
155
|
+
SimpleDeploy::StackDestroyer.should_receive(:new).
|
156
|
+
with(:name => 'test-stack').
|
157
|
+
and_return @stack_destroyer_mock
|
158
|
+
@stack_destroyer_mock.should_receive(:destroy).and_return(true)
|
126
159
|
|
127
160
|
@stack.destroy.should be_true
|
128
161
|
end
|
129
162
|
|
130
163
|
it "should not destroy if the stack is protected" do
|
131
|
-
|
132
|
-
@stack.stub(:stack) { stack_mock }
|
164
|
+
@entry_mock.should_receive(:delete_attributes).never
|
133
165
|
|
134
|
-
|
166
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
167
|
+
with(:name => 'test-stack').
|
168
|
+
and_return @stack_reader_mock
|
169
|
+
@stack_reader_mock.should_receive(:attributes).and_return('protection' => 'on')
|
170
|
+
SimpleDeploy::StackDestroyer.should_receive(:new).never
|
135
171
|
|
136
172
|
@stack.destroy.should_not be_true
|
137
173
|
end
|
138
174
|
|
139
175
|
it "should destroy if protection is undefined" do
|
140
|
-
|
141
|
-
@stack.stub(:stack) { stack_mock }
|
142
|
-
|
143
|
-
stack_mock.should_receive(:destroy)
|
144
|
-
|
145
|
-
@stack.destroy.should be_true
|
146
|
-
end
|
176
|
+
@entry_mock.should_receive(:delete_attributes)
|
147
177
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
178
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
179
|
+
with(:name => 'test-stack').
|
180
|
+
and_return @stack_reader_mock
|
181
|
+
@stack_reader_mock.should_receive(:attributes).and_return({})
|
182
|
+
SimpleDeploy::StackDestroyer.should_receive(:new).
|
183
|
+
with(:name => 'test-stack').
|
184
|
+
and_return @stack_destroyer_mock
|
185
|
+
@stack_destroyer_mock.should_receive(:destroy).and_return(true)
|
154
186
|
|
155
187
|
@stack.destroy.should be_true
|
156
188
|
end
|
@@ -158,46 +190,45 @@ describe SimpleDeploy do
|
|
158
190
|
|
159
191
|
describe 'instances' do
|
160
192
|
before do
|
161
|
-
@
|
162
|
-
|
193
|
+
@stack_reader_mock = mock 'stack reader'
|
194
|
+
|
195
|
+
@instances = [
|
196
|
+
{ 'instancesSet' => [{ 'ipAddress' => '50.40.30.20',
|
197
|
+
'privateIpAddress' => '10.1.2.3' }] }
|
198
|
+
]
|
163
199
|
end
|
164
200
|
|
165
201
|
it 'should use the private IP when vpc' do
|
166
|
-
stack = SimpleDeploy::Stack.new :environment => 'test-env',
|
167
|
-
:name => 'test-stack',
|
168
|
-
:logger => 'my-logger',
|
169
|
-
:config => @config_stub,
|
170
|
-
:internal => false
|
171
|
-
stack.stub(:stack) { @stack_mock }
|
172
|
-
|
173
202
|
@instances.first['instancesSet'].first['vpcId'] = 'my-vpc'
|
174
|
-
@stack_mock.stub(:instances).and_return(@instances)
|
175
203
|
|
176
|
-
|
204
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
205
|
+
with(:name => 'test-stack').
|
206
|
+
and_return @stack_reader_mock
|
207
|
+
@stack_reader_mock.should_receive(:instances).and_return(@instances)
|
208
|
+
|
209
|
+
@stack.instances.should == ['10.1.2.3']
|
177
210
|
end
|
178
211
|
|
179
212
|
it 'should use the private IP when internal' do
|
180
|
-
stack = SimpleDeploy::Stack.new :
|
181
|
-
:
|
182
|
-
:logger => 'my-logger',
|
183
|
-
:config => @config_stub,
|
213
|
+
stack = SimpleDeploy::Stack.new :name => 'test-stack',
|
214
|
+
:environment => 'test-env',
|
184
215
|
:internal => true
|
185
|
-
|
186
|
-
|
216
|
+
|
217
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
218
|
+
with(:name => 'test-stack').
|
219
|
+
and_return @stack_reader_mock
|
220
|
+
@stack_reader_mock.should_receive(:instances).and_return(@instances)
|
187
221
|
|
188
222
|
stack.instances.should == ['10.1.2.3']
|
189
223
|
end
|
190
224
|
|
191
225
|
it 'should use the public IP when not vpc and not internal' do
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
stack.
|
198
|
-
@stack_mock.stub(:instances).and_return(@instances)
|
199
|
-
|
200
|
-
stack.instances.should == ['50.40.30.20']
|
226
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
227
|
+
with(:name => 'test-stack').
|
228
|
+
and_return @stack_reader_mock
|
229
|
+
@stack_reader_mock.should_receive(:instances).and_return(@instances)
|
230
|
+
|
231
|
+
@stack.instances.should == ['50.40.30.20']
|
201
232
|
end
|
202
233
|
|
203
234
|
it 'should handle instanceSets with multiple intances' do
|
@@ -205,15 +236,12 @@ describe SimpleDeploy do
|
|
205
236
|
{ 'ipAddress' => '50.40.30.20', 'privateIpAddress' => '10.1.2.3' },
|
206
237
|
{ 'ipAddress' => '50.40.30.21', 'privateIpAddress' => '10.1.2.4' }] }]
|
207
238
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
:internal => false
|
213
|
-
stack.stub(:stack) { @stack_mock }
|
214
|
-
@stack_mock.stub(:instances).and_return(@instances)
|
239
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
240
|
+
with(:name => 'test-stack').
|
241
|
+
and_return @stack_reader_mock
|
242
|
+
@stack_reader_mock.should_receive(:instances).and_return(@instances)
|
215
243
|
|
216
|
-
stack.instances.should == ['50.40.30.20', '50.40.30.21']
|
244
|
+
@stack.instances.should == ['50.40.30.20', '50.40.30.21']
|
217
245
|
end
|
218
246
|
end
|
219
247
|
|
@@ -221,7 +249,6 @@ describe SimpleDeploy do
|
|
221
249
|
before do
|
222
250
|
@stack = SimpleDeploy::Stack.new :environment => 'test-env',
|
223
251
|
:name => 'test-stack',
|
224
|
-
:logger => 'my-logger',
|
225
252
|
:config => @config_stub,
|
226
253
|
:internal => false
|
227
254
|
@deployment_mock = mock "deployment"
|
@@ -248,7 +275,6 @@ describe SimpleDeploy do
|
|
248
275
|
before do
|
249
276
|
@stack = SimpleDeploy::Stack.new :environment => 'test-env',
|
250
277
|
:name => 'test-stack',
|
251
|
-
:logger => 'my-logger',
|
252
278
|
:config => @config_stub,
|
253
279
|
:internal => false
|
254
280
|
@execute_mock = mock "execute"
|
@@ -270,46 +296,47 @@ describe SimpleDeploy do
|
|
270
296
|
|
271
297
|
describe "wait_for_stable" do
|
272
298
|
before do
|
299
|
+
@status_mock = mock 'status'
|
273
300
|
@stack = SimpleDeploy::Stack.new :name => 'test-stack',
|
274
|
-
:logger => 'my-logger',
|
275
301
|
:config => @config_stub,
|
276
302
|
:internal => false
|
277
|
-
@stack_mock.stub(:attributes).and_return({})
|
278
|
-
Stackster::Stack.should_receive(:new).
|
279
|
-
with(:name => 'test-stack',
|
280
|
-
:config => @environment_config_mock,
|
281
|
-
:logger => @logger_stub).
|
282
|
-
and_return @stack_mock
|
283
303
|
end
|
284
304
|
|
285
|
-
it "should call wait_for_stable on
|
286
|
-
|
305
|
+
it "should call wait_for_stable on status" do
|
306
|
+
SimpleDeploy::Status.should_receive(:new).
|
307
|
+
with(:name => 'test-stack').
|
308
|
+
and_return @status_mock
|
309
|
+
@status_mock.should_receive(:wait_for_stable)
|
310
|
+
|
287
311
|
@stack.wait_for_stable
|
288
312
|
end
|
289
313
|
end
|
290
314
|
|
291
315
|
describe "exists?" do
|
292
316
|
before do
|
317
|
+
@stack_reader_mock = mock 'stack reader'
|
293
318
|
@stack = SimpleDeploy::Stack.new :name => 'test-stack',
|
294
|
-
:logger => 'my-logger',
|
295
319
|
:config => @config_stub,
|
296
320
|
:internal => false
|
297
|
-
@stack_mock.stub(:attributes).and_return({})
|
298
|
-
Stackster::Stack.should_receive(:new).
|
299
|
-
with(:name => 'test-stack',
|
300
|
-
:config => @environment_config_mock,
|
301
|
-
:logger => @logger_stub).
|
302
|
-
and_return @stack_mock
|
303
321
|
end
|
304
322
|
|
305
323
|
it "should return true if stack exists" do
|
306
|
-
|
324
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
325
|
+
with(:name => 'test-stack').
|
326
|
+
and_return @stack_reader_mock
|
327
|
+
@stack_reader_mock.should_receive(:status).and_return('CREATE_COMPLETE')
|
328
|
+
|
307
329
|
@stack.exists?.should be_true
|
308
330
|
end
|
309
331
|
|
310
332
|
it "should return false if the stack does not exist" do
|
311
|
-
|
312
|
-
|
333
|
+
SimpleDeploy::StackReader.should_receive(:new).
|
334
|
+
with(:name => 'test-stack').
|
335
|
+
and_return @stack_reader_mock
|
336
|
+
@stack_reader_mock.should_receive(:status).
|
337
|
+
and_raise(SimpleDeploy::Exceptions::UnknownStack.new(
|
338
|
+
'Stack:test-stack does not exist'))
|
339
|
+
|
313
340
|
@stack.exists?.should be_false
|
314
341
|
end
|
315
342
|
end
|