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
82875816
Commit
82875816
authored
Jun 24, 2016
by
Steven Murray
Browse files
Improved catalogue::getTapes() unittest
parent
e04c8a2a
Changes
4
Hide whitespace changes
Inline
Side-by-side
catalogue/InMemoryCatalogueTest.cpp
View file @
82875816
...
@@ -1011,6 +1011,133 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, createTape_same_twice) {
...
@@ -1011,6 +1011,133 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, createTape_same_twice) {
comment
),
catalogue
::
UserError
);
comment
),
catalogue
::
UserError
);
}
}
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
createTape_many_tapes
)
{
using
namespace
cta
;
const
std
::
string
logicalLibrary
=
"logical_library_name"
;
const
std
::
string
tapePool
=
"tape_pool_name"
;
const
std
::
string
encryptionKey
=
"encryption_key"
;
const
uint64_t
capacityInBytes
=
(
uint64_t
)
10
*
1000
*
1000
*
1000
*
1000
;
const
bool
disabled
=
true
;
const
bool
full
=
false
;
const
std
::
string
comment
=
"create tape"
;
ASSERT_TRUE
(
m_catalogue
->
getLogicalLibraries
().
empty
());
m_catalogue
->
createLogicalLibrary
(
m_cliSI
,
logicalLibrary
,
"create logical library"
);
ASSERT_TRUE
(
m_catalogue
->
getTapePools
().
empty
());
m_catalogue
->
createTapePool
(
m_cliSI
,
tapePool
,
2
,
true
,
"create tape pool"
);
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
const
uint64_t
nbTapes
=
10
;
for
(
uint64_t
i
=
1
;
i
<=
nbTapes
;
i
++
)
{
std
::
ostringstream
vid
;
vid
<<
"vid"
<<
i
;
m_catalogue
->
createTape
(
m_cliSI
,
vid
.
str
(),
logicalLibrary
,
tapePool
,
encryptionKey
,
capacityInBytes
,
disabled
,
full
,
comment
);
}
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
();
ASSERT_EQ
(
nbTapes
,
tapes
.
size
());
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
ASSERT_EQ
(
nbTapes
,
vidToTape
.
size
());
for
(
uint64_t
i
=
1
;
i
<=
nbTapes
;
i
++
)
{
std
::
ostringstream
vid
;
vid
<<
"vid"
<<
i
;
auto
vidAndTapeItor
=
vidToTape
.
find
(
vid
.
str
());
ASSERT_FALSE
(
vidToTape
.
end
()
==
vidAndTapeItor
);
const
common
::
dataStructures
::
Tape
tape
=
vidAndTapeItor
->
second
;
ASSERT_EQ
(
vid
.
str
(),
tape
.
vid
);
ASSERT_EQ
(
logicalLibrary
,
tape
.
logicalLibraryName
);
ASSERT_EQ
(
tapePool
,
tape
.
tapePoolName
);
ASSERT_EQ
(
encryptionKey
,
tape
.
encryptionKey
);
ASSERT_EQ
(
capacityInBytes
,
tape
.
capacityInBytes
);
ASSERT_TRUE
(
disabled
==
tape
.
disabled
);
ASSERT_TRUE
(
full
==
tape
.
full
);
ASSERT_EQ
(
comment
,
tape
.
comment
);
const
common
::
dataStructures
::
EntryLog
creationLog
=
tape
.
creationLog
;
ASSERT_EQ
(
m_cliSI
.
username
,
creationLog
.
username
);
ASSERT_EQ
(
m_cliSI
.
host
,
creationLog
.
host
);
const
common
::
dataStructures
::
EntryLog
lastModificationLog
=
tape
.
lastModificationLog
;
ASSERT_EQ
(
creationLog
,
lastModificationLog
);
}
{
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
vid
=
"vid1"
;
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
1
,
tapes
.
size
());
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
ASSERT_EQ
(
1
,
vidToTape
.
size
());
ASSERT_EQ
(
"vid1"
,
vidToTape
.
begin
()
->
first
);
ASSERT_EQ
(
"vid1"
,
vidToTape
.
begin
()
->
second
.
vid
);
}
{
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
logicalLibrary
=
logicalLibrary
;
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
nbTapes
,
tapes
.
size
());
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
ASSERT_EQ
(
nbTapes
,
vidToTape
.
size
());
ASSERT_EQ
(
logicalLibrary
,
vidToTape
.
begin
()
->
second
.
logicalLibraryName
);
}
{
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
tapePool
=
tapePool
;
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
nbTapes
,
tapes
.
size
());
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
ASSERT_EQ
(
nbTapes
,
vidToTape
.
size
());
ASSERT_EQ
(
tapePool
,
vidToTape
.
begin
()
->
second
.
tapePoolName
);
}
{
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
capacityInBytes
=
"10000000000000"
;
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
nbTapes
,
tapes
.
size
());
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
ASSERT_EQ
(
nbTapes
,
vidToTape
.
size
());
ASSERT_EQ
(
capacityInBytes
,
vidToTape
.
begin
()
->
second
.
capacityInBytes
);
}
{
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
disabled
=
"true"
;
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
nbTapes
,
tapes
.
size
());
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
ASSERT_EQ
(
nbTapes
,
vidToTape
.
size
());
ASSERT_TRUE
(
vidToTape
.
begin
()
->
second
.
disabled
);
}
{
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
full
=
"false"
;
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
nbTapes
,
tapes
.
size
());
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
ASSERT_EQ
(
nbTapes
,
vidToTape
.
size
());
ASSERT_FALSE
(
vidToTape
.
begin
()
->
second
.
full
);
}
{
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
vid
=
"non_existant_vid"
;
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_TRUE
(
tapes
.
empty
());
}
}
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
deleteTape
)
{
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
deleteTape
)
{
using
namespace
cta
;
using
namespace
cta
;
...
...
catalogue/RdbmsCatalogue.cpp
View file @
82875816
...
@@ -1266,9 +1266,9 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
...
@@ -1266,9 +1266,9 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
searchCriteria
.
logicalLibrary
.
empty
()
&&
searchCriteria
.
logicalLibrary
.
empty
()
&&
searchCriteria
.
tapePool
.
empty
()
&&
searchCriteria
.
tapePool
.
empty
()
&&
searchCriteria
.
capacityInBytes
.
empty
()
&&
searchCriteria
.
capacityInBytes
.
empty
()
&&
searchCriteria
.
isD
isabled
.
empty
()
&&
searchCriteria
.
d
isabled
.
empty
()
&&
searchCriteria
.
isF
ull
.
empty
()
&&
searchCriteria
.
f
ull
.
empty
()
&&
searchCriteria
.
lbp
IsOn
.
empty
()))
{
searchCriteria
.
lbp
.
empty
()))
{
sql
+=
" WHERE "
;
sql
+=
" WHERE "
;
}
}
...
@@ -1295,21 +1295,21 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
...
@@ -1295,21 +1295,21 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
if
(
addedAWhereConstraint
)
sql
+=
" AND "
;
if
(
addedAWhereConstraint
)
sql
+=
" AND "
;
sql
+=
" CAPACITY_IN_BYTES = :CAPACITY_IN_BYTES"
;
sql
+=
" CAPACITY_IN_BYTES = :CAPACITY_IN_BYTES"
;
}
}
if
(
!
searchCriteria
.
isD
isabled
.
empty
())
{
if
(
!
searchCriteria
.
d
isabled
.
empty
())
{
if
(
!
isValidBool
(
searchCriteria
.
isD
isabled
))
{
if
(
!
isValidBool
(
searchCriteria
.
d
isabled
))
{
throw
UserError
(
"Disabled tapes search criterion "
+
searchCriteria
.
isD
isabled
+
" is not a valid boolean"
);
throw
UserError
(
"Disabled tapes search criterion "
+
searchCriteria
.
d
isabled
+
" is not a valid boolean"
);
}
}
sql
+=
" IS_DISABLED = :IS_DISABLED"
;
sql
+=
" IS_DISABLED = :IS_DISABLED"
;
}
}
if
(
!
searchCriteria
.
isF
ull
.
empty
())
{
if
(
!
searchCriteria
.
f
ull
.
empty
())
{
if
(
!
isValidBool
(
searchCriteria
.
isF
ull
))
{
if
(
!
isValidBool
(
searchCriteria
.
f
ull
))
{
throw
UserError
(
"Full tapes search criterion "
+
searchCriteria
.
isF
ull
+
" is not a valid boolean"
);
throw
UserError
(
"Full tapes search criterion "
+
searchCriteria
.
f
ull
+
" is not a valid boolean"
);
}
}
sql
+=
" IS_FULL = :IS_FULL"
;
sql
+=
" IS_FULL = :IS_FULL"
;
}
}
if
(
!
searchCriteria
.
lbp
IsOn
.
empty
())
{
if
(
!
searchCriteria
.
lbp
.
empty
())
{
if
(
!
isValidBool
(
searchCriteria
.
lbp
IsOn
))
{
if
(
!
isValidBool
(
searchCriteria
.
lbp
))
{
throw
UserError
(
"LBP search criterion "
+
searchCriteria
.
lbp
IsOn
+
" is not a valid boolean"
);
throw
UserError
(
"LBP search criterion "
+
searchCriteria
.
lbp
+
" is not a valid boolean"
);
}
}
sql
+=
" LBP_IS_ON = :LBP_IS_ON"
;
sql
+=
" LBP_IS_ON = :LBP_IS_ON"
;
}
}
...
@@ -1321,10 +1321,9 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
...
@@ -1321,10 +1321,9 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
if
(
!
searchCriteria
.
tapePool
.
empty
())
stmt
->
bindString
(
":TAPE_POOL_NAME"
,
searchCriteria
.
tapePool
);
if
(
!
searchCriteria
.
tapePool
.
empty
())
stmt
->
bindString
(
":TAPE_POOL_NAME"
,
searchCriteria
.
tapePool
);
if
(
!
searchCriteria
.
capacityInBytes
.
empty
())
stmt
->
bindUint64
(
":CAPACITY_IN_BYTES"
,
if
(
!
searchCriteria
.
capacityInBytes
.
empty
())
stmt
->
bindUint64
(
":CAPACITY_IN_BYTES"
,
utils
::
toUint64
(
searchCriteria
.
capacityInBytes
));
utils
::
toUint64
(
searchCriteria
.
capacityInBytes
));
if
(
!
searchCriteria
.
isDisabled
.
empty
())
stmt
->
bindUint64
(
":IS_DISABLED"
,
if
(
!
searchCriteria
.
disabled
.
empty
())
stmt
->
bindUint64
(
":IS_DISABLED"
,
toUpper
(
searchCriteria
.
disabled
)
==
"TRUE"
);
toUpper
(
searchCriteria
.
isDisabled
)
==
"TRUE"
);
if
(
!
searchCriteria
.
full
.
empty
())
stmt
->
bindUint64
(
":IS_FULL"
,
toUpper
(
searchCriteria
.
full
)
==
"TRUE"
);
if
(
!
searchCriteria
.
isFull
.
empty
())
stmt
->
bindUint64
(
":IS_FULL"
,
toUpper
(
searchCriteria
.
isFull
)
==
"TRUE"
);
if
(
!
searchCriteria
.
lbp
.
empty
())
stmt
->
bindUint64
(
":LBP_IS_ON"
,
toUpper
(
searchCriteria
.
lbp
)
==
"TRUE"
);
if
(
!
searchCriteria
.
lbpIsOn
.
empty
())
stmt
->
bindUint64
(
":LBP_IS_ON"
,
toUpper
(
searchCriteria
.
lbpIsOn
)
==
"TRUE"
);
std
::
unique_ptr
<
DbRset
>
rset
(
stmt
->
executeQuery
());
std
::
unique_ptr
<
DbRset
>
rset
(
stmt
->
executeQuery
());
while
(
rset
->
next
())
{
while
(
rset
->
next
())
{
...
...
catalogue/TapeSearchCriteria.hpp
View file @
82875816
...
@@ -57,17 +57,17 @@ struct TapeSearchCriteria {
...
@@ -57,17 +57,17 @@ struct TapeSearchCriteria {
/**
/**
* Set to true if searching for disabled tapes.
* Set to true if searching for disabled tapes.
*/
*/
std
::
string
isD
isabled
;
std
::
string
d
isabled
;
/**
/**
* Set to true if searching for full tapes.
* Set to true if searching for full tapes.
*/
*/
std
::
string
isF
ull
;
std
::
string
f
ull
;
/**
/**
* Set to true if searching for tapes with logical block protection enabled.
* Set to true if searching for tapes with logical block protection enabled.
*/
*/
std
::
string
lbp
IsOn
;
std
::
string
lbp
;
};
// struct TapeSearchCriteria
};
// struct TapeSearchCriteria
...
...
xroot_plugins/XrdCtaFile.cpp
View file @
82875816
...
@@ -880,22 +880,22 @@ int XrdCtaFile::xCom_tape() {
...
@@ -880,22 +880,22 @@ int XrdCtaFile::xCom_tape() {
}
}
cta
::
catalogue
::
TapeSearchCriteria
searchCriteria
;
cta
::
catalogue
::
TapeSearchCriteria
searchCriteria
;
if
(
hasOption
(
"-e"
,
"--enabled"
))
{
if
(
hasOption
(
"-e"
,
"--enabled"
))
{
searchCriteria
.
isD
isabled
=
"false"
;
searchCriteria
.
d
isabled
=
"false"
;
}
}
if
(
hasOption
(
"-d"
,
"--disabled"
))
{
if
(
hasOption
(
"-d"
,
"--disabled"
))
{
searchCriteria
.
isD
isabled
=
"true"
;
searchCriteria
.
d
isabled
=
"true"
;
}
}
if
(
hasOption
(
"-f"
,
"--free"
))
{
if
(
hasOption
(
"-f"
,
"--free"
))
{
searchCriteria
.
isF
ull
=
"false"
;
searchCriteria
.
f
ull
=
"false"
;
}
}
if
(
hasOption
(
"-F"
,
"--full"
))
{
if
(
hasOption
(
"-F"
,
"--full"
))
{
searchCriteria
.
isF
ull
=
"true"
;
searchCriteria
.
f
ull
=
"true"
;
}
}
if
(
hasOption
(
"-p"
,
"--lbp"
))
{
if
(
hasOption
(
"-p"
,
"--lbp"
))
{
searchCriteria
.
lbp
IsOn
=
"true"
;
searchCriteria
.
lbp
=
"true"
;
}
}
if
(
hasOption
(
"-P"
,
"--nolbp"
))
{
if
(
hasOption
(
"-P"
,
"--nolbp"
))
{
searchCriteria
.
lbp
IsOn
=
"false"
;
searchCriteria
.
lbp
=
"false"
;
}
}
std
::
list
<
cta
::
common
::
dataStructures
::
Tape
>
list
=
m_catalogue
->
getTapes
(
searchCriteria
);
std
::
list
<
cta
::
common
::
dataStructures
::
Tape
>
list
=
m_catalogue
->
getTapes
(
searchCriteria
);
if
(
list
.
size
()
>
0
)
{
if
(
list
.
size
()
>
0
)
{
...
...
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