forked from xapi-project/xenvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·118 lines (93 loc) · 5.16 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
set -e
set -x
# There is an important bugfix in the master branch. If you see
# ECONNREFUSED you might need this:
# opam pin add conduit git://github.com/mirage/ocaml-conduit -y
# If you are using a XenServer build environment then the patch is
# already included in the RPM.
if [ "$EUID" -ne "0" ]; then
echo "I am not running with EUID 0. I will use the mock device mapper interface"
USE_MOCK=1
MOCK_ARG="--mock-devmapper"
else
echo "I am running with EUID 0. I will use the real device mapper interface"
USE_MOCK=0
MOCK_ARG=""
fi
# Making a 1G disk
rm -f bigdisk
dd if=/dev/zero of=bigdisk bs=1 seek=256G count=0
if [ "$USE_MOCK" -eq "0" ]; then
LOOP=$(losetup -f)
echo Using $LOOP
losetup $LOOP bigdisk
else
LOOP=`pwd`/bigdisk
fi
cat test.xenvmd.conf.in | sed -r "s|@BIGDISK@|$LOOP|g" > test.xenvmd.conf
mkdir -p /tmp/xenvm.d
./xenvm.native format $LOOP --vg djstest --configdir /tmp/xenvm.d $MOCK_ARG
./xenvmd.native --config ./test.xenvmd.conf > xenvmd.log &
sleep 2
./xenvm.native set-vg-info --pvpath $LOOP -S /tmp/xenvmd djstest --local-allocator-path /tmp/host1-socket --uri file://local/services/xenvmd/djstest --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native lvcreate -n badname -L 4 djstest --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native lvrename /dev/djstest/badname /dev/djstest/live --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native vgchange /dev/djstest -ay --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native vgchange /dev/djstest -an --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native lvchange -ay /dev/djstest/live --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native lvdisplay /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native lvdisplay /dev/djstest -c --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native lvs /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native pvs ./bigdisk --configdir /tmp/xenvm.d $MOCK_ARG
#./xenvm.native benchmark
# create and connect to hosts
./xenvm.native host-create /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native host-connect /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
cat test.local_allocator.conf.in | sed -r "s|@BIGDISK@|$LOOP|g" | sed -r "s|@HOST@|host1|g" > test.local_allocator.host1.conf
./local_allocator.native --config ./test.local_allocator.host1.conf $MOCK_ARG > local_allocator.host1.log &
./xenvm.native host-disconnect /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native host-connect /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
./local_allocator.native --config ./test.local_allocator.host1.conf $MOCK_ARG > local_allocator.host1.log2 &
for ((i=0; i<10; i++)); do
./xenvm.native host-disconnect /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native host-connect /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
./local_allocator.native --config ./test.local_allocator.host1.conf $MOCK_ARG > local_allocator.host1.log3 &
done
sleep 20
./xenvm.native lvextend /dev/djstest/live -L 128M --live --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native host-create /dev/djstest host2 --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native host-connect /dev/djstest host2 --configdir /tmp/xenvm.d $MOCK_ARG
cat test.local_allocator.conf.in | sed -r "s|@BIGDISK@|$LOOP|g" | sed -r "s|@HOST@|host2|g" > test.local_allocator.host2.conf
./local_allocator.native --config ./test.local_allocator.host2.conf $MOCK_ARG > local_allocator.host2.log &
sleep 30
./xenvm.native host-list /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG
# Let's check that xenvmd retains its list of connected hosts over a restart
./xenvm.native host-list /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG | sort > host-list.out
kill `cat /tmp/xenvmd.lock`
./xenvmd.native --config ./test.xenvmd.conf > xenvmd.log.2 &
sleep 10
./xenvm.native host-list /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG | sort > host-list.out2
diff -u host-list.out host-list.out2
# simulate a host failure and uncooperative disconnect
kill `cat /tmp/host2-socket.lock`
./xenvm.native host-disconnect --uncooperative /dev/djstest host2 --configdir /tmp/xenvm.d $MOCK_ARG
# check we've lost a host in the host-list
./xenvm.native host-list /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG | sort > host-list.out3
grep -v host2 host-list.out2 | diff -u - host-list.out3
# check it doesn't reconnect after a restart
kill `cat /tmp/xenvmd.lock`
./xenvmd.native --config ./test.xenvmd.conf > xenvmd.log.3 &
sleep 10
./xenvm.native host-list /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG | sort > host-list.out4
diff -u host-list.out3 host-list.out4
# destroy hosts
./xenvm.native host-destroy /dev/djstest host2 --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native host-disconnect /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
./xenvm.native host-destroy /dev/djstest host1 --configdir /tmp/xenvm.d $MOCK_ARG
#shutdown
./xenvm.native lvchange -an /dev/djstest/live --configdir /tmp/xenvm.d $MOCK_ARG || true
./xenvm.native shutdown /dev/djstest --configdir /tmp/xenvm.d $MOCK_ARG
#echo Run 'sudo ./xenvm.native host-connect /dev/djstest host1' to connect to the local allocator'
#echo Run 'sudo ./local_allocator.native' and type 'djstest-live' to request an allocation
echo Run './cleanup.sh' to remove all volumes and devices
sleep 10