(#9811) Add test for volume consistency and improve documentation
This commit is contained in:
parent
428eb3ed93
commit
a3ef471cb0
|
@ -5,13 +5,15 @@ require Vagrant.source_root.join("plugins/providers/docker/synced_folder")
|
|||
describe VagrantPlugins::DockerProvider::SyncedFolder do
|
||||
subject { described_class.new }
|
||||
|
||||
describe "#usable?" do
|
||||
let(:provider_config) { double("provider_config", volumes: []) }
|
||||
let(:machine) { double("machine") }
|
||||
|
||||
before do
|
||||
allow(machine).to receive(:provider_name).and_return(:docker)
|
||||
allow(machine).to receive(:provider_config).and_return(provider_config)
|
||||
end
|
||||
|
||||
describe "#usable?" do
|
||||
it "is usable" do
|
||||
expect(subject).to be_usable(machine)
|
||||
end
|
||||
|
@ -27,4 +29,46 @@ describe VagrantPlugins::DockerProvider::SyncedFolder do
|
|||
to raise_error(VagrantPlugins::DockerProvider::Errors::SyncedFolderNonDocker)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#prepare" do
|
||||
let(:folders) {{"/guest/dir1"=>
|
||||
{:guestpath=>"/guest/dir1",
|
||||
:hostpath=>"/Users/brian/code/vagrant-sandbox",
|
||||
:disabled=>false,
|
||||
:__vagrantfile=>true},
|
||||
"/dev/vagrant"=>
|
||||
{:guestpath=>"/dev/vagrant",
|
||||
:hostpath=>"/Users/brian/code/vagrant",
|
||||
:disabled=>false,
|
||||
:__vagrantfile=>true}}}
|
||||
|
||||
let(:consistency_folders) {{"/guest/dir1"=>
|
||||
{:docker_consistency=>"cached",
|
||||
:guestpath=>"/guest/dir1",
|
||||
:hostpath=>"/Users/brian/code/vagrant-sandbox",
|
||||
:disabled=>false,
|
||||
:__vagrantfile=>true},
|
||||
"/dev/vagrant"=>
|
||||
{:docker_consistency=>"delegated",
|
||||
:guestpath=>"/dev/vagrant",
|
||||
:hostpath=>"/Users/brian/code/vagrant",
|
||||
:disabled=>false,
|
||||
:__vagrantfile=>true}}}
|
||||
let(:options) { {} }
|
||||
|
||||
let(:volumes) { ["/Users/brian/code/vagrant-sandbox:/guest/dir1",
|
||||
"/Users/brian/code/vagrant:/dev/vagrant"] }
|
||||
let(:consistency_volumes) { ["/Users/brian/code/vagrant-sandbox:/guest/dir1:cached",
|
||||
"/Users/brian/code/vagrant:/dev/vagrant:delegated"] }
|
||||
|
||||
it "prepares folders to mount" do
|
||||
subject.prepare(machine, folders, options)
|
||||
expect(machine.provider_config.volumes).to eq(volumes)
|
||||
end
|
||||
|
||||
it "sets volume consistency if specified" do
|
||||
subject.prepare(machine, consistency_folders, options)
|
||||
expect(machine.provider_config.volumes).to eq(consistency_volumes)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,10 +77,10 @@ Private and public networks are not currently supported.
|
|||
|
||||
### Volume Consistency
|
||||
|
||||
Docker's [volume consistency](https://github.com/moby/moby/pull/31047) setting can be specified using the `docker_consistency` option when defining a synced folder. This can
|
||||
Docker's [volume consistency](https://docs.docker.com/v17.09/engine/admin/volumes/bind-mounts/) setting can be specified using the `docker_consistency` option when defining a synced folder. This can
|
||||
[greatly improve performance on macOS](https://docs.docker.com/docker-for-mac/osxfs-caching). An example is shown using the `cached` and `delegated` settings:
|
||||
|
||||
```
|
||||
```ruby
|
||||
config.vm.synced_folder "/host/dir1", "/guest/dir1", docker_consistency: "cached"
|
||||
config.vm.synced_folder "/host/dir2", "/guest/dir2", docker_consistency: "delegated"
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue