Commit a1a50a43 authored by Shane Snyder's avatar Shane Snyder

create-write-persist-proxy test case

parent 5a7c5572
......@@ -3,4 +3,5 @@ check_PROGRAMS += \
tests/proxy/proxy-server-daemon
TESTS += \
tests/proxy/proxy-write-read.sh
tests/proxy/proxy-write-read.sh \
tests/proxy/proxy-create-write-persist-read.sh
#!/bin/bash -x
if [ -z $srcdir ]; then
echo srcdir variable not set.
exit 1
fi
source $srcdir/tests/proxy/proxy-test-util.sh
# start 1 proxy server with 2 second wait, 20s timeout
test_start_servers 1 2 20
# start 1 proxy server with 2 second wait, 20s timeout
test_start_proxy_servers $svr1 "-b" 1 2 20
sleep 1
#####################
# tear down
run_to 10 tests/proxy/proxy-test $proxy_svr1
if [ $? -ne 0 ]; then
wait
exit 1
fi
wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
exit 0
......@@ -22,6 +22,7 @@ struct options
{
char *listen_addr_str;
char *bake_svr_addr_str;
int batch_rpc;
char *host_file;
};
......@@ -29,6 +30,7 @@ struct proxy_server_context
{
bake_target_id_t svr_bti;
bake_region_id_t the_rid;
int batch_rpc;
};
static struct proxy_server_context *g_proxy_svr_ctx = NULL;
......@@ -38,6 +40,7 @@ static void usage(int argc, char **argv)
fprintf(stderr, "Usage: proxy-server-daemon [OPTIONS] <listen_addr> <bake_server_addr>\n");
fprintf(stderr, " listen_addr is the Mercury address to listen on\n");
fprintf(stderr, " bake_server_addr is the Mercury address of the BAKE server\n");
fprintf(stderr, " [-b] to batch the BAKE region create, write, and persist operations in one RPC\n");
fprintf(stderr, " [-f filename] to write the proxy server address to a file\n");
fprintf(stderr, "Example: ./proxy-server-daemon na+sm na+sm://3005/0\n");
return;
......@@ -50,10 +53,13 @@ static void parse_args(int argc, char **argv, struct options *opts)
memset(opts, 0, sizeof(*opts));
/* get options */
while((opt = getopt(argc, argv, "f:")) != -1)
while((opt = getopt(argc, argv, "bf:")) != -1)
{
switch(opt)
{
case 'b':
opts->batch_rpc = 1;
break;
case 'f':
opts->host_file = optarg;
break;
......@@ -89,6 +95,7 @@ int main(int argc, char **argv)
if(!g_proxy_svr_ctx)
return(-1);
memset(g_proxy_svr_ctx, 0, sizeof(*g_proxy_svr_ctx));
g_proxy_svr_ctx->batch_rpc = opts.batch_rpc;
/* start margo */
mid = margo_init(opts.listen_addr_str, MARGO_SERVER_MODE, 0, -1);
......@@ -182,21 +189,32 @@ static void proxy_write_ult(hg_handle_t handle)
hret = margo_get_input(handle, &in);
assert(hret == HG_SUCCESS);
/* XXX we need a create_write_persist call to save on RTTs */
/* create BAKE region to store this write in */
ret = bake_create(g_proxy_svr_ctx->svr_bti, in.bulk_size,
&(g_proxy_svr_ctx->the_rid));
assert(ret == 0);
/* perform proxy write on behalf of client */
ret = bake_proxy_write(g_proxy_svr_ctx->svr_bti, g_proxy_svr_ctx->the_rid,
0, in.bulk_handle, in.bulk_offset, in.bulk_addr, in.bulk_size);
assert(ret == 0);
/* persist the BAKE region */
ret = bake_persist(g_proxy_svr_ctx->svr_bti, g_proxy_svr_ctx->the_rid);
assert(ret == 0);
if(g_proxy_svr_ctx->batch_rpc)
{
/* create the BAKE region, write to it on behalf of the client,
* and persist the region all in one RPC
*/
ret = bake_create_write_persist_proxy(g_proxy_svr_ctx->svr_bti,
in.bulk_size, 0, in.bulk_handle, in.bulk_offset, in.bulk_addr,
in.bulk_size, &(g_proxy_svr_ctx->the_rid));
assert(ret == 0);
}
else
{
/* create BAKE region to store this write in */
ret = bake_create(g_proxy_svr_ctx->svr_bti, in.bulk_size,
&(g_proxy_svr_ctx->the_rid));
assert(ret == 0);
/* perform proxy write on behalf of client */
ret = bake_proxy_write(g_proxy_svr_ctx->svr_bti, g_proxy_svr_ctx->the_rid,
0, in.bulk_handle, in.bulk_offset, in.bulk_addr, in.bulk_size);
assert(ret == 0);
/* persist the BAKE region */
ret = bake_persist(g_proxy_svr_ctx->svr_bti, g_proxy_svr_ctx->the_rid);
assert(ret == 0);
}
/* set return value */
out.ret = 0;
......
......@@ -5,14 +5,15 @@ source $srcdir/tests/test-util.sh
function test_start_proxy_servers ()
{
bake_svr_addr=${1}
nservers=${2:-4}
startwait=${3:-15}
maxtime=${4:-120}
opts=${2}
nservers=${3:-4}
startwait=${4:-15}
maxtime=${5:-120}
# start daemons
for i in `seq $nservers`
do
run_to ${maxtime} tests/proxy/proxy-server-daemon -f $TMPBASE/proxy-svr-1.addr na+sm $bake_svr_addr &
run_to ${maxtime} tests/proxy/proxy-server-daemon $opts -f $TMPBASE/proxy-svr-1.addr na+sm $bake_svr_addr &
if [ $? -ne 0 ]; then
# TODO: this doesn't actually work; can't check return code of
# something executing in background. We have to rely on the
......
......@@ -10,7 +10,7 @@ source $srcdir/tests/proxy/proxy-test-util.sh
test_start_servers 1 2 20
# start 1 proxy server with 2 second wait, 20s timeout
test_start_proxy_servers $svr1 1 2 20
test_start_proxy_servers $svr1 "" 1 2 20
sleep 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment