testlab 0.9.1 → 1.0.0

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.
Files changed (52) hide show
  1. data/README.md +26 -20
  2. data/bin/tl +2 -3
  3. data/features/support/Labfile.local +11 -1
  4. data/features/support/Labfile.vagrant +7 -1
  5. data/lib/commands/container.rb +3 -3
  6. data/lib/commands/network.rb +2 -2
  7. data/lib/commands/testlab.rb +15 -15
  8. data/lib/testlab/container/actions.rb +9 -1
  9. data/lib/testlab/container/io.rb +20 -7
  10. data/lib/testlab/container/lifecycle.rb +20 -37
  11. data/lib/testlab/container/lxc.rb +2 -2
  12. data/lib/testlab/container/status.rb +2 -2
  13. data/lib/testlab/container.rb +4 -2
  14. data/lib/testlab/labfile.rb +1 -1
  15. data/lib/testlab/network/actions.rb +40 -4
  16. data/lib/testlab/network/lifecycle.rb +14 -31
  17. data/lib/testlab/network/status.rb +22 -2
  18. data/lib/testlab/node/actions.rb +8 -0
  19. data/lib/testlab/node/lifecycle.rb +14 -35
  20. data/lib/testlab/providers/local.rb +2 -2
  21. data/lib/testlab/providers/vagrant.rb +0 -2
  22. data/lib/testlab/provisioners/apt.rb +2 -2
  23. data/lib/testlab/provisioners/apt_cacher_ng.rb +12 -4
  24. data/lib/testlab/provisioners/bind.rb +23 -11
  25. data/lib/testlab/provisioners/chef/omni_bus.rb +4 -4
  26. data/lib/testlab/provisioners/chef/omni_truck.rb +2 -2
  27. data/lib/testlab/provisioners/chef/ruby_gem_client.rb +4 -4
  28. data/lib/testlab/provisioners/chef/ruby_gem_server.rb +2 -2
  29. data/lib/testlab/provisioners/raring.rb +2 -2
  30. data/lib/testlab/provisioners/resolv.rb +7 -5
  31. data/lib/testlab/provisioners/route.rb +4 -4
  32. data/lib/testlab/provisioners/shell.rb +2 -2
  33. data/lib/testlab/provisioners/templates/apt/bootstrap.erb +2 -2
  34. data/lib/testlab/provisioners/templates/apt_cacher_ng/bootstrap.erb +0 -2
  35. data/lib/testlab/provisioners/templates/apt_cacher_ng/security.conf.erb +1 -0
  36. data/lib/testlab/provisioners/templates/bind/bind-db.erb +1 -1
  37. data/lib/testlab/provisioners/templates/chef/omni_bus.erb +1 -1
  38. data/lib/testlab/provisioners/templates/chef/omni_truck.erb +1 -1
  39. data/lib/testlab/provisioners/templates/chef/ruby_gem_client.erb +1 -1
  40. data/lib/testlab/provisioners/templates/chef/ruby_gem_server.erb +1 -1
  41. data/lib/testlab/provisioners/templates/raring/bootstrap.erb +2 -2
  42. data/lib/testlab/user/lifecycle.rb +2 -2
  43. data/lib/testlab/utility/gli.rb +10 -10
  44. data/lib/testlab/utility/misc.rb +11 -0
  45. data/lib/testlab/version.rb +1 -1
  46. data/lib/testlab.rb +12 -12
  47. data/spec/container_spec.rb +14 -14
  48. data/spec/network_spec.rb +10 -8
  49. data/spec/node_spec.rb +10 -10
  50. data/spec/provisioners/shell_spec.rb +3 -3
  51. data/spec/testlab_spec.rb +12 -12
  52. metadata +5 -4
@@ -1,6 +1,6 @@
1
1
  class TestLab
2
2
  unless const_defined?(:VERSION)
3
3
  # TestLab Gem Version
4
- VERSION = "0.9.1"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
data/lib/testlab.rb CHANGED
@@ -9,8 +9,8 @@ require 'testlab/monkeys'
9
9
  # TestLab - A framework for building lightweight virtual infrastructure using LXC
10
10
  #
11
11
  # The core concept with the TestLab is the *Labfile*. This file dictates the
12
- # topology of your virtual infrastructure. With simple commands you can setup
13
- # and teardown this infrastructure on the fly for all sorts of purposes from
12
+ # topology of your virtual infrastructure. With simple commands you can build
13
+ # and demolish this infrastructure on the fly for all sorts of purposes from
14
14
  # automating infrastructure testing to testing new software to experimenting
15
15
  # in general where you want to spin up alot of servers but do not want the
16
16
  # overhead of virtualization. At it's core TestLab uses Linux Containers (LXC)
@@ -273,26 +273,26 @@ class TestLab
273
273
  true
274
274
  end
275
275
 
276
- # Test Lab Setup
276
+ # Test Lab Provision
277
277
  #
278
- # Attempts to setup our lab topology. This calls the setup method on all of
279
- # our nodes.
278
+ # Attempts to provision our lab topology. This calls the provision method on
279
+ # all of our nodes.
280
280
  #
281
281
  # @return [Boolean] True if successful.
282
- def setup
283
- method_proxy(:setup)
282
+ def provision
283
+ method_proxy(:provision)
284
284
 
285
285
  true
286
286
  end
287
287
 
288
- # Test Lab Teardown
288
+ # Test Lab Deprovision
289
289
  #
290
- # Attempts to tearddown our lab topology. This calls the teardown method on
291
- # all of our nodes.
290
+ # Attempts to tearddown our lab topology. This calls the deprovision method
291
+ # on all of our nodes.
292
292
  #
293
293
  # @return [Boolean] True if successful.
294
- def teardown
295
- reverse_method_proxy(:teardown)
294
+ def deprovision
295
+ reverse_method_proxy(:deprovision)
296
296
 
297
297
  true
298
298
  end
@@ -193,54 +193,54 @@ describe TestLab::Container do
193
193
  end
194
194
  end
195
195
 
196
- describe "#setup" do
196
+ describe "#provision" do
197
197
  context "with no provisioner" do
198
- it "should setup the container" do
198
+ it "should provision the container" do
199
199
  subject.node.stub(:state) { :running }
200
200
  subject.lxc.stub(:exists?) { true }
201
201
  subject.lxc.stub(:state) { :stopped }
202
- subject.provisioners = Array.new
202
+ subject.stub(:provisioners) { Array.new }
203
203
 
204
- subject.setup
204
+ subject.provision
205
205
  end
206
206
  end
207
207
 
208
208
  context "with the shell provisioner" do
209
- it "should setup the container" do
209
+ it "should provision the container" do
210
210
  subject and (subject = TestLab::Container.first('server-shell'))
211
211
 
212
212
  subject.node.stub(:state) { :running }
213
213
  subject.lxc.stub(:exists?) { true }
214
214
  subject.lxc.stub(:state) { :stopped }
215
- subject.provisioners = Array.new
215
+ subject.stub(:provisioners) { Array.new }
216
216
 
217
- subject.setup
217
+ subject.provision
218
218
  end
219
219
  end
220
220
  end
221
221
 
222
- describe "#teardown" do
222
+ describe "#deprovision" do
223
223
  context "with no provisioner" do
224
- it "should teardown the container" do
224
+ it "should deprovision the container" do
225
225
  subject.node.stub(:state) { :running }
226
226
  subject.lxc.stub(:exists?) { true }
227
227
  subject.lxc.stub(:state) { :stopped }
228
- subject.provisioners = Array.new
228
+ subject.stub(:provisioners) { Array.new }
229
229
 
230
- subject.teardown
230
+ subject.deprovision
231
231
  end
232
232
  end
233
233
 
234
234
  context "with the shell provisioner" do
235
- it "should teardown the container" do
235
+ it "should deprovision the container" do
236
236
  subject and (subject = TestLab::Container.first('server-shell'))
237
237
 
238
238
  subject.node.stub(:state) { :running }
239
239
  subject.lxc.stub(:exists?) { true }
240
240
  subject.lxc.stub(:state) { :stopped }
241
- subject.provisioners = Array.new
241
+ subject.stub(:provisioners) { Array.new }
242
242
 
243
- subject.teardown
243
+ subject.deprovision
244
244
  end
245
245
  end
246
246
 
data/spec/network_spec.rb CHANGED
@@ -111,7 +111,7 @@ describe TestLab::Network do
111
111
  it "should create the network bridge" do
112
112
  subject.node.stub(:state) { :running }
113
113
  subject.stub(:state) { :not_created }
114
- subject.node.ssh.stub(:exec) { true }
114
+ subject.node.ssh.stub(:bootstrap) { true }
115
115
  subject.create
116
116
  end
117
117
  end
@@ -120,7 +120,7 @@ describe TestLab::Network do
120
120
  it "should destroy the network bridge" do
121
121
  subject.node.stub(:state) { :running }
122
122
  subject.stub(:state) { :stopped }
123
- subject.node.ssh.stub(:exec) { true }
123
+ subject.node.ssh.stub(:bootstrap) { true }
124
124
  subject.destroy
125
125
  end
126
126
  end
@@ -129,7 +129,7 @@ describe TestLab::Network do
129
129
  it "should online the network bridge" do
130
130
  subject.node.stub(:state) { :running }
131
131
  subject.stub(:state) { :stopped }
132
- subject.node.ssh.stub(:exec) { true }
132
+ subject.node.ssh.stub(:bootstrap) { true }
133
133
  subject.up
134
134
  end
135
135
  end
@@ -138,30 +138,32 @@ describe TestLab::Network do
138
138
  it "should offline the network bridge" do
139
139
  subject.node.stub(:state) { :running }
140
140
  subject.stub(:state) { :running }
141
- subject.node.ssh.stub(:exec) { true }
141
+ subject.node.ssh.stub(:bootstrap) { true }
142
142
  subject.down
143
143
  end
144
144
  end
145
145
 
146
- describe "#setup" do
146
+ describe "#provision" do
147
147
  it "should create and online the network" do
148
148
  subject.node.stub(:state) { :running }
149
149
  subject.stub(:state) { :running }
150
150
  subject.stub(:create) { true }
151
151
  subject.stub(:up) { true }
152
+ subject.stub(:provisioners) { Array.new }
152
153
 
153
- subject.setup
154
+ subject.provision
154
155
  end
155
156
  end
156
157
 
157
- describe "#teardown" do
158
+ describe "#deprovision" do
158
159
  it "should create and online the network" do
159
160
  subject.node.stub(:state) { :running }
160
161
  subject.stub(:state) { :running }
161
162
  subject.stub(:down) { true }
162
163
  subject.stub(:destroy) { true }
164
+ subject.stub(:provisioners) { Array.new }
163
165
 
164
- subject.teardown
166
+ subject.deprovision
165
167
  end
166
168
  end
167
169
 
data/spec/node_spec.rb CHANGED
@@ -99,21 +99,21 @@ describe TestLab::Node do
99
99
  end
100
100
  end
101
101
 
102
- describe "setup" do
103
- it "should setup the node" do
104
- subject.provisioners = Array.new
105
- subject.containers.each { |c| c.provisioners = Array.new }
102
+ describe "provision" do
103
+ it "should provision the node" do
106
104
  subject.stub(:state) { :running }
107
- subject.setup
105
+ subject.stub(:provisioners) { Array.new }
106
+
107
+ subject.provision
108
108
  end
109
109
  end
110
110
 
111
- describe "teardown" do
112
- it "should teardown the node" do
113
- subject.provisioners = Array.new
114
- subject.containers.each { |c| c.provisioners = Array.new }
111
+ describe "deprovision" do
112
+ it "should deprovision the node" do
115
113
  subject.stub(:state) { :running }
116
- subject.teardown
114
+ subject.stub(:provisioners) { Array.new }
115
+
116
+ subject.deprovision
117
117
  end
118
118
  end
119
119
 
@@ -38,7 +38,7 @@ describe TestLab::Provisioner::Shell do
38
38
 
39
39
  describe "methods" do
40
40
 
41
- describe "setup" do
41
+ describe "provision" do
42
42
  context "bootstrap successful" do
43
43
  it "should provision the container" do
44
44
  subject.node.ssh.stub(:file).and_yield(StringIO.new)
@@ -48,7 +48,7 @@ describe TestLab::Provisioner::Shell do
48
48
  subject.lxc_clone.stub(:exists?) { false }
49
49
 
50
50
  p = TestLab::Provisioner::Shell.new(subject.config, @ui)
51
- p.on_container_setup(subject)
51
+ p.on_container_provision(subject)
52
52
  end
53
53
  end
54
54
 
@@ -61,7 +61,7 @@ describe TestLab::Provisioner::Shell do
61
61
  subject.lxc_clone.stub(:exists?) { false }
62
62
 
63
63
  p = TestLab::Provisioner::Shell.new(Hash.new, @ui)
64
- lambda{ p.on_container_setup(subject) }.should raise_error TestLab::Provisioner::ShellError
64
+ lambda{ p.on_container_provision(subject) }.should raise_error TestLab::Provisioner::ShellError
65
65
  end
66
66
  end
67
67
  end
data/spec/testlab_spec.rb CHANGED
@@ -38,35 +38,35 @@ describe TestLab do
38
38
 
39
39
  describe "methods" do
40
40
 
41
- describe "setup" do
42
- it "should setup the test lab" do
41
+ describe "provision" do
42
+ it "should provision the test lab" do
43
43
  subject.stub(:dead?) { false }
44
44
  subject.nodes.each do |node|
45
- node.stub(:setup) { true }
45
+ node.stub(:provision) { true }
46
46
  end
47
47
  subject.containers.each do |container|
48
- container.stub(:setup) { true }
48
+ container.stub(:provision) { true }
49
49
  end
50
50
  subject.networks.each do |network|
51
- network.stub(:setup) { true }
51
+ network.stub(:provision) { true }
52
52
  end
53
- subject.setup
53
+ subject.provision
54
54
  end
55
55
  end
56
56
 
57
- describe "teardown" do
58
- it "should teardown the test lab" do
57
+ describe "deprovision" do
58
+ it "should deprovision the test lab" do
59
59
  subject.stub(:dead?) { false }
60
60
  subject.nodes.each do |node|
61
- node.stub(:teardown) { true }
61
+ node.stub(:deprovision) { true }
62
62
  end
63
63
  subject.containers.each do |container|
64
- container.stub(:teardown) { true }
64
+ container.stub(:deprovision) { true }
65
65
  end
66
66
  subject.networks.each do |network|
67
- network.stub(:teardown) { true }
67
+ network.stub(:deprovision) { true }
68
68
  end
69
- subject.teardown
69
+ subject.deprovision
70
70
  end
71
71
  end
72
72
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-16 00:00:00.000000000 Z
12
+ date: 2013-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
@@ -287,6 +287,7 @@ files:
287
287
  - lib/testlab/provisioners/templates/apt/bootstrap.erb
288
288
  - lib/testlab/provisioners/templates/apt_cacher_ng/00proxy.erb
289
289
  - lib/testlab/provisioners/templates/apt_cacher_ng/bootstrap.erb
290
+ - lib/testlab/provisioners/templates/apt_cacher_ng/security.conf.erb
290
291
  - lib/testlab/provisioners/templates/bind/bind-db.erb
291
292
  - lib/testlab/provisioners/templates/bind/bind-zone.erb
292
293
  - lib/testlab/provisioners/templates/bind/bind.erb
@@ -331,7 +332,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
331
332
  version: '0'
332
333
  segments:
333
334
  - 0
334
- hash: 4125715587205282977
335
+ hash: 4468279295087134630
335
336
  required_rubygems_version: !ruby/object:Gem::Requirement
336
337
  none: false
337
338
  requirements:
@@ -340,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
340
341
  version: '0'
341
342
  segments:
342
343
  - 0
343
- hash: 4125715587205282977
344
+ hash: 4468279295087134630
344
345
  requirements: []
345
346
  rubyforge_project:
346
347
  rubygems_version: 1.8.25