[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24284 - in gnunet/src: include testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24284 - in gnunet/src: include testbed |
Date: |
Fri, 12 Oct 2012 11:02:44 +0200 |
Author: harsha
Date: 2012-10-12 11:02:44 +0200 (Fri, 12 Oct 2012)
New Revision: 24284
Modified:
gnunet/src/include/gnunet_testbed_service.h
gnunet/src/testbed/gnunet-testbed-profiler.c
gnunet/src/testbed/test_testbed_api_hosts.c
gnunet/src/testbed/testbed_api_hosts.c
Log:
host file support for testbed profiler
Modified: gnunet/src/include/gnunet_testbed_service.h
===================================================================
--- gnunet/src/include/gnunet_testbed_service.h 2012-10-12 07:47:02 UTC (rev
24283)
+++ gnunet/src/include/gnunet_testbed_service.h 2012-10-12 09:02:44 UTC (rev
24284)
@@ -133,6 +133,17 @@
/**
+ * Checks whether a host can be used to start testbed service
+ *
+ * @param host the host to check
+ * @return GNUNET_YES if testbed service can be started on the given host
+ * remotely; GNUNET_NO if not
+ */
+int
+GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host);
+
+
+/**
* Enumeration with (at most 64) possible event types that
* can be monitored using the testbed framework.
*/
Modified: gnunet/src/testbed/gnunet-testbed-profiler.c
===================================================================
--- gnunet/src/testbed/gnunet-testbed-profiler.c 2012-10-12 07:47:02 UTC
(rev 24283)
+++ gnunet/src/testbed/gnunet-testbed-profiler.c 2012-10-12 09:02:44 UTC
(rev 24284)
@@ -27,9 +27,15 @@
#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_testbed_service.h"
+#include "testbed_api_hosts.h"
/**
+ * An array of hosts loaded from the hostkeys file
+ */
+static struct GNUNET_TESTBED_Host **hosts;
+
+/**
* The array of peers; we fill this as the peers are given to us by the testbed
*/
static struct GNUNET_TESTBED_Peer **peers;
@@ -55,6 +61,11 @@
static unsigned int num_peers;
/**
+ * Number of hosts in the hosts array
+ */
+static unsigned int num_hosts;
+
+/**
* Global testing status
*/
static int result;
@@ -69,9 +80,15 @@
static void
do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ unsigned int nhost;
+
if (GNUNET_SCHEDULER_NO_TASK != abort_task)
GNUNET_SCHEDULER_cancel (abort_task);
GNUNET_free_non_null (peers);
+ for (nhost = 0; nhost < num_hosts; nhost++)
+ if (NULL != hosts[nhost])
+ GNUNET_TESTBED_host_destroy (hosts[nhost]);
+ GNUNET_free_non_null (hosts);
GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed
run */
}
@@ -85,7 +102,7 @@
static void
do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Profiling timedout -- Aborting\n");
abort_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
}
@@ -150,12 +167,38 @@
const struct GNUNET_CONFIGURATION_Handle *config)
{
uint64_t event_mask;
+ unsigned int nhost;
+ if (NULL == args[0])
+ {
+ FPRINTF (stderr, _("No hosts-file specified on command line\n"));
+ return;
+ }
if (0 == num_peers)
{
result = GNUNET_OK;
return;
}
+ num_hosts = GNUNET_TESTBED_hosts_load_from_file (args[0], &hosts);
+ if (0 == num_hosts)
+ {
+ FPRINTF (stderr, _("No hosts loaded\n"));
+ return;
+ }
+ for (nhost = 0; nhost < num_hosts; nhost++)
+ {
+ if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost]))
+ {
+ FPRINTF (stderr, _("Host %s cannot start testbed\n"),
+ GNUNET_TESTBED_host_get_hostname_ (hosts[nhost]));
+ break;
+ }
+ }
+ if (num_hosts != nhost)
+ {
+ GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
+ return;
+ }
peers = GNUNET_malloc (num_peers * sizeof (struct GNUNET_TESTBED_Peer *));
event_mask = 0;
event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
@@ -183,6 +226,9 @@
{ 'n', "num-peers", "COUNT",
gettext_noop ("create COUNT number of peers"),
GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers },
+ { 'n', "num-peers", "COUNT",
+ gettext_noop ("create COUNT number of peers"),
+ GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers },
GNUNET_GETOPT_OPTION_END
};
int ret;
@@ -192,7 +238,7 @@
result = GNUNET_SYSERR;
ret =
- GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-profiler [OPTIONS]",
+ GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-profiler [OPTIONS]
hosts-file",
_("Profiler for testbed"),
options, &run, NULL);
if (GNUNET_OK != ret)
Modified: gnunet/src/testbed/test_testbed_api_hosts.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_hosts.c 2012-10-12 07:47:02 UTC (rev
24283)
+++ gnunet/src/testbed/test_testbed_api_hosts.c 2012-10-12 09:02:44 UTC (rev
24284)
@@ -102,6 +102,7 @@
&hosts);
GNUNET_assert (15 == num_hosts);
GNUNET_assert (NULL != hosts);
+ result = GNUNET_YES;
shutdown_id =
GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (2), &do_shutdown, NULL);
}
@@ -118,7 +119,7 @@
GNUNET_GETOPT_OPTION_END
};
- status = GNUNET_YES;
+ status = GNUNET_SYSERR;
if (GNUNET_OK !=
GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
"test_testbed_api_hosts", "nohelp", options, &run,
Modified: gnunet/src/testbed/testbed_api_hosts.c
===================================================================
--- gnunet/src/testbed/testbed_api_hosts.c 2012-10-12 07:47:02 UTC (rev
24283)
+++ gnunet/src/testbed/testbed_api_hosts.c 2012-10-12 09:02:44 UTC (rev
24284)
@@ -26,12 +26,10 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "gnunet_core_service.h"
-#include "gnunet_constants.h"
#include "gnunet_transport_service.h"
-#include "gnunet_hello_lib.h"
-#include "gnunet_container_lib.h"
#include "testbed_api.h"
#include "testbed_api_hosts.h"
@@ -475,4 +473,68 @@
}
+/**
+ * Checks whether a host can be used to start testbed service
+ *
+ * @param host the host to check
+ * @return GNUNET_YES if testbed service can be started on the given host
+ * remotely; GNUNET_NO if not
+ */
+int
+GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
+{
+ char *remote_args[11];
+ char *portstr;
+ char *ssh_addr;
+ const char *hostname;
+ struct GNUNET_OS_Process *auxp;
+ unsigned long code;
+ enum GNUNET_OS_ProcessStatusType type;
+ int ret;
+ unsigned int argp;
+
+ portstr = NULL;
+ ssh_addr = NULL;
+ hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
+ if (NULL == host->username)
+ ssh_addr = GNUNET_strdup (hostname);
+ else
+ GNUNET_asprintf (&ssh_addr, "address@hidden", host->username, hostname);
+ argp = 0;
+ remote_args[argp++] = "ssh";
+ GNUNET_asprintf (&portstr, "%u", host->port);
+ remote_args[argp++] = "-p";
+ remote_args[argp++] = portstr;
+ remote_args[argp++] = "-o";
+ remote_args[argp++] = "BatchMode=yes";
+ remote_args[argp++] = "-o";
+ remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
+ remote_args[argp++] = ssh_addr;
+ remote_args[argp++] = "which";
+ remote_args[argp++] = "gnunet-helper-testbed";
+ remote_args[argp++] = NULL;
+ GNUNET_assert (argp == 11);
+ auxp =
+ GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
+ NULL, "ssh", remote_args);
+ if (NULL == auxp)
+ {
+ GNUNET_free (ssh_addr);
+ GNUNET_free (portstr);
+ return GNUNET_NO;
+ }
+ do
+ {
+ ret = GNUNET_OS_process_status (auxp, &type, &code);
+ GNUNET_assert (GNUNET_SYSERR != ret);
+ (void) usleep (300);
+ }
+ while (GNUNET_NO == ret);
+ //(void) GNUNET_OS_process_wait (auxp);
+ GNUNET_OS_process_destroy (auxp);
+ GNUNET_free (ssh_addr);
+ GNUNET_free (portstr);
+ return (0 != code) ? GNUNET_NO : GNUNET_YES;
+}
+
/* end of testbed_api_hosts.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24284 - in gnunet/src: include testbed,
gnunet <=