diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-11 18:44:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-11 18:44:19 +0000 |
commit | 72002c196893a932c5f3bcdde818581a6209d4c9 (patch) | |
tree | 44d32864e4fbcde253a2bb313ac14146857085c6 /src/ats/test_ats_reservation_api.c | |
parent | 7a257361b5e118f33adb182dd1996fccd52ecda8 (diff) | |
download | gnunet-72002c196893a932c5f3bcdde818581a6209d4c9.tar.gz gnunet-72002c196893a932c5f3bcdde818581a6209d4c9.zip |
finish implementing reservation test, and fix bandwidth reservation logic
Diffstat (limited to 'src/ats/test_ats_reservation_api.c')
-rw-r--r-- | src/ats/test_ats_reservation_api.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/src/ats/test_ats_reservation_api.c b/src/ats/test_ats_reservation_api.c index e45ffe2cc..54aa74a59 100644 --- a/src/ats/test_ats_reservation_api.c +++ b/src/ats/test_ats_reservation_api.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file ats/test_ats_reservation_api.c | 21 | * @file ats/test_ats_reservation_api.c |
22 | * @brief test ATS | 22 | * @brief test ATS bandwidth reservation API |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
@@ -28,7 +28,7 @@ | |||
28 | /** | 28 | /** |
29 | * Global timeout for the testcase. | 29 | * Global timeout for the testcase. |
30 | */ | 30 | */ |
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) | 31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Definition of the test as a sequence of commands. | 34 | * Definition of the test as a sequence of commands. |
@@ -63,36 +63,35 @@ static struct Command test_commands[] = { | |||
63 | .add_label = "add-address-0-0" | 63 | .add_label = "add-address-0-0" |
64 | } | 64 | } |
65 | }, | 65 | }, |
66 | /* 3: reserve 32k -- should work */ | 66 | /* 3: sleep 7s, should give us 5s * 64k/s = 320k buffer; |
67 | Note that this depends on MAX_BANDWIDTH_CARRY_S. We | ||
68 | sleep more than 5s to show that only MAX_BANDWIDTH carries. */ | ||
67 | { | 69 | { |
68 | .code = CMD_RESERVE_BANDWIDTH, | 70 | .code = CMD_SLEEP, |
69 | .label = "initial reservation", | 71 | .label = "sleep", |
70 | .details.reserve_bandwidth = { | 72 | .details.sleep.delay = { 7 * 1000LL * 1000LL } |
71 | .pid = 0, | ||
72 | .amount = 32 * 1024, | ||
73 | .expected_result = GNUNET_OK | ||
74 | } | ||
75 | }, | 73 | }, |
76 | /* 4: reserve another 32k -- might work */ | 74 | /* 4: reserve 128k -- should work (5s carry, so we had 320k) */ |
77 | { | 75 | { |
78 | .code = CMD_RESERVE_BANDWIDTH, | 76 | .code = CMD_RESERVE_BANDWIDTH, |
79 | .details.reserve_bandwidth = { | 77 | .details.reserve_bandwidth = { |
80 | .pid = 0, | 78 | .pid = 0, |
81 | .amount = 32 * 1024, | 79 | .amount = 128 * 1024, |
82 | .expected_result = GNUNET_NO | 80 | .expected_result = GNUNET_YES |
83 | } | 81 | } |
84 | }, | 82 | }, |
85 | /* 5: reserve another 128k -- might work */ | 83 | /* 5: reserve another 192k -- should just work (now exactly pushing the limit) */ |
86 | { | 84 | { |
87 | .code = CMD_RESERVE_BANDWIDTH, | 85 | .code = CMD_RESERVE_BANDWIDTH, |
88 | .label = "big reservation", | 86 | .label = "big reservation", |
89 | .details.reserve_bandwidth = { | 87 | .details.reserve_bandwidth = { |
90 | .pid = 0, | 88 | .pid = 0, |
91 | .amount = 128 * 1024, | 89 | .amount = 192 * 1024, |
92 | .expected_result = GNUNET_NO | 90 | .expected_result = GNUNET_YES |
93 | } | 91 | } |
94 | }, | 92 | }, |
95 | /* 6: reserve another 32k -- should now fail */ | 93 | /* 6: reserve another 32k -- should now fail (if MAX_BANDWIDTH_CARRY_S |
94 | is precisely observed) */ | ||
96 | { | 95 | { |
97 | .code = CMD_RESERVE_BANDWIDTH, | 96 | .code = CMD_RESERVE_BANDWIDTH, |
98 | .label = "failing reservation", | 97 | .label = "failing reservation", |
@@ -102,21 +101,37 @@ static struct Command test_commands[] = { | |||
102 | .expected_result = GNUNET_SYSERR | 101 | .expected_result = GNUNET_SYSERR |
103 | } | 102 | } |
104 | }, | 103 | }, |
105 | /* 7: remove address */ | 104 | /* 7: sleep 3s, should give us 3s * 64k/s - 32k = 160k buffer */ |
105 | { | ||
106 | .code = CMD_SLEEP, | ||
107 | .label = "sleep", | ||
108 | .details.sleep.delay = { 6 * 1000LL * 1000LL } | ||
109 | }, | ||
110 | /* 8: reserve another 160k -- should now work */ | ||
111 | { | ||
112 | .code = CMD_RESERVE_BANDWIDTH, | ||
113 | .label = "successful final reservation", | ||
114 | .details.reserve_bandwidth = { | ||
115 | .pid = 0, | ||
116 | .amount = 160 * 1024, | ||
117 | .expected_result = GNUNET_YES | ||
118 | } | ||
119 | }, | ||
120 | /* 9: remove address */ | ||
106 | { | 121 | { |
107 | .code = CMD_DEL_ADDRESS, | 122 | .code = CMD_DEL_ADDRESS, |
108 | .details.del_address = { | 123 | .details.del_address = { |
109 | .add_label = "add-address-0-0" | 124 | .add_label = "add-address-0-0" |
110 | } | 125 | } |
111 | }, | 126 | }, |
112 | /* 8: check we got disconnected */ | 127 | /* 10: check we got disconnected */ |
113 | { | 128 | { |
114 | .code = CMD_AWAIT_DISCONNECT_SUGGESTION, | 129 | .code = CMD_AWAIT_DISCONNECT_SUGGESTION, |
115 | .details.await_disconnect_suggestion = { | 130 | .details.await_disconnect_suggestion = { |
116 | .pid = 0 | 131 | .pid = 0 |
117 | } | 132 | } |
118 | }, | 133 | }, |
119 | /* 9: just for symmetry, also stop asking for the connection */ | 134 | /* 11: just for symmetry, also stop asking for the connection */ |
120 | { | 135 | { |
121 | .code = CMD_REQUEST_CONNECTION_STOP, | 136 | .code = CMD_REQUEST_CONNECTION_STOP, |
122 | .details.request_connection_stop = { | 137 | .details.request_connection_stop = { |