summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2018-10-04 10:31:45 +0200
committerXavi Hernandez <xhernandez@redhat.com>2018-10-04 10:44:04 +0200
commitdbafe63ea5602db3ad65a3e4fba15b6ee97776ce (patch)
treee03fe79a9a0b2460254889b6e05da3274d07e809
parent83a89296a3d12a3fc2a643c0630be5ce659204ea (diff)
Reduce execution time of bug-1559004-EMLINK-handling.t
This patch reduces the execution time of bug-1559004-EMLINK-handling.t from ~14 minutes to ~90 seconds. To do so, it creates some fake hard links directly on the brick instead of creating them through the volume. Change-Id: I9715ff1a4eba47574c733d4f28e68f42f56a7d3f updates: bz#1193929 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
-rw-r--r--tests/bugs/index/bug-1559004-EMLINK-handling.t63
1 files changed, 51 insertions, 12 deletions
diff --git a/tests/bugs/index/bug-1559004-EMLINK-handling.t b/tests/bugs/index/bug-1559004-EMLINK-handling.t
index 0bd70a0283f..5596fa56c4c 100644
--- a/tests/bugs/index/bug-1559004-EMLINK-handling.t
+++ b/tests/bugs/index/bug-1559004-EMLINK-handling.t
@@ -4,9 +4,39 @@
. $(dirname $0)/../../volume.rc
. $(dirname $0)/../../afr.rc
+function create_fake_links() {
+ local dst="$1"
+ local dir="$2"
+ local end=0
+ local start=0
+ local src
+
+ src="$(ls ${dst}/.glusterfs/indices/${dir}/${dir}-* | head -1)"
+ mkdir -p ${dst}/.glusterfs/dummy/${dir}
+ while ln ${src} ${dst}/.glusterfs/dummy/${dir}/link-${end}; do
+ end="$((${end} + 1))"
+ done
+
+ if [[ ${end} -gt 50 ]]; then
+ start="$((${end} - 50))"
+ fi
+ if [[ ${end} -gt 0 ]]; then
+ end="$((${end} - 1))"
+ fi
+
+ for i in $(seq ${start} ${end}); do
+ rm -f ${dst}/.glusterfs/dummy/${dir}/link-${i}
+ done
+}
+
+function count_fake_links() {
+ local dst="$1"
+ local dir="$2"
+
+ echo "$(find ${dst}/.glusterfs/dummy/${dir}/ -name "link-*" | wc -l)"
+}
+
cleanup
-TESTS_EXPECTED_IN_LOOP=30
-SCRIPT_TIMEOUT=1800
TEST glusterd
TEST pidof glusterd
@@ -32,21 +62,30 @@ TEST mount -t ext4 -o loop $B0/ext4-3 $B0/ext43
TEST $CLI volume create $V0 replica 3 $H0:$B0/ext4{1,2,3}
TEST $CLI volume start $V0
TEST $CLI volume heal $V0 granular-entry-heal enable
-TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0
TEST kill_brick $V0 $H0 $B0/ext41
-for i in {1..15}
-do
- TEST_IN_LOOP mkdir $M0/d${i}
- TEST_IN_LOOP touch $M0/d${i}/{1..5000}
-done
+
+# Make sure indices exist and are initialized
+TEST touch $M0/dummy
+
+# Create enough hard links on bricks to make it fail faster. This is much
+# faster than creating ~70000 files on a volume.
+create_fake_links $B0/ext42 xattrop &
+create_fake_links $B0/ext42 entry-changes &
+wait
+count_xattrop="$(count_fake_links $B0/ext42 xattrop)"
+count_entry="$(count_fake_links $B0/ext42 entry-changes)"
+
+TEST mkdir $M0/d{1..10}
+TEST touch $M0/d{1..10}/{1..10}
#On ext4 max number of hardlinks is ~65k, so there should be 2 base index files
EXPECT "^2$" echo $(ls $B0/ext42/.glusterfs/indices/xattrop | grep xattrop | wc -l)
EXPECT "^2$" echo $(ls $B0/ext42/.glusterfs/indices/entry-changes | grep entry-changes | wc -l)
-#Number of hardlinks: 75000 for files, 15 for dirs and 2 for base-indices
-#and root-dir for xattrop
-EXPECT "75018" echo $(ls -l $B0/ext42/.glusterfs/indices/xattrop | grep xattrop | awk '{sum+=$2} END{print sum}')
-EXPECT "75017" echo $(ls -l $B0/ext42/.glusterfs/indices/entry-changes | grep entry-changes | awk '{sum+=$2} END{print sum}')
+#Number of hardlinks: count_xattrop/count_entry for fake links, 101 for files,
+# 10 for dirs and 2 for base-indices and root-dir for xattrop
+EXPECT "$((${count_xattrop} + 114))" echo $(ls -l $B0/ext42/.glusterfs/indices/xattrop | grep xattrop | awk '{sum+=$2} END{print sum}')
+EXPECT "$((${count_entry} + 113))" echo $(ls -l $B0/ext42/.glusterfs/indices/entry-changes | grep entry-changes | awk '{sum+=$2} END{print sum}')
cleanup