infrataster 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +133 -0
  6. data/Rakefile +1 -0
  7. data/example/.gitignore +4 -0
  8. data/example/.rspec +2 -0
  9. data/example/Berksfile +2 -0
  10. data/example/Gemfile +8 -0
  11. data/example/README.md +13 -0
  12. data/example/Vagrantfile +81 -0
  13. data/example/cookbooks/app/recipes/default.rb +36 -0
  14. data/example/cookbooks/db/files/default/my.cnf +127 -0
  15. data/example/cookbooks/db/recipes/default.rb +14 -0
  16. data/example/cookbooks/proxy/metadata.rb +1 -0
  17. data/example/cookbooks/proxy/recipes/default.rb +26 -0
  18. data/example/cookbooks/proxy/templates/default/app.erb +13 -0
  19. data/example/cookbooks/proxy/templates/default/static.erb +14 -0
  20. data/example/sinatra_app/.gitignore +1 -0
  21. data/example/sinatra_app/Gemfile +5 -0
  22. data/example/sinatra_app/app.rb +6 -0
  23. data/example/sinatra_app/config.ru +2 -0
  24. data/example/spec/spec_helper.rb +31 -0
  25. data/example/spec/web_spec.rb +64 -0
  26. data/infrataster.gemspec +30 -0
  27. data/lib/infrataster/browsermob_proxy.rb +31 -0
  28. data/lib/infrataster/contexts/base_context.rb +14 -0
  29. data/lib/infrataster/contexts/capybara_context.rb +56 -0
  30. data/lib/infrataster/contexts/http_context.rb +20 -0
  31. data/lib/infrataster/contexts/mysql_query_context.rb +26 -0
  32. data/lib/infrataster/contexts.rb +36 -0
  33. data/lib/infrataster/helpers/rspec_helper.rb +15 -0
  34. data/lib/infrataster/helpers/type_helper.rb +24 -0
  35. data/lib/infrataster/helpers.rb +4 -0
  36. data/lib/infrataster/rspec.rb +17 -0
  37. data/lib/infrataster/server.rb +125 -0
  38. data/lib/infrataster/types/base_type.rb +15 -0
  39. data/lib/infrataster/types/capybara_type.rb +21 -0
  40. data/lib/infrataster/types/http_type.rb +24 -0
  41. data/lib/infrataster/types/mysql_query_type.rb +21 -0
  42. data/lib/infrataster/types/server_type.rb +25 -0
  43. data/lib/infrataster/types.rb +5 -0
  44. data/lib/infrataster/version.rb +3 -0
  45. data/lib/infrataster.rb +12 -0
  46. metadata +214 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3856ecbc568b65e542d045e1a487276cd8af2d91
4
+ data.tar.gz: ec9de90a7d2f8b93b48aa81260414587f008983a
5
+ SHA512:
6
+ metadata.gz: 18e6571f13959f66b4b6a98d4df2cd529bfcb4ccc545866463d3ea09320ebc12733a184de1a594aad977091985d9b65f10cad50ad2f267cd715384d596568f16
7
+ data.tar.gz: ab7a261a28a0de03bd81c342ae42743c92ee0c89832a13b0a94e7f7de72a4e55fa0cd65227a3cb2f2135c778f6d5695d7bee90643a625db7a6c3b262210d723d
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/browsermob-proxy
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in infrataster.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ryota Arai
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # Infrataster
2
+
3
+ Infrastructure Behavior Testing Framework.
4
+
5
+ ## Usage
6
+
7
+ **You can see [example directory](example) too.**
8
+
9
+ First, create `Gemfile`:
10
+
11
+ ```ruby
12
+ source 'https://rubygems.org'
13
+
14
+ gem 'infrataster'
15
+ ```
16
+
17
+ Install gems:
18
+
19
+ ```
20
+ $ bundle install
21
+ ```
22
+
23
+ Initialize rspec directory:
24
+
25
+ ```
26
+ $ rspec --init
27
+ create spec/spec_helper.rb
28
+ create .rspec
29
+ ```
30
+
31
+ `require 'infrataster/rspec'` and define target servers for testing in `spec/spec_helper.rb`:
32
+
33
+ ```ruby
34
+ # spec/spec_helper.rb
35
+ require 'infrataster/rspec'
36
+
37
+ Infrataster::Server.define(
38
+ :proxy, # name
39
+ '192.168.33.10', # ip address
40
+ vagrant: true, # for vagrant VM
41
+ )
42
+ Infrataster::Server.define(
43
+ :app, # name
44
+ '172.16.33.11', # ip address
45
+ vagrant: true, # for vagrant VM
46
+ from: :proxy # access to this machine via SSH port forwarding from proxy
47
+ )
48
+ Infrataster::Server.define(
49
+ :db, # name
50
+ '172.16.33.12', # ip address
51
+ vagrant: true, # for vagrant VM
52
+ from: :app, # access to this machine via SSH port forwarding from app
53
+ mysql: {user: 'app', password: 'app'}
54
+ # settings for MySQL
55
+ )
56
+ ```
57
+
58
+ If you use `capybara`, you should download and extract [BrowserMob Proxy](http://bmp.lightbody.net/) and set `Infrataster::BrowsermobProxy.bin_path` to binary path in `spec/spec_helper.rb`:
59
+
60
+ ```ruby
61
+ # spec/spec_helper.rb
62
+ Infrataster::BrowsermobProxy.bin_path = '/path/to/browsermob/bin/browsermob'
63
+ ```
64
+
65
+ Then, you can write spec files:
66
+
67
+ ```ruby
68
+ # spec/example_spec.rb
69
+ require 'spec_helper'
70
+
71
+ describe server(:app) do
72
+ describe http('http://app') do
73
+ it "responds content including 'Hello Sinatra'" do
74
+ expect(response.body).to include('Hello Sinatra')
75
+ end
76
+ it "responds as 'text/html'" do
77
+ expect(response.header.content_type).to eq('text/html')
78
+ end
79
+ end
80
+ describe capybara('http://app') do
81
+ it "responds content including 'Hello Sinatra'" do
82
+ visit '/'
83
+ expect(page).to have_content('Hello Sinatra')
84
+ end
85
+ end
86
+ end
87
+
88
+ describe server(:db) do
89
+ describe mysql_query('SHOW STATUS') do
90
+ it 'responds uptime' do
91
+ row = results.find {|r| r['Variable_name'] == 'Uptime' }
92
+ expect(row['Value'].to_i).to be > 0
93
+ end
94
+ end
95
+ end
96
+
97
+ describe server(:proxy) do
98
+ describe http('http://app') do
99
+ it "responds content including 'Hello Sinatra'" do
100
+ expect(response.body).to include('Hello Sinatra')
101
+ end
102
+ end
103
+ describe http('http://static') do
104
+ it "responds content including 'Welcome to nginx!'" do
105
+ expect(response.body).to include('Welcome to nginx!')
106
+ end
107
+ end
108
+ describe capybara('http://app') do
109
+ it "responds content including 'Hello Sinatra'" do
110
+ visit '/'
111
+ expect(page).to have_content('Hello Sinatra')
112
+ end
113
+ end
114
+ describe capybara('http://static') do
115
+ it "responds content including 'Welcome to nginx!'" do
116
+ visit '/'
117
+ expect(page).to have_content('Welcome to nginx!')
118
+ end
119
+ end
120
+ end
121
+ ```
122
+
123
+ ## Example
124
+
125
+ [infrataster/example](example)
126
+
127
+ ## Contributing
128
+
129
+ 1. Fork it ( http://github.com/ryotarai/infrataster/fork )
130
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
131
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
132
+ 4. Push to the branch (`git push origin my-new-feature`)
133
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ /Gemfile.lock
2
+ /Berksfile.lock
3
+ /.vagrant
4
+ /vendor
data/example/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/example/Berksfile ADDED
@@ -0,0 +1,2 @@
1
+ site :opscode
2
+ cookbook 'apt'
data/example/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'infrataster', path: '..'
4
+ gem 'berkshelf', github: 'berkshelf/berkshelf'
5
+
6
+ gem 'pry'
7
+ gem 'pry-byebug'
8
+ gem 'pry-rescue'
data/example/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Infrataster Example
2
+
3
+ ```
4
+ $ cd example
5
+ $ wget https://s3-us-west-1.amazonaws.com/lightbody-bmp/browsermob-proxy-2.0-beta-9-bin.zip
6
+ $ unzip browsermob-proxy-2.0-beta-9-bin.zip
7
+ $ mv browsermob-proxy-2.0-beta-9 vendor/browsermob
8
+ $ bundle install
9
+ $ bundle exec berks vendor vendor/cookbooks
10
+ $ vagrant up
11
+ $ bundle exec rspec
12
+ ```
13
+
@@ -0,0 +1,81 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ COOKBOOK_PATH = ['./cookbooks', './vendor/cookbooks']
8
+ APP_IP = "172.16.33.11"
9
+
10
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
11
+ config.vm.box = "hashicorp/precise64"
12
+
13
+ config.vm.define :proxy do |c|
14
+ c.vm.network "private_network", ip: "192.168.33.10"
15
+ c.vm.network "private_network", ip: "172.16.33.10", virtualbox__intnet: "infrataster-example"
16
+
17
+ c.vm.provision "chef_solo" do |chef|
18
+ chef.cookbooks_path = COOKBOOK_PATH
19
+ chef.add_recipe "proxy"
20
+ chef.json = {'app_ip' => APP_IP}
21
+ end
22
+ end
23
+
24
+ config.vm.define :app do |c|
25
+ c.vm.network "private_network", ip: APP_IP, virtualbox__intnet: "infrataster-example"
26
+
27
+ c.vm.provision "chef_solo" do |chef|
28
+ chef.cookbooks_path = COOKBOOK_PATH
29
+ chef.add_recipe "app"
30
+ chef.json = {}
31
+ end
32
+ end
33
+
34
+ config.vm.define :db do |c|
35
+ c.vm.network "private_network", ip: '172.16.33.12', virtualbox__intnet: "infrataster-example"
36
+
37
+ c.vm.provision "chef_solo" do |chef|
38
+ chef.cookbooks_path = COOKBOOK_PATH
39
+ chef.add_recipe "db"
40
+ chef.json = {'app_ip' => APP_IP}
41
+ end
42
+ end
43
+
44
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
45
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
46
+ # some recipes and/or roles.
47
+ #
48
+ # config.vm.provision "chef_solo" do |chef|
49
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
50
+ # chef.roles_path = "../my-recipes/roles"
51
+ # chef.data_bags_path = "../my-recipes/data_bags"
52
+ # chef.add_recipe "mysql"
53
+ # chef.add_role "web"
54
+ #
55
+ # # You may also specify custom JSON attributes:
56
+ # chef.json = { :mysql_password => "foo" }
57
+ # end
58
+
59
+ # Enable provisioning with chef server, specifying the chef server URL,
60
+ # and the path to the validation key (relative to this Vagrantfile).
61
+ #
62
+ # The Opscode Platform uses HTTPS. Substitute your organization for
63
+ # ORGNAME in the URL and validation key.
64
+ #
65
+ # If you have your own Chef Server, use the appropriate URL, which may be
66
+ # HTTP instead of HTTPS depending on your configuration. Also change the
67
+ # validation key to validation.pem.
68
+ #
69
+ # config.vm.provision "chef_client" do |chef|
70
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
71
+ # chef.validation_key_path = "ORGNAME-validator.pem"
72
+ # end
73
+ #
74
+ # If you're using the Opscode platform, your validator client is
75
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
76
+ #
77
+ # If you have your own Chef Server, the default validation client name is
78
+ # chef-validator, unless you changed the configuration.
79
+ #
80
+ # chef.validation_client_name = "ORGNAME-validator"
81
+ end
@@ -0,0 +1,36 @@
1
+ include_recipe 'apt'
2
+
3
+ package 'python-software-properties' do
4
+ action :install
5
+ end
6
+
7
+ execute 'apt-add-repository ppa:brightbox/ruby-ng && apt-get update'
8
+
9
+ package 'build-essential' do
10
+ action :install
11
+ end
12
+
13
+ package 'ruby2.1' do
14
+ action :install
15
+ end
16
+
17
+ package 'ruby2.1-dev' do
18
+ action :install
19
+ end
20
+
21
+ execute 'gem install bundler' do
22
+ not_if "gem list | grep -q 'bundler '"
23
+ end
24
+
25
+ execute 'bundle install' do
26
+ cwd '/vagrant/sinatra_app'
27
+ end
28
+
29
+ execute "kill $(cat /tmp/thin.pid) && sleep 2" do
30
+ only_if "test -e /tmp/thin.pid"
31
+ end
32
+
33
+ execute "bundle exec thin start --pid /tmp/thin.pid --daemonize --port 80" do
34
+ cwd '/vagrant/sinatra_app'
35
+ end
36
+
@@ -0,0 +1,127 @@
1
+ #
2
+ # The MySQL database server configuration file.
3
+ #
4
+ # You can copy this to one of:
5
+ # - "/etc/mysql/my.cnf" to set global options,
6
+ # - "~/.my.cnf" to set user-specific options.
7
+ #
8
+ # One can use all long options that the program supports.
9
+ # Run program with --help to get a list of available options and with
10
+ # --print-defaults to see which it would actually understand and use.
11
+ #
12
+ # For explanations see
13
+ # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
14
+
15
+ # This will be passed to all mysql clients
16
+ # It has been reported that passwords should be enclosed with ticks/quotes
17
+ # escpecially if they contain "#" chars...
18
+ # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
19
+ [client]
20
+ port = 3306
21
+ socket = /var/run/mysqld/mysqld.sock
22
+
23
+ # Here is entries for some specific programs
24
+ # The following values assume you have at least 32M ram
25
+
26
+ # This was formally known as [safe_mysqld]. Both versions are currently parsed.
27
+ [mysqld_safe]
28
+ socket = /var/run/mysqld/mysqld.sock
29
+ nice = 0
30
+
31
+ [mysqld]
32
+ #
33
+ # * Basic Settings
34
+ #
35
+ user = mysql
36
+ pid-file = /var/run/mysqld/mysqld.pid
37
+ socket = /var/run/mysqld/mysqld.sock
38
+ port = 3306
39
+ basedir = /usr
40
+ datadir = /var/lib/mysql
41
+ tmpdir = /tmp
42
+ lc-messages-dir = /usr/share/mysql
43
+ skip-external-locking
44
+ #
45
+ # Instead of skip-networking the default is now to listen only on
46
+ # localhost which is more compatible and is not less secure.
47
+ bind-address = 0.0.0.0
48
+ #
49
+ # * Fine Tuning
50
+ #
51
+ key_buffer = 16M
52
+ max_allowed_packet = 16M
53
+ thread_stack = 192K
54
+ thread_cache_size = 8
55
+ # This replaces the startup script and checks MyISAM tables if needed
56
+ # the first time they are touched
57
+ myisam-recover = BACKUP
58
+ #max_connections = 100
59
+ #table_cache = 64
60
+ #thread_concurrency = 10
61
+ #
62
+ # * Query Cache Configuration
63
+ #
64
+ query_cache_limit = 1M
65
+ query_cache_size = 16M
66
+ #
67
+ # * Logging and Replication
68
+ #
69
+ # Both location gets rotated by the cronjob.
70
+ # Be aware that this log type is a performance killer.
71
+ # As of 5.1 you can enable the log at runtime!
72
+ #general_log_file = /var/log/mysql/mysql.log
73
+ #general_log = 1
74
+ #
75
+ # Error log - should be very few entries.
76
+ #
77
+ log_error = /var/log/mysql/error.log
78
+ #
79
+ # Here you can see queries with especially long duration
80
+ #log_slow_queries = /var/log/mysql/mysql-slow.log
81
+ #long_query_time = 2
82
+ #log-queries-not-using-indexes
83
+ #
84
+ # The following can be used as easy to replay backup logs or for replication.
85
+ # note: if you are setting up a replication slave, see README.Debian about
86
+ # other settings you may need to change.
87
+ #server-id = 1
88
+ #log_bin = /var/log/mysql/mysql-bin.log
89
+ expire_logs_days = 10
90
+ max_binlog_size = 100M
91
+ #binlog_do_db = include_database_name
92
+ #binlog_ignore_db = include_database_name
93
+ #
94
+ # * InnoDB
95
+ #
96
+ # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
97
+ # Read the manual for more InnoDB related options. There are many!
98
+ #
99
+ # * Security Features
100
+ #
101
+ # Read the manual, too, if you want chroot!
102
+ # chroot = /var/lib/mysql/
103
+ #
104
+ # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
105
+ #
106
+ # ssl-ca=/etc/mysql/cacert.pem
107
+ # ssl-cert=/etc/mysql/server-cert.pem
108
+ # ssl-key=/etc/mysql/server-key.pem
109
+
110
+
111
+
112
+ [mysqldump]
113
+ quick
114
+ quote-names
115
+ max_allowed_packet = 16M
116
+
117
+ [mysql]
118
+ #no-auto-rehash # faster start of mysql but no tab completition
119
+
120
+ [isamchk]
121
+ key_buffer = 16M
122
+
123
+ #
124
+ # * IMPORTANT: Additional settings that can override those from this file!
125
+ # The files must end with '.cnf', otherwise they'll be ignored.
126
+ #
127
+ !includedir /etc/mysql/conf.d/
@@ -0,0 +1,14 @@
1
+ include_recipe 'apt'
2
+
3
+ package 'mysql-server'
4
+
5
+ service 'mysql' do
6
+ supports(:restart => true)
7
+ end
8
+
9
+ cookbook_file '/etc/mysql/my.cnf' do
10
+ notifies :restart, 'service[mysql]'
11
+ end
12
+
13
+ execute "mysql -uroot -e \"GRANT ALL PRIVILEGES ON *.* TO 'app'@'#{node['app_ip']}' IDENTIFIED BY 'app';\""
14
+
@@ -0,0 +1 @@
1
+ depends 'apt'
@@ -0,0 +1,26 @@
1
+ include_recipe 'apt'
2
+
3
+ package "nginx" do
4
+ action :install
5
+ end
6
+
7
+ service "nginx" do
8
+ action :start
9
+ supports(:reload => true)
10
+ end
11
+
12
+ file "/etc/nginx/sites-enabled/default" do
13
+ action :delete
14
+ notifies :reload, 'service[nginx]'
15
+ end
16
+
17
+ %w!app static!.each do |app|
18
+ template "/etc/nginx/sites-available/#{app}" do
19
+ notifies :reload, 'service[nginx]'
20
+ end
21
+
22
+ link "/etc/nginx/sites-enabled/#{app}" do
23
+ to "/etc/nginx/sites-available/#{app}"
24
+ end
25
+ end
26
+
@@ -0,0 +1,13 @@
1
+ server {
2
+ listen 80;
3
+
4
+ root /usr/share/nginx/www;
5
+ index index.html index.htm;
6
+
7
+ server_name app;
8
+
9
+ location / {
10
+ proxy_pass http://<%= node['app_ip'] %>;
11
+ }
12
+ }
13
+
@@ -0,0 +1,14 @@
1
+ server {
2
+ listen 80;
3
+
4
+ root /usr/share/nginx/www;
5
+ index index.html index.htm;
6
+
7
+ server_name static;
8
+
9
+ location / {
10
+ try_files $uri $uri/ /index.html;
11
+ }
12
+ }
13
+
14
+
@@ -0,0 +1 @@
1
+ log
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'thin'
5
+
@@ -0,0 +1,6 @@
1
+ require 'sinatra'
2
+
3
+ get '/' do
4
+ "Hello Sinatra!"
5
+ end
6
+
@@ -0,0 +1,2 @@
1
+ require './app'
2
+ run Sinatra::Application
@@ -0,0 +1,31 @@
1
+ require 'infrataster/rspec'
2
+
3
+ Infrataster::Server.define(
4
+ :proxy,
5
+ '192.168.33.10',
6
+ vagrant: true,
7
+ )
8
+ Infrataster::Server.define(
9
+ :app,
10
+ '172.16.33.11',
11
+ vagrant: true,
12
+ from: :proxy
13
+ )
14
+ Infrataster::Server.define(
15
+ :db,
16
+ '172.16.33.12',
17
+ vagrant: true,
18
+ from: :app,
19
+ mysql: {user: 'app', password: 'app'}
20
+ )
21
+
22
+ Infrataster::BrowsermobProxy.bin_path = File.expand_path('../../../vendor/browsermob-proxy/bin/browsermob-proxy', __FILE__)
23
+
24
+ RSpec.configure do |config|
25
+ config.treat_symbols_as_metadata_keys_with_true_values = true
26
+ config.run_all_when_everything_filtered = true
27
+ config.filter_run :focus
28
+
29
+ config.order = 'random'
30
+ end
31
+
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe server(:app) do
4
+ describe http('http://app') do
5
+ it "responds content including 'Hello Sinatra'" do
6
+ expect(response.body).to include('Hello Sinatra')
7
+ end
8
+ it "responds as 'text/html'" do
9
+ expect(response.content_type).to eq('text/html')
10
+ end
11
+ it "responds OK 200" do
12
+ expect(response.code).to eq('200')
13
+ end
14
+ end
15
+ describe capybara('http://app') do
16
+ it "responds content including 'Hello Sinatra'" do
17
+ visit '/'
18
+ expect(page).to have_content('Hello Sinatra')
19
+ end
20
+ end
21
+ end
22
+
23
+ describe server(:db) do
24
+ describe mysql_query('SHOW STATUS') do
25
+ it 'responds uptime' do
26
+ row = results.find {|r| r['Variable_name'] == 'Uptime' }
27
+ expect(row['Value'].to_i).to be > 0
28
+ end
29
+ end
30
+ end
31
+
32
+ describe server(:proxy) do
33
+ describe http('http://app') do
34
+ it "responds content including 'Hello Sinatra'" do
35
+ expect(response.body).to include('Hello Sinatra')
36
+ end
37
+ it "responds as 'text/html'" do
38
+ expect(response.content_type).to eq('text/html')
39
+ end
40
+ end
41
+ describe http('http://static') do
42
+ it "responds content including 'Welcome to nginx!'" do
43
+ expect(response.body).to include('Welcome to nginx!')
44
+ end
45
+ it "responds as 'text/html'" do
46
+ expect(response.content_type).to eq('text/html')
47
+ end
48
+ end
49
+ describe capybara('http://app') do
50
+ it "responds content including 'Hello Sinatra'" do
51
+ visit '/'
52
+ expect(page).to have_content('Hello Sinatra')
53
+ end
54
+ end
55
+ describe capybara('http://static') do
56
+ it "responds content including 'Welcome to nginx!'" do
57
+ visit '/'
58
+ expect(page).to have_content('Welcome to nginx!')
59
+ end
60
+ end
61
+ end
62
+
63
+
64
+