2 This file is part of GNUnet.
3 Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file ats/test_ats_reservation_api.c
22 * @brief test ATS bandwidth reservation API
23 * @author Christian Grothoff
26 #include "test_ats_lib.h"
29 * Global timeout for the testcase.
31 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
34 * Definition of the test as a sequence of commands.
36 static struct Command test_commands[] = {
37 /* 0: add initial address */
39 .code = CMD_ADD_ADDRESS,
40 .label = "add-address-0-0",
41 .details.add_address = {
46 /* use network with 65k quota! */
47 .scope = GNUNET_ATS_NET_WAN
51 /* 1: some solver still require explicit start */
53 .code = CMD_REQUEST_CONNECTION_START,
55 .details.request_connection_start = {
59 /* 2: check we got an address */
61 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
62 .details.await_address_suggestion = {
63 .add_label = "add-address-0-0"
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. */
72 .details.sleep.delay = { 7 * 1000LL * 1000LL }
74 /* 4: reserve 128k -- should work (5s carry, so we had 320k) */
76 .code = CMD_RESERVE_BANDWIDTH,
77 .details.reserve_bandwidth = {
80 .expected_result = GNUNET_YES
83 /* 5: reserve another 192k -- should just work (now exactly pushing the limit) */
85 .code = CMD_RESERVE_BANDWIDTH,
86 .label = "big reservation",
87 .details.reserve_bandwidth = {
90 .expected_result = GNUNET_YES
93 /* 6: reserve another 32k -- should now fail (if MAX_BANDWIDTH_CARRY_S
94 is precisely observed) */
96 .code = CMD_RESERVE_BANDWIDTH,
97 .label = "failing reservation",
98 .details.reserve_bandwidth = {
101 .expected_result = GNUNET_SYSERR
104 /* 7: sleep 3s, should give us 3s * 64k/s - 32k = 160k buffer */
108 .details.sleep.delay = { 6 * 1000LL * 1000LL }
110 /* 8: reserve another 160k -- should now work */
112 .code = CMD_RESERVE_BANDWIDTH,
113 .label = "successful final reservation",
114 .details.reserve_bandwidth = {
116 .amount = 160 * 1024,
117 .expected_result = GNUNET_YES
120 /* 9: remove address */
122 .code = CMD_DEL_ADDRESS,
123 .details.del_address = {
124 .add_label = "add-address-0-0"
127 /* 10: check we got disconnected */
129 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
130 .details.await_disconnect_suggestion = {
134 /* 11: just for symmetry, also stop asking for the connection */
136 .code = CMD_REQUEST_CONNECTION_STOP,
137 .details.request_connection_stop = {
138 .connect_label = "request-0",
141 /* Test ends successfully */
152 return TEST_ATS_run (argc,
159 /* end of file test_ats_reservation_api.c */