Browse Source

NFS test: rearrange code to test multiple client configurations

This also gets rid of BASENET, which was an unneeded idea in hindsight.
master
David Dillow 16 years ago
parent
commit
cc75acdcab
  1. 3
      test/TEST-20-NFS/server-init
  2. 78
      test/TEST-20-NFS/test.sh

3
test/TEST-20-NFS/server-init

@ -3,11 +3,10 @@ export TERM=linux
export PS1='nfstest-server:\w\$ ' export PS1='nfstest-server:\w\$ '
stty sane stty sane
echo "made it to the rootfs!" echo "made it to the rootfs!"
. /etc/basenet
echo server > /proc/sys/kernel/hostname echo server > /proc/sys/kernel/hostname
ip addr add 127.0.0.1/8 dev lo ip addr add 127.0.0.1/8 dev lo
ip link set lo up ip link set lo up
ip addr add $BASENET.1/24 dev eth0 ip addr add 192.168.50.1/24 dev eth0
ip link set eth0 up ip link set eth0 up
rpcbind rpcbind
modprobe nfsd modprobe nfsd

78
test/TEST-20-NFS/test.sh

@ -2,37 +2,60 @@
TEST_DESCRIPTION="root filesystem on NFS" TEST_DESCRIPTION="root filesystem on NFS"


KVERSION=${KVERSION-$(uname -r)} KVERSION=${KVERSION-$(uname -r)}
BASENET=${BASENET-192.168.100}


test_run() { run_server() {
# Start server first # Start server first
echo "NFS TEST SETUP: Starting DHCP/NFS server"

$testdir/run-qemu -hda server.ext2 -m 512M -nographic \ $testdir/run-qemu -hda server.ext2 -m 512M -nographic \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net socket,mcast=230.0.0.1:1234 \ -net socket,mcast=230.0.0.1:1234 \
-serial udp:127.0.0.1:9999 \ -serial udp:127.0.0.1:9999 \
-kernel /boot/vmlinuz-$KVERSION \ -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/sda rw quiet console=ttyS0,115200n81" \ -append "root=/dev/sda rw quiet console=ttyS0,115200n81" \
-initrd initramfs.server -pidfile server.pid -daemonize -initrd initramfs.server -pidfile server.pid -daemonize || return 1
sudo chmod 644 server.pid sudo chmod 644 server.pid || return 1

# Starting the server messes up the terminal, fix that
stty sane


echo Sleeping 10 seconds to give the server a head start echo Sleeping 10 seconds to give the server a head start
sleep 10 sleep 10
}

client_test() {
local test_name="$1"
local mac=$2
local cmdline="$3"

echo "CLIENT TEST START: $test_name"

# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=client.img bs=1M count=1; then
echo "Unable to make client sda image" 1>&2
return 1
fi


$testdir/run-qemu -hda client.img -m 512M -nographic \ $testdir/run-qemu -hda client.img -m 512M -nographic \
-net nic,macaddr=52:54:00:12:35:56,model=e1000 \ -net nic,macaddr=$mac,model=e1000 \
-net socket,mcast=230.0.0.1:1234 \ -net socket,mcast=230.0.0.1:1234 \
-kernel /boot/vmlinuz-$KVERSION \ -kernel /boot/vmlinuz-$KVERSION \
-append "root=dhcp rw quiet console=ttyS0,115200n81" \ -append "$cmdline rw quiet console=ttyS0,115200n81" \
-initrd initramfs.testing -initrd initramfs.testing


if [[ -s server.pid ]]; then if [[ $? -eq 0 ]] && grep -m 1 -q nfs-OK client.img; then
sudo kill -TERM $(cat server.pid) echo "CLIENT TEST END: $test_name [OK]"
rm -f server.pid return 0
else
echo "CLIENT TEST END: $test_name [FAILED]"
return 1
fi
}

test_run() {
if ! run_server; then
echo "Failed to start server" 1>&2
return 1
fi fi
grep -m 1 -q nfs-OK client.img || return 1
client_test "NFSv3 root=dhcp" 52:54:00:12:34:00 "root=dhcp" || return 1
} }


test_setup() { test_setup() {
@ -60,25 +83,21 @@ test_setup() {


cat > etc/hosts <<EOF cat > etc/hosts <<EOF
127.0.0.1 localhost 127.0.0.1 localhost
$BASENET.1 server 192.168.50.1 server
$BASENET.100 workstation1 192.168.50.100 workstation1
$BASENET.101 workstation2 192.168.50.101 workstation2
$BASENET.102 workstation3 192.168.50.102 workstation3
$BASENET.103 workstation4 192.168.50.103 workstation4
EOF EOF
cat > etc/dnsmasq.conf <<EOF cat > etc/dnsmasq.conf <<EOF
expand-hosts expand-hosts
domain=test.net domain=test.net
dhcp-range=$BASENET.100,$BASENET.150,168h dhcp-range=192.168.50.100,192.168.50.150,168h
dhcp-option=17,"$BASENET.1:/client" dhcp-option=17,"192.168.50.1:/client"
EOF
cat > etc/basenet <<EOF
BASENET=$BASENET
EOF EOF

cat > etc/exports <<EOF cat > etc/exports <<EOF
/ $BASENET.0/24(ro,fsid=0,insecure,no_subtree_check,no_root_squash) / 192.168.50.0/24(ro,fsid=0,insecure,no_subtree_check,no_root_squash)
/client $BASENET.0/24(ro,insecure,no_subtree_check,no_root_squash) /client 192.168.50.0/24(ro,insecure,no_subtree_check,no_root_squash)
EOF EOF
) )
inst /etc/nsswitch.conf /etc/nsswitch.conf inst /etc/nsswitch.conf /etc/nsswitch.conf
@ -131,18 +150,15 @@ EOF


# Make server's dracut image # Make server's dracut image
$basedir/dracut -l -i overlay / \ $basedir/dracut -l -i overlay / \
-m "dash udev-rules base rootfs-block" \ -m "dash udev-rules base rootfs-block debug" \
-d "ata_piix ext2 sd_mod e1000" \ -d "ata_piix ext2 sd_mod e1000" \
-f initramfs.server $KVERSION || return 1 -f initramfs.server $KVERSION || return 1


# Make client's dracut image # Make client's dracut image
$basedir/dracut -l -i overlay / \ $basedir/dracut -l -i overlay / \
-m "dash udev-rules base network nfs" \ -m "dash udev-rules base network nfs debug" \
-d "e1000 nfs sunrpc" \ -d "e1000 nfs sunrpc" \
-f initramfs.testing $KVERSION || return 1 -f initramfs.testing $KVERSION || return 1

# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
dd if=/dev/zero of=client.img bs=1M count=1
} }


test_cleanup() { test_cleanup() {

Loading…
Cancel
Save