ruby_yacht 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -5
- data/doc/TODO.md +1 -5
- data/doc/configuration.md +51 -0
- data/doc/plugins.md +4 -0
- data/lib/ruby_yacht/dsl/configuration.rb +26 -1
- data/lib/ruby_yacht/dsl/dsl.rb +35 -3
- data/lib/ruby_yacht/dsl/hook.rb +4 -0
- data/lib/ruby_yacht/dsl/project.rb +11 -0
- data/lib/ruby_yacht/images/app/Dockerfile.erb +2 -1
- data/lib/ruby_yacht/images/app/checkout.bash +1 -1
- data/lib/ruby_yacht/images/app-dependencies/Dockerfile.erb +7 -1
- data/lib/ruby_yacht/images/database/Dockerfile.erb +3 -1
- data/lib/ruby_yacht/images/database/checkout.bash +3 -4
- data/lib/ruby_yacht/images/web/Dockerfile.erb +2 -0
- data/lib/ruby_yacht/plugins/nginx.rb +5 -0
- data/lib/ruby_yacht/plugins/rails/scripts/load_seeds.rb +10 -1
- data/lib/ruby_yacht/plugins/rails/scripts/prepare_rails_for_launch.rb +1 -1
- data/lib/ruby_yacht/plugins/rails/scripts/update_rails_config.rb +6 -4
- data/lib/ruby_yacht/plugins/rails.rb +30 -17
- data/lib/ruby_yacht/plugins.rb +1 -1
- data/lib/ruby_yacht/runner/build_images.rb +5 -7
- data/lib/ruby_yacht/runner/run_containers.rb +1 -2
- data/ruby_yacht.gemspec +2 -2
- data/spec/docker/run.bash +4 -0
- data/spec/dsl/configuration_spec.rb +29 -0
- data/spec/dsl/dsl_spec.rb +56 -0
- data/spec/dsl/hook_spec.rb +28 -5
- data/spec/dsl/project_spec.rb +46 -0
- data/spec/dsl/server_type_spec.rb +3 -0
- data/spec/fixtures/app-dependencies-dockerfile-generic +3 -1
- data/spec/fixtures/app-dependencies-dockerfile-generic-with-library-install +3 -1
- data/spec/fixtures/app-dependencies-dockerfile-rails +4 -3
- data/spec/fixtures/app-dependencies-dockerfile-rails-production +35 -0
- data/spec/fixtures/app-dependencies-dockerfile-with-https-repository +25 -0
- data/spec/fixtures/app-dependencies-dockerfile-with-no-repository +2 -0
- data/spec/fixtures/database-dockerfile +1 -1
- data/spec/fixtures/database-dockerfile-mysql +1 -1
- data/spec/fixtures/database-dockerfile-rails +2 -6
- data/spec/fixtures/database-dockerfile-rails-mysql +38 -0
- data/spec/fixtures/database-dockerfile-rails-with-no-repository +1 -3
- data/spec/fixtures/database-dockerfile-with-seed-hooks +1 -1
- data/spec/fixtures/local_config.yml +8 -0
- data/spec/fixtures/mars-dockerfile +0 -1
- data/spec/fixtures/mars-dockerfile-rails +0 -1
- data/spec/fixtures/mars-dockerfile-rails-with-no-repository +0 -1
- data/spec/fixtures/mars-dockerfile-with-after-checkout-hooks +0 -1
- data/spec/fixtures/mars-dockerfile-with-before-startup-hooks +0 -1
- data/spec/fixtures/mars-dockerfile-with-custom-file-copy +0 -1
- data/spec/fixtures/mars-dockerfile-with-local-database +0 -1
- data/spec/fixtures/mars-dockerfile-with-no-repository +0 -1
- data/spec/fixtures/mars-dockerfile-with-remote-database +0 -1
- data/spec/fixtures/mars-startup-rails +1 -1
- data/spec/fixtures/mars-startup-rails-with-no-repository +1 -1
- data/spec/fixtures/web-dockerfile-nginx +3 -0
- data/spec/integration/01_normal_config_spec.rb +352 -0
- data/spec/integration/{create_new_project_spec.rb → 02_creating_new_project_spec.rb} +2 -2
- data/spec/integration/03_no_repository_spec.rb +56 -0
- data/spec/integration/04_no_database_spec.rb +58 -0
- data/spec/integration/05_https_repository_spec.rb +52 -0
- data/spec/integration/06_production_environment_spec.rb +72 -0
- data/spec/integration/07_local_checkout_spec.rb +52 -0
- data/spec/integration/08_multiple_projects_spec.rb +46 -0
- data/spec/integration/09_titular_app_spec.rb +53 -0
- data/spec/integration/10_misc_scenarios_spec.rb +97 -0
- data/spec/integration/run.rb +18 -2
- data/spec/plugins/rails_spec.rb +73 -16
- data/spec/runner/build_images_spec.rb +17 -1
- data/spec/runner/run_containers_spec.rb +3 -3
- data/spec/support/integration_helpers.rb +18 -4
- metadata +30 -20
- data/spec/integration/build_images_spec.rb +0 -210
- data/spec/integration/build_spec.rb +0 -23
- data/spec/integration/checkout_spec.rb +0 -94
- data/spec/integration/implode_spec.rb +0 -20
- data/spec/integration/run_containers_spec.rb +0 -279
- data/spec/integration/services_spec.rb +0 -99
- data/spec/integration/shell_spec.rb +0 -31
- data/spec/integration/update_hosts_spec.rb +0 -35
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RubyYacht::Runner::Build, :integration do
|
4
|
-
include IntegrationHelpers
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
configure_project
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
run_command 'build'
|
12
|
-
wait_on_command_success 'curl apollo.johnbrownlee.com'
|
13
|
-
end
|
14
|
-
|
15
|
-
after :all do
|
16
|
-
restore_hosts_file
|
17
|
-
end
|
18
|
-
|
19
|
-
it "allows accessing the containers through their hostnames" do
|
20
|
-
results = `curl apollo.johnbrownlee.com 2>&1`
|
21
|
-
expect(results).to include '<a href="http://mars.apollo.johnbrownlee.com/">'
|
22
|
-
end
|
23
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RubyYacht::Runner::Checkout, :integration do
|
4
|
-
include IntegrationHelpers
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
configure_project
|
8
|
-
run_command 'build_images'
|
9
|
-
run_command 'run_containers'
|
10
|
-
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
11
|
-
end
|
12
|
-
|
13
|
-
after :all do
|
14
|
-
IntegrationHelpers.clear_docker_containers
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'with a valid command' do
|
18
|
-
before :all do
|
19
|
-
@result = run_command 'checkout mars checkout-test-branch'
|
20
|
-
wait_on_command_result 'curl -H Host:mars.apollo.johnbrownlee.com localhost/posts -d ""', contains: '"tag":null'
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'returns true' do
|
24
|
-
expect(@result).to be_truthy
|
25
|
-
end
|
26
|
-
|
27
|
-
it "updates the code from the server" do
|
28
|
-
results = `docker exec apollo-mars ls app/controllers`.split("\n")
|
29
|
-
expect(results).to include 'users_controller.rb'
|
30
|
-
expect(results).to include 'posts_controller.rb'
|
31
|
-
end
|
32
|
-
|
33
|
-
it "runs new database migrations" do
|
34
|
-
results = run_command_in_docker(:mars, 'mysql -uapollo -ptestpass -hapollo-database -e "show fields from apollo.posts"').split("\n")
|
35
|
-
expect(results).to include "tag\tvarchar(255)\tYES\t\tNULL\t"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "starts the server with the new code base" do
|
39
|
-
results = `docker exec apollo-mars curl localhost:8080/posts -d "user_id=1&title=First%20Post&contents=Hello,%20World&tag=party" 2>&1`
|
40
|
-
expect(results).to include '"tag":"party"'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'with a local checkout folder' do
|
45
|
-
before :all do
|
46
|
-
run_command 'build_images', environment: { CHECK_OUT_LOCALLY: 1 }
|
47
|
-
run_command 'run_containers', environment: { CHECK_OUT_LOCALLY: 1 }
|
48
|
-
run_command 'checkout mars checkout-test-branch', environment: { CHECK_OUT_LOCALLY: 1 }
|
49
|
-
end
|
50
|
-
|
51
|
-
it "updates the code from the server" do
|
52
|
-
results = `ls ../mars/app/controllers`.split("\n")
|
53
|
-
expect(results).to include 'users_controller.rb'
|
54
|
-
expect(results).to include 'posts_controller.rb'
|
55
|
-
end
|
56
|
-
|
57
|
-
after :all do
|
58
|
-
IntegrationHelpers.clear_docker_containers
|
59
|
-
IntegrationHelpers.clear_checkout_folders
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'with a production environment' do
|
64
|
-
before :all do
|
65
|
-
run_command 'build_images', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
66
|
-
run_command 'run_containers', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
67
|
-
run_command 'checkout mars master', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
68
|
-
end
|
69
|
-
|
70
|
-
it "does not install any non-production gems" do
|
71
|
-
gems = `docker exec -it apollo-mars gem list`
|
72
|
-
expect(gems).to include 'mysql2'
|
73
|
-
expect(gems).not_to include 'byebug'
|
74
|
-
end
|
75
|
-
|
76
|
-
after :all do
|
77
|
-
IntegrationHelpers.clear_docker_containers
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'with no branch' do
|
82
|
-
it 'returns false' do
|
83
|
-
result = run_command 'checkout mars'
|
84
|
-
expect(result).to be_falsey
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'with no app name' do
|
89
|
-
it 'returns false' do
|
90
|
-
result = run_command 'checkout'
|
91
|
-
expect(result).to be_falsey
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RubyYacht::Runner::Implode, :integration do
|
4
|
-
include IntegrationHelpers
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
configure_project
|
8
|
-
run_command 'build'
|
9
|
-
run_command 'run_containers'
|
10
|
-
run_command 'implode'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'removes all the images and containers' do
|
14
|
-
containers = `docker ps -a | grep apollo`
|
15
|
-
expect(containers).to eq ''
|
16
|
-
|
17
|
-
images = `docker images -a | grep apollo`
|
18
|
-
expect(images).to eq ''
|
19
|
-
end
|
20
|
-
end
|
@@ -1,279 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RubyYacht::Runner::RunContainers, :integration do
|
4
|
-
include IntegrationHelpers
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
configure_project
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:containers) { `docker ps | grep "apollo\\|jupiter"`.split("\n").collect { |line| line.split(/\s+/).last }.sort }
|
11
|
-
|
12
|
-
context 'with the normal settings' do
|
13
|
-
before :all do
|
14
|
-
run_command 'build_images'
|
15
|
-
run_command 'run_containers'
|
16
|
-
|
17
|
-
wait_on_command_success 'curl localhost'
|
18
|
-
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
19
|
-
wait_on_command_result 'curl -I -H Host:saturn.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
20
|
-
end
|
21
|
-
|
22
|
-
after :all do
|
23
|
-
IntegrationHelpers.clear_docker_containers
|
24
|
-
end
|
25
|
-
|
26
|
-
it "starts all the containers" do
|
27
|
-
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "makes the app servers accessible from the web server" do
|
31
|
-
results = run_command_in_docker :web, 'bash -c "apt-get install -y curl 2>&1; curl apollo-mars:8080/users 2>&1"'
|
32
|
-
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "makes the web server accessible from the host machine" do
|
36
|
-
results = `curl -H Host:apollo.johnbrownlee.com localhost 2>&1`
|
37
|
-
expect(results).to include '<a href="http://mars.apollo.johnbrownlee.com/">'
|
38
|
-
end
|
39
|
-
|
40
|
-
it "makes the app servers accessible from the host machine through the web server" do
|
41
|
-
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
42
|
-
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
43
|
-
|
44
|
-
results = `curl -H Host:saturn.apollo.johnbrownlee.com localhost 2>&1`
|
45
|
-
expect(results).to include 'Welcome to Saturn'
|
46
|
-
end
|
47
|
-
|
48
|
-
it "does not generate static assets" do
|
49
|
-
results = `docker exec -it apollo-mars ls /var/code/public`
|
50
|
-
expect(results).not_to include 'assets'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'with no database server' do
|
55
|
-
before :all do
|
56
|
-
run_command 'build_images', environment: { SKIP_DATABASE: 1 }
|
57
|
-
run_command 'run_containers', environment: { SKIP_DATABASE: 1 }
|
58
|
-
end
|
59
|
-
|
60
|
-
after :all do
|
61
|
-
IntegrationHelpers.clear_docker_containers
|
62
|
-
end
|
63
|
-
|
64
|
-
it "starts all the containers except the database server" do
|
65
|
-
expect(containers).to eq %w(apollo-mars apollo-saturn apollo-web)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "allows the apps to use their local sqlite databases" do
|
69
|
-
results = `docker exec -it apollo-mars rails r 'puts User.count'`
|
70
|
-
expect(results).to eq "0\r\n"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'with the apps checked out locally' do
|
75
|
-
before :all do
|
76
|
-
run_command 'build_images', environment: { CHECK_OUT_LOCALLY: 1 }
|
77
|
-
run_command 'run_containers', environment: { CHECK_OUT_LOCALLY: 1 }
|
78
|
-
end
|
79
|
-
|
80
|
-
after :all do
|
81
|
-
IntegrationHelpers.clear_docker_containers
|
82
|
-
IntegrationHelpers.clear_checkout_folders
|
83
|
-
end
|
84
|
-
|
85
|
-
it "starts all the containers" do
|
86
|
-
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "checks out the code to a local directory" do
|
90
|
-
results = `ls ..`.split("\n")
|
91
|
-
expect(results).to include "mars"
|
92
|
-
expect(results).to include "saturn"
|
93
|
-
|
94
|
-
results = `ls ../mars`.split("\n")
|
95
|
-
expect(results).to include 'app'
|
96
|
-
expect(results).to include 'Gemfile'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'with DNS server config' do
|
101
|
-
before :all do
|
102
|
-
run_command 'build_images', environment: { CONFIGURE_DNS: 1 }
|
103
|
-
run_command 'run_containers', environment: { CONFIGURE_DNS: 1 }
|
104
|
-
end
|
105
|
-
|
106
|
-
after :all do
|
107
|
-
IntegrationHelpers.clear_docker_containers
|
108
|
-
end
|
109
|
-
|
110
|
-
it "puts the custom config in the DNS server config" do
|
111
|
-
results = `docker exec apollo-mars cat /etc/resolv.conf`
|
112
|
-
expect(results).to include 'dns1.test.com'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
context 'with a production environment' do
|
117
|
-
before :all do
|
118
|
-
run_command 'build_images', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
119
|
-
run_command 'run_containers', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
120
|
-
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost/users', contains: '200 OK'
|
121
|
-
end
|
122
|
-
|
123
|
-
after :all do
|
124
|
-
IntegrationHelpers.clear_docker_containers
|
125
|
-
end
|
126
|
-
|
127
|
-
it "starts all the containers" do
|
128
|
-
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
129
|
-
end
|
130
|
-
|
131
|
-
it "generates static assets" do
|
132
|
-
results = `docker exec -it apollo-mars ls /var/code/public/assets`
|
133
|
-
expect(results).to include 'application-89720f5a46589c09bfd16b3e1c7c509bba7d6a3c3dd4f3a8e13e0d05a0fbf9c1.js'
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'with a primary app' do
|
138
|
-
before :all do
|
139
|
-
run_command 'build_images', environment: { CREATE_PRIMARY_APP: 1 }
|
140
|
-
run_command 'run_containers', environment: { CREATE_PRIMARY_APP: 1 }
|
141
|
-
wait_on_command_result 'curl -I -H Host:apollo.johnbrownlee.com localhost', contains: '200 OK'
|
142
|
-
wait_on_command_result 'curl -I -H Host:saturn.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
143
|
-
end
|
144
|
-
|
145
|
-
after :all do
|
146
|
-
IntegrationHelpers.clear_docker_containers
|
147
|
-
end
|
148
|
-
|
149
|
-
it "starts all the containers" do
|
150
|
-
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
151
|
-
end
|
152
|
-
|
153
|
-
it "makes the web server accessible from the host machine" do
|
154
|
-
results = `curl -H Host:apollo.johnbrownlee.com localhost/users 2>&1`
|
155
|
-
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
156
|
-
end
|
157
|
-
|
158
|
-
it "makes the main app accessible from the host machine through the web server" do
|
159
|
-
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
160
|
-
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
161
|
-
end
|
162
|
-
|
163
|
-
it "makes the secondary app accessible" do
|
164
|
-
results = `curl -H Host:saturn.apollo.johnbrownlee.com localhost 2>&1`
|
165
|
-
expect(results).to include 'Welcome to Saturn'
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context "with an app with the same name as the project" do
|
170
|
-
before :all do
|
171
|
-
run_command 'build_images', environment: { CREATE_TITULAR_APP: 1 }
|
172
|
-
run_command 'run_containers', environment: { CREATE_TITULAR_APP: 1 }
|
173
|
-
wait_on_command_result 'curl -I -H Host:apollo.johnbrownlee.com localhost', contains: '200 OK'
|
174
|
-
wait_on_command_result 'curl -I -H Host:saturn.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
175
|
-
end
|
176
|
-
|
177
|
-
after :all do
|
178
|
-
system "docker rm -f apollo 1> /dev/null"
|
179
|
-
system "docker rmi apollo 1> /dev/null"
|
180
|
-
IntegrationHelpers.clear_docker_containers
|
181
|
-
end
|
182
|
-
|
183
|
-
it "starts all the containers" do
|
184
|
-
expect(containers).to eq %w(apollo apollo-database apollo-saturn apollo-web)
|
185
|
-
end
|
186
|
-
|
187
|
-
it "makes the web server accessible from the host machine" do
|
188
|
-
results = `curl -H Host:apollo.johnbrownlee.com localhost/users 2>&1`
|
189
|
-
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
190
|
-
end
|
191
|
-
|
192
|
-
it "makes the secondary app accessible" do
|
193
|
-
results = `curl -H Host:saturn.apollo.johnbrownlee.com localhost 2>&1`
|
194
|
-
expect(results).to include 'Welcome to Saturn'
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context "with a second project" do
|
199
|
-
before :all do
|
200
|
-
run_command 'build_images', environment: { CREATE_SECOND_PROJECT: 1 }
|
201
|
-
run_command 'run_containers', environment: { CREATE_SECOND_PROJECT: 1 }
|
202
|
-
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
203
|
-
wait_on_command_result 'curl -I -H Host:saturn.jupiter.johnbrownlee.com localhost:8080', contains: '200 OK'
|
204
|
-
end
|
205
|
-
|
206
|
-
after :all do
|
207
|
-
IntegrationHelpers.clear_docker_containers
|
208
|
-
|
209
|
-
IntegrationHelpers.image_names.select { |name| name =~ /jupiter/ }.each do |name|
|
210
|
-
`docker rmi #{name} 1> /dev/null`
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
it "starts all the containers" do
|
215
|
-
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web jupiter-database jupiter-saturn jupiter-web)
|
216
|
-
end
|
217
|
-
|
218
|
-
it "makes the apps for both projects accessible" do
|
219
|
-
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
220
|
-
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
221
|
-
|
222
|
-
results = `curl -H Host:saturn.jupiter.johnbrownlee.com localhost:8080 2>&1`
|
223
|
-
expect(results).to include 'Welcome to Saturn'
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
context 'with no repository name' do
|
228
|
-
before :all do
|
229
|
-
run_command 'build_images', environment: { NO_REPOSITORY: 1, CHECK_OUT_LOCALLY: 1, SKIP_DATABASE: 1 }
|
230
|
-
run_command 'run_containers', environment: { NO_REPOSITORY: 1, CHECK_OUT_LOCALLY: 1, SKIP_DATABASE: 1 }
|
231
|
-
|
232
|
-
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
233
|
-
wait_on_command_result 'curl -I -H Host:saturn.jupiter.johnbrownlee.com localhost', contains: '200 OK'
|
234
|
-
end
|
235
|
-
|
236
|
-
after :all do
|
237
|
-
IntegrationHelpers.clear_docker_containers
|
238
|
-
FileUtils.rm_rf '../mars'
|
239
|
-
FileUtils.rm_rf '../saturn'
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'starts all the containers' do
|
243
|
-
expect(containers).to eq %w(apollo-mars apollo-saturn apollo-web)
|
244
|
-
end
|
245
|
-
|
246
|
-
it "brings up the app servers" do
|
247
|
-
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost 2>&1`
|
248
|
-
expect(results).to include 'Ruby on Rails: Welcome aboard'
|
249
|
-
end
|
250
|
-
|
251
|
-
it "checks out the code to a local directory" do
|
252
|
-
results = `ls ../mars`.split("\n")
|
253
|
-
expect(results).to include "app"
|
254
|
-
expect(results).to include "Gemfile"
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
context 'with a non-standard database port' do
|
259
|
-
before :all do
|
260
|
-
run_command 'build_images', environment: { USE_NONSTANDARD_MYSQL_PORT: 1 }
|
261
|
-
run_command 'run_containers', environment: { USE_NONSTANDARD_MYSQL_PORT: 1 }
|
262
|
-
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost/users', contains: '200 OK'
|
263
|
-
end
|
264
|
-
|
265
|
-
after :all do
|
266
|
-
IntegrationHelpers.clear_docker_containers
|
267
|
-
end
|
268
|
-
|
269
|
-
it 'sets up the database to listen on that port' do
|
270
|
-
results = run_command_in_docker :mars, 'mysql -uapollo -ptestpass -hapollo-database -P3333 apollo 2>&1'
|
271
|
-
expect(results).not_to include 'ERROR'
|
272
|
-
end
|
273
|
-
|
274
|
-
it 'allows the app to connect to the database on that port' do
|
275
|
-
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
276
|
-
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
277
|
-
end
|
278
|
-
end
|
279
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RubyYacht::Runner::Services, :integration do
|
4
|
-
include IntegrationHelpers
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
configure_project
|
8
|
-
run_command 'build_images'
|
9
|
-
run_command 'run_containers'
|
10
|
-
end
|
11
|
-
|
12
|
-
after :all do
|
13
|
-
IntegrationHelpers.clear_docker_containers
|
14
|
-
end
|
15
|
-
|
16
|
-
context "with the start command" do
|
17
|
-
before do
|
18
|
-
IntegrationHelpers.image_names.each do |image|
|
19
|
-
system "docker stop #{image} 1> /dev/null 2> /dev/null"
|
20
|
-
end
|
21
|
-
|
22
|
-
@result = run_command 'services start'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns a success" do
|
26
|
-
expect(@result).to be_truthy
|
27
|
-
end
|
28
|
-
|
29
|
-
it "starts the containers" do
|
30
|
-
results = `docker ps | grep apollo`.split("\n")
|
31
|
-
results = results.collect { |line| line.split(/\s+/).last }
|
32
|
-
results.sort!
|
33
|
-
|
34
|
-
expect(results).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "with the stop command" do
|
39
|
-
before do
|
40
|
-
IntegrationHelpers.image_names.each do |image|
|
41
|
-
system "docker start #{image} 1> /dev/null 2> /dev/null"
|
42
|
-
end
|
43
|
-
|
44
|
-
@result = run_command 'services stop'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns a success" do
|
48
|
-
expect(@result).to be_truthy
|
49
|
-
end
|
50
|
-
|
51
|
-
it "stops the containers" do
|
52
|
-
results = `docker ps | grep apollo`
|
53
|
-
expect(results).to eq ''
|
54
|
-
|
55
|
-
results = `docker ps -a | grep apollo`.split("\n")
|
56
|
-
results = results.collect { |line| line.split(/\s+/).last }
|
57
|
-
results.sort!
|
58
|
-
|
59
|
-
expect(results).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'with no database' do
|
64
|
-
before do
|
65
|
-
IntegrationHelpers.image_names.each do |image|
|
66
|
-
system "docker stop #{image} 1> /dev/null 2> /dev/null"
|
67
|
-
end
|
68
|
-
|
69
|
-
@result = run_command 'services start', environment: { SKIP_DATABASE: 1 }
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'does not start the database image' do
|
73
|
-
results = `docker ps | grep apollo`.split("\n")
|
74
|
-
results = results.collect { |line| line.split(/\s+/).last }
|
75
|
-
results.sort!
|
76
|
-
expect(results).to eq %w(apollo-mars apollo-saturn apollo-web)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "with an invalid command" do
|
81
|
-
before do
|
82
|
-
@result = run_command 'services crash'
|
83
|
-
end
|
84
|
-
|
85
|
-
it "returns a failure" do
|
86
|
-
expect(@result).to be_falsey
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context "with no command" do
|
91
|
-
before do
|
92
|
-
@result = run_command 'services'
|
93
|
-
end
|
94
|
-
|
95
|
-
it "returns a failure" do
|
96
|
-
expect(@result).to be_falsey
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|