2 This file is part of GNUnet.
3 Copyright (C) 2010-2015 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @file ats/test_ats_reservation_api.c
20 * @brief test ATS bandwidth reservation API
21 * @author Christian Grothoff
24 #include "test_ats_lib.h"
27 * Global timeout for the testcase.
29 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
32 * Definition of the test as a sequence of commands.
34 static struct Command test_commands[] = {
35 /* 0: add initial address */
37 .code = CMD_ADD_ADDRESS,
38 .label = "add-address-0-0",
39 .details.add_address = {
44 /* use network with 65k quota! */
45 .scope = GNUNET_ATS_NET_WAN
49 /* 1: some solver still require explicit start */
51 .code = CMD_REQUEST_CONNECTION_START,
53 .details.request_connection_start = {
57 /* 2: check we got an address */
59 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
60 .details.await_address_suggestion = {
61 .add_label = "add-address-0-0"
64 /* 3: sleep 7s, should give us 5s * 64k/s = 320k buffer;
65 Note that this depends on MAX_BANDWIDTH_CARRY_S. We
66 sleep more than 5s to show that only MAX_BANDWIDTH carries. */
70 .details.sleep.delay = { 7 * 1000LL * 1000LL }
72 /* 4: reserve 128k -- should work (5s carry, so we had 320k) */
74 .code = CMD_RESERVE_BANDWIDTH,
75 .details.reserve_bandwidth = {
78 .expected_result = GNUNET_YES
81 /* 5: reserve another 192k -- should just work (now exactly pushing the limit) */
83 .code = CMD_RESERVE_BANDWIDTH,
84 .label = "big reservation",
85 .details.reserve_bandwidth = {
88 .expected_result = GNUNET_YES
91 /* 6: reserve another 32k -- should now fail (if MAX_BANDWIDTH_CARRY_S
92 is precisely observed) */
94 .code = CMD_RESERVE_BANDWIDTH,
95 .label = "failing reservation",
96 .details.reserve_bandwidth = {
99 .expected_result = GNUNET_SYSERR
102 /* 7: sleep 3s, should give us 3s * 64k/s - 32k = 160k buffer */
106 .details.sleep.delay = { 6 * 1000LL * 1000LL }
108 /* 8: reserve another 160k -- should now work */
110 .code = CMD_RESERVE_BANDWIDTH,
111 .label = "successful final reservation",
112 .details.reserve_bandwidth = {
114 .amount = 160 * 1024,
115 .expected_result = GNUNET_YES
118 /* 9: remove address */
120 .code = CMD_DEL_ADDRESS,
121 .details.del_address = {
122 .add_label = "add-address-0-0"
125 /* 10: check we got disconnected */
127 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
128 .details.await_disconnect_suggestion = {
132 /* 11: just for symmetry, also stop asking for the connection */
134 .code = CMD_REQUEST_CONNECTION_STOP,
135 .details.request_connection_stop = {
136 .connect_label = "request-0",
139 /* Test ends successfully */
150 return TEST_ATS_run (argc,
157 /* end of file test_ats_reservation_api.c */