Skip to content

Commit

Permalink
tests: add in a vagrantfile for testing normal/slave/reverse mounts.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustymabe committed Jul 28, 2016
1 parent 0070b14 commit 61ba845
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/misc/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# This directory is for testing the three different mount modes
# that are supported by vagrant-sshfs

# To test we will first create the directory on the machien where
# we will mount the guest /etc/ into the host (the reverse mount).

mkdir /tmp/reverse_mount_etc

# Next we will define where our 3rd party host is (the normal mount).
# This can be another vagrant box or whatever machine you want.
export THIRD_PARTY_HOST='192.168.121.73'
export THIRD_PARTY_HOST_USER='vagrant'
export THIRD_PARTY_HOST_PASS='vagrant'

# Next vagrant up - will do 3 mounts (normal, slave, reverse).
vagrant up

# Next run the script to test the mounts:
$ bash dotests.sh
Testing normal mount!
a57e39fa692f294e860349a9451be67c
Testing slave mount!
e2c4ceac71dc414cb3ed864cff04a917
Testing reverse mount!
508619e7e68e446c84d1fcdf7e0dc577

# We are printing out the machine-id under each mount to prove each
# mount is from a different machine.
27 changes: 27 additions & 0 deletions test/misc/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Vagrant.configure(2) do |config|

config.ssh.insert_key = 'true'

# Test a forward normal mount:
# mounting a folder from a 3rd party host into guest
config.vm.synced_folder "/etc/", "/tmp/forward_normal_mount_etc/", type: "sshfs",
ssh_host: ENV['THIRD_PARTY_HOST'],
ssh_username: ENV['THIRD_PARTY_HOST_USER'],
ssh_password: ENV['THIRD_PARTY_HOST_PASS']

# Test a forward slave mount:
# mounting /etc/ from the vagrant host into the guest
config.vm.synced_folder "/etc/", "/tmp/forward_slave_mount_etc/", type: "sshfs"

# Test a reverse mount:
# mounting /etc/ from vagrant guest into vagrant host
config.vm.synced_folder "/tmp/reverse_mount_etc/", "/etc", type: "sshfs", reverse: true

host = 'vagrant-sshfs-tests'
box = 'fedora/24-cloud-base'

config.vm.define host do | tmp |
tmp.vm.hostname = host
tmp.vm.box = box
end
end
13 changes: 13 additions & 0 deletions test/misc/dotests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -eu

# Test the three mounts we have done

echo "Testing normal mount!"
vagrant ssh -- cat /tmp/forward_normal_mount_etc/machine-id

echo "Testing slave mount!"
vagrant ssh -- cat /tmp/forward_slave_mount_etc/machine-id

echo "Testing reverse mount!"
cat /tmp/reverse_mount_etc/machine-id

0 comments on commit 61ba845

Please sign in to comment.