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