Commit 5e2e586e authored by Shane Snyder's avatar Shane Snyder

add more testing framework

parent c7ddf09b
......@@ -5,13 +5,16 @@ TESTS_ENVIRONMENT += \
MKTEMP="$(MKTEMP)"
check_PROGRAMS += \
tests/ssg-launch-group
tests/ssg-launch-group \
tests/ssg-join-group
TESTS += \
tests/simple-group.sh
tests/simple-group.sh \
tests/join-group.sh
EXTRA_DIST += \
tests/simple-group.sh
tests/simple-group.sh \
tests/join-group.sh
check_PROGRAMS += tests/perf-regression/margo-p2p-latency
tests_perf_regression_margo_p2p_latency_LDADD = src/libssg.la
......
#!/bin/bash -x
if [ -z $srcdir ]; then
echo srcdir variable not set.
exit 1
fi
source $srcdir/tests/test-util.sh
TMPOUT=$($MKTEMP -d --tmpdir test-XXXXXX)
# launch initial group, storing GID
export SSG_GROUP_LAUNCH_NAME=simplest-group
export SSG_GROUP_LAUNCH_DURATION=10
export SSG_GROUP_LAUNCH_GIDFILE=$TMPOUT/gid.out
launch_ssg_group_mpi 4 na+sm
if [ $? -ne 0 ]; then
wait
rm -rf $TMPOUT
exit 1
fi
sleep 2
# try to join running group
export SSG_GROUP_LAUNCH_DURATION=8
join_ssg_group na+sm $SSG_GROUP_LAUNCH_GIDFILE
if [ $? -ne 0 ]; then
wait
rm -rf $TMPOUT
exit 1
fi
wait
if [ $? -ne 0 ]; then
rm -rf $TMPOUT
exit 1
fi
rm -rf $TMPOUT
exit 0
#!/bin/bash -x
if [ -z $srcdir ]; then
echo srcdir variable not set.
exit 1
fi
source $srcdir/tests/test-util.sh
# launch a group and wait for termination
export SSG_GROUP_LAUNCH_NAME=simplest-group
export SSG_GROUP_LAUNCH_DURATION=10
launch_ssg_group_mpi 4 na+sm
if [ $? -ne 0 ]; then
wait
exit 1
fi
wait
if [ $? -ne 0 ]; then
exit 1
fi
exit 0
/*
* Copyright (c) 2016 UChicago Argonne, LLC
*
* See COPYRIGHT in top-level directory.
*/
#include <ssg-config.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <margo.h>
#include <ssg.h>
#define DIE_IF(cond_expr, err_fmt, ...) \
do { \
if (cond_expr) { \
fprintf(stderr, "ERROR at %s:%d (" #cond_expr "): " \
err_fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
exit(EXIT_FAILURE); \
} \
} while(0)
struct group_join_opts
{
char *addr_str;
int duration;
char *gid_file;
};
static void usage()
{
fprintf(stderr,
"Usage: "
"ssg-join-group [OPTIONS] <ADDR> <GID>\n"
"Join an existing group given by GID using Mercury address ADDR.\n"
"\n"
"OPTIONS:\n"
"\t-d DUR\t\tSpecify a time duration (in seconds) to run the group for\n");
}
static void parse_args(int argc, char *argv[], struct group_join_opts *opts)
{
int c;
const char *options = "d:";
char *check = NULL;
while ((c = getopt(argc, argv, options)) != -1)
{
switch (c)
{
case 'd':
opts->duration = (int)strtol(optarg, &check, 0);
if (opts->duration < 0 || (check && *check != '\0'))
{
usage();
exit(EXIT_FAILURE);
}
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
if ((argc - optind) != 2)
{
usage();
exit(EXIT_FAILURE);
}
opts->addr_str = argv[optind++];
opts->gid_file = argv[optind++];
return;
}
int main(int argc, char *argv[])
{
struct group_join_opts opts;
margo_instance_id mid = MARGO_INSTANCE_NULL;
ssg_group_id_t in_g_id = SSG_GROUP_ID_NULL;
ssg_group_id_t out_g_id = SSG_GROUP_ID_NULL;
ssg_member_id_t my_id;
int group_size;
int sret;
/* set any default options (that may be overwritten by cmd args) */
opts.duration = 10; /* default to running for 10 seconds */
/* parse cmdline arguments */
parse_args(argc, argv, &opts);
/* init margo */
/* use the main xstream to drive progress & run handlers */
mid = margo_init(opts.addr_str, MARGO_SERVER_MODE, 0, -1);
DIE_IF(mid == MARGO_INSTANCE_NULL, "margo_init");
/* initialize SSG */
sret = ssg_init(mid);
DIE_IF(sret != SSG_SUCCESS, "ssg_init");
/* XXX do we want to use callback for testing anything about group??? */
out_g_id = ssg_group_join(in_g_id, NULL, NULL);
DIE_IF(out_g_id == SSG_GROUP_ID_NULL, "ssg_group_join");
ssg_group_id_free(in_g_id);
/* sleep for given duration to allow group time to run */
if (opts.duration > 0) margo_thread_sleep(mid, opts.duration * 1000.0);
/* get my group id and the size of the group */
my_id = ssg_get_group_self_id(out_g_id);
DIE_IF(my_id == SSG_MEMBER_ID_INVALID, "ssg_get_group_self_id");
group_size = ssg_get_group_size(out_g_id);
DIE_IF(group_size == 0, "ssg_get_group_size");
printf("group member %lu successfully created group (size == %d)\n",
my_id, group_size);
/* print group at each member */
ssg_group_dump(out_g_id);
/** cleanup **/
ssg_group_destroy(out_g_id);
ssg_finalize();
margo_finalize(mid);
return 0;
}
......@@ -24,32 +24,38 @@
if (cond_expr) { \
fprintf(stderr, "ERROR at %s:%d (" #cond_expr "): " \
err_fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
exit(1); \
exit(EXIT_FAILURE); \
} \
} while(0)
struct group_launch_opts
{
int duration;
char *gid_file;
char *addr_str;
char *group_mode;
char *group_addr_conf_file;
int duration;
char *gid_file;
char *group_name;
};
static void usage()
{
fprintf(stderr,
"Usage: "
"ssg-launch-group [OPTIONS] <addr> <create mode> [config file]\n"
"\t<addr> - Mercury address string\n"
"\t<create mode> - \"mpi\" (if supported) or \"conf\"\n"
"\tif \"conf\" is the mode, then [config file] is required\n");
"ssg-launch-group [OPTIONS] <ADDR> <MODE> [CONFFILE]\n"
"Create and launch group using given Mercury ADDR string and group create MODE (\"mpi\" or \"conf\").\n"
"NOTE: A path to an address CONFFILE is required when using \"conf\" mode.\n"
"\n"
"OPTIONS:\n"
"\t-d DUR\t\tSpecify a time duration (in seconds) to run the group for\n"
"\t-f FILE\t\tStore group GID at a given file path\n"
"\t-n NAME\t\tSpecify the name of the launched group\n");
}
static void parse_args(int argc, char *argv[], struct group_launch_opts *opts)
{
int c;
const char *options = "d:f:";
const char *options = "d:f:n:";
char *check = NULL;
while ((c = getopt(argc, argv, options)) != -1)
......@@ -67,87 +73,101 @@ static void parse_args(int argc, char *argv[], struct group_launch_opts *opts)
case 'f':
opts->gid_file = optarg;
break;
case 'n':
opts->group_name = optarg;
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
return;
#if 0
*addr_str = argv[ndx++];
*mode = argv[ndx++];
if ((argc - optind) < 2)
{
usage();
exit(EXIT_FAILURE);
}
if (strcmp(*mode, "conf") == 0)
opts->addr_str = argv[optind++];
opts->group_mode = argv[optind++];
if (strcmp(opts->group_mode, "conf") == 0)
{
if (ndx != (argc - 1))
if ((argc - optind) != 1)
{
usage();
exit(1);
exit(EXIT_FAILURE);
}
*conf_file = argv[ndx];
opts->group_addr_conf_file = argv[optind++];
}
else if (strcmp(*mode, "mpi") == 0)
else if (strcmp(opts->group_mode, "mpi") == 0)
{
#ifdef SSG_HAVE_MPI
if (ndx != argc)
if (optind != argc)
{
usage();
exit(1);
exit(EXIT_FAILURE);
}
#else
fprintf(stderr, "Error: MPI support not built in\n");
exit(1);
exit(EXIT_FAILURE);
#endif
}
else
{
usage();
exit(1);
exit(EXIT_FAILURE);
}
#endif
return;
}
int main(int argc, char *argv[])
{
struct group_launch_opts opts;
margo_instance_id mid = MARGO_INSTANCE_NULL;
const char *addr_str;
const char *group_name = "simple_group";
ssg_group_id_t g_id = SSG_GROUP_ID_NULL;
ssg_member_id_t my_id;
int group_size;
int sret;
/* XXX default options? */
struct group_launch_opts opts;
/* set any default options (that may be overwritten by cmd args) */
opts.duration = 10; /* default to running group for 10 seconds */
opts.group_name = "simple_group";
opts.gid_file = NULL;
/* parse cmdline arguments */
parse_args(argc, argv, &opts);
return 0;
#ifdef SSG_HAVE_MPI
if (strcmp(mode, "mpi") == 0)
if (strcmp(opts.group_mode, "mpi") == 0)
MPI_Init(&argc, &argv);
#endif
/* init margo */
/* use the main xstream to drive progress & run handlers */
mid = margo_init(addr_str, MARGO_SERVER_MODE, 0, -1);
mid = margo_init(opts.addr_str, MARGO_SERVER_MODE, 0, -1);
DIE_IF(mid == MARGO_INSTANCE_NULL, "margo_init");
/* initialize SSG */
sret = ssg_init(mid);
DIE_IF(sret != SSG_SUCCESS, "ssg_init");
if(strcmp(mode, "conf") == 0)
g_id = ssg_group_create_config(group_name, conf_file, NULL, NULL);
/* XXX do we want to use callback for testing anything about group??? */
if(strcmp(opts.group_mode, "conf") == 0)
g_id = ssg_group_create_config(opts.group_name, opts.group_addr_conf_file,
NULL, NULL);
#ifdef SSG_HAVE_MPI
else if(strcmp(mode, "mpi") == 0)
g_id = ssg_group_create_mpi(group_name, MPI_COMM_WORLD, NULL, NULL);
else if(strcmp(opts.group_mode, "mpi") == 0)
g_id = ssg_group_create_mpi(opts.group_name, MPI_COMM_WORLD, NULL, NULL);
#endif
DIE_IF(g_id == SSG_GROUP_ID_NULL, "ssg_group_create");
/* sleep to give all group members a chance to create the group */
if (sleep_time > 0) margo_thread_sleep(mid, sleep_time * 1000.0);
/* store the gid if requested */
if (opts.gid_file)
ssg_group_id_store(opts.gid_file, g_id);
/* sleep for given duration to allow group time to run */
if (opts.duration > 0) margo_thread_sleep(mid, opts.duration * 1000.0);
/* get my group id and the size of the group */
my_id = ssg_get_group_self_id(g_id);
......@@ -165,7 +185,7 @@ int main(int argc, char *argv[])
ssg_finalize();
margo_finalize(mid);
#ifdef SSG_HAVE_MPI
if (strcmp(mode, "mpi") == 0)
if (strcmp(opts.group_mode, "mpi") == 0)
MPI_Finalize();
#endif
......
#
# General test script utilities
#
if [ -z "$MKTEMP" ]; then
echo "Error: MKTEMP variable should be defined to its respective command"
exit 1
fi
function launch_ssg_group_mpi ()
{
nmembers=${1:-4}
hg_addr=${2:-"na+sm"}
options=""
# parse known cmdline options out of env
if [ ! -z $SSG_GROUP_LAUNCH_NAME ]; then
options="$options -n $SSG_GROUP_LAUNCH_NAME"
fi
if [ ! -z $SSG_GROUP_LAUNCH_DURATION ]; then
options="$options -d $SSG_GROUP_LAUNCH_DURATION"
fi
if [ ! -z $SSG_GROUP_LAUNCH_GIDFILE ]; then
options="$options -f $SSG_GROUP_LAUNCH_GIDFILE"
fi
# launch SSG group given options
mpirun -np $nmembers tests/ssg-launch-group $options $hg_addr mpi
}
function join_ssg_group ()
{
hg_addr=${1:-"na+sm"}
gid_file=${2}
options=""
if [ -z "$gid_file" ]; then
echo "Error: join_ssg_group requires a valid GID file argument"
exit 1
fi
# parse known cmdline options out of env
if [ ! -z $SSG_GROUP_LAUNCH_DURATION ]; then
options="$options -d $SSG_GROUP_LAUNCH_DURATION"
fi
tests/ssg-join-group $options $hg_addr $gid_file
}
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