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 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.
16 * @file ats/test_ats_reservation_api.c
17 * @brief test ATS bandwidth reservation API
18 * @author Christian Grothoff
21 #include "test_ats_lib.h"
24 * Global timeout for the testcase.
26 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
29 * Definition of the test as a sequence of commands.
31 static struct Command test_commands[] = {
32 /* 0: add initial address */
34 .code = CMD_ADD_ADDRESS,
35 .label = "add-address-0-0",
36 .details.add_address = {
41 /* use network with 65k quota! */
42 .scope = GNUNET_ATS_NET_WAN
46 /* 1: some solver still require explicit start */
48 .code = CMD_REQUEST_CONNECTION_START,
50 .details.request_connection_start = {
54 /* 2: check we got an address */
56 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
57 .details.await_address_suggestion = {
58 .add_label = "add-address-0-0"
61 /* 3: sleep 7s, should give us 5s * 64k/s = 320k buffer;
62 Note that this depends on MAX_BANDWIDTH_CARRY_S. We
63 sleep more than 5s to show that only MAX_BANDWIDTH carries. */
67 .details.sleep.delay = { 7 * 1000LL * 1000LL }
69 /* 4: reserve 128k -- should work (5s carry, so we had 320k) */
71 .code = CMD_RESERVE_BANDWIDTH,
72 .details.reserve_bandwidth = {
75 .expected_result = GNUNET_YES
78 /* 5: reserve another 192k -- should just work (now exactly pushing the limit) */
80 .code = CMD_RESERVE_BANDWIDTH,
81 .label = "big reservation",
82 .details.reserve_bandwidth = {
85 .expected_result = GNUNET_YES
88 /* 6: reserve another 32k -- should now fail (if MAX_BANDWIDTH_CARRY_S
89 is precisely observed) */
91 .code = CMD_RESERVE_BANDWIDTH,
92 .label = "failing reservation",
93 .details.reserve_bandwidth = {
96 .expected_result = GNUNET_SYSERR
99 /* 7: sleep 3s, should give us 3s * 64k/s - 32k = 160k buffer */
103 .details.sleep.delay = { 6 * 1000LL * 1000LL }
105 /* 8: reserve another 160k -- should now work */
107 .code = CMD_RESERVE_BANDWIDTH,
108 .label = "successful final reservation",
109 .details.reserve_bandwidth = {
111 .amount = 160 * 1024,
112 .expected_result = GNUNET_YES
115 /* 9: remove address */
117 .code = CMD_DEL_ADDRESS,
118 .details.del_address = {
119 .add_label = "add-address-0-0"
122 /* 10: check we got disconnected */
124 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
125 .details.await_disconnect_suggestion = {
129 /* 11: just for symmetry, also stop asking for the connection */
131 .code = CMD_REQUEST_CONNECTION_STOP,
132 .details.request_connection_stop = {
133 .connect_label = "request-0",
136 /* Test ends successfully */
147 return TEST_ATS_run (argc,
154 /* end of file test_ats_reservation_api.c */