Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 49f3a5f | 2017-09-23 01:36:33 -0400 | [diff] [blame] | 2 | /* |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 3 | * Copyright (c) 2014-2022, Regents of the University of California. |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of NDN repo-ng (Next generation of NDN repository). |
| 6 | * See AUTHORS.md for complete list of repo-ng authors and contributors. |
| 7 | * |
| 8 | * repo-ng is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 20 | #include "handles/delete-handle.hpp" |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 21 | #include "handles/write-handle.hpp" |
| 22 | |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame] | 23 | #include "storage/repo-storage.hpp" |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 24 | #include "storage/sqlite-storage.hpp" |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 25 | |
Junxiao Shi | 047a6fb | 2017-06-08 16:16:05 +0000 | [diff] [blame] | 26 | #include "command-fixture.hpp" |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame] | 27 | #include "../repo-storage-fixture.hpp" |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 28 | #include "../dataset-fixtures.hpp" |
| 29 | |
Davide Pesavento | 75e8d46 | 2021-05-16 17:00:42 -0400 | [diff] [blame] | 30 | #include <ndn-cxx/security/interest-signer.hpp> |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 31 | #include <ndn-cxx/security/signing-helpers.hpp> |
Shuo Chen | 028dcd3 | 2014-06-21 16:36:44 +0800 | [diff] [blame] | 32 | #include <ndn-cxx/util/random.hpp> |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 33 | #include <ndn-cxx/util/time.hpp> |
Davide Pesavento | 49f3a5f | 2017-09-23 01:36:33 -0400 | [diff] [blame] | 34 | |
| 35 | #include <boost/mpl/vector.hpp> |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 36 | #include <boost/test/unit_test.hpp> |
| 37 | |
| 38 | namespace repo { |
| 39 | namespace tests { |
| 40 | |
| 41 | using ndn::time::milliseconds; |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 42 | |
Davide Pesavento | 49f3a5f | 2017-09-23 01:36:33 -0400 | [diff] [blame] | 43 | // All the test cases in this test suite should be run at once. |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 44 | BOOST_AUTO_TEST_SUITE(TestBasicCommandInsertDelete) |
| 45 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 46 | const uint8_t CONTENT[] = {3, 1, 4, 1, 5, 9, 2, 6}; |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 47 | |
| 48 | template<class Dataset> |
Junxiao Shi | 047a6fb | 2017-06-08 16:16:05 +0000 | [diff] [blame] | 49 | class Fixture : public CommandFixture, public RepoStorageFixture, public Dataset |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 50 | { |
| 51 | public: |
| 52 | Fixture() |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 53 | : writeHandle(repoFace, *handle, dispatcher, scheduler, validator) |
| 54 | , deleteHandle(repoFace, *handle, dispatcher, scheduler, validator) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 55 | , insertFace(repoFace.getIoService()) |
| 56 | , deleteFace(repoFace.getIoService()) |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 57 | , signer(keyChain) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 58 | { |
Junxiao Shi | 2b7b831 | 2017-06-16 03:43:24 +0000 | [diff] [blame] | 59 | Name cmdPrefix("/repo/command"); |
| 60 | repoFace.registerPrefix(cmdPrefix, nullptr, |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 61 | [] (const Name&, const std::string& reason) { |
Junxiao Shi | 2b7b831 | 2017-06-16 03:43:24 +0000 | [diff] [blame] | 62 | BOOST_FAIL("Command prefix registration error: " << reason); |
| 63 | }); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Shuo Chen | 028dcd3 | 2014-06-21 16:36:44 +0800 | [diff] [blame] | 66 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 67 | scheduleInsertEvent(); |
| 68 | |
| 69 | void |
| 70 | scheduleDeleteEvent(); |
| 71 | |
| 72 | void |
| 73 | onInsertInterest(const Interest& interest); |
| 74 | |
| 75 | void |
| 76 | onRegisterFailed(const std::string& reason); |
| 77 | |
| 78 | void |
| 79 | delayedInterest(); |
| 80 | |
| 81 | void |
Alexander Afanasyev | 42290b2 | 2017-03-09 12:58:29 -0800 | [diff] [blame] | 82 | onInsertData(const Interest& interest, const Data& data); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 83 | |
| 84 | void |
Alexander Afanasyev | 42290b2 | 2017-03-09 12:58:29 -0800 | [diff] [blame] | 85 | onDeleteData(const Interest& interest, const Data& data); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 86 | |
| 87 | void |
| 88 | onInsertTimeout(const Interest& interest); |
| 89 | |
| 90 | void |
| 91 | onDeleteTimeout(const Interest& interest); |
| 92 | |
| 93 | void |
| 94 | sendInsertInterest(const Interest& interest); |
| 95 | |
| 96 | void |
| 97 | sendDeleteInterest(const Interest& deleteInterest); |
| 98 | |
| 99 | void |
Shuo Chen | 028dcd3 | 2014-06-21 16:36:44 +0800 | [diff] [blame] | 100 | checkInsertOk(const Interest& interest); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 101 | |
| 102 | void |
Shuo Chen | 028dcd3 | 2014-06-21 16:36:44 +0800 | [diff] [blame] | 103 | checkDeleteOk(const Interest& interest); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 104 | |
| 105 | public: |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 106 | WriteHandle writeHandle; |
| 107 | DeleteHandle deleteHandle; |
| 108 | Face insertFace; |
| 109 | Face deleteFace; |
Davide Pesavento | 9a8d7d8 | 2019-03-15 20:14:25 -0400 | [diff] [blame] | 110 | std::map<Name, ndn::scheduler::EventId> insertEvents; |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 111 | std::map<Name, Name> deleteNamePairs; |
Davide Pesavento | 75e8d46 | 2021-05-16 17:00:42 -0400 | [diff] [blame] | 112 | ndn::security::InterestSigner signer; |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 113 | }; |
| 114 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 115 | template<class T> |
| 116 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 117 | Fixture<T>::onInsertInterest(const Interest& interest) |
| 118 | { |
| 119 | Data data(Name(interest.getName())); |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 120 | data.setContent(CONTENT); |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 121 | data.setFreshnessPeriod(0_ms); |
Junxiao Shi | 047a6fb | 2017-06-08 16:16:05 +0000 | [diff] [blame] | 122 | keyChain.sign(data); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 123 | insertFace.put(data); |
Davide Pesavento | 9a8d7d8 | 2019-03-15 20:14:25 -0400 | [diff] [blame] | 124 | auto eventIt = insertEvents.find(interest.getName()); |
| 125 | if (eventIt != insertEvents.end()) { |
| 126 | eventIt->second.cancel(); |
| 127 | insertEvents.erase(eventIt); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 128 | } |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 129 | |
| 130 | // schedule an event to check whether insert is ok |
| 131 | scheduler.schedule(500_ms, [=] { this->checkInsertOk(interest); }); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 134 | template<class T> |
| 135 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 136 | Fixture<T>::onRegisterFailed(const std::string& reason) |
| 137 | { |
| 138 | BOOST_ERROR("ERROR: Failed to register prefix in local hub's daemon" + reason); |
| 139 | } |
| 140 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 141 | template<class T> |
| 142 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 143 | Fixture<T>::delayedInterest() |
| 144 | { |
| 145 | BOOST_ERROR("Fetching interest does not come. It may be satisfied in CS or something is wrong"); |
| 146 | } |
| 147 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 148 | template<class T> |
| 149 | void |
| 150 | Fixture<T>::onInsertData(const Interest&, const Data& data) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 151 | { |
| 152 | RepoCommandResponse response; |
| 153 | response.wireDecode(data.getContent().blockFromValue()); |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 154 | BOOST_CHECK_EQUAL(response.getCode(), 100); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 157 | template<class T> |
| 158 | void |
Alexander Afanasyev | 42290b2 | 2017-03-09 12:58:29 -0800 | [diff] [blame] | 159 | Fixture<T>::onDeleteData(const Interest& interest, const Data& data) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 160 | { |
| 161 | RepoCommandResponse response; |
| 162 | response.wireDecode(data.getContent().blockFromValue()); |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 163 | BOOST_CHECK_EQUAL(response.getCode(), 200); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 164 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 165 | // schedule an event to check whether delete is ok |
| 166 | scheduler.schedule(100_ms, [=] { this->checkDeleteOk(interest); }); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 169 | template<class T> |
| 170 | void |
| 171 | Fixture<T>::onInsertTimeout(const Interest&) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 172 | { |
Junxiao Shi | 2b7b831 | 2017-06-16 03:43:24 +0000 | [diff] [blame] | 173 | BOOST_ERROR("Insert command timeout"); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 176 | template<class T> |
| 177 | void |
| 178 | Fixture<T>::onDeleteTimeout(const Interest&) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 179 | { |
Junxiao Shi | 2b7b831 | 2017-06-16 03:43:24 +0000 | [diff] [blame] | 180 | BOOST_ERROR("Delete command timeout"); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 183 | template<class T> |
| 184 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 185 | Fixture<T>::sendInsertInterest(const Interest& insertInterest) |
| 186 | { |
| 187 | insertFace.expressInterest(insertInterest, |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 188 | std::bind(&Fixture<T>::onInsertData, this, _1, _2), |
| 189 | std::bind(&Fixture<T>::onInsertTimeout, this, _1), // Nack |
| 190 | std::bind(&Fixture<T>::onInsertTimeout, this, _1)); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 193 | template<class T> |
| 194 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 195 | Fixture<T>::sendDeleteInterest(const Interest& deleteInterest) |
| 196 | { |
| 197 | deleteFace.expressInterest(deleteInterest, |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 198 | std::bind(&Fixture<T>::onDeleteData, this, _1, _2), |
| 199 | std::bind(&Fixture<T>::onDeleteTimeout, this, _1), // Nack |
| 200 | std::bind(&Fixture<T>::onDeleteTimeout, this, _1)); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 203 | template<class T> |
| 204 | void |
Shuo Chen | 028dcd3 | 2014-06-21 16:36:44 +0800 | [diff] [blame] | 205 | Fixture<T>::checkInsertOk(const Interest& interest) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 206 | { |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 207 | BOOST_TEST_CONTEXT("Interest " << interest) { |
| 208 | auto data = handle->readData(interest); |
| 209 | if (data) { |
| 210 | BOOST_TEST(data->getContent().value_bytes() == CONTENT, boost::test_tools::per_element()); |
| 211 | } |
| 212 | else { |
| 213 | BOOST_ERROR("Insert check failed"); |
| 214 | } |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame] | 215 | } |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 218 | template<class T> |
| 219 | void |
Shuo Chen | 028dcd3 | 2014-06-21 16:36:44 +0800 | [diff] [blame] | 220 | Fixture<T>::checkDeleteOk(const Interest& interest) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 221 | { |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 222 | auto nameIt = deleteNamePairs.find(interest.getName()); |
| 223 | BOOST_CHECK_MESSAGE(nameIt != deleteNamePairs.end(), "Delete name not found: " << interest.getName()); |
| 224 | Interest dataInterest(nameIt->second); |
| 225 | auto data = handle->readData(dataInterest); |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 226 | BOOST_CHECK(!data); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 229 | template<class T> |
| 230 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 231 | Fixture<T>::scheduleInsertEvent() |
| 232 | { |
| 233 | int timeCount = 1; |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 234 | for (auto i = this->data.begin(); i != this->data.end(); ++i) { |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 235 | Name insertCommandName("/repo/command/insert"); |
| 236 | RepoCommandParameter insertParameter; |
| 237 | insertParameter.setName(Name((*i)->getName()) |
Davide Pesavento | 49f3a5f | 2017-09-23 01:36:33 -0400 | [diff] [blame] | 238 | .appendNumber(ndn::random::generateWord64())); |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 239 | insertCommandName.append(tlv::GenericNameComponent, insertParameter.wireEncode()); |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 240 | Interest insertInterest = signer.makeCommandInterest(insertCommandName); |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 241 | // schedule a job to express insertInterest every 50ms |
Davide Pesavento | 8891c83 | 2019-03-20 23:20:35 -0400 | [diff] [blame] | 242 | scheduler.schedule(milliseconds(timeCount * 50 + 1000), |
| 243 | std::bind(&Fixture<T>::sendInsertInterest, this, insertInterest)); |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 244 | // schedule what to do when interest timeout |
Davide Pesavento | 8891c83 | 2019-03-20 23:20:35 -0400 | [diff] [blame] | 245 | auto delayEventId = scheduler.schedule(milliseconds(5000 + timeCount * 50), |
| 246 | std::bind(&Fixture<T>::delayedInterest, this)); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 247 | insertEvents[insertParameter.getName()] = delayEventId; |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 248 | // The delayEvent will be canceled in onInsertInterest |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 249 | insertFace.setInterestFilter(insertParameter.getName(), |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 250 | std::bind(&Fixture<T>::onInsertInterest, this, _2), |
Wentao Shang | 91fb4f2 | 2014-05-20 10:55:22 -0700 | [diff] [blame] | 251 | ndn::RegisterPrefixSuccessCallback(), |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 252 | std::bind(&Fixture<T>::onRegisterFailed, this, _2)); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 253 | timeCount++; |
| 254 | } |
| 255 | } |
| 256 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 257 | template<class T> |
| 258 | void |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 259 | Fixture<T>::scheduleDeleteEvent() |
| 260 | { |
| 261 | int timeCount = 1; |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 262 | for (auto i = this->data.begin(); i != this->data.end(); ++i) { |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 263 | Name deleteCommandName("/repo/command/delete"); |
| 264 | RepoCommandParameter deleteParameter; |
Davide Pesavento | 49f3a5f | 2017-09-23 01:36:33 -0400 | [diff] [blame] | 265 | deleteParameter.setProcessId(ndn::random::generateWord64()); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 266 | deleteParameter.setName((*i)->getName()); |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 267 | deleteCommandName.append(tlv::GenericNameComponent, deleteParameter.wireEncode()); |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 268 | Interest deleteInterest = signer.makeCommandInterest(deleteCommandName); |
| 269 | deleteNamePairs[deleteInterest.getName()] = (*i)->getName(); |
Davide Pesavento | 8891c83 | 2019-03-20 23:20:35 -0400 | [diff] [blame] | 270 | scheduler.schedule(milliseconds(4000 + timeCount * 50), |
| 271 | std::bind(&Fixture<T>::sendDeleteInterest, this, deleteInterest)); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 272 | timeCount++; |
| 273 | } |
| 274 | } |
| 275 | |
weijia yuan | 3aa8d2b | 2018-03-06 15:35:57 -0800 | [diff] [blame] | 276 | using Datasets = boost::mpl::vector<BasicDataset, |
| 277 | FetchByPrefixDataset, |
| 278 | SamePrefixDataset<10>>; |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 279 | |
| 280 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(InsertDelete, T, Datasets, Fixture<T>) |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 281 | { |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 282 | // schedule events |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame^] | 283 | this->scheduler.schedule(0_s, [this] { this->scheduleInsertEvent(); }); |
| 284 | this->scheduler.schedule(10_s, [this] { this->scheduleDeleteEvent(); }); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 285 | |
weijia yuan | 82cf914 | 2018-10-21 12:25:02 -0700 | [diff] [blame] | 286 | this->repoFace.processEvents(30_s); |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | BOOST_AUTO_TEST_SUITE_END() |
| 290 | |
Alexander Afanasyev | 42290b2 | 2017-03-09 12:58:29 -0800 | [diff] [blame] | 291 | } // namespace tests |
| 292 | } // namespace repo |