infrataster 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +166 -52
- data/Rakefile +13 -0
- data/ci/jenkins_build +22 -0
- data/lib/infrataster/browsermob_proxy.rb +1 -1
- data/lib/infrataster/contexts/capybara_context.rb +6 -3
- data/lib/infrataster/contexts/http_context.rb +1 -1
- data/lib/infrataster/contexts/mysql_query_context.rb +1 -1
- data/lib/infrataster/contexts.rb +4 -4
- data/lib/infrataster/helpers/resource_helper.rb +2 -0
- data/lib/infrataster/server.rb +2 -2
- data/lib/infrataster/version.rb +1 -1
- data/spec/integration/http_spec.rb +10 -1
- data/spec/integration/mysql_query_spec.rb +11 -0
- data/spec/integration/spec_helper.rb +2 -1
- data/spec/integration/vm/.gitignore +0 -1
- data/spec/integration/vm/Vagrantfile +5 -1
- data/spec/integration/vm/app/app.rb +10 -10
- data/spec/integration/vm/cookbooks/app/files/default/my.cnf +127 -0
- data/spec/integration/vm/cookbooks/app/recipes/default.rb +14 -0
- data/spec/integration/vm/vendor/.gitignore +2 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09a246ee278ac5692659d4002fbe88abe092955d
|
4
|
+
data.tar.gz: b410d985ebfd8285de301a37bf5e539d81216336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c821d85b3b61b7869f07d5e1394ad5fe534727e03f39885149c4d06b4beab92eb277da764c9109629422479f6eadfcd36debf2d043f5129fb755b3f938269b87
|
7
|
+
data.tar.gz: 3264f6f21d6f416ac97316a7b10fd39f88bd25260cd17d9d14c3c73237ca5a71c802c8f35741f890828ff5f91c95f8f2cb3dead15115366205fdb47d9e6fecf1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Infrataster Changelog
|
2
2
|
|
3
|
+
## v0.1.4
|
4
|
+
|
5
|
+
* Include RSpec::Matchers to use be_xxx matchers. (by @KitaitiMakoto)
|
6
|
+
* Don't raise any error for subjects which is not related to Infrataster. (by @KitaitiMakoto)
|
7
|
+
|
3
8
|
## v0.1.3
|
4
9
|
|
5
10
|
* Don't create multiple phantomjs and browsermob proxy. `capybara` resources become faster.
|
data/README.md
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
|
5
5
|
Infrastructure Behavior Testing Framework.
|
6
6
|
|
7
|
-
## Usage
|
8
|
-
|
9
|
-
**You can see [example directory](example) too.**
|
7
|
+
## Basic Usage with Vagrant
|
10
8
|
|
11
9
|
First, create `Gemfile`:
|
12
10
|
|
@@ -22,6 +20,32 @@ Install gems:
|
|
22
20
|
$ bundle install
|
23
21
|
```
|
24
22
|
|
23
|
+
Install Vagrant: [Official Docs](http://docs.vagrantup.com/v2/installation/index.html)
|
24
|
+
|
25
|
+
Create Vagrantfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Vagrantfile
|
29
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
30
|
+
config.vm.box = "hashicorp/precise64"
|
31
|
+
|
32
|
+
config.vm.define :proxy do |c|
|
33
|
+
c.vm.network "private_network", ip: "192.168.33.10"
|
34
|
+
c.vm.network "private_network", ip: "171.16.33.10", virtualbox__intnet: "infrataster-example"
|
35
|
+
end
|
36
|
+
|
37
|
+
config.vm.define :app do |c|
|
38
|
+
c.vm.network "private_network", ip: "171.16.33.11", virtualbox__intnet: "infrataster-example"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
Start VMs:
|
44
|
+
|
45
|
+
```
|
46
|
+
$ vagrant up
|
47
|
+
```
|
48
|
+
|
25
49
|
Initialize rspec directory:
|
26
50
|
|
27
51
|
```
|
@@ -47,21 +71,8 @@ Infrataster::Server.define(
|
|
47
71
|
vagrant: true, # for vagrant VM
|
48
72
|
from: :proxy # access to this machine via SSH port forwarding from proxy
|
49
73
|
)
|
50
|
-
Infrataster::Server.define(
|
51
|
-
:db, # name
|
52
|
-
'172.16.33.12', # ip address
|
53
|
-
vagrant: true, # for vagrant VM
|
54
|
-
from: :app, # access to this machine via SSH port forwarding from app
|
55
|
-
mysql: {user: 'app', password: 'app'}
|
56
|
-
# settings for MySQL
|
57
|
-
)
|
58
|
-
```
|
59
|
-
|
60
|
-
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`:
|
61
74
|
|
62
|
-
|
63
|
-
# spec/spec_helper.rb
|
64
|
-
Infrataster::BrowsermobProxy.bin_path = '/path/to/browsermob/bin/browsermob'
|
75
|
+
# Code generated by `rspec --init` is following...
|
65
76
|
```
|
66
77
|
|
67
78
|
Then, you can write spec files:
|
@@ -76,75 +87,174 @@ describe server(:app) do
|
|
76
87
|
expect(response.body).to include('Hello Sinatra')
|
77
88
|
end
|
78
89
|
it "responds as 'text/html'" do
|
79
|
-
expect(response.
|
80
|
-
end
|
81
|
-
end
|
82
|
-
describe capybara('http://app') do
|
83
|
-
it "responds content including 'Hello Sinatra'" do
|
84
|
-
visit '/'
|
85
|
-
expect(page).to have_content('Hello Sinatra')
|
90
|
+
expect(response.headers['content-type']).to match(%r{^text/html})
|
86
91
|
end
|
87
92
|
end
|
88
93
|
end
|
94
|
+
```
|
89
95
|
|
90
|
-
|
91
|
-
describe mysql_query('SHOW STATUS') do
|
92
|
-
it 'responds uptime' do
|
93
|
-
row = results.find {|r| r['Variable_name'] == 'Uptime' }
|
94
|
-
expect(row['Value'].to_i).to be > 0
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
96
|
+
Run tests:
|
98
97
|
|
99
|
-
|
100
|
-
|
98
|
+
```
|
99
|
+
$ bundle exec rspec
|
100
|
+
2 examples, 2 failures
|
101
|
+
```
|
102
|
+
|
103
|
+
Currently, the tests failed because the VM doesn't respond to HTTP request.
|
104
|
+
|
105
|
+
It's time to write provisioning instruction like Chef's cookbooks or Puppet's manifests!
|
106
|
+
|
107
|
+
## Server
|
108
|
+
|
109
|
+
"Server" is a server you tests. This supports Vagrant, which is very useful to run servers for testing. Of course, you can test real servers.
|
110
|
+
|
111
|
+
You should define servers in `spec_helper.rb` like the following:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
Infrataster::Server.define(
|
115
|
+
# Name of the server, this will be used in the spec files.
|
116
|
+
:proxy,
|
117
|
+
# IP address of the server
|
118
|
+
'192.168.44.10',
|
119
|
+
# If the server is provided by vagrant and this option is true,
|
120
|
+
# SSH configuration to connect to this server is got from `vagrant ssh-config` command automatically.
|
121
|
+
vagrant: true,
|
122
|
+
)
|
123
|
+
|
124
|
+
Infrataster::Server.define(
|
125
|
+
# Name of the server, this will be used in the spec files.
|
126
|
+
:app,
|
127
|
+
# IP address of the server
|
128
|
+
'172.16.44.11',
|
129
|
+
# If the server is provided by vagrant and this option is true,
|
130
|
+
# SSH configuration to connect to this server is got from `vagrant ssh-config` command automatically.
|
131
|
+
vagrant: true,
|
132
|
+
# Which gateway is used to connect to this server by SSH port forwarding?
|
133
|
+
from: :proxy,
|
134
|
+
# options for resources
|
135
|
+
mysql: {user: 'app', password: 'app'},
|
136
|
+
)
|
137
|
+
```
|
138
|
+
|
139
|
+
You can specify SSH configuration manually too:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
Infrataster::Server.define(
|
143
|
+
# ...
|
144
|
+
ssh: {host: 'hostname', user: 'testuser', keys: ['/path/to/id_rsa']}
|
145
|
+
)
|
146
|
+
```
|
147
|
+
|
148
|
+
## Resources
|
149
|
+
|
150
|
+
"Resource" is what you test by Infrataster. For instance, the following code describes `http` resource.
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
describe server(:app) do
|
154
|
+
describe http('http://example.com') do
|
101
155
|
it "responds content including 'Hello Sinatra'" do
|
102
156
|
expect(response.body).to include('Hello Sinatra')
|
103
157
|
end
|
104
158
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
159
|
+
end
|
160
|
+
```
|
161
|
+
|
162
|
+
### `http` resource
|
163
|
+
|
164
|
+
`http` resource tests HTTP response when sending HTTP request.
|
165
|
+
It accepts `method`, `params` and `header` as options.
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
describe server(:app) do
|
169
|
+
describe http(
|
170
|
+
'http://app.example.com',
|
171
|
+
method: :post,
|
172
|
+
params: {'foo' => 'bar'},
|
173
|
+
headers: {'USER' => 'VALUE'}
|
174
|
+
) do
|
175
|
+
it "responds with content including 'app'" do
|
176
|
+
expect(response.body).to include('app')
|
177
|
+
|
178
|
+
# `response` is a instance of `Faraday::Response`
|
179
|
+
# See: https://github.com/lostisland/faraday/blob/master/lib/faraday/response.rb
|
108
180
|
end
|
109
181
|
end
|
110
|
-
|
111
|
-
|
182
|
+
end
|
183
|
+
```
|
184
|
+
|
185
|
+
### `capybara` resource
|
186
|
+
|
187
|
+
`capybara` resource tests your web application by simulating real user's interaction.
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
describe server(:app) do
|
191
|
+
describe capybara('http://app.example.com') do
|
192
|
+
it 'shows food list' do
|
112
193
|
visit '/'
|
113
|
-
|
194
|
+
click_link 'Foods'
|
195
|
+
expect(page).to have_content 'Yummy Soup'
|
114
196
|
end
|
115
197
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
198
|
+
end
|
199
|
+
```
|
200
|
+
|
201
|
+
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`:
|
202
|
+
|
203
|
+
```ruby
|
204
|
+
# spec/spec_helper.rb
|
205
|
+
Infrataster::BrowsermobProxy.bin_path = '/path/to/browsermob/bin/browsermob'
|
206
|
+
```
|
207
|
+
|
208
|
+
(BrowserMob Proxy is needed to manipulate Host HTTP header.)
|
209
|
+
|
210
|
+
### `mysql_query` resource
|
211
|
+
|
212
|
+
`mysql_query` resource tests responce for mysql query.
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
describe server(:db) do
|
216
|
+
describe mysql_query('SHOW STATUS') do
|
217
|
+
it 'returns positive uptime' do
|
218
|
+
row = results.find {|r| r['Variable_name'] == 'Uptime' }
|
219
|
+
expect(row['Value'].to_i).to be > 0
|
220
|
+
|
221
|
+
# `results` is a instance of `Mysql2::Result`
|
222
|
+
# See: https://github.com/brianmario/mysql2
|
120
223
|
end
|
121
224
|
end
|
122
225
|
end
|
123
226
|
```
|
124
227
|
|
228
|
+
You can specify username and password by options passed to `Infrataster::Server.define`:
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
Infrataster::Server.define(
|
232
|
+
# ...
|
233
|
+
mysql: {user: 'app', password: 'app'}
|
234
|
+
)
|
235
|
+
```
|
236
|
+
|
125
237
|
## Example
|
126
238
|
|
127
|
-
[
|
239
|
+
* [example](example)
|
240
|
+
* [spec/integration](spec/integration)
|
128
241
|
|
129
|
-
##
|
242
|
+
## Tests
|
130
243
|
|
131
244
|
### Unit Tests
|
132
245
|
|
246
|
+
Unit tests are under `spec/unit` directory.
|
247
|
+
|
133
248
|
```
|
134
249
|
$ bundle exec rake spec:unit
|
135
250
|
```
|
136
251
|
|
137
252
|
### Integration Tests
|
138
253
|
|
139
|
-
|
254
|
+
Integration tests are under `spec/integration` directory.
|
140
255
|
|
141
256
|
```
|
142
257
|
$ bundle exec rake spec:integration:prepare
|
143
|
-
```
|
144
|
-
|
145
|
-
Run tests:
|
146
|
-
|
147
|
-
```
|
148
258
|
$ bundle exec rake spec:integration
|
149
259
|
```
|
150
260
|
|
@@ -152,6 +262,10 @@ $ bundle exec rake spec:integration
|
|
152
262
|
|
153
263
|
* https://speakerdeck.com/ryotarai/infrataster-infra-behavior-testing-framework-number-oedo04
|
154
264
|
|
265
|
+
## Changelog
|
266
|
+
|
267
|
+
[Changelog](CHANGELOG.md)
|
268
|
+
|
155
269
|
## Contributing
|
156
270
|
|
157
271
|
1. Fork it ( http://github.com/ryotarai/infrataster/fork )
|
data/Rakefile
CHANGED
@@ -20,6 +20,9 @@ namespace :spec do
|
|
20
20
|
namespace :integration do
|
21
21
|
integration_dir = 'spec/integration'
|
22
22
|
|
23
|
+
task :clean => ['destroy_vm', 'remove_berks'] do
|
24
|
+
end
|
25
|
+
|
23
26
|
task :prepare => ['download_browsermob', 'start_vm'] do
|
24
27
|
end
|
25
28
|
|
@@ -56,6 +59,16 @@ namespace :spec do
|
|
56
59
|
puts yellow('Starting VM...')
|
57
60
|
system '/usr/bin/vagrant up'
|
58
61
|
end
|
62
|
+
|
63
|
+
task :destroy_vm do
|
64
|
+
puts yellow('Destroying VM...')
|
65
|
+
system '/usr/bin/vagrant destroy -f'
|
66
|
+
end
|
67
|
+
|
68
|
+
task :remove_berks do
|
69
|
+
dir = File.join(integration_dir, 'vm/vendor/cookbooks')
|
70
|
+
FileUtils.rm_rf(dir)
|
71
|
+
end
|
59
72
|
end
|
60
73
|
end
|
61
74
|
|
data/ci/jenkins_build
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def exec(cmd, exit_if_fail = true)
|
4
|
+
env = {'CI' => 'true'}
|
5
|
+
system env, cmd
|
6
|
+
if exit_if_fail && $?.exitstatus != 0
|
7
|
+
puts "`#{cmd}` failed"
|
8
|
+
exit $?.exitstatus
|
9
|
+
end
|
10
|
+
|
11
|
+
$?.exitstatus
|
12
|
+
end
|
13
|
+
|
14
|
+
exec 'bundle install --path=vendor/bundle --jobs=4'
|
15
|
+
|
16
|
+
exec 'bundle exec rake spec:unit'
|
17
|
+
|
18
|
+
exec 'bundle exec rake spec:integration:prepare'
|
19
|
+
status = exec('bundle exec rake spec:integration', false)
|
20
|
+
exec 'bundle exec rake spec:integration:clean'
|
21
|
+
exit status
|
22
|
+
|
@@ -40,7 +40,8 @@ module Infrataster
|
|
40
40
|
proxy = BrowsermobProxy.proxy
|
41
41
|
proxy.header({"Host" => resource.uri.host})
|
42
42
|
|
43
|
-
address, port, @gateway_finalize_proc =
|
43
|
+
address, port, @gateway_finalize_proc =
|
44
|
+
server.open_gateway_on_from_server(resource.uri.port)
|
44
45
|
Capybara.app_host = "http://#{address}:#{port}"
|
45
46
|
end
|
46
47
|
|
@@ -48,8 +49,10 @@ module Infrataster
|
|
48
49
|
@gateway_finalize_proc.call if @gateway_finalize_proc
|
49
50
|
end
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
Capybara::Session::DSL_METHODS.each do |method|
|
53
|
+
define_method method do |*args, &block|
|
54
|
+
page.send method, *args, &block
|
55
|
+
end
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|
@@ -4,7 +4,7 @@ module Infrataster
|
|
4
4
|
module Contexts
|
5
5
|
class HttpContext < BaseContext
|
6
6
|
def response
|
7
|
-
server.
|
7
|
+
server.gateway_on_from_server(resource.uri.port) do |address, port|
|
8
8
|
url = "#{resource.uri.scheme}://#{address}:#{port}"
|
9
9
|
|
10
10
|
conn = Faraday.new(:url => url) do |faraday|
|
@@ -9,7 +9,7 @@ module Infrataster
|
|
9
9
|
options = options.merge(server.options[:mysql])
|
10
10
|
end
|
11
11
|
|
12
|
-
server.
|
12
|
+
server.gateway_on_from_server(options[:port]) do |address, new_port|
|
13
13
|
client = Mysql2::Client.new(
|
14
14
|
host: address,
|
15
15
|
port: new_port,
|
data/lib/infrataster/contexts.rb
CHANGED
@@ -10,10 +10,12 @@ module Infrataster
|
|
10
10
|
def from_example(example)
|
11
11
|
example_group = example.metadata[:example_group]
|
12
12
|
|
13
|
-
|
13
|
+
server_resource = find_described(Resources::ServerResource, example_group)
|
14
14
|
resource = find_described(Resources::BaseResource, example_group)
|
15
15
|
|
16
|
-
resource.
|
16
|
+
return if [server_resource, resource].any? &:nil?
|
17
|
+
|
18
|
+
resource.context_class.new(server_resource.server, resource)
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
@@ -25,8 +27,6 @@ module Infrataster
|
|
25
27
|
parent_example_group = example_group[:example_group]
|
26
28
|
if parent_example_group
|
27
29
|
find_described(resource_class, parent_example_group)
|
28
|
-
else
|
29
|
-
raise Error
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/infrataster/server.rb
CHANGED
@@ -83,7 +83,7 @@ module Infrataster
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
def
|
86
|
+
def open_gateway_on_from_server(port)
|
87
87
|
if from
|
88
88
|
new_port, finalize_proc = from.gateway_open(@address, port)
|
89
89
|
Logger.debug("tunnel: localhost:#{new_port} -> #{from.address} -> #{@address}:#{port}")
|
@@ -93,7 +93,7 @@ module Infrataster
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
def
|
96
|
+
def gateway_on_from_server(port)
|
97
97
|
if from
|
98
98
|
from.gateway_open(@address, port) do |new_port|
|
99
99
|
Logger.debug("tunnel: localhost:#{new_port} -> #{from.address} -> #{@address}:#{port}")
|
data/lib/infrataster/version.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'integration/spec_helper'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
+
describe 'Normal subject not related to Infrataster' do
|
5
|
+
it "doesn't raise any error" do
|
6
|
+
expect(subject).not_to raise_error
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
describe server(:proxy) do
|
5
11
|
describe http('http://app.example.com') do
|
6
12
|
it "sends GET request with Host header" do
|
@@ -24,10 +30,12 @@ describe server(:app) do
|
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
27
|
-
describe http('http://app.example.com', params: {'foo' => 'bar'}, headers: {'USER' => 'VALUE'}) do
|
33
|
+
describe http('http://app.example.com/path/to/resource', params: {'foo' => 'bar'}, headers: {'USER' => 'VALUE'}) do
|
28
34
|
it "sends GET request with params" do
|
29
35
|
expect(body_as_json['method']).to eq('GET')
|
36
|
+
expect(body_as_json['path']).to eq('/path/to/resource')
|
30
37
|
expect(body_as_json['params']).to eq({"foo" => "bar"})
|
38
|
+
expect(body_as_json['headers']['USER']).not_to be_empty
|
31
39
|
expect(body_as_json['headers']['USER']).to eq('VALUE')
|
32
40
|
end
|
33
41
|
end
|
@@ -36,6 +44,7 @@ describe server(:app) do
|
|
36
44
|
it "sends POST request with params" do
|
37
45
|
expect(body_as_json['method']).to eq('POST')
|
38
46
|
expect(body_as_json['params']).to eq({"foo" => "bar"})
|
47
|
+
expect(body_as_json['headers']['USER']).not_to be_empty
|
39
48
|
expect(body_as_json['headers']['USER']).to eq('VALUE')
|
40
49
|
end
|
41
50
|
end
|
@@ -9,7 +9,8 @@ Infrataster::Server.define(
|
|
9
9
|
:app,
|
10
10
|
'172.16.44.11',
|
11
11
|
vagrant: true,
|
12
|
-
from: :proxy
|
12
|
+
from: :proxy,
|
13
|
+
mysql: {user: 'app', password: 'app'},
|
13
14
|
)
|
14
15
|
|
15
16
|
Infrataster::BrowsermobProxy.bin_path = File.expand_path('../vm/vendor/browsermob/bin/browsermob-proxy', __FILE__)
|
@@ -11,7 +11,11 @@ INTERNAL_ADDRESSES = {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
14
|
-
|
14
|
+
if ENV['CI']
|
15
|
+
config.vm.box = "hashicorp/precise32"
|
16
|
+
else
|
17
|
+
config.vm.box = "hashicorp/precise64"
|
18
|
+
end
|
15
19
|
|
16
20
|
config.vm.define :proxy do |c|
|
17
21
|
c.vm.network "private_network", ip: "192.168.44.10"
|
@@ -2,25 +2,25 @@ require 'sinatra'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
get '/' do
|
5
|
-
result
|
6
|
-
|
7
|
-
'method' => 'GET',
|
8
|
-
'params' => params,
|
9
|
-
'headers' => RequestWrapper.new(request).headers,
|
10
|
-
}
|
5
|
+
result.to_json
|
6
|
+
end
|
11
7
|
|
8
|
+
get '/path/to/resource' do
|
12
9
|
result.to_json
|
13
10
|
end
|
14
11
|
|
15
12
|
post '/' do
|
16
|
-
result
|
13
|
+
result.to_json
|
14
|
+
end
|
15
|
+
|
16
|
+
def result
|
17
|
+
{
|
17
18
|
'app' => 'sinatra',
|
18
|
-
'method' =>
|
19
|
+
'method' => request.request_method,
|
20
|
+
'path' => request.path_info,
|
19
21
|
'params' => params,
|
20
22
|
'headers' => RequestWrapper.new(request).headers,
|
21
23
|
}
|
22
|
-
|
23
|
-
result.to_json
|
24
24
|
end
|
25
25
|
|
26
26
|
class RequestWrapper
|
@@ -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/
|
@@ -33,3 +33,17 @@ end
|
|
33
33
|
|
34
34
|
execute 'supervisorctl restart rackup'
|
35
35
|
|
36
|
+
# db
|
37
|
+
package 'mysql-server'
|
38
|
+
|
39
|
+
service 'mysql' do
|
40
|
+
action :start
|
41
|
+
supports :restart => true
|
42
|
+
end
|
43
|
+
|
44
|
+
cookbook_file '/etc/mysql/my.cnf' do
|
45
|
+
notifies :restart, 'service[mysql]'
|
46
|
+
end
|
47
|
+
|
48
|
+
execute "mysql -uroot -e \"GRANT ALL PRIVILEGES ON *.* TO 'app'@'%' IDENTIFIED BY 'app';\""
|
49
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infrataster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04
|
11
|
+
date: 2014-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- LICENSE.txt
|
179
179
|
- README.md
|
180
180
|
- Rakefile
|
181
|
+
- ci/jenkins_build
|
181
182
|
- infrataster.gemspec
|
182
183
|
- lib/infrataster.rb
|
183
184
|
- lib/infrataster/browsermob_proxy.rb
|
@@ -200,6 +201,7 @@ files:
|
|
200
201
|
- lib/infrataster/version.rb
|
201
202
|
- spec/integration/capybara_spec.rb
|
202
203
|
- spec/integration/http_spec.rb
|
204
|
+
- spec/integration/mysql_query_spec.rb
|
203
205
|
- spec/integration/spec_helper.rb
|
204
206
|
- spec/integration/vm/.gitignore
|
205
207
|
- spec/integration/vm/Berksfile
|
@@ -207,12 +209,14 @@ files:
|
|
207
209
|
- spec/integration/vm/app/Gemfile
|
208
210
|
- spec/integration/vm/app/app.rb
|
209
211
|
- spec/integration/vm/app/config.ru
|
212
|
+
- spec/integration/vm/cookbooks/app/files/default/my.cnf
|
210
213
|
- spec/integration/vm/cookbooks/app/files/default/rackup.conf
|
211
214
|
- spec/integration/vm/cookbooks/app/recipes/default.rb
|
212
215
|
- spec/integration/vm/cookbooks/apt-mirror/recipes/default.rb
|
213
216
|
- spec/integration/vm/cookbooks/proxy/files/default/index.html
|
214
217
|
- spec/integration/vm/cookbooks/proxy/recipes/default.rb
|
215
218
|
- spec/integration/vm/cookbooks/proxy/templates/default/integration-test.erb
|
219
|
+
- spec/integration/vm/vendor/.gitignore
|
216
220
|
- spec/unit/lib/infrataster/server_spec.rb
|
217
221
|
- spec/unit/spec_helper.rb
|
218
222
|
homepage: https://github.com/ryotarai/infrataster
|
@@ -242,6 +246,7 @@ summary: Infrastructure Behavior Testing Framework
|
|
242
246
|
test_files:
|
243
247
|
- spec/integration/capybara_spec.rb
|
244
248
|
- spec/integration/http_spec.rb
|
249
|
+
- spec/integration/mysql_query_spec.rb
|
245
250
|
- spec/integration/spec_helper.rb
|
246
251
|
- spec/integration/vm/.gitignore
|
247
252
|
- spec/integration/vm/Berksfile
|
@@ -249,11 +254,13 @@ test_files:
|
|
249
254
|
- spec/integration/vm/app/Gemfile
|
250
255
|
- spec/integration/vm/app/app.rb
|
251
256
|
- spec/integration/vm/app/config.ru
|
257
|
+
- spec/integration/vm/cookbooks/app/files/default/my.cnf
|
252
258
|
- spec/integration/vm/cookbooks/app/files/default/rackup.conf
|
253
259
|
- spec/integration/vm/cookbooks/app/recipes/default.rb
|
254
260
|
- spec/integration/vm/cookbooks/apt-mirror/recipes/default.rb
|
255
261
|
- spec/integration/vm/cookbooks/proxy/files/default/index.html
|
256
262
|
- spec/integration/vm/cookbooks/proxy/recipes/default.rb
|
257
263
|
- spec/integration/vm/cookbooks/proxy/templates/default/integration-test.erb
|
264
|
+
- spec/integration/vm/vendor/.gitignore
|
258
265
|
- spec/unit/lib/infrataster/server_spec.rb
|
259
266
|
- spec/unit/spec_helper.rb
|