[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23224 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23224 - gnunet/src/testbed |
Date: |
Tue, 14 Aug 2012 15:24:09 +0200 |
Author: harsha
Date: 2012-08-14 15:24:09 +0200 (Tue, 14 Aug 2012)
New Revision: 23224
Added:
gnunet/src/testbed/test_testbed_api_controllerlink.c
Modified:
gnunet/src/testbed/
gnunet/src/testbed/Makefile.am
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/test_testbed_api_2peers.c
gnunet/src/testbed/testbed_api.c
Log:
fixes
Property changes on: gnunet/src/testbed
___________________________________________________________________
Modified: svn:ignore
- Makefile.in
Makefile
.deps
gnunet-service-testbed
gnunet-testbed-helper
testbed.conf
test_testbed_api_hosts
test_testbed_api
test_testbed_api_2peers
test_testbed_api_operations
test_gnunet_testbed_helper
+ Makefile.in
Makefile
.deps
gnunet-service-testbed
gnunet-testbed-helper
testbed.conf
test_testbed_api_hosts
test_testbed_api
test_testbed_api_2peers
test_testbed_api_operations
test_testbed_api_controllerlink
test_gnunet_testbed_helper
Modified: gnunet/src/testbed/Makefile.am
===================================================================
--- gnunet/src/testbed/Makefile.am 2012-08-14 12:45:59 UTC (rev 23223)
+++ gnunet/src/testbed/Makefile.am 2012-08-14 13:24:09 UTC (rev 23224)
@@ -69,6 +69,7 @@
check_PROGRAMS = \
test_testbed_api_hosts \
+ test_testbed_api_controllerlink \
test_testbed_api_2peers \
test_testbed_api \
test_testbed_api_operations \
@@ -109,6 +110,12 @@
$(top_builddir)/src/util/libgnunetutil.la \
libgnunettestbed.la
+test_testbed_api_controllerlink_SOURCES = \
+ test_testbed_api_controllerlink.c
+test_testbed_api_controllerlink_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ libgnunettestbed.la
+
test_gnunet_testbed_helper_SOURCES = \
test_gnunet_testbed_helper.c
test_gnunet_testbed_helper_LDADD = \
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-08-14 12:45:59 UTC (rev
23223)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-08-14 13:24:09 UTC (rev
23224)
@@ -1112,11 +1112,12 @@
LOG_DEBUG ("-------ssh port: %u\n", ntohs (msg->ssh_port));
host = GNUNET_TESTBED_host_create_with_id (host_id, hostname, username,
ntohs (msg->ssh_port));
+ GNUNET_assert (NULL != host);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
reply_size = sizeof (struct GNUNET_TESTBED_HostConfirmedMessage);
if (GNUNET_OK != host_list_add (host))
{
- /* We are unable to add a host */
+ /* We are unable to add a host */
emsg = "A host exists with given host-id";
LOG_DEBUG ("%s: %u", emsg, host_id);
GNUNET_TESTBED_host_destroy (host);
@@ -1313,7 +1314,7 @@
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- if (config_size == dest_size)
+ if (config_size != dest_size)
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Uncompressed config size mismatch\n");
GNUNET_free (config);
Modified: gnunet/src/testbed/test_testbed_api_2peers.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_2peers.c 2012-08-14 12:45:59 UTC
(rev 23223)
+++ gnunet/src/testbed/test_testbed_api_2peers.c 2012-08-14 13:24:09 UTC
(rev 23224)
@@ -404,7 +404,7 @@
{
int ret;
- char *const argv2[] = { "test_testbed_api",
+ char *const argv2[] = { "test_testbed_api_2peers",
"-c", "test_testbed_api.conf",
NULL
};
Added: gnunet/src/testbed/test_testbed_api_controllerlink.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_controllerlink.c
(rev 0)
+++ gnunet/src/testbed/test_testbed_api_controllerlink.c 2012-08-14
13:24:09 UTC (rev 23224)
@@ -0,0 +1,306 @@
+/*
+ This file is part of GNUnet
+ (C) 2008--2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file testbed/test_testbed_api_controllerlink.c
+ * @brief testcase for testing controller to subcontroller linking
+ * @author Sree Harsha Totakura <address@hidden>
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_lib-new.h"
+#include "gnunet_testbed_service.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind,...) \
+ GNUNET_log (kind, __VA_ARGS__)
+
+/**
+ * Debug logging shorthand
+ */
+#define LOG_DEBUG(...) \
+ LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
+
+/**
+ * Different stages in testing
+ */
+enum Stage
+ {
+
+ /**
+ * Initial stage
+ */
+ INIT,
+
+ /**
+ * Master controller has started
+ */
+ MASTER_STARTED,
+
+ /**
+ * The first slave has been registered at master controller
+ */
+ SLAVE1_REGISTERED,
+
+ /**
+ * The second slave has been registered at the master controller
+ */
+ SLAVE2_REGISTERED,
+
+ /**
+ * Final stage
+ */
+ SUCCESS
+
+ };
+
+/**
+ * Host for running master controller
+ */
+static struct GNUNET_TESTBED_Host *host;
+
+/**
+ * The master controller process
+ */
+static struct GNUNET_TESTBED_ControllerProc *cp;
+
+/**
+ * Handle to master controller
+ */
+static struct GNUNET_TESTBED_Controller *mc;
+
+/**
+ * Slave host for running slave controller
+ */
+static struct GNUNET_TESTBED_Host *slave;
+
+/**
+ * Another slave host for running another slave controller
+ */
+static struct GNUNET_TESTBED_Host *slave2;
+
+/**
+ * Slave host registration handle
+ */
+static struct GNUNET_TESTBED_HostRegistrationHandle *rh;
+
+/**
+ * Handle to global configuration
+ */
+static struct GNUNET_CONFIGURATION_Handle *cfg;
+
+/**
+ * Abort task
+ */
+static GNUNET_SCHEDULER_TaskIdentifier abort_task;
+
+/**
+ * Event mask
+ */
+uint64_t event_mask;
+
+/**
+ * Global testing status
+ */
+static enum Stage result;
+
+
+/**
+ * Shutdown nicely
+ *
+ * @param cls NULL
+ * @param tc the task context
+ */
+static void
+do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ if (GNUNET_SCHEDULER_NO_TASK != abort_task)
+ GNUNET_SCHEDULER_cancel (abort_task);
+ if (NULL != mc)
+ GNUNET_TESTBED_controller_disconnect (mc);
+ if (NULL != cp)
+ GNUNET_TESTBED_controller_stop (cp);
+ if (NULL != slave2)
+ GNUNET_TESTBED_host_destroy (slave2);
+ if (NULL != slave)
+ GNUNET_TESTBED_host_destroy (slave);
+ if (NULL != host)
+ GNUNET_TESTBED_host_destroy (host);
+ if (NULL != cfg)
+ GNUNET_CONFIGURATION_destroy (cfg);
+ if (NULL != rh)
+ GNUNET_TESTBED_cancel_registration (rh);
+
+}
+
+
+/**
+ * abort task to run on test timed out
+ *
+ * @param cls NULL
+ * @param tc the task context
+ */
+static void
+do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
+ abort_task = GNUNET_SCHEDULER_NO_TASK;
+ do_shutdown (cls, tc);
+}
+
+
+/**
+ * Signature of the event handler function called by the
+ * respective event controller.
+ *
+ * @param cls closure
+ * @param event information about the event
+ */
+static void
+controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
+{
+ GNUNET_assert (0);
+}
+
+
+/**
+ * Callback which will be called to after a host registration succeeded or
failed
+ *
+ * @param cls the host which has been registered
+ * @param emsg the error message; NULL if host registration is successful
+ */
+static void
+registration_cont (void *cls, const char *emsg)
+{
+ rh = NULL;
+ switch (result)
+ {
+ case MASTER_STARTED:
+ GNUNET_assert (NULL == emsg);
+ result = SLAVE1_REGISTERED;
+ slave2 = GNUNET_TESTBED_host_create_with_id (2, "127.0.0.1", NULL, 0);
+ GNUNET_assert (NULL != slave2);
+ rh = GNUNET_TESTBED_register_host (mc, slave2, ®istration_cont, NULL);
+ GNUNET_assert (NULL != rh);
+ break;
+ case SLAVE1_REGISTERED:
+ GNUNET_assert (NULL == emsg);
+ GNUNET_assert (NULL != mc);
+ result = SLAVE2_REGISTERED;
+ GNUNET_assert (NULL != cfg);
+ GNUNET_TESTBED_controller_link (mc, slave, NULL, cfg, GNUNET_YES);
+ //GNUNET_TESTBED_controller_link (mc, host, slave
+ result = SUCCESS;
+ GNUNET_SCHEDULER_add_delayed
+ (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3),
+ &do_shutdown, NULL);
+ break;
+ case INIT:
+ case SUCCESS:
+ case SLAVE2_REGISTERED:
+ GNUNET_assert (0);
+ }
+}
+
+/**
+ * Callback to signal successfull startup of the controller process
+ *
+ * @param cls the closure from GNUNET_TESTBED_controller_start()
+ * @param cfg the configuration with which the controller has been started;
+ * NULL if status is not GNUNET_OK
+ * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
+ * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
+ */
+static void
+status_cb (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *config, int status)
+{
+ switch (result)
+ {
+ case INIT:
+ GNUNET_assert (GNUNET_OK == status);
+ event_mask = 0;
+ event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START);
+ event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
+ event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT);
+ event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED);
+ mc = GNUNET_TESTBED_controller_connect (config, host, event_mask,
+ &controller_cb, NULL);
+ GNUNET_assert (NULL != mc);
+ result = MASTER_STARTED;
+ slave = GNUNET_TESTBED_host_create_with_id (1, "127.0.0.1", NULL, 0);
+ GNUNET_assert (NULL != slave);
+ rh = GNUNET_TESTBED_register_host (mc, slave, ®istration_cont, NULL);
+ GNUNET_assert (NULL != rh);
+ break;
+ default:
+ GNUNET_assert (0);
+ }
+}
+
+
+/**
+ * Main run function.
+ *
+ * @param cls NULL
+ * @param args arguments passed to GNUNET_PROGRAM_run
+ * @param cfgfile the path to configuration file
+ * @param cfg the configuration file handle
+ */
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *config)
+{
+ host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
+ GNUNET_assert (NULL != host);
+ cfg = GNUNET_CONFIGURATION_dup (config);
+ cp =
+ GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL);
+ abort_task = GNUNET_SCHEDULER_add_delayed
+ (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30),
+ &do_abort, NULL);
+}
+
+
+/**
+ * Main function
+ */
+int main (int argc, char **argv)
+{
+ int ret;
+
+ char *const argv2[] = { "test_testbed_api_controllerlink",
+ "-c", "test_testbed_api.conf",
+ NULL
+ };
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
+ result = INIT;
+ ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
+ "test_testbed_api_controllerlink", "nohelp",
options, &run,
+ NULL);
+ if ((GNUNET_OK != ret) || (SUCCESS != result))
+ return 1;
+ return 0;
+}
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2012-08-14 12:45:59 UTC (rev 23223)
+++ gnunet/src/testbed/testbed_api.c 2012-08-14 13:24:09 UTC (rev 23224)
@@ -1005,7 +1005,7 @@
if (NULL == username)
GNUNET_asprintf (&cp->dst, "%s", hostname);
else
- GNUNET_asprintf (&cp->dst, "address@hidden", hostname, username);
+ GNUNET_asprintf (&cp->dst, "address@hidden", username, hostname);
argp = 0;
remote_args[argp++] = "ssh";
remote_args[argp++] = "-p";
@@ -1126,6 +1126,8 @@
}
}
GNUNET_assert (NULL != host);
+ GNUNET_TESTBED_mark_host_registered_at_ (host, controller);
+ controller->host = host;
controller->opq_peer_create =
GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
max_parallel_peer_create);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23224 - gnunet/src/testbed,
gnunet <=