vagrant-lxc 0.8.0 → 1.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/BOXES.md +13 -21
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +5 -2
- data/Gemfile +12 -13
- data/Gemfile.lock +66 -51
- data/README.md +39 -25
- data/development/Vagrantfile +0 -2
- data/lib/vagrant-backports/README.md +12 -0
- data/lib/vagrant-backports/action/handle_box.rb +1 -0
- data/lib/vagrant-backports/action/is_state.rb +34 -0
- data/lib/vagrant-backports/action/message.rb +20 -0
- data/lib/{vagrant-lxc → vagrant-backports}/action/wait_for_communicator.rb +6 -5
- data/lib/vagrant-backports/ui.rb +12 -0
- data/lib/vagrant-backports/utils.rb +27 -0
- data/lib/vagrant-lxc.rb +8 -0
- data/lib/vagrant-lxc/action.rb +81 -48
- data/lib/vagrant-lxc/action/boot.rb +2 -1
- data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +1 -0
- data/lib/vagrant-lxc/action/handle_box_metadata.rb +36 -14
- data/lib/vagrant-lxc/action/message.rb +0 -23
- data/lib/vagrant-lxc/action/prepare_nfs_settings.rb +64 -0
- data/lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb +19 -0
- data/lib/vagrant-lxc/action/setup_package_files.rb +6 -2
- data/lib/vagrant-lxc/{action → backports/action}/share_folders.rb +0 -0
- data/lib/vagrant-lxc/command/root.rb +58 -0
- data/lib/vagrant-lxc/command/sudoers.rb +87 -0
- data/lib/vagrant-lxc/driver.rb +21 -11
- data/lib/vagrant-lxc/plugin.rb +23 -5
- data/lib/vagrant-lxc/provider/cap/public_address.rb +17 -0
- data/lib/vagrant-lxc/synced_folder.rb +42 -0
- data/lib/vagrant-lxc/version.rb +1 -1
- data/locales/en.yml +6 -5
- data/scripts/lxc-template +165 -0
- data/spec/spec_helper.rb +9 -13
- data/spec/unit/action/clear_forwarded_ports_spec.rb +3 -3
- data/spec/unit/action/compress_rootfs_spec.rb +7 -5
- data/spec/unit/action/forward_ports_spec.rb +8 -8
- data/spec/unit/action/handle_box_metadata_spec.rb +71 -15
- data/spec/unit/action/setup_package_files_spec.rb +32 -8
- data/spec/unit/driver/cli_spec.rb +31 -30
- data/spec/unit/driver_spec.rb +35 -27
- data/spec/unit/support/unit_example_group.rb +6 -6
- data/spec/unit_helper.rb +4 -2
- data/tasks/spec.rake +18 -11
- data/vagrant-lxc.gemspec +7 -0
- data/vagrant-spec.config.rb +24 -0
- metadata +24 -36
- data/boxes/build-all.sh +0 -22
- data/boxes/build-debian-box.sh +0 -167
- data/boxes/build-openmandriva-box.sh +0 -159
- data/boxes/build-ubuntu-box.sh +0 -151
- data/boxes/common/cleanup +0 -7
- data/boxes/common/install-babushka +0 -16
- data/boxes/common/install-chef +0 -15
- data/boxes/common/install-puppet +0 -13
- data/boxes/common/install-salt +0 -12
- data/boxes/common/install-salt-debian +0 -28
- data/boxes/common/lxc-template +0 -226
- data/boxes/common/lxc-template-openmandriva +0 -225
- data/boxes/common/lxc.conf +0 -49
- data/boxes/common/metadata.json +0 -5
- data/lib/vagrant-lxc/action/check_created.rb +0 -21
- data/lib/vagrant-lxc/action/check_running.rb +0 -21
- data/lib/vagrant-lxc/action/created.rb +0 -20
- data/lib/vagrant-lxc/action/disconnect.rb +0 -18
- data/lib/vagrant-lxc/action/is_running.rb +0 -19
- data/spec/acceptance/sanity_check_spec.rb +0 -111
- data/spec/acceptance/support/acceptance_example_group.rb +0 -76
- data/spec/acceptance/support/machine_ext.rb +0 -12
- data/spec/acceptance/support/test_ui.rb +0 -22
- data/spec/acceptance_helper.rb +0 -21
@@ -5,16 +5,16 @@ require 'vagrant-lxc/action/setup_package_files'
|
|
5
5
|
describe Vagrant::LXC::Action::SetupPackageFiles do
|
6
6
|
let(:app) { double(:app, call: true) }
|
7
7
|
let(:env) { {machine: machine, tmp_path: tmp_path, ui: double(info: true), 'package.rootfs' => rootfs_path} }
|
8
|
-
let(:machine) {
|
8
|
+
let(:machine) { double(Vagrant::Machine, box: box) }
|
9
9
|
let!(:tmp_path) { Pathname.new(Dir.mktmpdir) }
|
10
|
-
let(:box) {
|
10
|
+
let(:box) { double(Vagrant::Box, directory: tmp_path.join('box')) }
|
11
11
|
let(:rootfs_path) { tmp_path.join('rootfs-amd64.tar.gz') }
|
12
12
|
|
13
13
|
subject { described_class.new(app, env) }
|
14
14
|
|
15
15
|
before do
|
16
16
|
box.directory.mkdir
|
17
|
-
files = %w( lxc-template metadata.json lxc.conf ).map { |f| box.directory.join(f) }
|
17
|
+
files = %w( lxc-template metadata.json lxc.conf lxc-config ).map { |f| box.directory.join(f) }
|
18
18
|
(files + [rootfs_path]).each do |file|
|
19
19
|
file.open('w') { |f| f.puts file.to_s }
|
20
20
|
end
|
@@ -30,20 +30,34 @@ describe Vagrant::LXC::Action::SetupPackageFiles do
|
|
30
30
|
before { subject.call(env) }
|
31
31
|
|
32
32
|
it 'copies box lxc-template to package directory' do
|
33
|
-
env['package.directory'].join('lxc-template').
|
33
|
+
expect(env['package.directory'].join('lxc-template')).to be_file
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'copies metadata.json to package directory' do
|
37
|
-
env['package.directory'].join('metadata.json').
|
37
|
+
expect(env['package.directory'].join('metadata.json')).to be_file
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'copies box lxc.conf to package directory' do
|
41
|
-
env['package.directory'].join('lxc-template').
|
41
|
+
expect(env['package.directory'].join('lxc-template')).to be_file
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'copies box lxc-config to package directory' do
|
45
|
+
expect(env['package.directory'].join('lxc-config')).to be_file
|
42
46
|
end
|
43
47
|
|
44
48
|
it 'moves the compressed rootfs to package directory' do
|
45
|
-
env['package.directory'].join(rootfs_path.basename).
|
46
|
-
env['package.rootfs'].
|
49
|
+
expect(env['package.directory'].join(rootfs_path.basename)).to be_file
|
50
|
+
expect(env['package.rootfs']).not_to be_file
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when lxc-template file is not present' do
|
55
|
+
before do
|
56
|
+
box.directory.join('lxc-template').delete
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'does not blow up' do
|
60
|
+
expect { subject.call(env) }.to_not raise_error
|
47
61
|
end
|
48
62
|
end
|
49
63
|
|
@@ -56,4 +70,14 @@ describe Vagrant::LXC::Action::SetupPackageFiles do
|
|
56
70
|
expect { subject.call(env) }.to_not raise_error
|
57
71
|
end
|
58
72
|
end
|
73
|
+
|
74
|
+
context 'when lxc-config file is not present' do
|
75
|
+
before do
|
76
|
+
box.directory.join('lxc-config').delete
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'does not blow up' do
|
80
|
+
expect { subject.call(env) }.to_not raise_error
|
81
|
+
end
|
82
|
+
end
|
59
83
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'unit_helper'
|
2
2
|
|
3
|
+
require 'vagrant-lxc/sudo_wrapper'
|
3
4
|
require 'vagrant-lxc/driver/cli'
|
4
5
|
|
5
6
|
describe Vagrant::LXC::Driver::CLI do
|
6
|
-
let(:sudo_wrapper) {
|
7
|
+
let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) }
|
7
8
|
|
8
9
|
subject { described_class.new(sudo_wrapper) }
|
9
10
|
|
@@ -12,18 +13,18 @@ describe Vagrant::LXC::Driver::CLI do
|
|
12
13
|
let(:result) { @result }
|
13
14
|
|
14
15
|
before do
|
15
|
-
subject.
|
16
|
+
allow(subject).to receive(:run).with(:ls).and_return(lxc_ls_out)
|
16
17
|
@result = subject.list
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'grabs previously created containers from lxc-ls output' do
|
20
|
-
result.
|
21
|
-
result.
|
22
|
-
result.
|
21
|
+
expect(result).to be_an Enumerable
|
22
|
+
expect(result).to include 'a-container'
|
23
|
+
expect(result).to include 'dup-container'
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'removes duplicates from lxc-ls output' do
|
26
|
-
result.uniq.
|
27
|
+
expect(result.uniq).to eq(result)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
@@ -31,11 +32,11 @@ describe Vagrant::LXC::Driver::CLI do
|
|
31
32
|
let(:lxc_version_out) { "lxc version: 0.x.y-rc1\n" }
|
32
33
|
|
33
34
|
before do
|
34
|
-
subject.
|
35
|
+
allow(subject).to receive(:run).with(:version).and_return(lxc_version_out)
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'parses the version from the output' do
|
38
|
-
subject.version.
|
39
|
+
expect(subject.version).to eq('0.x.y-rc1')
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
@@ -48,12 +49,12 @@ describe Vagrant::LXC::Driver::CLI do
|
|
48
49
|
subject { described_class.new(sudo_wrapper, name) }
|
49
50
|
|
50
51
|
before do
|
51
|
-
subject.
|
52
|
+
allow(subject).to receive(:run) { |*args| @run_args = args }
|
52
53
|
end
|
53
54
|
|
54
55
|
it 'issues a lxc-create with provided template, container name and hash of arguments' do
|
55
56
|
subject.create(template, config_file, template_args)
|
56
|
-
subject.
|
57
|
+
expect(subject).to have_received(:run).with(
|
57
58
|
:create,
|
58
59
|
'--template', template,
|
59
60
|
'--name', name,
|
@@ -65,7 +66,7 @@ describe Vagrant::LXC::Driver::CLI do
|
|
65
66
|
end
|
66
67
|
|
67
68
|
it 'wraps a low level error into something more meaningful in case the container already exists' do
|
68
|
-
subject.
|
69
|
+
allow(subject).to receive(:run) { raise Vagrant::LXC::Errors::ExecuteError, stderr: 'alreAdy Exists' }
|
69
70
|
expect {
|
70
71
|
subject.create(template, config_file, template_args)
|
71
72
|
}.to raise_error(Vagrant::LXC::Errors::ContainerAlreadyExists)
|
@@ -78,12 +79,12 @@ describe Vagrant::LXC::Driver::CLI do
|
|
78
79
|
subject { described_class.new(sudo_wrapper, name) }
|
79
80
|
|
80
81
|
before do
|
81
|
-
subject.
|
82
|
+
allow(subject).to receive(:run)
|
82
83
|
subject.destroy
|
83
84
|
end
|
84
85
|
|
85
86
|
it 'issues a lxc-destroy with container name' do
|
86
|
-
subject.
|
87
|
+
expect(subject).to have_received(:run).with(:destroy, '--name', name)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
@@ -92,12 +93,12 @@ describe Vagrant::LXC::Driver::CLI do
|
|
92
93
|
subject { described_class.new(sudo_wrapper, name) }
|
93
94
|
|
94
95
|
before do
|
95
|
-
subject.
|
96
|
+
allow(subject).to receive(:run)
|
96
97
|
end
|
97
98
|
|
98
99
|
it 'starts container on the background' do
|
99
100
|
subject.start
|
100
|
-
subject.
|
101
|
+
expect(subject).to have_received(:run).with(
|
101
102
|
:start,
|
102
103
|
'-d',
|
103
104
|
'--name', name
|
@@ -111,16 +112,16 @@ describe Vagrant::LXC::Driver::CLI do
|
|
111
112
|
|
112
113
|
before do
|
113
114
|
subject.stub(system: true)
|
114
|
-
subject.
|
115
|
+
allow(subject).to receive(:run)
|
115
116
|
end
|
116
117
|
|
117
118
|
it 'issues a lxc-shutdown with provided container name' do
|
118
119
|
subject.shutdown
|
119
|
-
subject.
|
120
|
+
expect(subject).to have_received(:run).with(:shutdown, '--name', name)
|
120
121
|
end
|
121
122
|
|
122
123
|
it 'raises a ShutdownNotSupported in case it is not supported' do
|
123
|
-
subject.
|
124
|
+
allow(subject).to receive(:system).with('which lxc-shutdown > /dev/null').and_return(false)
|
124
125
|
expect { subject.shutdown }.to raise_error(described_class::ShutdownNotSupported)
|
125
126
|
end
|
126
127
|
end
|
@@ -130,21 +131,21 @@ describe Vagrant::LXC::Driver::CLI do
|
|
130
131
|
subject { described_class.new(sudo_wrapper, name) }
|
131
132
|
|
132
133
|
before do
|
133
|
-
subject.
|
134
|
+
allow(subject).to receive(:run).and_return("state: STOPPED\npid: 2")
|
134
135
|
end
|
135
136
|
|
136
137
|
it 'calls lxc-info with the right arguments' do
|
137
138
|
subject.state
|
138
|
-
subject.
|
139
|
+
expect(subject).to have_received(:run).with(:info, '--name', name, retryable: true)
|
139
140
|
end
|
140
141
|
|
141
142
|
it 'maps the output of lxc-info status out to a symbol' do
|
142
|
-
subject.state.
|
143
|
+
expect(subject.state).to eq(:stopped)
|
143
144
|
end
|
144
145
|
|
145
146
|
it 'is not case sensitive' do
|
146
|
-
subject.
|
147
|
-
subject.state.
|
147
|
+
allow(subject).to receive(:run).and_return("StatE: STarTED\npid: 2")
|
148
|
+
expect(subject.state).to eq(:started)
|
148
149
|
end
|
149
150
|
end
|
150
151
|
|
@@ -160,17 +161,17 @@ describe Vagrant::LXC::Driver::CLI do
|
|
160
161
|
|
161
162
|
it 'calls lxc-attach with specified command' do
|
162
163
|
subject.attach(*command)
|
163
|
-
subject.
|
164
|
+
expect(subject).to have_received(:run).with(:attach, '--name', name, '--', *command)
|
164
165
|
end
|
165
166
|
|
166
167
|
it 'supports a "namespaces" parameter' do
|
167
|
-
subject.
|
168
|
+
allow(subject).to receive(:run).with(:attach, '-h', :show_stderr => true).and_return({:stdout => '', :stderr => '--namespaces'})
|
168
169
|
subject.attach *(command + [{namespaces: ['network', 'mount']}])
|
169
|
-
subject.
|
170
|
+
expect(subject).to have_received(:run).with(:attach, '--name', name, '--namespaces', 'NETWORK|MOUNT', '--', *command)
|
170
171
|
end
|
171
172
|
|
172
173
|
it 'raises a NamespacesNotSupported error if not supported' do
|
173
|
-
subject.
|
174
|
+
allow(subject).to receive(:run).with(:attach, '-h', :show_stderr => true).and_return({:stdout => '', :stderr => 'not supported'})
|
174
175
|
expect {
|
175
176
|
subject.attach *(command + [{namespaces: ['network', 'mount']}])
|
176
177
|
}.to raise_error(Vagrant::LXC::Errors::NamespacesNotSupported)
|
@@ -186,9 +187,9 @@ describe Vagrant::LXC::Driver::CLI do
|
|
186
187
|
end
|
187
188
|
|
188
189
|
it 'yields a cli object' do
|
189
|
-
subject.
|
190
|
+
allow(subject).to receive(:shutdown)
|
190
191
|
subject.transition_to(:stopped) { |c| c.shutdown }
|
191
|
-
subject.
|
192
|
+
expect(subject).to have_received(:shutdown)
|
192
193
|
end
|
193
194
|
|
194
195
|
it 'throws an exception if block is not provided' do
|
@@ -197,6 +198,6 @@ describe Vagrant::LXC::Driver::CLI do
|
|
197
198
|
}.to raise_error(described_class::TransitionBlockNotProvided)
|
198
199
|
end
|
199
200
|
|
200
|
-
|
201
|
+
skip 'waits for the expected container state'
|
201
202
|
end
|
202
203
|
end
|
data/spec/unit/driver_spec.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'unit_helper'
|
2
2
|
|
3
|
-
require 'vagrant'
|
4
3
|
require 'vagrant-lxc/driver'
|
5
4
|
require 'vagrant-lxc/driver/cli'
|
5
|
+
require 'vagrant-lxc/sudo_wrapper'
|
6
6
|
|
7
7
|
describe Vagrant::LXC::Driver do
|
8
8
|
describe 'container name validation' do
|
9
9
|
let(:unknown_container) { described_class.new('unknown', nil, cli) }
|
10
10
|
let(:valid_container) { described_class.new('valid', nil, cli) }
|
11
11
|
let(:new_container) { described_class.new(nil, nil) }
|
12
|
-
let(:cli) {
|
12
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, list: ['valid']) }
|
13
13
|
|
14
14
|
it 'raises a ContainerNotFound error if an unknown container name gets provided' do
|
15
15
|
expect {
|
@@ -37,21 +37,21 @@ describe Vagrant::LXC::Driver do
|
|
37
37
|
let(:template_opts) { {'--some' => 'random-option'} }
|
38
38
|
let(:config_file) { '/path/to/lxc-config-from-box' }
|
39
39
|
let(:rootfs_tarball) { '/path/to/cache/rootfs.tar.gz' }
|
40
|
-
let(:cli) {
|
40
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, :create => true, :name= => true) }
|
41
41
|
|
42
42
|
subject { described_class.new(nil, nil, cli) }
|
43
43
|
|
44
44
|
before do
|
45
|
-
subject.
|
45
|
+
allow(subject).to receive(:import_template).and_yield(template_name)
|
46
46
|
subject.create name, template_path, config_file, template_opts
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'sets the cli object container name' do
|
50
|
-
cli.
|
50
|
+
expect(cli).to have_received(:name=).with(name)
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'creates container with the right arguments' do
|
54
|
-
cli.
|
54
|
+
expect(cli).to have_received(:create).with(
|
55
55
|
template_name,
|
56
56
|
config_file,
|
57
57
|
template_opts
|
@@ -60,22 +60,22 @@ describe Vagrant::LXC::Driver do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe 'destruction' do
|
63
|
-
let(:cli) {
|
63
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, destroy: true) }
|
64
64
|
|
65
65
|
subject { described_class.new('name', nil, cli) }
|
66
66
|
|
67
67
|
before { subject.destroy }
|
68
68
|
|
69
69
|
it 'delegates to cli object' do
|
70
|
-
cli.
|
70
|
+
expect(cli).to have_received(:destroy)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe 'start' do
|
75
75
|
let(:customizations) { [['a', '1'], ['b', '2']] }
|
76
76
|
let(:internal_customization) { ['internal', 'customization'] }
|
77
|
-
let(:cli) {
|
78
|
-
let(:sudo) {
|
77
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, start: true) }
|
78
|
+
let(:sudo) { double(Vagrant::LXC::SudoWrapper, su_c: true) }
|
79
79
|
|
80
80
|
subject { described_class.new('name', sudo, cli) }
|
81
81
|
|
@@ -89,61 +89,62 @@ describe Vagrant::LXC::Driver do
|
|
89
89
|
it 'writes configurations to config file'
|
90
90
|
|
91
91
|
it 'starts container with configured customizations' do
|
92
|
-
cli.
|
92
|
+
expect(cli).to have_received(:start)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
describe 'halt' do
|
97
|
-
let(:cli) {
|
97
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, shutdown: true) }
|
98
98
|
|
99
99
|
subject { described_class.new('name', nil, cli) }
|
100
100
|
|
101
101
|
before do
|
102
|
-
cli.
|
102
|
+
allow(cli).to receive(:transition_to).and_yield(cli)
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'delegates to cli shutdown' do
|
106
|
-
cli.
|
106
|
+
expect(cli).to receive(:shutdown)
|
107
107
|
subject.forced_halt
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'expects a transition to running state to take place' do
|
111
|
-
cli.
|
111
|
+
expect(cli).to receive(:transition_to).with(:stopped)
|
112
112
|
subject.forced_halt
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'attempts to force the container to stop in case a shutdown doesnt work' do
|
116
|
-
cli.
|
117
|
-
cli.
|
118
|
-
cli.
|
116
|
+
allow(cli).to receive(:shutdown).and_raise(Vagrant::LXC::Driver::CLI::TargetStateNotReached.new :target, :source)
|
117
|
+
expect(cli).to receive(:transition_to).with(:stopped).twice
|
118
|
+
expect(cli).to receive(:stop)
|
119
119
|
subject.forced_halt
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'attempts to force the container to stop in case lxc-shutdown is not supported' do
|
123
|
-
cli.
|
124
|
-
cli.
|
125
|
-
cli.
|
123
|
+
allow(cli).to receive(:shutdown).and_raise(Vagrant::LXC::Driver::CLI::ShutdownNotSupported)
|
124
|
+
expect(cli).to receive(:transition_to).with(:stopped).twice
|
125
|
+
expect(cli).to receive(:stop)
|
126
126
|
subject.forced_halt
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
describe 'state' do
|
131
131
|
let(:cli_state) { :something }
|
132
|
-
let(:cli) {
|
132
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, state: cli_state) }
|
133
133
|
|
134
134
|
subject { described_class.new('name', nil, cli) }
|
135
135
|
|
136
136
|
it 'delegates to cli' do
|
137
|
-
subject.state.
|
137
|
+
expect(subject.state).to eq(cli_state)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
141
|
describe 'folder sharing' do
|
142
142
|
let(:shared_folder) { {guestpath: '/vagrant', hostpath: '/path/to/host/dir'} }
|
143
|
-
let(:
|
143
|
+
let(:ro_rw_folder) { {guestpath: '/vagrant/ro_rw', hostpath: '/path/to/host/dir', mount_options: ['ro', 'rw']} }
|
144
|
+
let(:folders) { [shared_folder, ro_rw_folder] }
|
144
145
|
let(:rootfs_path) { Pathname('/path/to/rootfs') }
|
145
146
|
let(:expected_guest_path) { "#{rootfs_path}/vagrant" }
|
146
|
-
let(:sudo_wrapper) {
|
147
|
+
let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) }
|
147
148
|
|
148
149
|
subject { described_class.new('name', sudo_wrapper) }
|
149
150
|
|
@@ -153,14 +154,21 @@ describe Vagrant::LXC::Driver do
|
|
153
154
|
end
|
154
155
|
|
155
156
|
it "creates guest folder under container's rootfs" do
|
156
|
-
sudo_wrapper.
|
157
|
+
expect(sudo_wrapper).to have_received(:run).with("mkdir", "-p", expected_guest_path)
|
157
158
|
end
|
158
159
|
|
159
160
|
it 'adds a mount.entry to its local customizations' do
|
160
|
-
subject.customizations.
|
161
|
+
expect(subject.customizations).to include [
|
161
162
|
'mount.entry',
|
162
163
|
"#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0"
|
163
164
|
]
|
164
165
|
end
|
166
|
+
|
167
|
+
it 'supports additional mount options' do
|
168
|
+
expect(subject.customizations).to include [
|
169
|
+
'mount.entry',
|
170
|
+
"#{ro_rw_folder[:hostpath]} #{rootfs_path}/vagrant/ro_rw none ro,rw 0 0"
|
171
|
+
]
|
172
|
+
end
|
165
173
|
end
|
166
174
|
end
|
@@ -2,23 +2,23 @@ module UnitExampleGroup
|
|
2
2
|
def self.included(base)
|
3
3
|
base.metadata[:type] = :unit
|
4
4
|
base.before do
|
5
|
-
Object.
|
5
|
+
allow_any_instance_of(Object).to receive(:system) { |instance, *args, &block|
|
6
6
|
UnitExampleGroup.prevent_system_calls(*args, &block)
|
7
7
|
}
|
8
|
-
Object.
|
8
|
+
allow_any_instance_of(Object).to receive(:`) { |instance, *args, &block|
|
9
9
|
UnitExampleGroup.prevent_system_calls(*args, &block)
|
10
10
|
}
|
11
|
-
Object.
|
11
|
+
allow_any_instance_of(Object).to receive(:exec) { |instance, *args, &block|
|
12
12
|
UnitExampleGroup.prevent_system_calls(*args, &block)
|
13
13
|
}
|
14
|
-
Object.
|
14
|
+
allow_any_instance_of(Object).to receive(:fork) { |instance, *args, &block|
|
15
15
|
UnitExampleGroup.prevent_system_calls(*args, &block)
|
16
16
|
}
|
17
|
-
Object.
|
17
|
+
allow_any_instance_of(Object).to receive(:spawn) { |instance, *args, &block|
|
18
18
|
UnitExampleGroup.prevent_system_calls(*args, &block)
|
19
19
|
}
|
20
20
|
require 'vagrant/util/subprocess'
|
21
|
-
Vagrant::Util::Subprocess.
|
21
|
+
allow(Vagrant::Util::Subprocess).to receive(:execute) { |*args, &block|
|
22
22
|
UnitExampleGroup.prevent_system_calls(*args, &block)
|
23
23
|
}
|
24
24
|
end
|