[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23415 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23415 - gnunet/src/testbed |
Date: |
Fri, 24 Aug 2012 19:52:55 +0200 |
Author: harsha
Date: 2012-08-24 19:52:55 +0200 (Fri, 24 Aug 2012)
New Revision: 23415
Modified:
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/test_testbed_api_controllerlink.c
gnunet/src/testbed/testbed_api.c
Log:
peer start/stop forwarding with tests
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-08-24 16:35:57 UTC (rev
23414)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-08-24 17:52:55 UTC (rev
23415)
@@ -1776,6 +1776,8 @@
{
const struct GNUNET_TESTBED_PeerStartMessage *msg;
struct GNUNET_TESTBED_PeerEventMessage *reply;
+ struct ForwardedOperationContext *fopc;
+ struct Peer *peer;
uint32_t peer_id;
msg = (const struct GNUNET_TESTBED_PeerStartMessage *) message;
@@ -1784,15 +1786,35 @@
|| (NULL == peer_list[peer_id]))
{
GNUNET_break (0);
- /* FIXME: reply with failure message or forward to slave controller */
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Asked to start a non existent peer with id: %u\n", peer_id);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
+ peer = peer_list[peer_id];
+ if (GNUNET_YES == peer->is_remote)
+ {
+ fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
+ GNUNET_SERVER_client_keep (client);
+ fopc->client = client;
+ fopc->operation_id = GNUNET_ntohll (msg->operation_id);
+ fopc->opc =
+ GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller,
+ fopc->operation_id,
+ &msg->header,
+ &forwarded_operation_reply_relay,
+ fopc);
+ fopc->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &forwarded_operation_timeout, fopc);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
if (GNUNET_OK !=
- GNUNET_TESTING_peer_start (peer_list[peer_id]->details.local.peer))
+ GNUNET_TESTING_peer_start (peer->details.local.peer))
{
- /* FIXME: return FAILURE message */
- GNUNET_break (0);
+ send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
+ "Failed to start");
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
@@ -1822,6 +1844,8 @@
{
const struct GNUNET_TESTBED_PeerStopMessage *msg;
struct GNUNET_TESTBED_PeerEventMessage *reply;
+ struct ForwardedOperationContext *fopc;
+ struct Peer *peer;
uint32_t peer_id;
msg = (const struct GNUNET_TESTBED_PeerStopMessage *) message;
@@ -1832,8 +1856,27 @@
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
+ peer = peer_list[peer_id];
+ if (GNUNET_YES == peer->is_remote)
+ {
+ fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
+ GNUNET_SERVER_client_keep (client);
+ fopc->client = client;
+ fopc->operation_id = GNUNET_ntohll (msg->operation_id);
+ fopc->opc =
+ GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller,
+ fopc->operation_id,
+ &msg->header,
+ &forwarded_operation_reply_relay,
+ fopc);
+ fopc->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &forwarded_operation_timeout, fopc);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
if (GNUNET_OK !=
- GNUNET_TESTING_peer_stop (peer_list[peer_id]->details.local.peer))
+ GNUNET_TESTING_peer_stop (peer->details.local.peer))
{
/* FIXME: return FAILURE message */
GNUNET_break (0);
Modified: gnunet/src/testbed/test_testbed_api_controllerlink.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_controllerlink.c 2012-08-24
16:35:57 UTC (rev 23414)
+++ gnunet/src/testbed/test_testbed_api_controllerlink.c 2012-08-24
17:52:55 UTC (rev 23415)
@@ -88,6 +88,26 @@
SLAVE2_PEER_CREATE_SUCCESS,
/**
+ * Peer startup on slave 1 successful
+ */
+ SLAVE1_PEER_START_SUCCESS,
+
+ /**
+ * Peer on slave 1 successfully stopped
+ */
+ SLAVE1_PEER_STOP_SUCCESS,
+
+ /**
+ * Peer startup on slave 2 successful
+ */
+ SLAVE2_PEER_START_SUCCESS,
+
+ /**
+ * Peer on slave 2 successfully stopped
+ */
+ SLAVE2_PEER_STOP_SUCCESS,
+
+ /**
* Peer destroy on slave 1 successful
*/
SLAVE1_PEER_DESTROY_SUCCESS,
@@ -200,7 +220,7 @@
* @param tc the task context
*/
static void
-do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
abort_task = GNUNET_SCHEDULER_NO_TASK;
@@ -209,6 +229,31 @@
/**
+ * Task for inserting delay between tests
+ *
+ * @param
+ * @return
+ */
+static void
+delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ switch (result)
+ {
+ case SLAVE1_PEER_START_SUCCESS:
+ op = GNUNET_TESTBED_peer_stop (slave1_peer);
+ GNUNET_assert (NULL != op);
+ break;
+ case SLAVE2_PEER_START_SUCCESS:
+ op = GNUNET_TESTBED_peer_stop (slave2_peer);
+ GNUNET_assert (NULL != op);
+ break;
+ default:
+ GNUNET_assert (0);
+ }
+}
+
+
+/**
* Functions of this signature are called when a peer has been successfully
* created
*
@@ -237,7 +282,7 @@
result = SLAVE2_PEER_CREATE_SUCCESS;
slave2_peer = peer;
GNUNET_TESTBED_operation_done (op);
- op = GNUNET_TESTBED_peer_destroy (slave1_peer);
+ op = GNUNET_TESTBED_peer_start (slave1_peer);
GNUNET_assert (NULL != op);
break;
default:
@@ -297,11 +342,47 @@
GNUNET_assert (NULL != op);
break;
case SLAVE2_PEER_CREATE_SUCCESS:
+ GNUNET_assert (GNUNET_TESTBED_ET_PEER_START == event->type);
+ GNUNET_assert (event->details.peer_start.host == slave);
+ GNUNET_assert (event->details.peer_start.peer == slave1_peer);
+ GNUNET_TESTBED_operation_done (op);
+ result = SLAVE1_PEER_START_SUCCESS;
+ GNUNET_SCHEDULER_add_delayed
+ (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+ &delay_task, NULL);
+ break;
+ case SLAVE1_PEER_START_SUCCESS:
+ GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type);
+ GNUNET_assert (event->details.peer_stop.peer == slave1_peer);
+ GNUNET_TESTBED_operation_done (op);
+ result = SLAVE1_PEER_STOP_SUCCESS;
+ op = GNUNET_TESTBED_peer_start (slave2_peer);
+ GNUNET_assert (NULL != op);
+ break;
+ case SLAVE1_PEER_STOP_SUCCESS:
+ GNUNET_assert (GNUNET_TESTBED_ET_PEER_START == event->type);
+ GNUNET_assert (event->details.peer_start.host == slave2);
+ GNUNET_assert (event->details.peer_start.peer == slave2_peer);
+ GNUNET_TESTBED_operation_done (op);
+ result = SLAVE2_PEER_START_SUCCESS;
+ GNUNET_SCHEDULER_add_delayed
+ (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+ &delay_task, NULL);
+ break;
+ case SLAVE2_PEER_START_SUCCESS:
+ GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type);
+ GNUNET_assert (event->details.peer_stop.peer == slave2_peer);
+ GNUNET_TESTBED_operation_done (op);
+ result = SLAVE2_PEER_STOP_SUCCESS;
+ op = GNUNET_TESTBED_peer_destroy (slave1_peer);
+ GNUNET_assert (NULL != op);
+ break;
+ case SLAVE2_PEER_STOP_SUCCESS:
check_operation_success (event);
GNUNET_TESTBED_operation_done (op);
result = SLAVE1_PEER_DESTROY_SUCCESS;
op = GNUNET_TESTBED_peer_destroy (slave2_peer);
- GNUNET_assert (NULL != slave2_peer);
+ GNUNET_assert (NULL != op);
break;
case SLAVE1_PEER_DESTROY_SUCCESS:
check_operation_success (event);
@@ -438,13 +519,14 @@
GNUNET_assert (GNUNET_SYSERR != ret);
(void) usleep (300);
} while (GNUNET_NO == ret);
+ GNUNET_OS_process_destroy (auxp);
if (0 != code)
{
(void) printf ("Unable to run the test as this system is not configured "
"to use password less SSH logins to localhost.\n"
"Marking test as successful\n");
- return 0;
- }
+ return 0;
+ }
result = INIT;
ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
"test_testbed_api_controllerlink", "nohelp",
options, &run,
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2012-08-24 16:35:57 UTC (rev 23414)
+++ gnunet/src/testbed/testbed_api.c 2012-08-24 17:52:55 UTC (rev 23415)
@@ -370,7 +370,7 @@
GNUNET_free (fo_data);
GNUNET_free (opc);
return GNUNET_YES;
- }
+ }
GNUNET_assert (OP_PEER_CREATE == opc->type);
GNUNET_assert (NULL != opc->data);
data = opc->data;
@@ -415,6 +415,18 @@
LOG_DEBUG ("Operation not found\n");
return GNUNET_YES;
}
+ if (OP_FORWARDED == opc->type)
+ {
+ struct ForwardedOperationData *fo_data;
+
+ fo_data = opc->data;
+ if (NULL != fo_data->cc)
+ fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg);
+ GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc);
+ GNUNET_free (fo_data);
+ GNUNET_free (opc);
+ return GNUNET_YES;
+ }
GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type));
peer = opc->data;
GNUNET_assert (NULL != peer);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23415 - gnunet/src/testbed,
gnunet <=