Commit a1a50a43 authored by Shane Snyder's avatar Shane Snyder

create-write-persist-proxy test case

parent 5a7c5572
...@@ -3,4 +3,5 @@ check_PROGRAMS += \ ...@@ -3,4 +3,5 @@ check_PROGRAMS += \
tests/proxy/proxy-server-daemon tests/proxy/proxy-server-daemon
TESTS += \ 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 ...@@ -22,6 +22,7 @@ struct options
{ {
char *listen_addr_str; char *listen_addr_str;
char *bake_svr_addr_str; char *bake_svr_addr_str;
int batch_rpc;
char *host_file; char *host_file;
}; };
...@@ -29,6 +30,7 @@ struct proxy_server_context ...@@ -29,6 +30,7 @@ struct proxy_server_context
{ {
bake_target_id_t svr_bti; bake_target_id_t svr_bti;
bake_region_id_t the_rid; bake_region_id_t the_rid;
int batch_rpc;
}; };
static struct proxy_server_context *g_proxy_svr_ctx = NULL; static struct proxy_server_context *g_proxy_svr_ctx = NULL;
...@@ -38,6 +40,7 @@ static void usage(int argc, char **argv) ...@@ -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, "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, " 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, " 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, " [-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"); fprintf(stderr, "Example: ./proxy-server-daemon na+sm na+sm://3005/0\n");
return; return;
...@@ -50,10 +53,13 @@ static void parse_args(int argc, char **argv, struct options *opts) ...@@ -50,10 +53,13 @@ static void parse_args(int argc, char **argv, struct options *opts)
memset(opts, 0, sizeof(*opts)); memset(opts, 0, sizeof(*opts));
/* get options */ /* get options */
while((opt = getopt(argc, argv, "f:")) != -1) while((opt = getopt(argc, argv, "bf:")) != -1)
{ {
switch(opt) switch(opt)
{ {
case 'b':
opts->batch_rpc = 1;
break;
case 'f': case 'f':
opts->host_file = optarg; opts->host_file = optarg;
break; break;
...@@ -89,6 +95,7 @@ int main(int argc, char **argv) ...@@ -89,6 +95,7 @@ int main(int argc, char **argv)
if(!g_proxy_svr_ctx) if(!g_proxy_svr_ctx)
return(-1); return(-1);
memset(g_proxy_svr_ctx, 0, sizeof(*g_proxy_svr_ctx)); memset(g_proxy_svr_ctx, 0, sizeof(*g_proxy_svr_ctx));
g_proxy_svr_ctx->batch_rpc = opts.batch_rpc;
/* start margo */ /* start margo */
mid = margo_init(opts.listen_addr_str, MARGO_SERVER_MODE, 0, -1); 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) ...@@ -182,21 +189,32 @@ static void proxy_write_ult(hg_handle_t handle)
hret = margo_get_input(handle, &in); hret = margo_get_input(handle, &in);
assert(hret == HG_SUCCESS); assert(hret == HG_SUCCESS);
/* XXX we need a create_write_persist call to save on RTTs */ if(g_proxy_svr_ctx->batch_rpc)
{
/* create BAKE region to store this write in */ /* create the BAKE region, write to it on behalf of the client,
ret = bake_create(g_proxy_svr_ctx->svr_bti, in.bulk_size, * and persist the region all in one RPC
&(g_proxy_svr_ctx->the_rid)); */
assert(ret == 0); 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,
/* perform proxy write on behalf of client */ in.bulk_size, &(g_proxy_svr_ctx->the_rid));
ret = bake_proxy_write(g_proxy_svr_ctx->svr_bti, g_proxy_svr_ctx->the_rid, assert(ret == 0);
0, in.bulk_handle, in.bulk_offset, in.bulk_addr, in.bulk_size); }
assert(ret == 0); else
{
/* persist the BAKE region */ /* create BAKE region to store this write in */
ret = bake_persist(g_proxy_svr_ctx->svr_bti, g_proxy_svr_ctx->the_rid); ret = bake_create(g_proxy_svr_ctx->svr_bti, in.bulk_size,
assert(ret == 0); &(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 */ /* set return value */
out.ret = 0; out.ret = 0;
......
...@@ -5,14 +5,15 @@ source $srcdir/tests/test-util.sh ...@@ -5,14 +5,15 @@ source $srcdir/tests/test-util.sh
function test_start_proxy_servers () function test_start_proxy_servers ()
{ {
bake_svr_addr=${1} bake_svr_addr=${1}
nservers=${2:-4} opts=${2}
startwait=${3:-15} nservers=${3:-4}
maxtime=${4:-120} startwait=${4:-15}
maxtime=${5:-120}
# start daemons # start daemons
for i in `seq $nservers` for i in `seq $nservers`
do 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 if [ $? -ne 0 ]; then
# TODO: this doesn't actually work; can't check return code of # TODO: this doesn't actually work; can't check return code of
# something executing in background. We have to rely on the # something executing in background. We have to rely on the
......
...@@ -10,7 +10,7 @@ source $srcdir/tests/proxy/proxy-test-util.sh ...@@ -10,7 +10,7 @@ source $srcdir/tests/proxy/proxy-test-util.sh
test_start_servers 1 2 20 test_start_servers 1 2 20
# start 1 proxy server with 2 second wait, 20s timeout # 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 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