Skip to content

Commit

Permalink
fix issue #21 - run folder test command twice on provision for new Po…
Browse files Browse the repository at this point in the history
…SH setup
  • Loading branch information
mefellows committed Jun 27, 2016
1 parent 0ca07a6 commit bb54952
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion lib/vagrant-dsc/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DSCError < Vagrant::Errors::VagrantError
end
class DSCUnsupportedOperation < DSCError
error_key(:unsupported_operation)
end
end

# DSC Provisioner Plugin.
#
Expand Down Expand Up @@ -219,6 +219,10 @@ def run_dsc_apply
# on the guest machine.
def verify_shared_folders(folders)
folders.each do |folder|
# Warm up PoSH communicator for new instances - any stderr results
# in failure: https://github.com/mefellows/vagrant-dsc/issues/21
@machine.communicate.test("test -d #{folder}", sudo: true)

@logger.info("Checking for shared folder: #{folder}")
if !@machine.communicate.test("test -d #{folder}", sudo: true)
raise DSCError, :missing_shared_folders
Expand Down
16 changes: 8 additions & 8 deletions spec/provisioner/provisioner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
it "should raise error if folders not shared" do
root_config.synced_folder_type = "nfs"

expect(communicator).to receive(:test).with("test -d foo/modules", {:sudo=>true}).and_return(false)
expect(communicator).to receive(:test).twice.with("test -d foo/modules", {:sudo=>true}).and_return(false)

subject.configure(root_config)

Expand All @@ -100,9 +100,9 @@
it "should ensure shared folders are properly shared" do
root_config.synced_folder_type = "nfs"

expect(communicator).to receive(:test).with("test -d foo/modules", {:sudo=>true}).and_return(true)
expect(communicator).to receive(:test).with("test -d foo/modules2", {:sudo=>true}).and_return(true)
expect(communicator).to receive(:test).with("test -d manifests", {:sudo=>true}).and_return(true)
expect(communicator).to receive(:test).twice.with("test -d foo/modules", {:sudo=>true}).and_return(true)
expect(communicator).to receive(:test).twice.with("test -d foo/modules2", {:sudo=>true}).and_return(true)
expect(communicator).to receive(:test).twice.with("test -d manifests", {:sudo=>true}).and_return(true)

subject.configure(root_config)

Expand Down Expand Up @@ -183,12 +183,12 @@
expect(subject).to receive(:run_dsc_apply)

subject.provision
end
end

it "should ensure shared folders are properly configured" do
allow(communicator).to receive(:test)
allow(communicator).to receive(:sudo)
allow(communicator).to receive(:upload)
allow(communicator).to receive(:upload)
allow(subject).to receive(:verify_dsc).and_return(true)
allow(subject).to receive(:run_dsc_apply).and_return(true)
allow(guest).to receive(:capability?)
Expand Down Expand Up @@ -225,7 +225,7 @@

it "should raise an error if Powershell version is invalid" do

end
end
end

describe "DSC runner script" do
Expand Down Expand Up @@ -288,7 +288,7 @@ def get_and_update_counter(name=nil) 1 end
it "should generate a valid powershell command" do
root_config.manifests_path = "../manifests"
root_config.configuration_file = configuration_file

script = subject.generate_dsc_runner_script
expect_script = "#
# DSC Runner.
Expand Down

0 comments on commit bb54952

Please sign in to comment.