Skip to content

Commit

Permalink
Add peer vm, minor changes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimrozakis committed Feb 24, 2016
1 parent 99d98c8 commit 3696245
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ TOPOLOGY = <<EOF
NETWORK TOPOLOGY
================
------ ------
| | 192.168.69.1 192.168.69.69 | |
| HOST |________________________________| PEER |
| | | | |
------ | ------
|
192.168.69.100
--------
vpn-proxy-tun1: 172.17.17.2 | | vpn-proxy-tun2: 172.17.17.4
Expand Down Expand Up @@ -52,6 +58,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use ubuntu for all vm's. This would also work with debian/jessie64.
config.vm.box = "ubuntu/trusty64"

# Create a `peer` vm, connected to the server using a host only network.
config.vm.define "peer", autostart: false do |peer|
peer.vm.hostname = "peer"
peer.vm.network "private_network", ip: "192.168.69.69"
end

# Create a `server` vm, connected to 2 proxies.
config.vm.define "server", primary: true do |server|
server.vm.hostname = "server"
Expand Down Expand Up @@ -124,7 +136,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Create two more `target` vm's, each connected to its corresponding `proxy`
# vm.
(1..2).each do |i|
config.vm.define "target#{2+i}" do |target|
config.vm.define "target#{2+i}", autostart: false do |target|
target.vm.hostname = "target#{2+i}"
target.vm.network "private_network",
virtualbox__intnet: "vpnproxy-lan#{2+i}",
Expand Down
29 changes: 29 additions & 0 deletions scripts/test-vagrant.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#!/bin/bash

is_up() {
[ -z "$1" ] && return 1
local state=$(vagrant status --machine-readable $1 | \
grep "^[0-9]*,$1,state," | cut -d, -f4)
if [ "$state" != "running" ]; then
echo "VM $1 is not running."
return 1
fi
}

assert_probe() {
is_up $1 && is_up $3 || return
TOTAL=$(($TOTAL+1))
local msg="$2\t\t$1\t\t$3\t\t"
local curl_opts="-s -m 2"
Expand Down Expand Up @@ -41,9 +52,15 @@ test_selfprobe() {
echo -e $HEADER
assert_probe server 127.0.0.1 server
assert_probe server 192.168.75.100 server
assert_probe server 192.168.69.100 server
assert_probe server 172.17.17.2 server
assert_probe server 172.17.17.4 server
echo
echo "### peer ###"
echo -e $HEADER
assert_probe peer 127.0.0.1 peer
assert_probe peer 192.168.69.69 peer
echo
echo "### proxy1 ###"
echo -e $HEADER
assert_probe proxy1 127.0.0.1 proxy1
Expand Down Expand Up @@ -121,6 +138,15 @@ test_server_proxies() {
assert_probe proxy2 192.168.75.100 server
}

test_peer_server() {
echo "Test that the peer can probe with the server"
echo "--------------------------------------------"
echo
echo -e $HEADER
assert_probe peer 192.168.69.100 server
assert_probe server 192.168.69.69 peer
}

test_server_targets() {
echo "Test that the server can probe the targets through the proxies"
echo "--------------------------------------------------------------"
Expand Down Expand Up @@ -169,6 +195,9 @@ test() {
test_server_proxies
echo
echo
test_peer_server
echo
echo
fi
test_server_targets
echo
Expand Down

0 comments on commit 3696245

Please sign in to comment.