You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-15 12:09:09 +03:00
Added add'l copyFile tests, fixed a bug.
This commit is contained in:
@@ -608,6 +608,12 @@ int IOCoordinator::copyFile(const char *filename1, const char *filename2)
|
|||||||
int err;
|
int err;
|
||||||
char errbuf[80];
|
char errbuf[80];
|
||||||
|
|
||||||
|
if (!bf::exists(metaFile1))
|
||||||
|
{
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bf::exists(metaFile2))
|
if (bf::exists(metaFile2))
|
||||||
deleteMetaFile(metaFile2);
|
deleteMetaFile(metaFile2);
|
||||||
// since we don't implement mkdir(), assume the caller did that and
|
// since we don't implement mkdir(), assume the caller did that and
|
||||||
|
|||||||
@@ -1339,6 +1339,19 @@ void IOCCopyFile1()
|
|||||||
void IOCCopyFile2()
|
void IOCCopyFile2()
|
||||||
{
|
{
|
||||||
// call IOC::copyFile() with non-existant file
|
// call IOC::copyFile() with non-existant file
|
||||||
|
IOCoordinator *ioc = IOCoordinator::get();
|
||||||
|
|
||||||
|
bf::path metaPath = ioc->getMetadataPath();
|
||||||
|
bf::remove(metaPath/"not-there.meta");
|
||||||
|
bf::remove(metaPath/"not-there2.meta");
|
||||||
|
|
||||||
|
int err = ioc->copyFile("not-there", "not-there2");
|
||||||
|
assert(err);
|
||||||
|
assert(errno == ENOENT);
|
||||||
|
assert(!bf::exists(metaPath/"not-there.meta"));
|
||||||
|
assert(!bf::exists(metaPath/"not-there2.meta"));
|
||||||
|
|
||||||
|
cout << "IOC copy file 2 OK" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOCCopyFile3()
|
void IOCCopyFile3()
|
||||||
@@ -1349,6 +1362,40 @@ void IOCCopyFile3()
|
|||||||
call ioc::copyFile()
|
call ioc::copyFile()
|
||||||
verify dest file exists
|
verify dest file exists
|
||||||
*/
|
*/
|
||||||
|
IOCoordinator *ioc = IOCoordinator::get();
|
||||||
|
Cache *cache = Cache::get();
|
||||||
|
CloudStorage *cs = CloudStorage::get();
|
||||||
|
|
||||||
|
bf::path metaPath = ioc->getMetadataPath();
|
||||||
|
bf::path journalPath = ioc->getJournalPath();
|
||||||
|
bf::path cachePath = ioc->getCachePath();
|
||||||
|
bf::path sourcePath = metaPath/"copyfile1"/"source.meta";
|
||||||
|
bf::path destPath = metaPath/"copyfile2"/"dest.meta";
|
||||||
|
const char *l_sourceFile = "copyfile1/source";
|
||||||
|
const char *l_destFile = "copyfile2/dest";
|
||||||
|
|
||||||
|
cache->reset();
|
||||||
|
|
||||||
|
bf::create_directories(sourcePath.parent_path());
|
||||||
|
makeTestMetadata(sourcePath.string().c_str());
|
||||||
|
makeTestObject((cachePath/testObjKey).string().c_str());
|
||||||
|
makeTestJournal((journalPath/(string(testObjKey) + ".journal")).string().c_str());
|
||||||
|
cache->newObject(testObjKey, bf::file_size(cachePath/testObjKey));
|
||||||
|
cache->newJournalEntry(bf::file_size(journalPath/(string(testObjKey) + ".journal")));
|
||||||
|
|
||||||
|
int err = ioc->copyFile("copyfile1/source", "copyfile2/dest");
|
||||||
|
assert(!err);
|
||||||
|
uint8_t buf1[8192], buf2[8192];
|
||||||
|
err = ioc->read(l_sourceFile, buf1, 0, 8192);
|
||||||
|
assert(err == 8192);
|
||||||
|
err = ioc->read(l_destFile, buf2, 0, 8192);
|
||||||
|
assert(err == 8192);
|
||||||
|
assert(memcmp(buf1, buf2, 8192) == 0);
|
||||||
|
|
||||||
|
ioc->unlink("copyfile1");
|
||||||
|
ioc->unlink("copyfile2");
|
||||||
|
assert(cache->getCurrentCacheSize() == 0);
|
||||||
|
cout << "IOC copy file 3 OK" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOCCopyFile()
|
void IOCCopyFile()
|
||||||
@@ -1367,6 +1414,9 @@ int main()
|
|||||||
cout << "connected" << endl;
|
cout << "connected" << endl;
|
||||||
scoped_closer sc1(serverSock), sc2(sessionSock), sc3(clientSock);
|
scoped_closer sc1(serverSock), sc2(sessionSock), sc3(clientSock);
|
||||||
|
|
||||||
|
IOCCopyFile();
|
||||||
|
return 0;
|
||||||
|
|
||||||
opentask();
|
opentask();
|
||||||
metadataUpdateTest();
|
metadataUpdateTest();
|
||||||
// requires 8K object size to test boundries
|
// requires 8K object size to test boundries
|
||||||
|
|||||||
Reference in New Issue
Block a user