]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: support and test the absence of PATH 1169/head
authorLoic Dachary <loic@dachary.org>
Wed, 29 Jan 2014 10:00:08 +0000 (11:00 +0100)
committerLoic Dachary <loic@dachary.org>
Thu, 30 Jan 2014 19:11:02 +0000 (20:11 +0100)
Although this is not exactly the context in which ceph-disk is run when
invoked by udev, it makes sure there is at least one sensible way of
using it when PATH is undefined.

Also make src/ceph.in not fail if PATH is not defined.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/ceph-disk
src/ceph.in
src/test/ceph-disk.sh

index 96295e2f203e3a451a62f63753f6074e4ba93911..53e0afd986d8879a7cfd04c88e72d9f5ea5518e1 100755 (executable)
@@ -2479,7 +2479,7 @@ def main():
         )
 
     if args.prepend_to_path != '':
-        path = os.environ.get('PATH', '')
+        path = os.environ.get('PATH', os.defpath)
         os.environ['PATH'] = args.prepend_to_path + ":" + path
 
     setup_statedir(args.statedir)
index 57816d35b422cbdc29f2e30b5a97bdef2a64246f..c1f5a84c48e95c0c931c6fafd835e608ea5099b4 100755 (executable)
@@ -44,7 +44,7 @@ if MYDIR.endswith('src') and \
         print >> sys.stderr, DEVMODEMSG
         os.execvp('python', ['python'] + sys.argv)
     sys.path.insert(0, os.path.join(MYDIR, 'pybind'))
-    if MYDIR not in os.environ['PATH']:
+    if os.environ.has_key('PATH') and MYDIR not in os.environ['PATH']:
         os.environ['PATH'] += ':' + MYDIR
 
 import argparse
index a8a365ff250c57ff055c86015e2e38adfd71df9c..35e2702669681ee9e52cb127fefae872b33e0a96 100755 (executable)
@@ -37,6 +37,10 @@ CEPH_DISK_ARGS+=" --prepend-to-path="
 CEPH_DISK_ARGS+=" --verbose"
 TIMEOUT=360
 
+cat=$(which cat)
+timeout=$(which timeout)
+diff=$(which diff)
+
 function setup() {
     teardown
     mkdir $DIR
@@ -139,6 +143,10 @@ function test_path() {
     tweak_path use_path || return 1
 }
 
+function test_no_path() {
+    ( unset PATH ; test_activate_dir ) || return 1
+}
+
 # ceph-disk prepare returns immediately on success if the magic file
 # exists on the --osd-data directory.
 function test_activate_dir_magic() {
@@ -179,18 +187,18 @@ function test_activate_dir() {
         prepare $osd_data || return 1
 
     CEPH_ARGS="$CEPH_ARGS --osd-journal-size=100 --osd-data=$osd_data" \
-        timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
+        $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
                       activate \
                      --mark-init=none \
                     $osd_data || return 1
-    timeout $TIMEOUT ./ceph osd pool set data size 1 || return 1
-    local id=$(cat $osd_data/whoami)
+    $timeout $TIMEOUT ./ceph osd pool set data size 1 || return 1
+    local id=$($cat $osd_data/whoami)
     local weight=1
     ./ceph osd crush add osd.$id $weight root=default host=localhost || return 1
     echo FOO > $DIR/BAR
-    timeout $TIMEOUT ./rados --pool data put BAR $DIR/BAR || return 1
-    timeout $TIMEOUT ./rados --pool data get BAR $DIR/BAR.copy || return 1
-    diff $DIR/BAR $DIR/BAR.copy || return 1
+    $timeout $TIMEOUT ./rados --pool data put BAR $DIR/BAR || return 1
+    $timeout $TIMEOUT ./rados --pool data get BAR $DIR/BAR.copy || return 1
+    $diff $DIR/BAR $DIR/BAR.copy || return 1
 }
 
 function test_find_cluster_by_uuid() {
@@ -209,6 +217,7 @@ function test_find_cluster_by_uuid() {
 function run() {
     local default_actions
     default_actions+="test_path "
+    default_actions+="test_no_path "
     default_actions+="test_find_cluster_by_uuid "
     default_actions+="test_prepend_to_path "
     default_actions+="test_activate_dir_magic "