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,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe
|
3
|
+
RSpec.describe 'creating new project', :integration do
|
4
4
|
include IntegrationHelpers
|
5
5
|
|
6
6
|
def run_command(command, environment: {}, capture_output: false)
|
@@ -17,7 +17,6 @@ RSpec.describe RubyYacht::Runner::CreateNewProject, :integration do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
before :all do
|
20
|
-
configure_project
|
21
20
|
run_command 'ruby_yacht new apollo ../apollo-config'
|
22
21
|
run_command 'cd ../apollo-config; ruby run.rb build'
|
23
22
|
wait_on_command_result 'curl -I -H Host:apollo.test.com localhost', contains: '200 OK'
|
@@ -25,6 +24,7 @@ RSpec.describe RubyYacht::Runner::CreateNewProject, :integration do
|
|
25
24
|
|
26
25
|
after :all do
|
27
26
|
IntegrationHelpers.clear_docker_containers
|
27
|
+
system "docker rmi apollo 1> /dev/null 2> /dev/null"
|
28
28
|
restore_hosts_file
|
29
29
|
FileUtils.rm_rf '../apollo-config'
|
30
30
|
FileUtils.rm_rf '../apollo'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'project with no repository', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
system 'docker rmi apollo-database 1> /dev/null 2> /dev/null'
|
8
|
+
run_command 'build_images', environment: { NO_REPOSITORY: 1, CHECK_OUT_LOCALLY: 1, SKIP_DATABASE: 1 }
|
9
|
+
end
|
10
|
+
|
11
|
+
after :all do
|
12
|
+
IntegrationHelpers.clear_docker_containers
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'building images' do
|
16
|
+
it 'creates images for the app, dependencies, and web server' do
|
17
|
+
expect(images).to eq ['apollo-mars', 'apollo-rails-app-dependencies', 'apollo-saturn', 'apollo-web']
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'creates a fresh app in the app image' do
|
21
|
+
results = run_command_in_docker :mars, 'ls /var/code'
|
22
|
+
expect(results).to include 'app'
|
23
|
+
expect(results).to include 'Gemfile'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'running containers' do
|
28
|
+
before :all do
|
29
|
+
run_command 'run_containers', environment: { NO_REPOSITORY: 1, CHECK_OUT_LOCALLY: 1, SKIP_DATABASE: 1 }
|
30
|
+
|
31
|
+
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
32
|
+
wait_on_command_result 'curl -I -H Host:saturn.jupiter.johnbrownlee.com localhost', contains: '200 OK'
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
IntegrationHelpers.clear_docker_containers
|
37
|
+
FileUtils.rm_rf '../mars'
|
38
|
+
FileUtils.rm_rf '../saturn'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'starts all the containers' do
|
42
|
+
expect(containers).to eq %w(apollo-mars apollo-saturn apollo-web)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "brings up the app servers" do
|
46
|
+
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost 2>&1`
|
47
|
+
expect(results).to include 'Ruby on Rails: Welcome aboard'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "checks out the code to a local directory" do
|
51
|
+
results = `ls ../mars`.split("\n")
|
52
|
+
expect(results).to include "app"
|
53
|
+
expect(results).to include "Gemfile"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'project with no database', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
system "docker rmi apollo-database 1> /dev/null 2> /dev/null"
|
8
|
+
run_command 'build_images', environment: { SKIP_DATABASE: 1 }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'building images' do
|
12
|
+
it "does not build a database image" do
|
13
|
+
expect(images).to eq ['apollo-mars', 'apollo-rails-app-dependencies', 'apollo-saturn', 'apollo-web']
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'does not install mysql on the app servers' do
|
17
|
+
results = run_command_in_docker :mars, 'which mysql'
|
18
|
+
expect(results).to eq ''
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'running containers' do
|
23
|
+
before :all do
|
24
|
+
run_command 'run_containers', environment: { SKIP_DATABASE: 1 }
|
25
|
+
end
|
26
|
+
|
27
|
+
after :all do
|
28
|
+
IntegrationHelpers.clear_docker_containers
|
29
|
+
end
|
30
|
+
|
31
|
+
it "starts all the containers except the database server" do
|
32
|
+
expect(containers).to eq %w(apollo-mars apollo-saturn apollo-web)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "allows the apps to use their local sqlite databases" do
|
36
|
+
results = `docker exec -it apollo-mars rails r 'puts User.count'`
|
37
|
+
expect(results).to eq "0\r\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'starting services' do
|
42
|
+
before do
|
43
|
+
IntegrationHelpers.image_names.each do |image|
|
44
|
+
system "docker stop #{image} 1> /dev/null 2> /dev/null"
|
45
|
+
end
|
46
|
+
|
47
|
+
run_command 'run_containers', environment: { SKIP_DATABASE: 1 }
|
48
|
+
run_command 'services start', environment: { SKIP_DATABASE: 1 }
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'does not start the database image' do
|
52
|
+
results = `docker ps | grep apollo`.split("\n")
|
53
|
+
results = results.collect { |line| line.split(/\s+/).last }
|
54
|
+
results.sort!
|
55
|
+
expect(results).to eq %w(apollo-mars apollo-saturn apollo-web)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'project with HTTPS repository', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
run_command 'build_images', environment: { HTTPS_REPOSITORY: 1 }
|
8
|
+
end
|
9
|
+
|
10
|
+
after :all do
|
11
|
+
IntegrationHelpers.clear_docker_containers
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'building images' do
|
15
|
+
it 'creates images for the app, dependencies, database, and web server' do
|
16
|
+
expect(images).to eq ['apollo-database', 'apollo-mars', 'apollo-rails-app-dependencies', 'apollo-saturn', 'apollo-web']
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'puts the HTTPS repository in the REPOSITORY_HOST environment variable' do
|
20
|
+
results = run_command_in_docker :mars, "bash -c 'echo $REPOSITORY_HOST'"
|
21
|
+
expect(results).to eq "https://github.com\n"
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'checks out the app in the app image' do
|
25
|
+
results = run_command_in_docker :mars, 'ls /var/code/app/models'
|
26
|
+
expect(results).to include 'user.rb'
|
27
|
+
expect(results).to include 'post.rb'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'running containers' do
|
32
|
+
before :all do
|
33
|
+
run_command 'run_containers', environment: { HTTPS_REPOSITORY: 1 }
|
34
|
+
|
35
|
+
wait_on_command_success 'curl localhost'
|
36
|
+
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
37
|
+
wait_on_command_result 'curl -I -H Host:saturn.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "starts all the containers" do
|
41
|
+
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "makes the app servers accessible from the host machine" do
|
45
|
+
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
46
|
+
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
47
|
+
|
48
|
+
results = `curl -H Host:saturn.apollo.johnbrownlee.com localhost 2>&1`
|
49
|
+
expect(results).to include 'Welcome to Saturn'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'project with production environment', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
run_command 'build_images', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
8
|
+
end
|
9
|
+
|
10
|
+
after :all do
|
11
|
+
IntegrationHelpers.clear_docker_containers
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'building images' do
|
15
|
+
it "does not install the non-production gems" do
|
16
|
+
results = run_command_in_docker 'rails-app-dependencies', 'gem list'
|
17
|
+
expect(results).to include 'mysql2'
|
18
|
+
expect(results).not_to include 'byebug'
|
19
|
+
expect(results).not_to include 'factory_girl'
|
20
|
+
|
21
|
+
results = run_command_in_docker :mars, 'gem list'
|
22
|
+
expect(results).to include 'mysql2'
|
23
|
+
expect(results).not_to include 'byebug'
|
24
|
+
expect(results).not_to include 'factory_girl'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "does not create a test database" do
|
28
|
+
start_database
|
29
|
+
results = run_command_in_docker :mars, 'mysql -uapollo -ptestpass -hapollo-database apollo_test 2>&1'
|
30
|
+
expect(results).to include 'ERROR'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'sets the RAILS_ENV variable' do
|
34
|
+
results = run_command_in_docker :mars, 'env'
|
35
|
+
expect(results).to include "RAILS_ENV=production"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'running containers' do
|
40
|
+
before :all do
|
41
|
+
run_command 'run_containers', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
42
|
+
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost/users', contains: '200 OK'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "starts all the containers" do
|
46
|
+
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "generates static assets" do
|
50
|
+
results = `docker exec -it apollo-mars ls /var/code/public/assets`
|
51
|
+
expect(results).to include 'application-89720f5a46589c09bfd16b3e1c7c509bba7d6a3c3dd4f3a8e13e0d05a0fbf9c1.js'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'starts the server in production mode' do
|
55
|
+
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/bad/path 2>&1`
|
56
|
+
expect(results).to include "<title>The page you were looking for doesn't exist (404)</title>"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'checking out new branches' do
|
61
|
+
before :all do
|
62
|
+
run_command 'run_containers', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
63
|
+
run_command 'checkout mars master', environment: { USE_PRODUCTION_ENVIRONMENT: 1 }
|
64
|
+
end
|
65
|
+
|
66
|
+
it "does not install any non-production gems" do
|
67
|
+
gems = `docker exec -it apollo-mars gem list`
|
68
|
+
expect(gems).to include 'mysql2'
|
69
|
+
expect(gems).not_to include 'byebug'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'project with a local checkout folder', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
run_command 'build_images', environment: { CHECK_OUT_LOCALLY: 1 }
|
8
|
+
end
|
9
|
+
|
10
|
+
after :all do
|
11
|
+
IntegrationHelpers.clear_docker_containers
|
12
|
+
IntegrationHelpers.clear_checkout_folders
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'running containers' do
|
16
|
+
before :all do
|
17
|
+
run_command 'run_containers', environment: { CHECK_OUT_LOCALLY: 1 }
|
18
|
+
end
|
19
|
+
|
20
|
+
it "starts all the containers" do
|
21
|
+
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "checks out the code to a local directory" do
|
25
|
+
results = `ls ..`.split("\n")
|
26
|
+
expect(results).to include "mars"
|
27
|
+
expect(results).to include "saturn"
|
28
|
+
|
29
|
+
results = `ls ../mars`.split("\n")
|
30
|
+
expect(results).to include 'app'
|
31
|
+
expect(results).to include 'Gemfile'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'checking out new branches' do
|
36
|
+
before :all do
|
37
|
+
run_command 'run_containers', environment: { CHECK_OUT_LOCALLY: 1 }
|
38
|
+
run_command 'checkout mars checkout-test-branch', environment: { CHECK_OUT_LOCALLY: 1 }
|
39
|
+
end
|
40
|
+
|
41
|
+
it "updates the code from the server" do
|
42
|
+
results = `ls ../mars/app/controllers`.split("\n")
|
43
|
+
expect(results).to include 'users_controller.rb'
|
44
|
+
expect(results).to include 'posts_controller.rb'
|
45
|
+
end
|
46
|
+
|
47
|
+
after :all do
|
48
|
+
IntegrationHelpers.clear_docker_containers
|
49
|
+
IntegrationHelpers.clear_checkout_folders
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'project with a multiple projects', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
run_command 'build_images', environment: { CREATE_SECOND_PROJECT: 1 }
|
8
|
+
end
|
9
|
+
|
10
|
+
after :all do
|
11
|
+
IntegrationHelpers.clear_docker_containers
|
12
|
+
IntegrationHelpers.image_names.select { |name| name =~ /jupiter/ }.each do |name|
|
13
|
+
`docker rmi #{name} 1> /dev/null`
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "running containers" do
|
18
|
+
before :all do
|
19
|
+
run_command 'run_containers', environment: { CREATE_SECOND_PROJECT: 1 }
|
20
|
+
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
21
|
+
wait_on_command_result 'curl -I -H Host:saturn.jupiter.johnbrownlee.com localhost:8080', contains: '200 OK'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "starts all the containers" do
|
25
|
+
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web jupiter-database jupiter-saturn jupiter-web)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'makes the apps for both projects accessible' do
|
29
|
+
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
30
|
+
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
31
|
+
|
32
|
+
results = `curl -H Host:saturn.jupiter.johnbrownlee.com localhost:8080 2>&1`
|
33
|
+
expect(results).to include 'Welcome to Saturn'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'makes the apps accessible within projects' do
|
37
|
+
results = `docker exec -it apollo-mars curl apollo-saturn:8080`
|
38
|
+
expect(results).to include 'Welcome to Saturn'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'does not make the apps accessible from one project to another' do
|
42
|
+
results = `docker exec -it apollo-mars curl jupiter-saturn:8080`
|
43
|
+
expect(results).to include 'Could not resolve host: jupiter-saturn'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'project with an app with the same name', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
system "docker rmi apollo-mars 1> /dev/null 2> /dev/null"
|
8
|
+
run_command 'build_images', environment: { CREATE_TITULAR_APP: 1 }
|
9
|
+
end
|
10
|
+
|
11
|
+
after :all do
|
12
|
+
system "docker rmi apollo 1> /dev/null 2> /dev/null"
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "building images" do
|
16
|
+
it "creates an image with the same name as the project" do
|
17
|
+
expect(images).to eq ['apollo', 'apollo-database', 'apollo-rails-app-dependencies', 'apollo-saturn', 'apollo-web']
|
18
|
+
end
|
19
|
+
|
20
|
+
it "checks out the app onto the image" do
|
21
|
+
results = `docker run --rm apollo ls /var/code/app/models`
|
22
|
+
expect(results).to include 'user.rb'
|
23
|
+
expect(results).to include 'post.rb'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "running containers" do
|
28
|
+
before :all do
|
29
|
+
run_command 'run_containers', environment: { CREATE_TITULAR_APP: 1 }
|
30
|
+
wait_on_command_result 'curl -I -H Host:apollo.johnbrownlee.com localhost', contains: '200 OK'
|
31
|
+
wait_on_command_result 'curl -I -H Host:saturn.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
32
|
+
end
|
33
|
+
|
34
|
+
after :all do
|
35
|
+
system "docker rm -f apollo 1> /dev/null"
|
36
|
+
IntegrationHelpers.clear_docker_containers
|
37
|
+
end
|
38
|
+
|
39
|
+
it "starts all the containers" do
|
40
|
+
expect(containers).to eq %w(apollo apollo-database apollo-saturn apollo-web)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "makes the web server accessible from the host machine" do
|
44
|
+
results = `curl -H Host:apollo.johnbrownlee.com localhost/users 2>&1`
|
45
|
+
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "makes the secondary app accessible" do
|
49
|
+
results = `curl -H Host:saturn.apollo.johnbrownlee.com localhost 2>&1`
|
50
|
+
expect(results).to include 'Welcome to Saturn'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'miscellaneous scenarios', :integration do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
context 'with DNS server config' do
|
7
|
+
before :all do
|
8
|
+
run_command 'build_images', environment: { CONFIGURE_DNS: 1 }
|
9
|
+
run_command 'run_containers', environment: { CONFIGURE_DNS: 1 }
|
10
|
+
end
|
11
|
+
|
12
|
+
after :all do
|
13
|
+
IntegrationHelpers.clear_docker_containers
|
14
|
+
end
|
15
|
+
|
16
|
+
it "puts the custom config in the DNS server config" do
|
17
|
+
results = `docker exec apollo-mars cat /etc/resolv.conf`
|
18
|
+
expect(results).to include 'dns1.test.com'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with a primary app' do
|
23
|
+
before :all do
|
24
|
+
run_command 'build_images', environment: { CREATE_PRIMARY_APP: 1 }
|
25
|
+
run_command 'run_containers', environment: { CREATE_PRIMARY_APP: 1 }
|
26
|
+
wait_on_command_result 'curl -I -H Host:apollo.johnbrownlee.com localhost', contains: '200 OK'
|
27
|
+
wait_on_command_result 'curl -I -H Host:saturn.apollo.johnbrownlee.com localhost', contains: '200 OK'
|
28
|
+
end
|
29
|
+
|
30
|
+
after :all do
|
31
|
+
IntegrationHelpers.clear_docker_containers
|
32
|
+
end
|
33
|
+
|
34
|
+
it "starts all the containers" do
|
35
|
+
expect(containers).to eq %w(apollo-database apollo-mars apollo-saturn apollo-web)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "makes the web server accessible from the host machine" do
|
39
|
+
results = `curl -H Host:apollo.johnbrownlee.com localhost/users 2>&1`
|
40
|
+
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "makes the main app accessible from the host machine through the web server" do
|
44
|
+
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
45
|
+
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "makes the secondary app accessible" do
|
49
|
+
results = `curl -H Host:saturn.apollo.johnbrownlee.com localhost 2>&1`
|
50
|
+
expect(results).to include 'Welcome to Saturn'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with a non-standard database port' do
|
55
|
+
before :all do
|
56
|
+
run_command 'build_images', environment: { USE_NONSTANDARD_MYSQL_PORT: 1 }
|
57
|
+
run_command 'run_containers', environment: { USE_NONSTANDARD_MYSQL_PORT: 1 }
|
58
|
+
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost/users', contains: '200 OK'
|
59
|
+
end
|
60
|
+
|
61
|
+
after :all do
|
62
|
+
IntegrationHelpers.clear_docker_containers
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'sets up the database to listen on that port' do
|
66
|
+
results = run_command_in_docker :mars, 'mysql -uapollo -ptestpass -hapollo-database -P3333 apollo 2>&1'
|
67
|
+
expect(results.downcase).not_to include 'error'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'allows the app to connect to the database on that port' do
|
71
|
+
results = `curl -H Host:mars.apollo.johnbrownlee.com localhost/users 2>&1`
|
72
|
+
expect(results).to include 'test_user@mars.apollo.johnbrownlee.com'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'with config from a local file' do
|
77
|
+
before :all do
|
78
|
+
run_command 'build_images', environment: { USE_LOCAL_CONFIG: 1 }
|
79
|
+
run_command 'run_containers', environment: { USE_LOCAL_CONFIG: 1 }
|
80
|
+
wait_on_command_result 'curl -I -H Host:mars.apollo.johnbrownlee.com localhost/users', contains: '200 OK'
|
81
|
+
end
|
82
|
+
|
83
|
+
after :all do
|
84
|
+
IntegrationHelpers.clear_docker_containers
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'allows connecting to the database with that local config' do
|
88
|
+
results = run_command_in_docker :mars, 'mysql -ujupiter -pjupiterpass -hapollo-database apollo 2>&1'
|
89
|
+
expect(results.downcase).not_to include 'error'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'sets the rails environment to the one in the file' do
|
93
|
+
results = run_command_in_docker :mars, 'env'
|
94
|
+
expect(results).to include 'RAILS_ENV=production'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|