gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35231 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r35231 - gnunet/src/ats
Date: Wed, 11 Feb 2015 19:44:19 +0100

Author: grothoff
Date: 2015-02-11 19:44:19 +0100 (Wed, 11 Feb 2015)
New Revision: 35231

Modified:
   gnunet/src/ats/gnunet-service-ats_plugins.c
   gnunet/src/ats/gnunet-service-ats_reservations.c
   gnunet/src/ats/test_ats_lib.c
   gnunet/src/ats/test_ats_lib.h
   gnunet/src/ats/test_ats_reservation_api.c
Log:
finish implementing reservation test, and fix bandwidth reservation logic

Modified: gnunet/src/ats/gnunet-service-ats_plugins.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-11 18:29:54 UTC (rev 
35230)
+++ gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-11 18:44:19 UTC (rev 
35231)
@@ -30,6 +30,7 @@
 #include "gnunet-service-ats_performance.h"
 #include "gnunet-service-ats_preferences.h"
 #include "gnunet-service-ats_plugins.h"
+#include "gnunet-service-ats_reservations.h"
 #include "gnunet-service-ats_scheduling.h"
 #include "gnunet-service-ats_normalization.h"
 
@@ -207,7 +208,8 @@
               GNUNET_i2s (&address->peer),
               (unsigned int) address->assigned_bw_in,
               (unsigned int) address->assigned_bw_out);
-
+  GAS_reservations_set_bandwidth (&address->peer,
+                                  GNUNET_BANDWIDTH_value_init 
(address->assigned_bw_in));
   /* Notify performance clients about changes to address */
   GAS_performance_notify_all_clients (&address->peer,
                                      address->plugin,

Modified: gnunet/src/ats/gnunet-service-ats_reservations.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_reservations.c    2015-02-11 18:29:54 UTC 
(rev 35230)
+++ gnunet/src/ats/gnunet-service-ats_reservations.c    2015-02-11 18:44:19 UTC 
(rev 35231)
@@ -29,7 +29,8 @@
 
 /**
  * Number of seconds that available bandwidth carries over
- * (can accumulate).
+ * (can accumulate).  Note that the
+ * test_ats_reservation_api test depends on this value!
  */
 #define MAX_BANDWIDTH_CARRY_S 5
 
@@ -117,7 +118,10 @@
   if (NULL == tracker)
   {
     tracker = GNUNET_new (struct GNUNET_BANDWIDTH_Tracker);
-    GNUNET_BANDWIDTH_tracker_init (tracker, NULL, NULL, bandwidth_in,
+    GNUNET_BANDWIDTH_tracker_init (tracker,
+                                   NULL,
+                                   NULL,
+                                   bandwidth_in,
                                    MAX_BANDWIDTH_CARRY_S);
     GNUNET_assert (GNUNET_OK ==
                    GNUNET_CONTAINER_multipeermap_put (trackers,

Modified: gnunet/src/ats/test_ats_lib.c
===================================================================
--- gnunet/src/ats/test_ats_lib.c       2015-02-11 18:29:54 UTC (rev 35230)
+++ gnunet/src/ats/test_ats_lib.c       2015-02-11 18:44:19 UTC (rev 35231)
@@ -567,7 +567,7 @@
                    (0 != res_delay.rel_value_us) );
     break;
   case GNUNET_SYSERR:
-    if ( (amount != cmd->details.reserve_bandwidth.amount) ||
+    if ( (amount != 0) ||
          (0 == res_delay.rel_value_us) )
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -858,6 +858,12 @@
                                           cmd);
         return;
       }
+    case CMD_SLEEP:
+      off++;
+      interpreter_task = GNUNET_SCHEDULER_add_delayed 
(cmd->details.sleep.delay,
+                                                       &interpreter,
+                                                       NULL);
+      return;
     } /* end switch */
   } /* end while(1) */
 }

Modified: gnunet/src/ats/test_ats_lib.h
===================================================================
--- gnunet/src/ats/test_ats_lib.h       2015-02-11 18:29:54 UTC (rev 35230)
+++ gnunet/src/ats/test_ats_lib.h       2015-02-11 18:44:19 UTC (rev 35231)
@@ -117,8 +117,13 @@
    * Reserve bandwidth, testing
    * #GNUNET_ATS_reserve_bandwidth().
    */
-  CMD_RESERVE_BANDWIDTH
+  CMD_RESERVE_BANDWIDTH,
 
+  /**
+   * Wait for a bit.
+   */
+  CMD_SLEEP
+
 };
 
 
@@ -435,6 +440,18 @@
 
 
 /**
+ * Details for the #CMD_SLEEP command.
+ */
+struct CommandSleep
+{
+  /**
+   * How long should we wait before running the next command?
+   */
+  struct GNUNET_TIME_Relative delay;
+};
+
+
+/**
  * A command for the test case interpreter.
  */
 struct Command
@@ -482,6 +499,8 @@
 
     struct CommandReserveBandwidth reserve_bandwidth;
 
+    struct CommandSleep sleep;
+
   } details;
 
 };

Modified: gnunet/src/ats/test_ats_reservation_api.c
===================================================================
--- gnunet/src/ats/test_ats_reservation_api.c   2015-02-11 18:29:54 UTC (rev 
35230)
+++ gnunet/src/ats/test_ats_reservation_api.c   2015-02-11 18:44:19 UTC (rev 
35231)
@@ -19,7 +19,7 @@
 */
 /**
  * @file ats/test_ats_reservation_api.c
- * @brief test ATS
+ * @brief test ATS bandwidth reservation API
  * @author Christian Grothoff
  */
 #include "platform.h"
@@ -28,7 +28,7 @@
 /**
  * Global timeout for the testcase.
  */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
 
 /**
  * Definition of the test as a sequence of commands.
@@ -63,36 +63,35 @@
       .add_label = "add-address-0-0"
     }
   },
-  /* 3: reserve 32k -- should work */
+  /* 3: sleep 7s, should give us 5s * 64k/s = 320k buffer;
+     Note that this depends on MAX_BANDWIDTH_CARRY_S.  We
+     sleep more than 5s to show that only MAX_BANDWIDTH carries. */
   {
-    .code = CMD_RESERVE_BANDWIDTH,
-    .label = "initial reservation",
-    .details.reserve_bandwidth = {
-      .pid = 0,
-      .amount = 32 * 1024,
-      .expected_result = GNUNET_OK
-    }
+    .code = CMD_SLEEP,
+    .label = "sleep",
+    .details.sleep.delay = { 7 * 1000LL * 1000LL }
   },
-  /* 4: reserve another 32k -- might work */
+  /* 4: reserve 128k -- should work (5s carry, so we had 320k) */
   {
     .code = CMD_RESERVE_BANDWIDTH,
     .details.reserve_bandwidth = {
       .pid = 0,
-      .amount = 32 * 1024,
-      .expected_result = GNUNET_NO
+      .amount = 128 * 1024,
+      .expected_result = GNUNET_YES
     }
   },
-  /* 5: reserve another 128k -- might work */
+  /* 5: reserve another 192k -- should just work (now exactly pushing the 
limit) */
   {
     .code = CMD_RESERVE_BANDWIDTH,
     .label = "big reservation",
     .details.reserve_bandwidth = {
       .pid = 0,
-      .amount = 128 * 1024,
-      .expected_result = GNUNET_NO
+      .amount = 192 * 1024,
+      .expected_result = GNUNET_YES
     }
   },
-  /* 6: reserve another 32k -- should now fail */
+  /* 6: reserve another 32k -- should now fail (if MAX_BANDWIDTH_CARRY_S
+     is precisely observed) */
   {
     .code = CMD_RESERVE_BANDWIDTH,
     .label = "failing reservation",
@@ -102,21 +101,37 @@
       .expected_result = GNUNET_SYSERR
     }
   },
-  /* 7: remove address */
+  /* 7: sleep 3s, should give us 3s * 64k/s - 32k = 160k buffer */
   {
+    .code = CMD_SLEEP,
+    .label = "sleep",
+    .details.sleep.delay = { 6 * 1000LL * 1000LL }
+  },
+  /* 8: reserve another 160k -- should now work */
+  {
+    .code = CMD_RESERVE_BANDWIDTH,
+    .label = "successful final reservation",
+    .details.reserve_bandwidth = {
+      .pid = 0,
+      .amount = 160 * 1024,
+      .expected_result = GNUNET_YES
+    }
+  },
+  /* 9: remove address */
+  {
     .code = CMD_DEL_ADDRESS,
     .details.del_address = {
       .add_label = "add-address-0-0"
     }
   },
-  /* 8: check we got disconnected */
+  /* 10: check we got disconnected */
   {
     .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
     .details.await_disconnect_suggestion = {
       .pid = 0
     }
   },
-  /* 9: just for symmetry, also stop asking for the connection */
+  /* 11: just for symmetry, also stop asking for the connection */
   {
     .code = CMD_REQUEST_CONNECTION_STOP,
     .details.request_connection_stop = {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]