From 522174b066044e51a7019bd6cad81117e83c394e Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 1 Jul 2014 08:42:58 +0200 Subject: [PATCH] qa: support running under non privileged user If the test is run against a cluster started with vstart.sh (which is the case for make check), the --asok-does-not-need-root disables the use of sudo and allows the test to run without requiring privileged user permissions. Signed-off-by: Loic Dachary --- qa/workunits/cephtool/test.sh | 16 ++++++++++------ src/test/vstart_wrapped_tests.sh | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 0b0ed2f27d1c0..dba80687ad896 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -3,6 +3,7 @@ set -e set -o functrace PS4=' ${FUNCNAME[0]}: $LINENO: ' +SUDO=sudo function get_pg() { @@ -58,7 +59,7 @@ function get_config_value_or_die() target=$1 config_opt=$2 - raw="`sudo ceph daemon $target config get $config_opt 2>/dev/null`" + raw="`$SUDO ceph daemon $target config get $config_opt 2>/dev/null`" if [[ $? -ne 0 ]]; then echo "error obtaining config opt '$config_opt' from '$target': $raw" exit 1 @@ -95,13 +96,13 @@ function test_mon_injectargs_SI() # Keep in mind that all integer based options (i.e., INT, # LONG, U32, U64) will accept SI unit modifiers. initial_value=$(get_config_value_or_die "mon.a" "mon_pg_warn_min_objects") - sudo ceph daemon mon.a config set mon_pg_warn_min_objects 10 + $SUDO ceph daemon mon.a config set mon_pg_warn_min_objects 10 expect_config_value "mon.a" "mon_pg_warn_min_objects" 10 - sudo ceph daemon mon.a config set mon_pg_warn_min_objects 10K + $SUDO ceph daemon mon.a config set mon_pg_warn_min_objects 10K expect_config_value "mon.a" "mon_pg_warn_min_objects" 10240 - sudo ceph daemon mon.a config set mon_pg_warn_min_objects 1G + $SUDO ceph daemon mon.a config set mon_pg_warn_min_objects 1G expect_config_value "mon.a" "mon_pg_warn_min_objects" 1073741824 - sudo ceph daemon mon.a config set mon_pg_warn_min_objects 10F > $TMPFILE || true + $SUDO ceph daemon mon.a config set mon_pg_warn_min_objects 10F > $TMPFILE || true check_response "'10F': (22) Invalid argument" # now test with injectargs ceph tell mon.a injectargs '--mon_pg_warn_min_objects 10' @@ -111,7 +112,7 @@ function test_mon_injectargs_SI() ceph tell mon.a injectargs '--mon_pg_warn_min_objects 1G' expect_config_value "mon.a" "mon_pg_warn_min_objects" 1073741824 expect_false ceph injectargs mon.a '--mon_pg_warn_min_objects 10F' - sudo ceph daemon mon.a config set mon_pg_warn_min_objects $initial_value + $SUDO ceph daemon mon.a config set mon_pg_warn_min_objects $initial_value } function test_tiering() @@ -833,6 +834,9 @@ while [[ $# -gt 0 ]]; do "-l" ) do_list=1 ;; + "--asok-does-not-need-root" ) + SUDO="" + ;; "-t" ) shift if [[ -z "$1" ]]; then diff --git a/src/test/vstart_wrapped_tests.sh b/src/test/vstart_wrapped_tests.sh index 71148af74c642..d80863f5d2225 100755 --- a/src/test/vstart_wrapped_tests.sh +++ b/src/test/vstart_wrapped_tests.sh @@ -25,6 +25,6 @@ while read line ; do fi echo "================ STOP =================" done <