glusterfs
1#!/bin/bash
2#
3# This test does not use 'showmount' from the nfs-utils package, it would
4# require setting up a portmapper (either rpcbind or portmap, depending on the
5# Linux distribution used for testing). The persistancy of the rmtab should not
6# affect the current showmount outputs, so existing regression tests should be
7# sufficient.
8#
9
10#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST
11
12# count the lines of a file, return 0 if the file does not exist
13function count_lines()14{
15if [ -e "$1" ]16then17wc -l < $118else19echo 020fi21}
22
23
24. $(dirname $0)/../../include.rc25. $(dirname $0)/../../nfs.rc26. $(dirname $0)/../../volume.rc27
28cleanup
29
30TEST glusterd
31TEST pidof glusterd
32
33TEST $CLI volume create $V0 $H0:$B0/brick134EXPECT 'Created' volinfo_field $V0 'Status'35TEST $CLI volume set $V0 nfs.disable false36
37TEST $CLI volume start $V0;38EXPECT 'Started' volinfo_field $V0 'Status'39
40# glusterfs/nfs needs some time to start up in the background
41EXPECT_WITHIN $NFS_EXPORT_TIMEOUT 1 is_nfs_export_available42
43# before mounting the rmtab should be empty
44EXPECT '0' count_lines $GLUSTERD_WORKDIR/nfs/rmtab45
46TEST mount_nfs $H0:/$V0 $N0 nolock47# the output would looks similar to:
48#
49# hostname-0=172.31.122.104
50# mountpoint-0=/ufo
51#
52EXPECT '2' count_lines $GLUSTERD_WORKDIR/nfs/rmtab53
54# duplicate mounts should not be recorded (client could have crashed)
55TEST mount_nfs $H0:/$V0 $N1 nolock56EXPECT '2' count_lines $GLUSTERD_WORKDIR/nfs/rmtab57
58# removing a mount should (even if there are two) should remove the entry
59EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N160EXPECT '0' count_lines $GLUSTERD_WORKDIR/nfs/rmtab61
62# unmounting the other mount should work flawlessly
63EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N064EXPECT '0' count_lines $GLUSTERD_WORKDIR/nfs/rmtab65
66TEST glusterfs --entry-timeout=0 --attribute-timeout=0 --volfile-server=$H0 --volfile-id=$V0 $M067
68# we'll create a fake rmtab here, similar to how an other storage server would do
69# using an invalid IP address to prevent (unlikely) collisions on the test-machine
70cat << EOF > $M0/rmtab71hostname-0=127.0.0.256
72mountpoint-0=/ufo
73EOF
74EXPECT '2' count_lines $M0/rmtab75
76# reconfigure merges the rmtab with the one on the volume
77TEST gluster volume set $V0 nfs.mount-rmtab $M0/rmtab78
79# glusterfs/nfs needs some time to restart
80EXPECT_WITHIN $NFS_EXPORT_TIMEOUT 1 is_nfs_export_available81
82# Apparently "is_nfs_export_available" might return even if the export is
83# not, in fact, available. (eyeroll) Give it a bit of extra time.
84#
85# TBD: fix the broken shell function instead of working around it here
86sleep 587
88# a new mount should be added to the rmtab, not overwrite exiting ones
89TEST mount_nfs $H0:/$V0 $N0 nolock90EXPECT_WITHIN $PROCESS_UP_TIMEOUT '4' count_lines $M0/rmtab91
92EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N093EXPECT '2' count_lines $M0/rmtab94
95# TODO: nfs/reconfigure() is never called and is therefor disabled. When the
96# NFS-server supports reloading and does not get restarted anymore, we should
97# add a test that includes the merging of entries in the old rmtab with the new
98# rmtab.
99
100cleanup
101