Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
eabec107
Commit
eabec107
authored
Jun 26, 2015
by
Eric Cano
Browse files
Created basic unit test for objectstore::ArchiveToFileRequest
parent
4bb73f9a
Changes
5
Hide whitespace changes
Inline
Side-by-side
objectstore/ArchiveToFileRequest.cpp
View file @
eabec107
...
...
@@ -57,23 +57,42 @@ void cta::objectstore::ArchiveToFileRequest::setArchiveFile(
m_payload
.
set_archivefile
(
archiveFile
);
}
std
::
string
cta
::
objectstore
::
ArchiveToFileRequest
::
getArchiveFile
()
{
checkPayloadReadable
();
return
m_payload
.
archivefile
();
}
void
cta
::
objectstore
::
ArchiveToFileRequest
::
setRemoteFile
(
const
std
::
string
&
remoteFile
)
{
check
HeaderRead
able
();
check
PayloadWrit
able
();
m_payload
.
set_remotefile
(
remoteFile
);
}
std
::
string
cta
::
objectstore
::
ArchiveToFileRequest
::
getRemoteFile
()
{
checkPayloadReadable
();
return
m_payload
.
remotefile
();
}
void
cta
::
objectstore
::
ArchiveToFileRequest
::
setPriority
(
uint64_t
priority
)
{
checkPayloadWritable
();
m_payload
.
set_priority
(
priority
);
}
void
cta
::
objectstore
::
ArchiveToFileRequest
::
setLog
(
void
cta
::
objectstore
::
ArchiveToFileRequest
::
set
Creation
Log
(
const
objectstore
::
CreationLog
&
creationLog
)
{
checkPayload
Read
able
();
checkPayload
Writ
able
();
creationLog
.
serialize
(
*
m_payload
.
mutable_log
());
}
auto
cta
::
objectstore
::
ArchiveToFileRequest
::
getCreationLog
()
->
CreationLog
{
checkPayloadReadable
();
CreationLog
ret
;
ret
.
deserialize
(
m_payload
.
log
());
return
ret
;
}
void
cta
::
objectstore
::
ArchiveToFileRequest
::
setArchiveToDirRequestAddress
(
const
std
::
string
&
dirRequestAddress
)
{
checkPayloadWritable
();
...
...
@@ -94,7 +113,7 @@ auto cta::objectstore::ArchiveToFileRequest::dumpJobs() -> std::list<JobDump> {
}
uint64_t
cta
::
objectstore
::
ArchiveToFileRequest
::
getSize
()
{
checkPayload
Writ
able
();
checkPayload
Read
able
();
return
m_payload
.
size
();
}
...
...
@@ -104,4 +123,3 @@ void cta::objectstore::ArchiveToFileRequest::setSize(uint64_t size) {
}
objectstore/ArchiveToFileRequest.hpp
View file @
eabec107
...
...
@@ -41,7 +41,8 @@ public:
void
setRemoteFile
(
const
std
::
string
&
remoteFile
);
std
::
string
getRemoteFile
();
void
setPriority
(
uint64_t
priority
);
void
setLog
(
const
objectstore
::
CreationLog
&
creationLog
);
void
setCreationLog
(
const
objectstore
::
CreationLog
&
creationLog
);
CreationLog
getCreationLog
();
void
setArchiveToDirRequestAddress
(
const
std
::
string
&
dirRequestAddress
);
void
setSize
(
uint64_t
size
);
uint64_t
getSize
();
...
...
objectstore/ArchiveToFileRequestTest.cpp
View file @
eabec107
...
...
@@ -20,6 +20,8 @@
#include
"ArchiveToFileRequest.hpp"
#include
"BackendVFS.hpp"
#include
"Agent.hpp"
#include
"CreationLog.hpp"
#include
"UserIdentity.hpp"
namespace
unitTests
{
...
...
@@ -27,6 +29,7 @@ TEST(ObjectStore, ArchiveToFileRequestBasicAccess) {
cta
::
objectstore
::
BackendVFS
be
;
cta
::
objectstore
::
Agent
agent
(
be
);
agent
.
generateName
(
"unitTest"
);
time_t
now
;
std
::
string
tapeAddress
=
agent
.
nextId
(
"ArchiveToFileRequest"
);
{
// Try to create the ArchiveToFileRequest entry
...
...
@@ -35,8 +38,8 @@ TEST(ObjectStore, ArchiveToFileRequestBasicAccess) {
atfr
.
setArchiveFile
(
"cta://dir/file"
);
atfr
.
setRemoteFile
(
"eos://dir2/file2"
);
atfr
.
setSize
(
12345678
);
atfr
.
setLog
(
cta
::
CreationLog
(
cta
::
UserIdentity
(
123
,
456
),
"testHost"
,
time
(
NULL
),
"Comment"
));
atfr
.
set
Creation
Log
(
cta
::
CreationLog
(
cta
::
UserIdentity
(
123
,
456
),
"testHost"
,
now
=
time
(
NULL
),
"Comment"
));
atfr
.
setPriority
(
12
);
atfr
.
insert
();
}
...
...
@@ -45,7 +48,15 @@ TEST(ObjectStore, ArchiveToFileRequestBasicAccess) {
cta
::
objectstore
::
ArchiveToFileRequest
atfr
(
tapeAddress
,
be
);
cta
::
objectstore
::
ScopedSharedLock
atfrl
(
atfr
);
atfr
.
fetch
();
ASSERT_EQ
(
"cta://dir/file"
,
atfr
.
getARchiveFile
());
ASSERT_EQ
(
"cta://dir/file"
,
atfr
.
getArchiveFile
());
ASSERT_EQ
(
"eos://dir2/file2"
,
atfr
.
getRemoteFile
());
ASSERT_EQ
(
12345678
,
atfr
.
getSize
());
cta
::
objectstore
::
CreationLog
log
(
atfr
.
getCreationLog
());
ASSERT_EQ
(
123
,
log
.
user
.
uid
);
ASSERT_EQ
(
456
,
log
.
user
.
gid
);
ASSERT_EQ
(
"testHost"
,
log
.
host
);
ASSERT_EQ
(
now
,
log
.
time
);
ASSERT_EQ
(
"Comment"
,
log
.
comment
);
}
}
...
...
objectstore/CMakeLists.txt
View file @
eabec107
...
...
@@ -34,6 +34,7 @@ set(ObjectStoreUnitTests
RootEntryTest.cpp
TapeTest.cpp
GarbageCollectorTest.cpp
ArchiveToFileRequestTest.cpp
)
add_library
(
ctaobjectstoreunittests SHARED
${
ObjectStoreUnitTests
}
)
...
...
scheduler/OStoreDB/OStoreDB.cpp
View file @
eabec107
...
...
@@ -409,7 +409,7 @@ void OStoreDB::queue(const cta::ArchiveToFileRequest& rqst) {
atfr
.
setArchiveFile
(
rqst
.
getArchiveFile
());
atfr
.
setRemoteFile
(
rqst
.
getRemoteFile
());
atfr
.
setPriority
(
rqst
.
getPriority
());
atfr
.
setLog
(
rqst
.
getCreationLog
());
atfr
.
set
Creation
Log
(
rqst
.
getCreationLog
());
// We will need to identity tapepools is order to construct the request
RootEntry
re
(
m_objectStore
);
ScopedSharedLock
rel
(
re
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment