diff --git a/testdefs.sh b/testdefs.sh index c78ca439..36ca640f 100644 --- a/testdefs.sh +++ b/testdefs.sh @@ -884,7 +884,7 @@ add_servald_interface() { # - set variables LOGx to the full path of server log file for instance x: LOGA, # LOGB, etc, # - wait for all instances to detect each other -# - assert that all instances are in each others' peer lists +# - TODO: assert that all instances are in each others' peer lists start_servald_instances() { push_instance tfw_log "# start servald instances $*" diff --git a/testdefs_rest.sh b/testdefs_rest.sh index 45a2c216..f3077251 100644 --- a/testdefs_rest.sh +++ b/testdefs_rest.sh @@ -25,12 +25,15 @@ setup_rest_utilities() { } # Setup function: -# - configure the given (or current) instance with helpful debug options and -# some standard REST API usernames/passwords +# - configure log diagnostics that are useful for debugging REST requests +# - configure some standard REST API usernames/passwords setup_rest_config() { local _instance="$1" [ -z "$_instance" ] || push_and_set_instance $_instance || return $? executeOk_servald config \ + set log.console.level debug \ + set log.console.show_pid on \ + set log.console.show_time on \ set debug.http_server on \ set debug.httpd on \ set api.restful.users.harry.password potter \ diff --git a/testdefs_routing.sh b/testdefs_routing.sh index 403e1304..e3b5edd0 100644 --- a/testdefs_routing.sh +++ b/testdefs_routing.sh @@ -17,6 +17,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Setup function: +# - configure log diagnostics that are useful for debugging routing +# - disable Rhizome to speed up tests +setup_route_config() { + executeOk_servald config \ + set log.console.level debug \ + set log.console.show_pid on \ + set log.console.show_time on \ + set debug.mdprequests yes \ + set debug.linkstate yes \ + set debug.subscriber yes \ + set debug.verbose yes \ + set debug.overlayrouting yes \ + set debug.overlayinterfaces yes \ + set rhizome.enable no +} + interface_is_up() { $GREP "Interface .* is up" $instance_servald_log || return 1 return 0 diff --git a/testdefs_swift.sh b/testdefs_swift.sh index 551774d1..ec972367 100644 --- a/testdefs_swift.sh +++ b/testdefs_swift.sh @@ -24,11 +24,47 @@ assert_swift_executable_exists() { executeSwiftOk help } +# Setup function: +# - configure log diagnostics that are useful for debugging a Swift API +# - configure REST API credentials to support the Swift client +setup_swift_config() { + local _instance="$1" + [ -z "$_instance" ] || push_and_set_instance $_instance || return $? + executeOk_servald config \ + set log.console.level debug \ + set log.console.show_pid on \ + set log.console.show_time on \ + set debug.http_server on \ + set debug.httpd on \ + set "api.restful.users.$SWIFT_TEST_USER.password" "$SWIFT_TEST_PASSWORD" + [ -z "$_instance" ] || pop_instance + return 0 +} + +# Setup function: +# - wait for the current instance's server to start processing REST requests +# - initialise the SWIFT_PORT_{I} shell variable with the port number of the REST +# server running in instance {I} +# - zero the request count for the rest_request() function +wait_until_swift_server_ready() { + local _instance + case $1 in + '') _instance=$instance_name;; + +[A-Z]) _instance=${1#+};; + *) error "invalid instance arg: $1";; + esac + wait_until servald_restful_http_server_started +$_instance + local _portvar=SWIFT_TEST_PORT_$_instance + get_servald_restful_http_server_port $_portvar +$_instance +} + executeSwiftOk() { + local _portvar=SWIFT_TEST_PORT_$instance_name + [ -n "${!_portvar}" ] || error "\$$_portvar is not set" executeOk --stdout --stderr --core-backtrace \ --executable="$swift_client_util" \ -- \ - --port "${SWIFT_TEST_PORT?}" \ + --port "${!_portvar}" \ ${SWIFT_TEST_USER:+--user "$SWIFT_TEST_USER" --password "$SWIFT_TEST_PASSWORD"} \ "$@" } diff --git a/tests/keyringjava b/tests/keyringjava index aab8e303..dd0ebee3 100755 --- a/tests/keyringjava +++ b/tests/keyringjava @@ -28,7 +28,7 @@ setup() { setup_servald_so assert_java_classes_exist set_instance +A - set_keyring_config + setup_keyring_config set_extra_config if [ -z "$IDENTITY_COUNT" ]; then create_single_identity @@ -48,7 +48,7 @@ teardown() { report_all_servald_servers } -set_keyring_config() { +setup_keyring_config() { executeOk_servald config \ set log.console.level debug \ set debug.httpd on \ diff --git a/tests/keyringrestful b/tests/keyringrestful index 534881d6..00c71e73 100755 --- a/tests/keyringrestful +++ b/tests/keyringrestful @@ -30,7 +30,7 @@ setup() { setup_servald setup_rest_config +A set_instance +A - set_keyring_config + setup_keyring_config if [ -z "$IDENTITY_COUNT" ]; then create_single_identity else @@ -50,7 +50,7 @@ teardown() { report_all_servald_servers } -set_keyring_config() { +setup_keyring_config() { executeOk_servald config \ set debug.keyring on \ set debug.verbose on \ diff --git a/tests/keyringswift b/tests/keyringswift index 1a576bcc..be7142cd 100755 --- a/tests/keyringswift +++ b/tests/keyringswift @@ -25,11 +25,9 @@ source "${0%/*}/../testdefs_swift.sh" setup() { setup_servald + setup_swift_config +A set_instance +A - set_keyring_config - set_extra_config - executeOk_servald config \ - set "api.restful.users.$SWIFT_TEST_USER.password" "$SWIFT_TEST_PASSWORD" + setup_keyring_config if [ -z "$IDENTITY_COUNT" ]; then create_single_identity else @@ -37,8 +35,7 @@ setup() { fi export SERVALD_RHIZOME_DB_RETRY_LIMIT_MS=60000 start_servald_server - wait_until servald_restful_http_server_started +A - get_servald_restful_http_server_port SWIFT_TEST_PORT +A + wait_until_swift_server_ready +A } teardown() { @@ -48,18 +45,15 @@ teardown() { report_all_servald_servers } -set_keyring_config() { +setup_keyring_config() { executeOk_servald config \ set log.console.level debug \ - set debug.httpd on \ + set log.console.show_pid on \ + set log.console.show_time on \ set debug.keyring on \ set debug.verbose on } -set_extra_config() { - : -} - doc_keyringList="Swift API list keyring identities" setup_keyringList() { IDENTITY_COUNT=10 diff --git a/tests/routejava b/tests/routejava index 195c110b..d38f7812 100755 --- a/tests/routejava +++ b/tests/routejava @@ -25,7 +25,6 @@ source "${0%/*}/../testdefs_rest.sh" source "${0%/*}/../testdefs_java.sh" setup() { - setup_rest_utilities #XXX setup_servald setup_servald_so assert_java_classes_exist @@ -40,23 +39,12 @@ teardown() { } configure_servald_server() { - executeOk_servald config \ - set debug.mdprequests yes \ - set debug.linkstate yes \ - set debug.subscriber yes \ - set debug.verbose yes \ - set debug.overlayrouting yes \ - set debug.overlayinterfaces yes \ - set log.console.level debug \ - set log.console.show_pid on \ - set log.console.show_time on \ - set rhizome.enable no + setup_route_config } doc_RouteListAll="Java API list entire routing table" setup_RouteListAll() { setup - setup_rest_config +A #XXX DIDA1=565656 NAMEA1="Neddy Seagoon" DIDA2=3020304 @@ -69,7 +57,6 @@ setup_RouteListAll() { wait_until --timeout=20 path_exists +A +B wait_until --timeout=10 path_exists +B +A set_instance +A - rest_request GET "/restful/route/all.json" #XXX } test_RouteListAll() { executeJavaOk org.servalproject.test.Route list-all diff --git a/tests/routerestful b/tests/routerestful index 38bb282c..19768501 100755 --- a/tests/routerestful +++ b/tests/routerestful @@ -31,16 +31,7 @@ setup() { } configure_servald_server() { - executeOk_servald config \ - set debug.mdprequests yes \ - set debug.linkstate yes \ - set debug.subscriber yes \ - set debug.verbose yes \ - set debug.overlayrouting yes \ - set log.console.level debug \ - set log.console.show_pid on \ - set log.console.show_time on \ - set rhizome.enable no + setup_route_config } finally() { diff --git a/tests/routing b/tests/routing index f6676ad3..2eb3a51d 100755 --- a/tests/routing +++ b/tests/routing @@ -24,16 +24,7 @@ source "${0%/*}/../testdefs.sh" source "${0%/*}/../testdefs_routing.sh" configure_servald_server() { - executeOk_servald config \ - set debug.mdprequests yes \ - set debug.linkstate yes \ - set debug.subscriber yes \ - set debug.verbose yes \ - set debug.overlayrouting yes \ - set log.console.level debug \ - set log.console.show_pid on \ - set log.console.show_time on \ - set rhizome.enable no + setup_route_config } teardown() {