DataTransferSessionTest.cpp 59.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/******************************************************************************
 *
 * This file is part of the Castor project.
 * See http://castor.web.cern.ch/castor
 *
 * Copyright (C) 2003  CERN
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * 
 *
 * @author Castor Dev team, castor-dev@cern.ch
 *****************************************************************************/

24
25
26
27
#define __STDC_CONSTANT_MACROS // For using stdint macros (stdint is included
// by inttypes.h, so we shoot first)
#include <stdint.h>
#include <inttypes.h>
28
#include <gtest/gtest.h>
29

30
#include "castor/legacymsg/RmcProxyDummy.hpp"
31
#include "castor/log/StringLogger.hpp"
32
33
34
#include "castor/mediachanger/MediaChangerFacade.hpp"
#include "castor/mediachanger/MmcProxyDummy.hpp"
#include "castor/messages/AcsProxyDummy.hpp"
35
#include "castor/messages/TapeserverProxyDummy.hpp"
36
#include "castor/server/ProcessCapDummy.hpp"
37
#include "castor/server/Threading.hpp"
38
#include "castor/tape/tapeserver/daemon/DataTransferSession.hpp"
39
#include "castor/tape/tapeserver/daemon/VolumeInfo.hpp"
40
41
#include "castor/tape/tapeserver/system/Wrapper.hpp"
#include "castor/tape/tapeserver/file/File.hpp"
42
#include "castor/tape/tapeserver/drive/FakeDrive.hpp"
43
#include "common/exception/Exception.hpp"
44
#include "common/make_unique.hpp"
45
#include "common/utils/utils.hpp"
46
#include "scheduler/Scheduler.hpp"
47
48
//#include "smc_struct.h"
#include "catalogue/InMemoryCatalogue.hpp"
49
#include "remotens/MockRemoteNS.hpp"
50
#include "remotens/MockRemoteFullFS.hpp"
51
//#include "scheduler/DummyScheduler.hpp"
52
#include "scheduler/OStoreDB/OStoreDBFactory.hpp"
53
#include "scheduler/MountType.hpp"
54
//#include "nameserver/NameServer.hpp"
55
56
57
#include "scheduler/testingMocks/MockRetrieveMount.hpp"
#include "scheduler/testingMocks/MockArchiveJob.hpp"
#include "scheduler/testingMocks/MockArchiveMount.hpp"
58

59
#include <dirent.h>
60
#include <fcntl.h>
61
#include <stdexcept>
Eric Cano's avatar
Eric Cano committed
62
63
64
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
65
66
#include <unistd.h>
#include <zlib.h>
Eric Cano's avatar
Eric Cano committed
67

68
using namespace castor::tape::tapeserver;
69
using namespace castor::tape::tapeserver::daemon;
70

Eric Cano's avatar
Eric Cano committed
71
namespace unitTests {
72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
namespace {

/**
 * This structure is used to parameterize scheduler tests.
 */
struct DataTransferSessionTestParam {
  cta::SchedulerDatabaseFactory &dbFactory;

  DataTransferSessionTestParam(
    cta::SchedulerDatabaseFactory &dbFactory):
    dbFactory(dbFactory) {
 }
}; // struct DataTransferSessionTest

}

/**
 * The data transfer test is a parameterized test.  It takes a pair of name server
 * and scheduler database factories as a parameter.
 */
class DataTransferSessionTest: public ::testing::TestWithParam<DataTransferSessionTestParam> {
public:
  
  DataTransferSessionTest() { }
97

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

  class FailedToGetCatalogue: public std::exception {
  public:
    const char *what() const throw() {
      return "Failed to get catalogue";
    }
  };

  class FailedToGetScheduler: public std::exception {
  public:
    const char *what() const throw() {
      return "Failed to get scheduler";
    }
  };

    virtual void SetUp() {
    using namespace cta;

    const DataTransferSessionTestParam &param = GetParam();
    m_db = param.dbFactory.create();
118
119
120
121
    const uint64_t nbConns = 1;
    //m_catalogue = make_unique<catalogue::SchemaCreatingSqliteCatalogue>(m_tempSqliteFile.path(), nbConns);
    m_catalogue = make_unique<catalogue::InMemoryCatalogue>(nbConns);
    m_scheduler = make_unique<Scheduler>(*m_catalogue, *m_db, 5, 2*1000*1000);
122
    
123
124
    strncpy(m_tmpDir, "/tmp/DataTransferSessionTestXXXXXX", sizeof(m_tmpDir));
    if(!mkdtemp(m_tmpDir)) {
125
      const std::string errMsg = cta::utils::errnoToString(errno);
126
127
128
129
130
131
      std::ostringstream msg;
      msg << "Failed to create directory with template"
        " /tmp/DataTransferSessionTestXXXXXX: " << errMsg;
      bzero(m_tmpDir, sizeof(m_tmpDir));
      throw cta::exception::Exception(msg.str());
    }
132
    
133
134
135
    struct stat statBuf;
    bzero(&statBuf, sizeof(statBuf));
    if(stat(m_tmpDir, &statBuf)) {
136
      const std::string errMsg = cta::utils::errnoToString(errno);
137
138
139
140
141
142
143
144
      std::ostringstream msg;
      msg << "Failed to stat directory " << m_tmpDir << ": " << errMsg;
      throw cta::exception::Exception(msg.str());
    }

    std::ostringstream cmd;
    cmd << "touch " << m_tmpDir << "/hello";
    system(cmd.str().c_str());
145
146
  }

147
148
149
150
151
  virtual void TearDown() {
    m_scheduler.reset();
    m_catalogue.reset();
    m_db.reset();
    
152
153
154
155
156
157
158
    // If Setup() created a temporary directory
    if(m_tmpDir) {

      // Openn the directory
      std::unique_ptr<DIR, std::function<int(DIR*)>>
        dir(opendir(m_tmpDir), closedir);
      if(NULL == dir.get()) {
159
        const std::string errMsg = cta::utils::errnoToString(errno);
160
161
162
163
164
165
166
167
168
169
170
171
        std::ostringstream msg;
        msg << "Failed to open directory " << m_tmpDir << ": " << errMsg;
        throw cta::exception::Exception(msg.str());
      }

      // Delete each of the files within the directory
      struct dirent *entry = NULL;
      while((entry = readdir(dir.get()))) {
        const std::string entryName(entry->d_name);
        if(entryName != "." && entryName != "..") {
          const std::string entryPath = std::string(m_tmpDir) + "/" + entryName;
          if(unlink(entryPath.c_str())) {
172
            const std::string errMsg = cta::utils::errnoToString(errno);
173
174
175
176
177
178
179
180
181
            std::ostringstream msg;
            msg << "Failed to unlink " << entryPath;
            throw cta::exception::Exception(msg.str());
          }
        }
      }

      // Delete the now empty directory
      if(rmdir(m_tmpDir)) {
182
        const std::string errMsg = cta::utils::errnoToString(errno);
183
184
185
186
187
        std::ostringstream msg;
        msg << "Failed to delete directory " << m_tmpDir << ": " << errMsg;
        throw cta::exception::Exception(msg.str());
      }
    }
188
  }
189

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
  cta::catalogue::Catalogue &getCatalogue() {
    cta::catalogue::Catalogue *const ptr = m_catalogue.get();
    if(NULL == ptr) {
      throw FailedToGetCatalogue();
    }
    return *ptr;
  }
    
  cta::Scheduler &getScheduler() {
    cta::Scheduler *const ptr = m_scheduler.get();
    if(NULL == ptr) {
      throw FailedToGetScheduler();
    }
    return *ptr;
  }
  
  void setupDefaultCatalogue() {
    using namespace cta;
    auto & catalogue=getCatalogue();

    const std::string mountPolicyName = "mount_group";
    const uint64_t archivePriority = 1;
    const uint64_t minArchiveRequestAge = 2;
    const uint64_t retrievePriority = 3;
    const uint64_t minRetrieveRequestAge = 4;
    const uint64_t maxDrivesAllowed = 5;
    const std::string mountPolicyComment = "create mount group";

    ASSERT_TRUE(catalogue.getMountPolicies().empty());

    catalogue.createMountPolicy(
      s_adminOnAdminHost,
      mountPolicyName,
      archivePriority,
      minArchiveRequestAge,
      retrievePriority,
      minRetrieveRequestAge,
      maxDrivesAllowed,
      mountPolicyComment);

    const std::list<common::dataStructures::MountPolicy> groups = catalogue.getMountPolicies();
    ASSERT_EQ(1, groups.size());
    const common::dataStructures::MountPolicy group = groups.front();
    ASSERT_EQ(mountPolicyName, group.name);
    ASSERT_EQ(archivePriority, group.archivePriority);
    ASSERT_EQ(minArchiveRequestAge, group.archiveMinRequestAge);
    ASSERT_EQ(retrievePriority, group.retrievePriority);
    ASSERT_EQ(minRetrieveRequestAge, group.retrieveMinRequestAge);
    ASSERT_EQ(maxDrivesAllowed, group.maxDrivesAllowed);
    ASSERT_EQ(mountPolicyComment, group.comment);

    const std::string ruleComment = "create requester mount-rule";
    cta::common::dataStructures::UserIdentity userIdentity;
    catalogue.createRequesterMountRule(s_adminOnAdminHost, mountPolicyName, s_diskInstance, s_userName, ruleComment);

    const std::list<common::dataStructures::RequesterMountRule> rules = catalogue.getRequesterMountRules();
    ASSERT_EQ(1, rules.size());

    const common::dataStructures::RequesterMountRule rule = rules.front();

    ASSERT_EQ(s_userName, rule.name);
    ASSERT_EQ(mountPolicyName, rule.mountPolicy);
    ASSERT_EQ(ruleComment, rule.comment);
    ASSERT_EQ(s_adminOnAdminHost.username, rule.creationLog.username);
    ASSERT_EQ(s_adminOnAdminHost.host, rule.creationLog.host);
    ASSERT_EQ(rule.creationLog, rule.lastModificationLog);

    common::dataStructures::StorageClass storageClass;
    storageClass.diskInstance = s_diskInstance;
    storageClass.name = s_storageClassName;
    storageClass.nbCopies = 1;
    storageClass.comment = "create storage class";
    m_catalogue->createStorageClass(s_adminOnAdminHost, storageClass);

    const uint16_t nbPartialTapes = 1;
    const std::string tapePoolComment = "Tape-pool comment";
    const bool tapePoolEncryption = false;
    ASSERT_NO_THROW(catalogue.createTapePool(s_adminOnAdminHost, s_tapePoolName,
      nbPartialTapes, tapePoolEncryption, tapePoolComment));
    const uint16_t copyNb = 1;
    const std::string archiveRouteComment = "Archive-route comment";
    catalogue.createArchiveRoute(s_adminOnAdminHost, s_diskInstance, s_storageClassName, copyNb, s_tapePoolName,
      archiveRouteComment);
  }

private:

  // Prevent copying
  DataTransferSessionTest(const DataTransferSessionTest &) = delete;

  // Prevent assignment
  DataTransferSessionTest & operator= (const DataTransferSessionTest &) = delete;

  std::unique_ptr<cta::SchedulerDatabase> m_db;
  std::unique_ptr<cta::catalogue::Catalogue> m_catalogue;
  std::unique_ptr<cta::Scheduler> m_scheduler;
  
protected:
  // Default parameters for storage classes, etc...
  const std::string s_userName = "user_name";
  const std::string s_diskInstance = "disk_instance";
  const std::string s_storageClassName = "TestStorageClass";
  const cta::common::dataStructures::SecurityIdentity s_adminOnAdminHost = { "admin1", "host1" };
  const std::string s_tapePoolName = "TestTapePool";
  const std::string s_libraryName = "TestLogicalLibrary";
295
  const std::string s_vid = "TstVid"; // We really need size <= 6 characters due to tape label format.
296
  //TempFile m_tempSqliteFile;
297
298
299
300
301
302
303
  /**
   * Temporary directory created with mkdtemp that will be used to contain the
   * destination remote files of the tests that need to create them.
   *
   * Please note that a new temporary directory is created and deleted for each
   * test by the Setup() and TearDown() methods.
   */
304
  char m_tmpDir[100];
305

306
307
}; // class DataTransferSessionTest

308
TEST_P(DataTransferSessionTest, DataTransferSessionGooddayRecall) {
Eric Cano's avatar
Eric Cano committed
309
310
311
  // 0) Prepare the logger for everyone
  castor::log::StringLogger logger("tapeServerUnitTest");
  
312
  setupDefaultCatalogue();
313
  // 1) prepare the fake scheduler
314
  std::string vid = s_vid;
315
316
  // cta::MountType::Enum mountType = cta::MountType::RETRIEVE;

317
318
  // 3) Prepare the necessary environment (logger, plus system wrapper), 
  castor::tape::System::mockWrapper mockSys;
319
320
  mockSys.delegateToFake();
  mockSys.disableGMockCallsCounting();
321
  mockSys.fake.setupForVirtualDriveSLC6();
322
323
324
  //delete is unnecessary
  //pointer with ownership will be passed to the application,
  //which will do the delete 
325
  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
326
327

  // 4) Create the scheduler
328
329
330
331
332
333
  auto & catalogue = getCatalogue();
  auto & scheduler = getScheduler();
//  cta::catalogue::InMemoryCatalogue catalogue;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(catalogue, db, 1, 1);
//
334
  // Always use the same requester
335
  const cta::common::dataStructures::SecurityIdentity requester;
336
337
338
339

  // List to remember the path of each remote file so that the existance of the
  // files can be tested for at the end of the test
  std::list<std::string> remoteFilePaths;
340
  
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
  // 5) Create the environment for the migration to happen (library + tape) 
    const std::string libraryComment = "Library comment";
  ASSERT_NO_THROW(catalogue.createLogicalLibrary(s_adminOnAdminHost, s_libraryName,
    libraryComment));
  {
    auto libraries = catalogue.getLogicalLibraries();
    ASSERT_EQ(1, libraries.size());
    ASSERT_EQ(s_libraryName, libraries.front().name);
    ASSERT_EQ(libraryComment, libraries.front().comment);
  }
  const uint64_t capacityInBytes = 12345678;
  const std::string tapeComment = "Tape comment";
  bool notDisabled = false;
  bool notFull = false;
  catalogue.createTape(s_adminOnAdminHost, s_vid, s_libraryName,
    s_tapePoolName, "", capacityInBytes, notDisabled, notFull, tapeComment);
357
  
358
  // 6) Prepare files for reading by writing them to the mock system
359
360
361
  {
    // Label the tape
    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], 
362
        s_vid, false);
363
364
    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
    // And write to it
365
    castor::tape::tapeserver::daemon::VolumeInfo volInfo;
366
    volInfo.vid=s_vid;
367
    castor::tape::tapeFile::WriteSession ws(*mockSys.fake.m_pathToDrive["/dev/nst0"],
368
       volInfo , 0, true, false);
369
370
371

    // Write a few files on the virtual tape and modify the archive name space
    // so that it is in sync
372
    uint8_t data[1000];
373
    size_t archiveFileSize=sizeof(data);
374
375
    castor::tape::SCSI::Structures::zeroStruct(&data);
    for (int fseq=1; fseq <= 10 ; fseq ++) {
376
377
      // Create a path to a remote destination file
      std::ostringstream remoteFilePath;
378
      remoteFilePath << "file://" << m_tmpDir << "/test" << fseq;
379
380
      remoteFilePaths.push_back(remoteFilePath.str());

381
      // Create an archive file entry in the archive namespace
382
383
      std::ostringstream archiveFilePath;
      archiveFilePath << "/test" << fseq;
384
      cta::catalogue::TapeFileWritten tapeFileWritten;
385
      
386
      // Write the file to tape
387
388
389
390
      cta::MockArchiveMount mam(catalogue);
      std::unique_ptr<cta::ArchiveJob> ftm(new cta::MockArchiveJob(mam, catalogue));
      ftm->tapeFile.fSeq = fseq;
      ftm->archiveFile.archiveFileID = fseq;
391
      castor::tape::tapeFile::WriteFile wf(&ws, *ftm, archiveFileSize);
392
      tapeFileWritten.blockId = wf.getBlockId();
393
      // Write the data (one block)
394
      wf.write(data, archiveFileSize);
395
396
      // Close the file
      wf.close();
397

398
399
400
401
402
403
404
405
406
      // Create file entry in the archive namespace
      tapeFileWritten.archiveFileId=fseq;
      tapeFileWritten.checksumType="ADLER32";
      tapeFileWritten.checksumValue=cta::utils::getAdler32String(data, archiveFileSize);
      tapeFileWritten.vid=volInfo.vid;
      tapeFileWritten.size=archiveFileSize;
      tapeFileWritten.fSeq=fseq;
      tapeFileWritten.copyNb=1;
      tapeFileWritten.compressedSize=archiveFileSize; // No compression
407
408
409
410
411
412
413
414
      tapeFileWritten.diskInstance = s_diskInstance;
      tapeFileWritten.diskFileId = fseq;
      tapeFileWritten.diskFilePath = remoteFilePath.str();
      tapeFileWritten.diskFileUser = s_userName;
      tapeFileWritten.diskFileGroup = "someGroup";
      tapeFileWritten.diskFileRecoveryBlob = "B106";
      tapeFileWritten.storageClassName = s_storageClassName;
      tapeFileWritten.tapeDrive = "drive0";
415
      catalogue.fileWrittenToTape(tapeFileWritten);
416

417
      // Schedule the retrieval of the file
Daniele Kruse's avatar
Daniele Kruse committed
418
      std::string diskInstance="disk_instance";
419
420
      cta::common::dataStructures::RetrieveRequest rReq;
      rReq.archiveFileID=fseq;
421
422
      rReq.requester.name = s_userName;
      rReq.requester.group = "someGroup";
423
      rReq.dstURL = remoteFilePaths.back();
424
425
      std::list<std::string> archiveFilePaths;
      archiveFilePaths.push_back(archiveFilePath.str());
Daniele Kruse's avatar
Daniele Kruse committed
426
      scheduler.queueRetrieve(diskInstance, rReq);
427
428
    }
  }
429
430

  // 6) Create the data transfer session
431
  DriveConfig driveConfig("T10D6116", "TestLogicalLibrary", "/dev/tape_T10D6116", "manual");
432
433
434
435
436
437
  DataTransferConfig castorConf;
  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
  castorConf.nbBufs = 10;
  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
  castorConf.bulkRequestRecallMaxFiles = 1000;
  castorConf.nbDiskThreads = 1;
438
439
440
441
  castor::messages::AcsProxyDummy acs;
  castor::mediachanger::MmcProxyDummy mmc;
  castor::legacymsg::RmcProxyDummy rmc;
  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
442
  castor::server::ProcessCap capUtils;
443
  castor::messages::TapeserverProxyDummy initialProcess;
444
  castor::tape::tapeserver::daemon::DataTransferSession sess("tapeHost", logger, mockSys,
445
    driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
446
447

  // 7) Run the data transfer session
448
  sess.execute();
449
450

  // 8) Check the session git the correct VID
451
  ASSERT_EQ(s_vid, sess.getVid());
452

453
  // 9) Check the remote files exist and have the correct size
454
  for(auto & path: remoteFilePaths) {
455
456
    struct stat statBuf;
    bzero(&statBuf, sizeof(statBuf));
457
    const int statRc = stat(path.substr(7).c_str(), &statBuf); //remove the "file://" for stat-ing
458
    ASSERT_EQ(0, statRc);
459
    ASSERT_EQ(1000, statBuf.st_size); //same size of data
460
  }
461
}
462
//
463
464
465
466
//TEST_P(DataTransferSessionTest, DataTransferSessionWrongRecall) {
//  // This test is the same as the previous one, with 
//  // wrong parameters set for the recall, so that we fail 
//  // to recall the first file and cancel the second.
467
//
468
469
470
471
472
473
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//  // cta::MountType::Enum mountType = cta::MountType::RETRIEVE;
474
//
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//  //delete is unnecessary
//  //pointer with ownership will be passed to the application,
//  //which will do the delete 
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
//
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteNS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//
//  // List to remember the path of each remote file so that the existance of the
//  // files can be tested for at the end of the test
//  std::list<std::string> remoteFilePaths;
//  
//  // 5) Create the tapepool, library and tape for the scheduler.
//  // Make mounts immediate.
//  ASSERT_NO_THROW(scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), ""));
//  ASSERT_NO_THROW(scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), ""));
//  ASSERT_NO_THROW(scheduler.createTapePool(requester, "TapePool", 1, ""));
//  cta::MountCriteria immediateMount;
//  immediateMount.maxAge = 0;
//  immediateMount.maxBytesQueued = 1;
//  immediateMount.maxFilesQueued = 1;
//  immediateMount.quota = 10;
//  ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("TapePool", cta::MountCriteriaByDirection(immediateMount, immediateMount)));                   
//  ASSERT_NO_THROW(scheduler.createLogicalLibrary(requester, "T10KD6", ""));
//  ASSERT_NO_THROW(scheduler.createTape(requester, "V12345", "T10KD6", "TapePool", 10*1000*1000, ""));
//  
//  // 5) Prepare files for reading by writing them to the mock system
//  {
//    // Label the tape
//    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], 
//        "V12345", false);
//    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
//    // And write to it
//    castor::tape::tapeserver::daemon::VolumeInfo volInfo;
//    volInfo.vid="V12345";
//    castor::tape::tapeFile::WriteSession ws(*mockSys.fake.m_pathToDrive["/dev/nst0"],
//       volInfo , 0, true, false);
//
//    // Write a few files on the virtual tape and modify the archive name space
//    // so that it is in sync
//    uint8_t data[1000];
//    castor::tape::SCSI::Structures::zeroStruct(&data);
//    int fseq=1;
//    {
//      // Create a path to a remote destination file
//      std::ostringstream remoteFilePath;
//      remoteFilePath << "file://" << m_tmpDir << "/test" << fseq;
//      remoteFilePaths.push_back(remoteFilePath.str());
//
//      // Create an archive file entry in the archive namespace
//      std::ostringstream archiveFilePath;
//      archiveFilePath << "/test" << fseq;
//      const mode_t archiveFileMode = 0655;
//      const uint64_t archiveFileSize = 1000;
//      ASSERT_NO_THROW(ns.createFile(
//        requester,
//        archiveFilePath.str(),
//        archiveFileMode,
//        cta::Checksum(cta::Checksum::CHECKSUMTYPE_ADLER32, cta::utils::getAdler32(data, sizeof data)),
//        archiveFileSize));
//
//      // Write the file to tape
//      cta::catalogue::SqliteCatalogue sqliteCatalogue;
//      cta::MockArchiveMount mam(mns);
//      cta::MockRetrieveMount mrm;
//      std::unique_ptr<cta::RetrieveJob> ftr(new cta::MockRetrieveJob(mrm));
//      std::unique_ptr<cta::ArchiveJob> ftm_temp(new cta::MockArchiveJob(mam, mns));
//      ftr->tapeFile.tapeFileLocation.fSeq = fseq;
//      ftm_temp->tapeFile.tapeFileLocation.fSeq = fseq;
//      ftr->archiveFile.fileId = 1000 + fseq;
//      ftm_temp->archiveFile.fileId = 1000 + fseq;
//      castor::tape::tapeFile::WriteFile wf(&ws, *ftm_temp, archiveFileSize);
//      ftr->tapeFile.tapeFileLocation.blockId = wf.getBlockId();
//      ftr->remotePath = remoteFilePath.str();
//      // Write the data (one block)
//      wf.write(data, sizeof(data));
//      // Close the file
//      wf.close();
//
//      // Create tape file entry in the archive namespace that is beyond the end
//      // of data
//      cta::NameServerTapeFile tapeFile;
//      tapeFile.copyNb = 1;
//      tapeFile.tapeFileLocation.fSeq = fseq + 10000;
//      tapeFile.tapeFileLocation.blockId = wf.getBlockId() + 10000;
//      tapeFile.tapeFileLocation.vid = volInfo.vid;
//      tapeFile.tapeFileLocation.copyNb = 1;
//      tapeFile.size = archiveFileSize;
//      tapeFile.compressedSize = archiveFileSize; // No compression
//      cta::Checksum tapeFileChecksum(cta::Checksum::CHECKSUMTYPE_ADLER32, cta::utils::getAdler32(data, sizeof data));
//      tapeFile.checksum = tapeFileChecksum;
//      ASSERT_NO_THROW(ns.addTapeFile(
//        requester,
//        archiveFilePath.str(),
//        tapeFile));
//
//      // Schedule the retrieval of the file
//      std::list<std::string> archiveFilePaths;
//      archiveFilePaths.push_back(archiveFilePath.str());
//      ASSERT_NO_THROW(scheduler.queueRetrieveRequest(
//        requester,
//        archiveFilePaths,
//        remoteFilePath.str()));
//    }
590
//  }
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
//
//  // 6) Create the data transfer session
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
//  castorConf.nbBufs = 10;
//  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
//  castorConf.bulkRequestRecallMaxFiles = 1000;
//  castorConf.nbDiskThreads = 1;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::server::ProcessCap capUtils;
//  castor::messages::TapeserverProxyDummy initialProcess;
//  DataTransferSession sess("tapeHost", logger, mockSys,
//    driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//
//  // 7) Run the data transfer session
//  ASSERT_NO_THROW(sess.execute());
//
//  // 8) Check the session git the correct VID
//  ASSERT_EQ("V12345", sess.getVid());
//
//  // 9) Check the remote files exist and have the correct size
//  std::string temp = logger.getLog();
//  ASSERT_NE(std::string::npos, logger.getLog().find("trying to position beyond the end of data"));
//}
//
//TEST_P(DataTransferSessionTest, DataTransferSessionNoSuchDrive) {
//  
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//  // cta::MountType::Enum mountType = cta::MountType::RETRIEVE;
//
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//  //delete is unnecessary
//  //pointer with ownership will be passed to the application,
//  //which will do the delete 
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
//
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteNS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//  
//  // List to remember the path of each remote file so that the existance of the
//  // files can be tested for at the end of the test
//  std::list<std::string> remoteFilePaths;
//  
//  // 5) Create the tapepool, library and tape for the scheduler.
//  // Make mounts immediate.
//  ASSERT_NO_THROW(scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), ""));
//  ASSERT_NO_THROW(scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), ""));
//  ASSERT_NO_THROW(scheduler.createTapePool(requester, "TapePool", 1, ""));
//  cta::MountCriteria immediateMount;
//  immediateMount.maxAge = 0;
//  immediateMount.maxBytesQueued = 1;
//  immediateMount.maxFilesQueued = 1;
//  immediateMount.quota = 10;
//  ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("TapePool", cta::MountCriteriaByDirection(immediateMount, immediateMount)));                   
//  ASSERT_NO_THROW(scheduler.createLogicalLibrary(requester, "T10KD6", ""));
//  ASSERT_NO_THROW(scheduler.createTape(requester, "V12345", "T10KD6", "TapePool", 10*1000*1000, ""));
//  
//  // 5) Prepare files for reading by writing them to the mock system
//  {
//    // Label the tape
//    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], 
//        "V12345", false);
//    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
//    // And write to it
//    castor::tape::tapeserver::daemon::VolumeInfo volInfo;
//    volInfo.vid="V12345";
//    castor::tape::tapeFile::WriteSession ws(*mockSys.fake.m_pathToDrive["/dev/nst0"],
//       volInfo , 0, true, false);
//
//    // Write a few files on the virtual tape and modify the archive name space
//    // so that it is in sync
//    uint8_t data[1000];
//    castor::tape::SCSI::Structures::zeroStruct(&data);
//    int fseq=1;
//    {
//      // Create a path to a remote destination file
//      std::ostringstream remoteFilePath;
//      remoteFilePath << "file://" << m_tmpDir << "/test" << fseq;
//      remoteFilePaths.push_back(remoteFilePath.str());
//
//      // Create an archive file entry in the archive namespace
//      std::ostringstream archiveFilePath;
//      archiveFilePath << "/test" << fseq;
//      const mode_t archiveFileMode = 0655;
//      const uint64_t archiveFileSize = 1000;
//      ASSERT_NO_THROW(ns.createFile(
//        requester,
//        archiveFilePath.str(),
//        archiveFileMode,
//        cta::Checksum(cta::Checksum::CHECKSUMTYPE_ADLER32, cta::utils::getAdler32(data, sizeof data)),
//        archiveFileSize));
//
//      // Write the file to tape
//      cta::catalogue::SqliteCatalogue sqliteCatalogue;
//      cta::MockArchiveMount mam(mns);
//      cta::MockRetrieveMount mrm;
//      std::unique_ptr<cta::RetrieveJob> ftr(new cta::MockRetrieveJob(mrm));
//      std::unique_ptr<cta::ArchiveJob> ftm_temp(new cta::MockArchiveJob(mam, mns));
//      ftr->tapeFile.tapeFileLocation.fSeq = fseq;
//      ftm_temp->tapeFile.tapeFileLocation.fSeq = fseq;
//      ftr->archiveFile.fileId = 1000 + fseq;
//      ftm_temp->archiveFile.fileId = 1000 + fseq;
//      castor::tape::tapeFile::WriteFile wf(&ws, *ftm_temp, archiveFileSize);
//      ftr->tapeFile.tapeFileLocation.blockId = wf.getBlockId();
//      ftr->remotePath = remoteFilePath.str();
//      // Write the data (one block)
//      wf.write(data, sizeof(data));
//      // Close the file
//      wf.close();
//
//      // Create tape file entry in the archive namespace that is beyond the end
//      // of data
//      cta::NameServerTapeFile tapeFile;
//      tapeFile.copyNb = 1;
//      tapeFile.tapeFileLocation.fSeq = fseq + 1000;
//      tapeFile.tapeFileLocation.blockId = wf.getBlockId();
//      tapeFile.tapeFileLocation.vid = volInfo.vid;
//      tapeFile.tapeFileLocation.copyNb = 1;
//      tapeFile.size = archiveFileSize;
//      tapeFile.compressedSize = archiveFileSize; // No compression
//      cta::Checksum tapeFileChecksum(cta::Checksum::CHECKSUMTYPE_ADLER32, cta::utils::getAdler32(data, sizeof data));
//      tapeFile.checksum = tapeFileChecksum;
//      ASSERT_NO_THROW(ns.addTapeFile(
//        requester,
//        archiveFilePath.str(),
//        tapeFile));
//
//      // Schedule the retrieval of the file
//      std::list<std::string> archiveFilePaths;
//      archiveFilePaths.push_back(archiveFilePath.str());
//      ASSERT_NO_THROW(scheduler.queueRetrieveRequest(
//        requester,
//        archiveFilePaths,
//        remoteFilePath.str()));
//    }
//  }
//  
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/noSuchDrive", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024;
//  castorConf.nbBufs = 10;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::messages::TapeserverProxyDummy initialProcess;
//  castor::server::ProcessCapDummy capUtils;
//  DataTransferSession sess("tapeHost", logger, mockSys,
//    driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//  ASSERT_NO_THROW(sess.execute());
//  std::string temp = logger.getLog();
//  ASSERT_NE(std::string::npos, logger.getLog().find("Could not stat path: /dev/noSuchDrive"));
//}
//
//TEST_P(DataTransferSessionTest, DataTransferSessionFailtoMount) {
//  
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//  // cta::MountType::Enum mountType = cta::MountType::RETRIEVE;
//
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteNS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//  
//  // List to remember the path of each remote file so that the existance of the
//  // files can be tested for at the end of the test
//  std::list<std::string> remoteFilePaths;
//  
//  // 5) Create the tapepool, library and tape for the scheduler.
//  // Make mounts immediate.
//  ASSERT_NO_THROW(scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), ""));
//  ASSERT_NO_THROW(scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), ""));
//  ASSERT_NO_THROW(scheduler.createTapePool(requester, "TapePool", 1, ""));
//  cta::MountCriteria immediateMount;
//  immediateMount.maxAge = 0;
//  immediateMount.maxBytesQueued = 1;
//  immediateMount.maxFilesQueued = 1;
//  immediateMount.quota = 10;
//  ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("TapePool", cta::MountCriteriaByDirection(immediateMount, immediateMount)));                   
//  ASSERT_NO_THROW(scheduler.createLogicalLibrary(requester, "T10KD6", ""));
//  ASSERT_NO_THROW(scheduler.createTape(requester, "V12345", "T10KD6", "TapePool", 10*1000*1000, ""));
//
//  //delete is unnecessary
//  //pointer with ownership will be passed to the application,
//  //which will do the delete 
//  const bool failOnMount=true;
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive(failOnMount);
//  
//  // We can prepare files for reading on the drive
//  {
//    
//    // Label the tape
//    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], 
//        "V12345");
//    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
//    // And write to it
//    castor::tape::tapeserver::daemon::VolumeInfo volInfo;
//    volInfo.vid="V12345";
//    castor::tape::tapeFile::WriteSession ws(*mockSys.fake.m_pathToDrive["/dev/nst0"],
//       volInfo , 0, true);
//
//    // Write a few files on the virtual tape and modify the archive name space
//    // so that it is in sync
//    uint8_t data[1000];
//    castor::tape::SCSI::Structures::zeroStruct(&data);
//    for (int fseq=1; fseq <= 10 ; fseq ++) {
//      // Create a path to a remote destination file
//      std::ostringstream remoteFilePath;
//      remoteFilePath << "file://" << m_tmpDir << "/test" << fseq;
//      remoteFilePaths.push_back(remoteFilePath.str());
//
//      // Create an archive file entry in the archive namespace
//      std::ostringstream archiveFilePath;
//      archiveFilePath << "/test" << fseq;
//      const mode_t archiveFileMode = 0655;
//      const uint64_t archiveFileSize = 1000;
//      ASSERT_NO_THROW(ns.createFile(
//        requester,
//        archiveFilePath.str(),
//        archiveFileMode,
//        cta::Checksum(),
//        archiveFileSize));
//
//      // Write the file to tape
//      cta::MockNameServer  mns;
//      cta::MockArchiveMount mam(mns);
//      cta::MockRetrieveMount mrm;
//      std::unique_ptr<cta::RetrieveJob> ftr(new cta::MockRetrieveJob(mrm));
//      std::unique_ptr<cta::ArchiveJob> ftm_temp(new cta::MockArchiveJob(mam, mns));
//      ftr->tapeFile.tapeFileLocation.fSeq = fseq;
//      ftm_temp->tapeFile.tapeFileLocation.fSeq = fseq;
//      ftr->archiveFile.fileId = 1000 + fseq;
//      ftm_temp->archiveFile.fileId = 1000 + fseq;
//      castor::tape::tapeFile::WriteFile wf(&ws, *ftm_temp, archiveFileSize);
//      ftr->tapeFile.tapeFileLocation.blockId = wf.getPosition();
//      ftr->remotePath = remoteFilePath.str();
//      // Write the data (one block)
//      wf.write(data, sizeof(data));
//      // Close the file
//      wf.close();
//
//      // Create tape file entry in the archive namespace
//      cta::NameServerTapeFile tapeFile;
//      tapeFile.copyNb = 1;
//      tapeFile.tapeFileLocation.fSeq = fseq;
//      tapeFile.tapeFileLocation.blockId = wf.getPosition();
//      tapeFile.tapeFileLocation.vid = volInfo.vid;
//      tapeFile.tapeFileLocation.copyNb = 1;
//      tapeFile.size = archiveFileSize;
//      tapeFile.compressedSize = archiveFileSize; // No compression
//      cta::Checksum tapeFileChecksum(cta::Checksum::CHECKSUMTYPE_ADLER32, cta::utils::getAdler32(data, sizeof data));
//      tapeFile.checksum = tapeFileChecksum;
//      ASSERT_NO_THROW(ns.addTapeFile(
//        requester,
//        archiveFilePath.str(),
//        tapeFile));
//
//      // Schedule the retrieval of the file
//      std::list<std::string> archiveFilePaths;
//      archiveFilePaths.push_back(archiveFilePath.str());
//      ASSERT_NO_THROW(scheduler.queueRetrieveRequest(
//        requester,
//        archiveFilePaths,
//        remoteFilePath.str()));
//    }
//  }
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
//  castorConf.nbBufs = 10;
//  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
//  castorConf.bulkRequestRecallMaxFiles = 1000;
//  castorConf.nbDiskThreads = 3;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::server::ProcessCap capUtils;
//  castor::messages::TapeserverProxyDummy initialProcess;
//  DataTransferSession sess("tapeHost", logger, mockSys,
//    driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//  ASSERT_NO_THROW(sess.execute());
//  std::string temp = logger.getLog();
//  ASSERT_NE(std::string::npos, logger.getLog().find("Failed to mount the tape"));
//}
//
//TEST_P(DataTransferSessionTest, DataTransferSessionEmptyOnVolReq) {
//  
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//  // cta::MountType::Enum mountType = cta::MountType::RETRIEVE;
//
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//  
//  // The drive will not even be opened. so no need for one.
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = NULL;
//  
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteNS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//  
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
//  castorConf.nbBufs = 10;
//  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
//  castorConf.bulkRequestRecallMaxFiles = 1000;
//  castorConf.nbDiskThreads = 3;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::server::ProcessCap capUtils;
//  castor::messages::TapeserverProxyDummy initialProcess;
//  DataTransferSession sess("tapeHost", logger, mockSys,
//    driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//  ASSERT_NO_THROW(sess.execute());
//  std::string temp = logger.getLog();
//  temp += "";
//  ASSERT_EQ("", sess.getVid());
//  // We should not have logged any error
//  ASSERT_EQ(std::string::npos, logger.getLog().find("LVL=E"));
//}
//
//TEST_P(DataTransferSessionTest, DataTransferSessionGooddayMigration) {
//  
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteFullFS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//  
//  // Create the bootstrap admin user and host
//  ASSERT_NO_THROW(scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), "admin user"));
//  ASSERT_NO_THROW(scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), "admin host"));
//  
//  // create a single copy storage class
//  ASSERT_NO_THROW(scheduler.createStorageClass(requester, "SINGLE", 1, 1, "comment"));
//  
//  // assign it to the root directory
//  ASSERT_NO_THROW(scheduler.setDirStorageClass(requester, "/", "SINGLE"));
//  
//  // create the logical library
//  ASSERT_NO_THROW(scheduler.createLogicalLibrary(requester, "T10KD6", "the illogical library"));
//  
//  // create the tape pool
//  ASSERT_NO_THROW(scheduler.createTapePool(requester, "swimmingpool", 2, "the swimming pool"));
//  
//  cta::MountCriteria immediateMount;
//  immediateMount.maxAge = 0;
//  immediateMount.maxBytesQueued = 1;
//  immediateMount.maxFilesQueued = 1;
//  immediateMount.quota = 10;
//  ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("swimmingpool", cta::MountCriteriaByDirection(immediateMount, immediateMount)));
//  
//  // create the route
//  ASSERT_NO_THROW(scheduler.createArchiveRoute(requester, "SINGLE", 1, "swimmingpool", "iArchive"));
//  
//  // create the tape
//  std::string comment = "the magic tape";
//  ASSERT_NO_THROW(scheduler.createTape(requester, "V12345", "T10KD6", "swimmingpool", 100000, comment));
//  
//  // List to remember the path of each remote file so that the existence of the
//  // files can be tested for at the end of the test
//  std::list<std::string> remoteFilePaths;
//
//  //delete is unnecessary
//  //pointer with ownership will be passed to the application,
//  //which will do the delete
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive();
//  
//  // We can prepare files for writing on the drive
//  {    
//    // Label the tape
//    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], "V12345");
//    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
//    
//    // schedule the archivals
//    for(int fseq=1; fseq <= 10 ; fseq ++) { 
//      // Create a path to a remote source file
//      std::ostringstream fileName;
//      fileName << "/test" << fseq;
//      remoteFilePaths.push_back(fileName.str());
//      
//      // Create the file to be migrated in the fake remote NS
//      cta::RemotePath rpath(rns.createFullURL(fileName.str()));
//      rns.createFile(rpath.getRaw(), 1000);
//
//      // Schedule the archival of the file
//      std::list<std::string> remoteFilePathList;
//      remoteFilePathList.push_back(rns.createFullURL(fileName.str()));
//      ASSERT_NO_THROW(scheduler.queueArchiveRequest(requester, remoteFilePathList, fileName.str()));
//    }
//  }
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
//  castorConf.nbBufs = 10;
//  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
//  castorConf.bulkRequestRecallMaxFiles = 1000;
//  castorConf.nbDiskThreads = 1;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::server::ProcessCap capUtils;
//  castor::messages::TapeserverProxyDummy initialProcess;
//  DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//  ASSERT_NO_THROW(sess.execute());
//  std::string temp = logger.getLog();
//  temp += "";
//  ASSERT_EQ("V12345", sess.getVid());
1062
//  for(auto i=remoteFilePaths.begin(); i!=remoteFilePaths.end(); i++) {
1063
1064
1065
1066
1067
//    ASSERT_NO_THROW(ns.statFile(requester, *i));
//    std::unique_ptr<cta::common::archiveNS::ArchiveFileStatus> stat(ns.statFile(requester, *i));
//    ASSERT_NE(NULL, (uint64_t)(stat.get()));
//    ASSERT_EQ(0100777, stat->mode);
//    ASSERT_EQ(1000, stat->size);
1068
//  }
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
//}
//
////
//// This test is the same as the previous one, except that the files are deleted
//// from filesystem immediately. The disk tasks will then fail on open.
/////
//TEST_P(DataTransferSessionTest, DataTransferSessionMissingFilesMigration) {
//  
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteFullFS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//  
//  // Create the bootstrap admin user and host
//  ASSERT_NO_THROW(scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), "admin user"));
//  ASSERT_NO_THROW(scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), "admin host"));
//  
//  // create a single copy storage class
//  ASSERT_NO_THROW(scheduler.createStorageClass(requester, "SINGLE", 1, 1, "comment"));
//  
//  // assign it to the root directory
//  ASSERT_NO_THROW(scheduler.setDirStorageClass(requester, "/", "SINGLE"));
//  
//  // create the logical library
//  ASSERT_NO_THROW(scheduler.createLogicalLibrary(requester, "T10KD6", "the illogical library"));
//  
//  // create the tape pool
//  ASSERT_NO_THROW(scheduler.createTapePool(requester, "swimmingpool", 2, "the swimming pool"));
//
//  // Make the pool mount immediately
//  cta::MountCriteria immediateMount;
//  immediateMount.maxAge = 0;
//  immediateMount.maxBytesQueued = 1;
//  immediateMount.maxFilesQueued = 1;
//  immediateMount.quota = 10;
//  ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("swimmingpool", cta::MountCriteriaByDirection(immediateMount, immediateMount)));
//  
//  // create the route
//  ASSERT_NO_THROW(scheduler.createArchiveRoute(requester, "SINGLE", 1, "swimmingpool", "iArchive"));
//  
//  // create the tape
//  std::string comment = "the magic tape";
//  ASSERT_NO_THROW(scheduler.createTape(requester, "V12345", "T10KD6", "swimmingpool", 100000, comment));
//  
//  // List to remember the path of each remote file so that the existence of the
//  // files can be tested for at the end of the test
//  std::list<std::string> remoteFilePaths;
//
//  //delete is unnecessary
//  //pointer with ownership will be passed to the application,
//  //which will do the delete
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive();
//  
//  // We can prepare files for writing on the drive
//  {    
//    // Label the tape
//    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], "V12345");
//    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
//    
//    // schedule the archivals
//    for(int fseq=1; fseq <= 10 ; fseq ++) {      
//      // Create a path to a remote destination file
//      std::ostringstream fileName;
//      fileName << "/test" << fseq;
//      remoteFilePaths.push_back(fileName.str());
//      
//      // create the file in the remote file system (to be deleted after queueing
//      // the request)
//      cta::RemotePath rpath(rns.createFullURL(fileName.str()));
//      rns.createFile(rpath.getRaw(), 1000);
//
//      // Schedule the archival of the file
//      std::list<std::string> remoteFilePathList;
//      remoteFilePathList.push_back(rns.createFullURL(fileName.str()));
//      ASSERT_NO_THROW(scheduler.queueArchiveRequest(requester, remoteFilePathList, fileName.str()));
//      
//      // Delete the file
//      rns.deleteFile(rpath.getRaw());
//    }
//  }
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
//  castorConf.nbBufs = 10;
//  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
//  castorConf.bulkRequestRecallMaxFiles = 1000;
//  castorConf.nbDiskThreads = 1;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::server::ProcessCap capUtils;
//  castor::messages::TapeserverProxyDummy initialProcess;
//  DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//  ASSERT_NO_THROW(sess.execute()); //the session should run though, but not get any file through
//  // We should no have logged a single successful file read.
//  ASSERT_EQ(std::string::npos, logger.getLog().find("MSG=\"File successfully read from disk\""));
//}
//
////
//// This test is identical to the good day migration, but the tape will accept
//// only a finite number of bytes and hence we will report a full tape skip the
//// last migrations
////
//TEST_P(DataTransferSessionTest, DataTransferSessionTapeFullMigration) {
//  
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteNS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//  
//  // Create the bootstrap admin user and host
//  ASSERT_NO_THROW(scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), "admin user"));
//  ASSERT_NO_THROW(scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), "admin host"));
//  
//  // create a single copy storage class
//  ASSERT_NO_THROW(scheduler.createStorageClass(requester, "SINGLE", 1, 1, "comment"));
//  
//  // assign it to the root directory
//  ASSERT_NO_THROW(scheduler.setDirStorageClass(requester, "/", "SINGLE"));
//  
//  // create the logical library
//  ASSERT_NO_THROW(scheduler.createLogicalLibrary(requester, "T10KD6", "the illogical library"));
//  
//  // create the tape pool
//  ASSERT_NO_THROW(scheduler.createTapePool(requester, "swimmingpool", 2, "the swimming pool"));
//  
//  // Make the pool mount immediately
//  cta::MountCriteria immediateMount;
//  immediateMount.maxAge = 0;
//  immediateMount.maxBytesQueued = 1;
//  immediateMount.maxFilesQueued = 1;
//  immediateMount.quota = 10;
//  ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("swimmingpool", cta::MountCriteriaByDirection(immediateMount, immediateMount)));
//  
//  // create the route
//  ASSERT_NO_THROW(scheduler.createArchiveRoute(requester, "SINGLE", 1, "swimmingpool", "iArchive"));
//  
//  // create the tape
//  std::string comment = "the magic tape";
//  ASSERT_NO_THROW(scheduler.createTape(requester, "V12345", "T10KD6", "swimmingpool", 100000, comment));
//  
//  // List to remember the path of each remote file so that the existence of the
//  // files can be tested for at the end of the test
//  std::list<std::string> remoteFilePaths;
//
//  //delete is unnecessary
//  //pointer with ownership will be passed to the application,
//  //which will do the delete
//  const uint64_t tapeSize = 5000;
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive(tapeSize);
//  
//  // We can prepare files for writing on the drive
//  {    
//    // Label the tape
//    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], "V12345");
//    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
//    
//    // schedule the archivals
//    for(int fseq=1; fseq <= 10 ; fseq ++) {      
//      // Create a path to a remote destination file
//      std::ostringstream remoteFilePath;
//      remoteFilePath << "file://test" << fseq;
//      remoteFilePaths.push_back(remoteFilePath.str());
//      
//      // Create the entry in the remote namespace (same user id of the requester)
//      cta::RemotePath rpath(remoteFilePath.str());
//      cta::RemoteFileStatus rstatus(requester.getUser(), 0777, 1000);
//      rns.createEntry(rpath, rstatus);
//
//      // Schedule the archival of the file
//      std::list<std::string> remoteFilePathList;
//      remoteFilePathList.push_back(remoteFilePath.str());
//      ASSERT_NO_THROW(scheduler.queueArchiveRequest(requester, remoteFilePathList, rpath.getAfterScheme()));
//    }
//  }
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
//  castorConf.nbBufs = 10;
//  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
//  castorConf.bulkRequestRecallMaxFiles = 1000;
//  castorConf.nbDiskThreads = 1;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::server::ProcessCap capUtils;
//  castor::messages::TapeserverProxyDummy initialProcess;
//  DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//  ASSERT_NO_THROW(sess.execute());
//  std::string temp = logger.getLog();
//  temp += "";
//  ASSERT_EQ("V12345", sess.getVid());
////  //TODO: only 4 files out of 10 should have been migrated to this small tape (we need to check this with the "m" bit)
////  for(auto i=remoteFilePaths.begin(); i!=remoteFilePaths.end(); i++) {
////    cta::RemotePath rpath(*i);
////    ASSERT_NO_THROW(ns.statFile(requester, rpath.getAfterScheme()));
////    std::unique_ptr<cta::ArchiveFileStatus> stat(ns.statFile(requester, rpath.getAfterScheme()));
////    ASSERT_NE((uint64_t)(stat.get()), NULL);
////    ASSERT_EQ(stat->mode, 0777);
////    ASSERT_EQ(stat->size, 1000);
////  }
//}
//
//TEST_P(DataTransferSessionTest, DataTransferSessionTapeFullOnFlushMigration) {
//  
//    
//  // 0) Prepare the logger for everyone
//  castor::log::StringLogger logger("tapeServerUnitTest");
//  
//  // 1) prepare the fake scheduler
//  std::string vid = "V12345";
//
//  // 3) Prepare the necessary environment (logger, plus system wrapper), 
//  castor::tape::System::mockWrapper mockSys;
//  mockSys.delegateToFake();
//  mockSys.disableGMockCallsCounting();
//  mockSys.fake.setupForVirtualDriveSLC6();
//
//  // 4) Create the scheduler
//  cta::catalogue::SqliteCatalogue sqliteCatalogue;
//  cta::MockRemoteNS rns;
//  cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest");
//  cta::Scheduler scheduler(ns, db, rns);
//
//  // Always use the same requester
//  const cta::SecurityIdentity requester;
//  
//  // Create the bootstrap admin user and host
//  ASSERT_NO_THROW(scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), "admin user"));
//  ASSERT_NO_THROW(scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), "admin host"));
//  
//  // create a single copy storage class
//  ASSERT_NO_THROW(scheduler.createStorageClass(requester, "SINGLE", 1, 1, "comment"));
//  
//  // assign it to the root directory
//  ASSERT_NO_THROW(scheduler.setDirStorageClass(requester, "/", "SINGLE"));
//  
//  // create the logical library
//  ASSERT_NO_THROW(scheduler.createLogicalLibrary(requester, "T10KD6", "the illogical library"));
//  
//  // create the tape pool
//  ASSERT_NO_THROW(scheduler.createTapePool(requester, "swimmingpool", 2, "the swimming pool"));
//  
//  // Make the pool mount immediately
//  cta::MountCriteria immediateMount;
//  immediateMount.maxAge = 0;
//  immediateMount.maxBytesQueued = 1;
//  immediateMount.maxFilesQueued = 1;
//  immediateMount.quota = 10;
//  ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("swimmingpool", cta::MountCriteriaByDirection(immediateMount, immediateMount)));
//  
//  // create the route
//  ASSERT_NO_THROW(scheduler.createArchiveRoute(requester, "SINGLE", 1, "swimmingpool", "iArchive"));
//  
//  // create the tape
//  std::string comment = "the magic tape";
//  ASSERT_NO_THROW(scheduler.createTape(requester, "V12345", "T10KD6", "swimmingpool", 100000, comment));
//  
//  // List to remember the path of each remote file so that the existence of the
//  // files can be tested for at the end of the test
//  std::list<std::string> remoteFilePaths;
//
//  //delete is unnecessary
//  //pointer with ownership will be passed to the application,
//  //which will do the delete
//  const uint64_t tapeSize = 5000;
//  mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive(tapeSize,
//        castor::tape::tapeserver::drive::FakeDrive::OnFlush);
//  
//  // We can prepare files for writing on the drive
//  {    
//    // Label the tape
//    castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], "V12345");
//    mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
//    
//    // schedule the archivals
//    for(int fseq=1; fseq <= 10 ; fseq ++) {      
//      // Create a path to a remote destination file
//      std::ostringstream remoteFilePath;
//      remoteFilePath << "file://test" << fseq;
//      remoteFilePaths.push_back(remoteFilePath.str());
//      
//      // Create the entry in the remote namespace (same user id of the requester)
//      cta::RemotePath rpath(remoteFilePath.str());
//      cta::RemoteFileStatus rstatus(requester.getUser(), 0777, 1000);
//      rns.createEntry(rpath, rstatus);
//
//      // Schedule the archival of the file
//      std::list<std::string> remoteFilePathList;
//      remoteFilePathList.push_back(remoteFilePath.str());
//      ASSERT_NO_THROW(scheduler.queueArchiveRequest(requester, remoteFilePathList, rpath.getAfterScheme()));
//    }
//  }
//  DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual");
//  DataTransferConfig castorConf;
//  castorConf.bufsz = 1024*1024; // 1 MB memory buffers
//  castorConf.nbBufs = 10;
//  castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000;
//  castorConf.bulkRequestRecallMaxFiles = 1000;
//  castorConf.nbDiskThreads = 1;
//  castor::messages::AcsProxyDummy acs;
//  castor::mediachanger::MmcProxyDummy mmc;
//  castor::legacymsg::RmcProxyDummy rmc;
//  castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
//  castor::server::ProcessCap capUtils;
//  castor::messages::TapeserverProxyDummy initialProcess;
//  DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
//  ASSERT_NO_THROW(sess.execute());
//  std::string temp = logger.getLog();
//  temp += "";
//  ASSERT_EQ("V12345", sess.getVid());
////  //TODO: only 4 files out of 10 should have been migrated to this small tape (we need to check this with the "m" bit)
////  for(auto i=remoteFilePaths.begin(); i!=remoteFilePaths.end(); i++) {
////    cta::RemotePath rpath(*i);
////    ASSERT_NO_THROW(ns.statFile(requester, rpath.getAfterScheme()));
////    std::unique_ptr<cta::ArchiveFileStatus> stat(ns.statFile(requester, rpath.getAfterScheme()));
////    ASSERT_NE((uint64_t)(stat.get()), NULL);
////    ASSERT_EQ(stat->mode, 0777);
////    ASSERT_EQ(stat->size, 1000);
////  }
//}

#undef TEST_MOCK_DB
#ifdef TEST_MOCK_DB
static cta::MockSchedulerDatabaseFactory mockDbFactory;
INSTANTIATE_TEST_CASE_P(MockSchedulerTest, SchedulerTest,
  ::testing::Values(SchedulerTestParam(mockDbFactory)));
#endif

#define TEST_VFS
#ifdef TEST_VFS
static cta::OStoreDBFactory<cta::objectstore::BackendVFS> OStoreDBFactoryVFS;

INSTANTIATE_TEST_CASE_P(OStoreDBPlusMockSchedulerTestVFS, DataTransferSessionTest,
  ::testing::Values(DataTransferSessionTestParam(OStoreDBFactoryVFS)));
#endif

#undef TEST_RADOS
#ifdef TEST_RADOS
static cta::OStoreDBFactory<cta::objectstore::BackendRados> OStoreDBFactoryRados("rados://tapetest@tapetest");

INSTANTIATE_TEST_CASE_P(OStoreDBPlusMockSchedulerTestRados, SchedulerTest,
  ::testing::Values(SchedulerTestParam(OStoreDBFactoryRados)));
#endif
1447

1448
} // namespace unitTest