Refactor routing and Swift test set-up

Add some servald config set-up functions to 'testdefs_routing.sh' and
'testdefs_swift.sh' that can be re-used in the Swift Routing API tests.

Improve some commenting on existing functions, for consistency.
This commit is contained in:
Andrew Bettison 2018-04-09 08:11:44 +09:30
parent 12bc773d4d
commit dce8b378d2
10 changed files with 73 additions and 54 deletions

View File

@ -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 $*"

View File

@ -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 \

View File

@ -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

View File

@ -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"} \
"$@"
}

View File

@ -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 \

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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() {

View File

@ -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() {