]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: use gsed on FreeBSD for inplace editting 13903/head
authorWillem Jan Withagen <wjw@digiware.nl>
Thu, 9 Mar 2017 12:42:34 +0000 (13:42 +0100)
committerWillem Jan Withagen <wjw@digiware.nl>
Sun, 19 Mar 2017 17:02:26 +0000 (18:02 +0100)
 - FreeBSD sed(1) requires a extension on -i
   so replace the usuage with GNU sed: gsed

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
install-deps.sh
qa/workunits/ceph-helpers.sh
src/test/crush/crush-classes.sh
src/test/mon/osd-crush.sh
src/test/test_crush_bucket.sh

index e1e8722d5438232ca5fc72da7a7311c4c61770c1..7f190fb51cdef613896622afa4b93d3d5a87d814 100755 (executable)
@@ -44,6 +44,7 @@ if [ x`uname`x = xFreeBSDx ]; then
         misc/e2fsprogs-libuuid \
         misc/getopt \
         textproc/expat2 \
+        textproc/gsed \
         textproc/libxml2 \
         textproc/xmlstarlet \
        textproc/jq \
index efaff9cbfbd1963d1abd28d5049b5301c4ee0d68..2e23c4a450867ca831386b7a37bcaec2b7a6a127 100755 (executable)
@@ -29,6 +29,11 @@ else
        echo "Missing xmlstarlet binary!"
        exit 1
 fi
+if [ `uname` = FreeBSD ]; then
+    SED=gsed
+else
+    SED=sed
+fi 
 
 #! @file ceph-helpers.sh
 #  @brief Toolbox to manage Ceph cluster dedicated to testing
index d1758f7f42ad5c65d8e9b7eb44650c6fa0f093fe..b7762eb7372e1f787e007a0fdb5afde937a1368d 100755 (executable)
@@ -71,7 +71,7 @@ function TEST_classes() {
     #
     ceph osd getcrushmap > $dir/map || return 1
     crushtool -d $dir/map -o $dir/map.txt || return 1
-    sed -i \
+    ${SED} -i \
         -e '/device 0 osd.0/s/$/ class ssd/' \
         -e '/step take default/s/$/ class ssd/' \
         $dir/map.txt || return 1
index 982ec904b25f8cbe207010824670e718554817e2..ef0c84de0bbaa0fdb085c57a134907953783a235 100755 (executable)
@@ -27,7 +27,7 @@ function run() {
     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
     CEPH_ARGS+="--mon-host=$CEPH_MON "
 
-    local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+    local funcs=${@:-$(set | ${SED} -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
     for func in $funcs ; do
         setup $dir || return 1
         $func $dir || return 1
@@ -146,9 +146,9 @@ function generate_manipulated_rules() {
     ceph osd getcrushmap -o $dir/original_map
     crushtool -d $dir/original_map -o $dir/decoded_original_map
     #manipulate the rulesets , to make the rule_id != ruleset_id
-    sed -i 's/ruleset 0/ruleset 3/' $dir/decoded_original_map
-    sed -i 's/ruleset 2/ruleset 0/' $dir/decoded_original_map
-    sed -i 's/ruleset 1/ruleset 2/' $dir/decoded_original_map
+    ${SED} -i 's/ruleset 0/ruleset 3/' $dir/decoded_original_map
+    ${SED} -i 's/ruleset 2/ruleset 0/' $dir/decoded_original_map
+    ${SED} -i 's/ruleset 1/ruleset 2/' $dir/decoded_original_map
 
     crushtool -c $dir/decoded_original_map -o $dir/new_map
     ceph osd setcrushmap -i $dir/new_map
index 48fd15063b1887c87e407adb9545b1ebba7b4626..ead183e213bedb9cc7052f0bbbb39bddfc5adc66 100755 (executable)
@@ -16,7 +16,7 @@ function run() {
     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
     CEPH_ARGS+="--mon-host=$CEPH_MON "
 
-    local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+    local funcs=${@:-$(set | ${SED} -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
     for func in $funcs ; do
         $func $dir || return 1
     done
@@ -33,12 +33,12 @@ function TEST_crush_bucket() {
 
     ceph osd getcrushmap -o "$dir/map1" || return 1
     crushtool -d "$dir/map1" -o "$dir/map1.txt"|| return 1
-    local var=`ceph osd crush dump|grep -w id|grep '-'|grep -Eo '[0-9]+'|sort|uniq|sed -n '$p'`
+    local var=`ceph osd crush dump|grep -w id|grep '-'|grep -Eo '[0-9]+'|sort|uniq|${SED} -n '$p'`
     local id=`expr  $var + 1`
-    local item=`sed -n '/^root/,/}/p' $dir/map1.txt|grep  'item'|head -1`
-    local weight=`sed -n '/^root/,/}/p' $dir/map1.txt|grep  'item'|head -1|awk '{print $4}'`
+    local item=`${SED} -n '/^root/,/}/p' $dir/map1.txt|grep  'item'|head -1`
+    local weight=`${SED} -n '/^root/,/}/p' $dir/map1.txt|grep  'item'|head -1|awk '{print $4}'`
     local bucket="host test {\n id -$id\n # weight $weight\n alg straw \n hash 0  # rjenkins1 \n $item\n}\n"
-    sed -i "/# buckets/a\ $bucket" "$dir/map1.txt"
+    ${SED} -i "/# buckets/a\ $bucket" "$dir/map1.txt"
     crushtool  -c "$dir/map1.txt" -o "$dir/map1.bin" 2>"$dir/rev"
     local result=$(cat "$dir/rev")
     if [ "$result" != "" ];