houcho 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Gemfile.lock +32 -0
  4. data/bin/houcho +3 -262
  5. data/houcho.gemspec +2 -1
  6. data/lib/houcho/attribute.rb +99 -0
  7. data/lib/houcho/ci.rb +18 -13
  8. data/lib/houcho/cli/attribute.rb +70 -0
  9. data/lib/houcho/cli/host.rb +46 -0
  10. data/lib/houcho/cli/outerrole.rb +53 -0
  11. data/lib/houcho/cli/role.rb +69 -0
  12. data/lib/houcho/cli/spec.rb +103 -0
  13. data/lib/houcho/cli.rb +52 -0
  14. data/lib/houcho/config.rb +28 -0
  15. data/lib/houcho/database.rb +99 -0
  16. data/lib/houcho/element.rb +79 -50
  17. data/lib/houcho/host.rb +30 -9
  18. data/lib/houcho/outerrole/cloudforecast.rb +94 -0
  19. data/{templates/role/cf_roles.yaml → lib/houcho/outerrole/yabitz.rb} +0 -0
  20. data/lib/houcho/outerrole.rb +52 -0
  21. data/lib/houcho/repository.rb +59 -0
  22. data/lib/houcho/role.rb +78 -91
  23. data/lib/houcho/spec/runner.rb +156 -85
  24. data/lib/houcho/spec.rb +72 -3
  25. data/lib/houcho/version.rb +1 -1
  26. data/lib/houcho.rb +10 -52
  27. data/spec/houcho_spec.rb +334 -91
  28. metadata +31 -22
  29. data/lib/houcho/cloudforecast/host.rb +0 -25
  30. data/lib/houcho/cloudforecast/role.rb +0 -25
  31. data/lib/houcho/cloudforecast.rb +0 -59
  32. data/lib/houcho/yamlhandle.rb +0 -31
  33. data/spec/spec_helper.rb +0 -15
  34. data/templates/conf/houcho.conf +0 -10
  35. data/templates/conf/kk.rb +0 -14
  36. data/templates/conf/rspec.conf +0 -1
  37. data/templates/master +0 -94
  38. data/templates/role/cloudforecast/.gitkeep +0 -0
  39. data/templates/role/cloudforecast.yaml +0 -0
  40. data/templates/role/hosts.yaml +0 -0
  41. data/templates/role/hosts_ignored.yaml +0 -0
  42. data/templates/role/roles.yaml +0 -0
  43. data/templates/role/specs.yaml +0 -0
  44. data/templates/spec/sample_spec.rb +0 -13
  45. data/templates/spec/spec_helper.rb +0 -29
data/lib/houcho.rb CHANGED
@@ -1,55 +1,13 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'fileutils'
3
- require 'rainbow'
4
- require 'systemu'
5
- require 'tempfile'
6
- require 'find'
7
- require 'yaml'
8
- require 'json'
9
- require 'houcho/yamlhandle'
10
- require 'houcho/element'
11
- require 'houcho/role'
12
- require 'houcho/host'
13
- require 'houcho/spec'
14
- require 'houcho/spec/runner'
15
- require 'houcho/cloudforecast'
16
- require 'houcho/cloudforecast/role'
17
- require 'houcho/cloudforecast/host'
18
- require 'houcho/ci'
1
+ require "rubygems"
2
+ require "houcho/role"
3
+ require "houcho/element"
4
+ require "houcho/host"
5
+ require "houcho/spec"
6
+ require "houcho/spec/runner"
7
+ require "houcho/outerrole"
8
+ require "houcho/outerrole/cloudforecast"
9
+ require "houcho/repository"
10
+ require "houcho/attribute"
19
11
 
20
12
  module Houcho
21
- def init_repo
22
- templates = File.expand_path("#{File.dirname(__FILE__)}/../templates")
23
-
24
- %W{conf role spec}.each do |d|
25
- FileUtils.cp_r("#{templates}/#{d}", d) if ! Dir.exist?(d)
26
- end
27
-
28
- File.symlink('./conf/rspec.conf', './.rspec') if ! File.exists? '.rspec'
29
-
30
- `git init; git add .; git commit -a -m 'initialized houcho repository'` if ! Dir.exist?('.git')
31
- end
32
-
33
-
34
- def puts_details(e, indentsize = 0, cnt = 1)
35
- case e
36
- when Array
37
- e.sort.each.with_index(1) do |v, i|
38
- (indentsize-1).times {print ' '}
39
- print i != e.size ? '├─ ' : '└─ '
40
- puts v
41
- end
42
- puts ''
43
- when Hash
44
- e.each do |k,v|
45
- if ! indentsize.zero?
46
- (indentsize).times {print ' '}
47
- end
48
- k = k.color(0,255,0)
49
- k = '[' + k.color(219,112,147) + ']' if indentsize.zero?
50
- puts k
51
- puts_details(v, indentsize+1, cnt+1)
52
- end
53
- end
54
- end
55
13
  end
data/spec/houcho_spec.rb CHANGED
@@ -1,164 +1,407 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
 
3
- spectmp = Dir.mktmpdir('spec')
4
- include Houcho
3
+ require "tmpdir"
4
+ spectmp = Dir.mktmpdir("houcho")
5
+ ENV["HOUCHO_ROOT"] = spectmp
6
+
7
+ require "rspec"
8
+ require "houcho"
9
+ require "fileutils"
5
10
 
6
11
  describe Houcho do
7
12
  before :all do
8
- Dir.chdir(spectmp)
9
- init_repo
10
- Role.create(['studio3104', 'studio3105'])
11
- Host.attach('hostA', 'studio3104')
12
-
13
- File.write('spec/specA_spec.rb',' ')
14
- Spec.attach('specA', 'studio3104')
13
+ Houcho::Repository.init
15
14
 
16
- File.write('./role/cloudforecast/cf.yaml', <<EOD
15
+ File.write("#{Houcho::Config::CFYAMLDIR}/cf.yaml", <<YAML
17
16
  --- #houcho
18
17
  servers:
19
18
  - label: rspec
20
19
  config: studio3104
21
20
  hosts:
22
- - test1.studio3104.com
23
- - test2.studio3104.com
24
- EOD
21
+ - 192.168.1.11 test1.studio3104.com
22
+ - 192.168.1.12 test2.studio3104.com
23
+ YAML
25
24
  )
26
- CloudForecast.load_yaml
27
- CloudForecast::Role.attach('houcho::rspec::studio3104', 'studio3104')
25
+
26
+ File.write("#{Houcho::Config::SPECDIR}/specA_spec.rb"," ")
27
+ File.write("#{Houcho::Config::SPECDIR}/specB_spec.rb"," ")
28
+ File.write("#{Houcho::Config::SPECDIR}/specC_spec.rb"," ")
29
+
30
+ @role = Houcho::Role.new
31
+ @host = Houcho::Host.new
32
+ @spec = Houcho::Spec.new
33
+ @outerrole = Houcho::OuterRole.new
34
+ @specrunner = Houcho::Spec::Runner.new
35
+
36
+ @role.create(["studio3104", "studio3105"])
37
+
38
+ Houcho::OuterRole::CloudForecast.load
39
+
40
+ @host.attach("hostA", "studio3104")
41
+ @outerrole.attach("houcho::rspec::studio3104", "studio3104")
42
+ @spec.attach("specA", "studio3104")
28
43
  end
29
44
 
30
45
 
31
- describe Role do
32
- context 'create and delete a role' do
33
- it { Role.create('www') }
34
- it { expect { Role.create('www') }.to raise_error }
35
- it { Role.delete('www') }
36
- it { expect { Role.delete('web') }.to raise_error }
46
+ after :all do
47
+ FileUtils.rm_rf(spectmp)
48
+ end
49
+
50
+
51
+ describe Houcho::Role do
52
+ context "create and delete a role" do
53
+ it { @role.create("www") }
54
+ it { @role.delete("www") }
55
+
56
+ it do
57
+ expect { @role.create("studio3104") }.to(
58
+ raise_error(Houcho::RoleExistenceException, "role already exist - studio3104")
59
+ )
60
+ end
61
+
62
+ it do
63
+ expect { @role.delete("web") }.to(
64
+ raise_error(Houcho::RoleExistenceException, "role does not exist - web")
65
+ )
66
+ end
37
67
  end
38
68
 
39
- context 'create and delete two roles' do
40
- it { Role.create(['studio3104::www', 'studio3104::database']) }
41
- it { expect { Role.create(['studio3104::www', 'studio3104::database']) }.to raise_error }
42
- it { Role.delete(['studio3104::www', 'studio3104::database']) }
43
- it { expect { Role.delete(['studio3104::www', 'studio3104::database']) }.to raise_error }
69
+
70
+ context "create and delete two roles" do
71
+ it { @role.create(["studio3104::www", "studio3104::database"]) }
72
+ it { @role.delete(["studio3104::www", "studio3104::database"]) }
73
+
74
+ it do
75
+ expect { @role.create(["studio3104", "studio3105"]) }.to(
76
+ raise_error(Houcho::RoleExistenceException, "role already exist - studio3104")
77
+ )
78
+ end
79
+
80
+ it do
81
+ expect { @role.delete(["studio3104::www", "studio3104::database"]) }.to(
82
+ raise_error(Houcho::RoleExistenceException, "role does not exist - studio3104::www")
83
+ )
84
+ end
44
85
  end
45
86
 
46
- context 'rename a role' do
47
- it { Role.rename('studio3105', 'studio3106') }
48
- it { expect { Role.rename('invalid_role', 'studio3106') }.to raise_error }
49
- it { expect { Role.rename('studio3106', 'studio3104') }.to raise_error }
50
- it { Role.rename('studio3106', 'studio3105') }
87
+
88
+ context "rename a role" do
89
+ it { @role.rename("studio3105", "studio3106") }
90
+
91
+ it do
92
+ expect { @role.rename("invalid_role", "studio3106") }.to(
93
+ raise_error(Houcho::RoleExistenceException, "role does not exist - invalid_role")
94
+ )
95
+ end
96
+
97
+ it do
98
+ expect { @role.rename("studio3106", "studio3104") }.to(
99
+ raise_error(Houcho::RoleExistenceException, "role already exist - studio3104")
100
+ )
101
+ end
102
+
103
+ it { @role.rename("studio3106", "studio3105") }
51
104
  end
52
105
 
53
- context 'get all roles' do
54
- it { expect(Role.all).to eq(['studio3104', 'studio3105']) }
106
+
107
+ context "get all roles" do
108
+ it { expect(@role.list).to eq(["studio3104", "studio3105"]) }
55
109
  end
56
110
 
57
- context 'get details of a role' do
111
+
112
+ context "get details of a role" do
58
113
  it do
59
- expect(Role.details(['studio3104'])).to eq(
114
+ expect(@role.details(["studio3104"])).to eq(
60
115
  {
61
- 'studio3104' => {
62
- 'host' => [ 'hostA' ],
63
- 'spec' => [ 'specA' ],
64
- 'cf' => { 'houcho::rspec::studio3104' => { 'host' => [ 'test1.studio3104.com', 'test2.studio3104.com', ] } }
116
+ "studio3104" => {
117
+ "host" => [ "hostA" ],
118
+ "spec" => [ "specA" ],
119
+ "outer role" => {
120
+ "houcho::rspec::studio3104" => {
121
+ "host" => [ "test1.studio3104.com", "test2.studio3104.com" ]
122
+ }
123
+ }
65
124
  }
66
125
  }
67
126
  )
68
127
  end
69
128
  end
70
129
 
71
- it { expect(Role.index('studio3104')).to be(1)}
72
- it { expect(Role.indexes_regexp(/studio310\d/)).to eq([1,2])}
73
- it { expect(Role.name(1)).to eq('studio3104')}
130
+ it { expect(@role.id("studio3104")).to be(1)}
131
+ it { expect(@role.id(/studio310\d/)).to eq([1,2])}
132
+ it { expect(@role.name(1)).to eq("studio3104")}
133
+
134
+ context "set, get and delete attribute of a role" do
135
+ it { @role.set_attr("studio3104", { A: "apple", B: "banana", C: "chocolate" }) }
136
+ it { expect(@role.get_attr("studio3104")).to eq({ A: "apple", B: "banana", C: "chocolate" }) }
137
+ it { expect(@role.get_attr_json("studio3104")).to eq("{\"A\":\"apple\",\"B\":\"banana\",\"C\":\"chocolate\"}") }
138
+ it { expect(@role.get_attr("studio3104", "A")).to eq({ A: "apple" }) }
139
+ it { expect(@role.get_attr("invalid_role")).to eq({}) }
140
+ it { expect(@role.get_attr_json("invalid_role")).to eq("{}") }
141
+
142
+ it { expect { @role.set_attr("studio3104", { "A" => "anpanman" }) }.to(
143
+ raise_error(Houcho::AttributeExceptiotn, "attribute has already defined value in role - A")
144
+ )}
145
+
146
+ it "force set" do
147
+ expect(@role.set_attr!("studio3104", { "A" => "anpanman" }))
148
+ end
149
+
150
+ it { expect { @role.set_attr("invalid_role",{ A: "apple", B: "banana", C: "chocolate" }) }.to(
151
+ raise_error(Houcho::RoleExistenceException, "role does not exist - invalid_role")
152
+ ) }
153
+
154
+ it { expect(@role.del_attr("studio3104", "C")).to eq({ :C => "chocolate" }) }
155
+ it { expect(@role.get_attr("studio3104")).to eq({ A: "anpanman", B: "banana" }) }
156
+ it { expect(@role.del_attr("studio3104")).to eq({ A: "anpanman", B: "banana" }) }
157
+ it { expect(@role.get_attr("studio3104")).to eq({}) }
158
+ end
74
159
  end
75
160
 
76
161
 
77
162
  describe Houcho::Host do
78
- context 'attach and detach hosts to roles' do
79
- it { Host.attach(['host1', 'host2'], ['studio3104', 'studio3105']) }
80
- it { expect { Host.attach('host1', 'invalid_role') }.to raise_error }
81
- it { Host.detach(['host1', 'host2'], ['studio3104', 'studio3105']) }
82
- it { expect { Host.detach('host1', 'invalid_role') }.to raise_error }
163
+ context "attach and detach hosts to roles" do
164
+ it { @host.attach(["host1", "host2"], ["studio3104", "studio3105"]) }
165
+ it { @host.detach(["host1", "host2"], ["studio3104", "studio3105"]) }
166
+
167
+ it do
168
+ expect { @host.attach("host1", "invalid_role") }.to(
169
+ raise_error(Houcho::RoleExistenceException, "role does not exist - invalid_role")
170
+ )
171
+ end
172
+
173
+ it do
174
+ expect { @host.detach("host1", "invalid_role") }.to(
175
+ raise_error(Houcho::RoleExistenceException, "role does not exist - invalid_role")
176
+ )
177
+ end
83
178
  end
84
179
 
85
- context 'get details of a host' do
86
- it 'host from original defined' do
87
- expect(Host.details(['hostA'])).to eq(
88
- { 'hostA' => { 'role' => [ 'studio3104' ] } }
180
+ context "get details of a host" do
181
+ it "host from original defined" do
182
+ expect(@host.details(["hostA"])).to eq(
183
+ { "hostA" => { "role" => [ "studio3104" ] } }
89
184
  )
90
185
  end
91
186
 
92
- it 'host from cf defined' do
93
- expect(Host.details(['test1.studio3104.com'])).to eq(
94
- { 'test1.studio3104.com' => { 'cf' => [ 'houcho::rspec::studio3104' ] } }
187
+ it "host from cf defined" do
188
+ expect(@host.details(["test1.studio3104.com"])).to eq(
189
+ { "test1.studio3104.com" => { "outer role" => [ "houcho::rspec::studio3104" ] } }
95
190
  )
96
191
  end
97
192
 
98
- it 'both' do
99
- expect(Host.details(['hostA', 'test1.studio3104.com'])).to eq(
193
+ it "both" do
194
+ expect(@host.details(["hostA", "test1.studio3104.com"])).to eq(
100
195
  {
101
- 'hostA' => { 'role' => [ 'studio3104' ] },
102
- 'test1.studio3104.com' => { 'cf' => [ 'houcho::rspec::studio3104' ] },
196
+ "hostA" => { "role" => [ "studio3104" ] },
197
+ "test1.studio3104.com" => { "outer role" => [ "houcho::rspec::studio3104" ] },
103
198
  }
104
199
  )
105
200
  end
201
+ end
106
202
 
107
- context 'get host list attached or defined cf' do
108
- it 'all of hosts' do
109
- expect(Host.elements).to eq(["hostA"])
110
- end
203
+ context "get host list attached or defined cf" do
204
+ it "all of hosts" do
205
+ expect(@host.list).to eq(["test1.studio3104.com", "test2.studio3104.com", "hostA"])
206
+ end
207
+
208
+ it "hosts of one of role" do
209
+ expect(@host.list(1)).to eq(["hostA"])
210
+ end
211
+ end
212
+
213
+ context "set, get and delete attribute of a host" do
214
+ it { @host.set_attr("hostA", { A: "apple", B: "banana", C: "chocolate" }) }
215
+ it { expect(@host.get_attr("hostA")).to eq({ A: "apple", B: "banana", C: "chocolate" }) }
216
+ it { expect(@host.get_attr_json("hostA")).to eq("{\"A\":\"apple\",\"B\":\"banana\",\"C\":\"chocolate\"}") }
217
+ it { expect(@host.get_attr("hostA", "A")).to eq({ A: "apple" }) }
218
+ it { expect(@host.get_attr("hostX")).to eq({}) }
219
+ it { expect(@host.get_attr_json("hostX")).to eq("{}") }
220
+
221
+ it { expect { @host.set_attr("hostA", { "A" => "anpanman" }) }.to(
222
+ raise_error(Houcho::AttributeExceptiotn, "attribute has already defined value in host - A")
223
+ )}
224
+
225
+ it "force set" do
226
+ expect(@host.set_attr!("hostA", { "A" => "anpanman" }))
227
+ end
228
+
229
+ it { expect { @host.set_attr("hostX",{ A: "apple", B: "banana", C: "chocolate" }) }.to(
230
+ raise_error(Houcho::HostExistenceException, "host does not exist - hostX")
231
+ ) }
232
+
233
+ it { expect(@host.del_attr("hostA", "C")).to eq({ :C => "chocolate" }) }
234
+ it { expect(@host.get_attr("hostA")).to eq({ A: "anpanman", B: "banana" }) }
235
+ it { expect(@host.del_attr("hostA")).to eq({ A: "anpanman", B: "banana" }) }
236
+ it { expect(@host.get_attr("hostA")).to eq({}) }
237
+ end
238
+ end
239
+
240
+
241
+ describe Houcho::Spec do
242
+ context "get details of a spec" do
243
+ it "host from original defined" do
244
+ expect(@spec.details(["specA"])).to eq(
245
+ { "specA" => { "role" => [ "studio3104" ] } }
246
+ )
247
+ end
248
+ end
249
+
250
+ context "attach and detach hosts to roles" do
251
+ it { @spec.attach(["specA", "specB"], ["studio3104", "studio3105"]) }
252
+ it { @spec.detach("specB", ["studio3104", "studio3105"]) }
253
+
254
+ it do
255
+ expect { @spec.attach("specA", "invalid_role") }.to(
256
+ raise_error(Houcho::RoleExistenceException, "role does not exist - invalid_role")
257
+ )
258
+ end
259
+
260
+ it do
261
+ expect { @spec.detach("specA", "invalid_role") }.to(
262
+ raise_error(Houcho::RoleExistenceException, "role does not exist - invalid_role")
263
+ )
264
+ end
265
+
266
+ it do
267
+ expect { @spec.attach("invalid_spec", "studio3104") }.to(
268
+ raise_error(Houcho::SpecFileException, "No such spec file - invalid_spec")
269
+ )
270
+ end
271
+ end
272
+
273
+ context "delete spec file" do
274
+ it {
275
+ @spec.check_existence("specC")
276
+ @spec.delete("specC")
277
+ expect { @spec.check_existence("specC") }.to(
278
+ raise_error(Houcho::SpecFileException, "No such spec file - specC")
279
+ )
280
+ }
281
+ it { expect { @spec.delete("specX") }.to(
282
+ raise_error(Houcho::SpecFileException, "No such spec file - specX")
283
+ ) }
284
+ it { expect { @spec.delete("specA") }.to(
285
+ raise_error(Houcho::SpecFileException,"spec file has been attached to role - specA")
286
+ ) }
287
+ it "force delete" do
288
+ @spec.check_existence("specA")
289
+ @spec.delete!("specA")
290
+ expect { @spec.check_existence("specA") }.to(
291
+ raise_error(Houcho::SpecFileException, "No such spec file - specA")
292
+ )
293
+ end
294
+ it {
295
+ File.write("#{Houcho::Config::SPECDIR}/specA_spec.rb"," ")
296
+ File.write("#{Houcho::Config::SPECDIR}/specC_spec.rb"," ")
297
+ @spec.attach("specA", ["studio3104", "studio3105"])
298
+ }
299
+ end
300
+
301
+ context "rename a spec file" do
302
+ it { @spec.rename("specC", "specSE") }
303
+
304
+ it { expect { @spec.rename("specX", "specXXX") }.to(
305
+ raise_error(Houcho::SpecFileException, "No such spec file - specX")
306
+ ) }
307
+
308
+ it { expect { @spec.rename("specSE", "specA") }.to(
309
+ raise_error(Houcho::SpecFileException, "spec file already exist - specA")
310
+ ) }
311
+
312
+ it { @spec.rename("specSE", "specC") }
313
+ end
314
+ end
111
315
 
112
- it 'hosts of one of role' do
113
- expect(Host.elements(1)).to eq(["hostA"])
114
- end
316
+
317
+ describe Houcho::OuterRole do
318
+ context "set, get and delete attribute of a role" do
319
+ it { @outerrole.set_attr(
320
+ "houcho::rspec::studio3104",
321
+ { A: "apple", B: "banana", C: "chocolate" }
322
+ ) }
323
+ it { expect(@outerrole.get_attr("houcho::rspec::studio3104")).to(
324
+ eq({ A: "apple", B: "banana", C: "chocolate" })
325
+ ) }
326
+ it { expect(@outerrole.get_attr_json("houcho::rspec::studio3104")).to(
327
+ eq("{\"A\":\"apple\",\"B\":\"banana\",\"C\":\"chocolate\"}")
328
+ ) }
329
+ it { expect(@outerrole.get_attr("houcho::rspec::studio3104", "A")).to(
330
+ eq({ A: "apple" })
331
+ ) }
332
+ it { expect(@outerrole.get_attr("invalid_role")).to eq({}) }
333
+ it { expect(@outerrole.get_attr_json("invalid_role")).to eq("{}") }
334
+
335
+ it { expect { @outerrole.set_attr(
336
+ "houcho::rspec::studio3104", { "A" => "anpanman" }
337
+ ) }.to(
338
+ raise_error(
339
+ Houcho::AttributeExceptiotn,
340
+ "attribute has already defined value in outerrole - A"
341
+ )
342
+ ) }
343
+
344
+ it "force set" do
345
+ expect(@outerrole.set_attr!("houcho::rspec::studio3104", { "A" => "anpanman" }))
115
346
  end
347
+
348
+ it { expect { @outerrole.set_attr("invalid_role",{ A: "apple", B: "banana", C: "chocolate" }) }.to(
349
+ raise_error(Houcho::OuterRoleExistenceException, "outer role does not exist - invalid_role")
350
+ ) }
351
+
352
+ it { expect(@outerrole.del_attr("houcho::rspec::studio3104", "C")).to eq({ :C => "chocolate" }) }
353
+ it { expect(@outerrole.get_attr("houcho::rspec::studio3104")).to eq({ A: "anpanman", B: "banana" }) }
354
+ it { expect(@outerrole.del_attr("houcho::rspec::studio3104")).to eq({ A: "anpanman", B: "banana" }) }
355
+ it { expect(@outerrole.get_attr("houcho::rspec::studio3104")).to eq({}) }
116
356
  end
117
357
  end
118
358
 
119
359
 
120
360
  describe Houcho::Spec::Runner do
121
- context 'run role' do
361
+ context "run role" do
122
362
  it do
123
- expect(Spec::Runner.exec(['studio3104'],[],[],[],{},true)).to eq([
124
- 'TARGET_HOST=hostA parallel_rspec spec/specA_spec.rb',
125
- 'TARGET_HOST=test1.studio3104.com parallel_rspec spec/specA_spec.rb',
126
- 'TARGET_HOST=test2.studio3104.com parallel_rspec spec/specA_spec.rb'
363
+ expect(@specrunner.execute_role("studio3104", [], true)).to eq([
364
+ "TARGET_HOST=hostA parallel_rspec #{Houcho::Config::SPECDIR}/specA_spec.rb",
365
+ "TARGET_HOST=test1.studio3104.com parallel_rspec #{Houcho::Config::SPECDIR}/specA_spec.rb",
366
+ "TARGET_HOST=test2.studio3104.com parallel_rspec #{Houcho::Config::SPECDIR}/specA_spec.rb"
127
367
  ])
128
368
  end
129
369
 
130
- it 'with exclude host' do
131
- expect(Spec::Runner.exec(['studio3104'],['test1.studio3104.com'],[],[],{},true)).to eq([
132
- 'TARGET_HOST=hostA parallel_rspec spec/specA_spec.rb',
133
- 'TARGET_HOST=test2.studio3104.com parallel_rspec spec/specA_spec.rb'
370
+ it "with exclude host" do
371
+ expect(@specrunner.execute_role("studio3104", "test1.studio3104.com", true)).to eq([
372
+ "TARGET_HOST=hostA parallel_rspec #{Houcho::Config::SPECDIR}/specA_spec.rb",
373
+ "TARGET_HOST=test2.studio3104.com parallel_rspec #{Houcho::Config::SPECDIR}/specA_spec.rb"
134
374
  ])
135
375
  end
136
376
  end
137
377
 
138
- context 'run manually' do
378
+ context "run manually" do
139
379
  it do
140
- expect(Spec::Runner.exec([],[],['test3.studio3104.com', 'test4.studio3104.com'],['specA'],{},true)).to eq([
141
- 'TARGET_HOST=test3.studio3104.com parallel_rspec spec/specA_spec.rb',
142
- 'TARGET_HOST=test4.studio3104.com parallel_rspec spec/specA_spec.rb'
380
+ expect(@specrunner.execute_manually(
381
+ ["test3.studio3104.com", "test4.studio3104.com"],
382
+ "specA",
383
+ true
384
+ )).to eq([
385
+ "TARGET_HOST=test3.studio3104.com parallel_rspec #{Houcho::Config::SPECDIR}/specA_spec.rb",
386
+ "TARGET_HOST=test4.studio3104.com parallel_rspec #{Houcho::Config::SPECDIR}/specA_spec.rb"
143
387
  ])
144
388
  end
145
389
 
146
- it 'case of spec not exist' do
147
- expect { Spec::Runner.exec([],[],['test5.studio3104.com'],['specA', 'specX'],{},true) }.to raise_error
390
+ it "case of spec not exist" do
391
+ expect { @specrunner.execute_manually("test5.studio3104.com", ["specA", "specX"], true) }.to(
392
+ raise_error Houcho::SpecFileException, "No such spec file - specX"
393
+ )
148
394
  end
149
395
  end
150
396
 
151
- context 'check spec' do
152
- it { expect(Spec::Runner.check(['specA'], 2, true).size).to be(2) }
153
- it 'case of spec not exist' do
154
- expect { Spec::Runner.check(['specX'], 2, true) }.to raise_error
397
+ context "check spec" do
398
+ it { expect(@specrunner.check("specA", 2, true).size).to be(2) }
399
+
400
+ it "case of spec not exist" do
401
+ expect { @specrunner.check("specX", 2) }.to(
402
+ raise_error Houcho::SpecFileException, "No such spec file - specX"
403
+ )
155
404
  end
156
405
  end
157
406
  end
158
-
159
-
160
- after :all do
161
- Dir.chdir('/')
162
- FileUtils.rm_rf(spectmp)
163
- end
164
407
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: houcho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi SUZUKI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-22 00:00:00.000000000 Z
11
+ date: 2013-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: parallel_tests
42
+ name: parallel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3-ruby
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -146,38 +160,34 @@ extra_rdoc_files: []
146
160
  files:
147
161
  - .gitignore
148
162
  - Gemfile
163
+ - Gemfile.lock
149
164
  - LICENSE.txt
150
165
  - README.md
151
166
  - Rakefile
152
167
  - bin/houcho
153
168
  - houcho.gemspec
154
169
  - lib/houcho.rb
170
+ - lib/houcho/attribute.rb
155
171
  - lib/houcho/ci.rb
156
- - lib/houcho/cloudforecast.rb
157
- - lib/houcho/cloudforecast/host.rb
158
- - lib/houcho/cloudforecast/role.rb
172
+ - lib/houcho/cli.rb
173
+ - lib/houcho/cli/attribute.rb
174
+ - lib/houcho/cli/host.rb
175
+ - lib/houcho/cli/outerrole.rb
176
+ - lib/houcho/cli/role.rb
177
+ - lib/houcho/cli/spec.rb
178
+ - lib/houcho/config.rb
179
+ - lib/houcho/database.rb
159
180
  - lib/houcho/element.rb
160
181
  - lib/houcho/host.rb
182
+ - lib/houcho/outerrole.rb
183
+ - lib/houcho/outerrole/cloudforecast.rb
184
+ - lib/houcho/outerrole/yabitz.rb
185
+ - lib/houcho/repository.rb
161
186
  - lib/houcho/role.rb
162
187
  - lib/houcho/spec.rb
163
188
  - lib/houcho/spec/runner.rb
164
189
  - lib/houcho/version.rb
165
- - lib/houcho/yamlhandle.rb
166
190
  - spec/houcho_spec.rb
167
- - spec/spec_helper.rb
168
- - templates/conf/houcho.conf
169
- - templates/conf/kk.rb
170
- - templates/conf/rspec.conf
171
- - templates/master
172
- - templates/role/cf_roles.yaml
173
- - templates/role/cloudforecast.yaml
174
- - templates/role/cloudforecast/.gitkeep
175
- - templates/role/hosts.yaml
176
- - templates/role/hosts_ignored.yaml
177
- - templates/role/roles.yaml
178
- - templates/role/specs.yaml
179
- - templates/spec/sample_spec.rb
180
- - templates/spec/spec_helper.rb
181
191
  homepage: https://github.com/studio3104/houcho
182
192
  licenses:
183
193
  - MIT
@@ -204,4 +214,3 @@ specification_version: 4
204
214
  summary: covering to run serverspec
205
215
  test_files:
206
216
  - spec/houcho_spec.rb
207
- - spec/spec_helper.rb