Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
a65e2519
Commit
a65e2519
authored
9 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Added MockNameServer unit test for double copy tape files
parent
cd0f62f1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nameserver/mockNS/MockNameServerTest.cpp
+92
-21
92 additions, 21 deletions
nameserver/mockNS/MockNameServerTest.cpp
with
92 additions
and
21 deletions
nameserver/mockNS/MockNameServerTest.cpp
+
92
−
21
View file @
a65e2519
...
...
@@ -201,8 +201,8 @@ TEST_F(cta_MockNameServerTest, storageClass_inheritance) {
}
}
TEST_F
(
cta_MockNameServerTest
,
add
ing
_and_get
ting
_tapeFile
s
)
{
using
namespace
cta
;
TEST_F
(
cta_MockNameServerTest
,
add_and_get
_1
_tapeFile
)
{
using
namespace
cta
;
std
::
unique_ptr
<
MockNameServer
>
ns
;
ASSERT_NO_THROW
(
ns
.
reset
(
new
MockNameServer
()));
...
...
@@ -210,17 +210,61 @@ TEST_F(cta_MockNameServerTest, adding_and_getting_tapeFiles) {
const
std
::
string
archiveFileName
=
"file1"
;
const
std
::
string
archiveFilePath
=
std
::
string
(
"/"
)
+
archiveFileName
;
const
uint64_t
archiveFileSize
=
256
*
1024
;
const
std
::
string
vid
=
"V12345"
;
const
uint8_t
copyNb
=
1
;
const
uint64_t
fseq
=
1
;
const
Checksum
checksum
=
cta
::
Checksum
(
Checksum
::
CHECKSUMTYPE_ADLER32
,
ByteArray
((
uint32_t
)
0x11223344
));
// Create a file entry in the archive namespace
ASSERT_NO_THROW
(
ns
->
setOwner
(
s_adminOnAdminHost
,
"/"
,
s_user
));
ASSERT_NO_THROW
(
ns
->
createFile
(
s_userOnUserHost
,
"/file1"
,
0666
,
archiveFileSize
));
{
ArchiveDirIterator
itor
;
ASSERT_NO_THROW
(
itor
=
ns
->
getDirContents
(
s_userOnUserHost
,
"/"
));
ASSERT_EQ
(
itor
.
hasMore
(),
true
);
ASSERT_EQ
(
itor
.
next
().
name
,
archiveFileName
);
ASSERT_EQ
(
itor
.
hasMore
(),
false
);
}
// Add a tape file entry to the file entry in the archive namespace
NameServerTapeFile
tapeFile1
;
tapeFile1
.
copyNb
=
1
;
tapeFile1
.
tapeFileLocation
.
fSeq
=
1
;
// block 0: VOL
// block 1: HDR1
// block 2: HDR2
// block 3: UHL1
// block 4: File mark
// block 5: First block of user file
const
uint64_t
blockId
=
5
;
const
uint32_t
adlerChecksum
=
0x11223344
;
tapeFile1
.
tapeFileLocation
.
blockId
=
5
;
tapeFile1
.
tapeFileLocation
.
vid
=
"V12345"
;
tapeFile1
.
tapeFileLocation
.
copyNb
=
1
;
tapeFile1
.
size
=
archiveFileSize
;
tapeFile1
.
compressedSize
=
archiveFileSize
;
// No compression
tapeFile1
.
checksum
=
checksum
;
ASSERT_NO_THROW
(
ns
->
addTapeFile
(
s_userOnUserHost
,
archiveFilePath
,
tapeFile1
));
// Get back the tape file entry
std
::
list
<
NameServerTapeFile
>
tapeFiles
;
ASSERT_NO_THROW
(
tapeFiles
=
ns
->
getTapeFiles
(
s_userOnUserHost
,
archiveFilePath
));
ASSERT_EQ
(
1
,
tapeFiles
.
size
());
ASSERT_TRUE
(
tapeFile1
==
tapeFiles
.
front
());
}
TEST_F
(
cta_MockNameServerTest
,
add_and_get_2_tapeFiles
)
{
using
namespace
cta
;
std
::
unique_ptr
<
MockNameServer
>
ns
;
ASSERT_NO_THROW
(
ns
.
reset
(
new
MockNameServer
()));
const
std
::
string
archiveFileName
=
"file1"
;
const
std
::
string
archiveFilePath
=
std
::
string
(
"/"
)
+
archiveFileName
;
const
uint64_t
archiveFileSize
=
256
*
1024
;
const
Checksum
checksum
=
cta
::
Checksum
(
Checksum
::
CHECKSUMTYPE_ADLER32
,
ByteArray
((
uint32_t
)
0x11223344
));
// Create a file entry in the archive namespace
ASSERT_NO_THROW
(
ns
->
setOwner
(
s_adminOnAdminHost
,
"/"
,
s_user
));
...
...
@@ -235,28 +279,55 @@ TEST_F(cta_MockNameServerTest, adding_and_getting_tapeFiles) {
}
// Add a tape file entry to the file entry in the archive namespace
NameServerTapeFile
tapeFile
;
tapeFile
.
copyNb
=
copyNb
;
tapeFile
.
tapeFileLocation
.
fSeq
=
fseq
;
tapeFile
.
tapeFileLocation
.
blockId
=
blockId
;
tapeFile
.
tapeFileLocation
.
vid
=
vid
;
tapeFile
.
tapeFileLocation
.
copyNb
=
copyNb
;
tapeFile
.
size
=
archiveFileSize
;
tapeFile
.
compressedSize
=
archiveFileSize
;
// No compression
cta
::
Checksum
tapeFileChecksum
(
Checksum
::
CHECKSUMTYPE_ADLER32
,
cta
::
ByteArray
(
adlerChecksum
));
tapeFile
.
checksum
=
tapeFileChecksum
;
NameServerTapeFile
tapeFile1
;
tapeFile1
.
copyNb
=
1
;
tapeFile1
.
tapeFileLocation
.
fSeq
=
1
;
// block 0: VOL
// block 1: HDR1
// block 2: HDR2
// block 3: UHL1
// block 4: File mark
// block 5: First block of user file
tapeFile1
.
tapeFileLocation
.
blockId
=
5
;
tapeFile1
.
tapeFileLocation
.
vid
=
"V12345"
;
tapeFile1
.
tapeFileLocation
.
copyNb
=
1
;
tapeFile1
.
size
=
archiveFileSize
;
tapeFile1
.
compressedSize
=
archiveFileSize
;
// No compression
tapeFile1
.
checksum
=
checksum
;
ASSERT_NO_THROW
(
ns
->
addTapeFile
(
s_userOnUserHost
,
archiveFilePath
,
tapeFile1
));
// Add another tape file entry to the file entry in the archive namespace
NameServerTapeFile
tapeFile2
;
tapeFile2
.
copyNb
=
2
;
tapeFile2
.
tapeFileLocation
.
fSeq
=
1
;
// block 0: VOL
// block 1: HDR1
// block 2: HDR2
// block 3: UHL1
// block 4: File mark
// block 5: First block of user file
tapeFile2
.
tapeFileLocation
.
blockId
=
5
;
tapeFile2
.
tapeFileLocation
.
vid
=
"V67890"
;
tapeFile2
.
tapeFileLocation
.
copyNb
=
2
;
tapeFile2
.
size
=
archiveFileSize
;
tapeFile2
.
compressedSize
=
archiveFileSize
;
// No compression
tapeFile2
.
checksum
=
checksum
;
ASSERT_NO_THROW
(
ns
->
addTapeFile
(
s_userOnUserHost
,
archiveFilePath
,
tapeFile
));
tapeFile
2
));
// Get back the tape file entry
std
::
list
<
NameServerTapeFile
>
tapeFiles
;
ASSERT_NO_THROW
(
tapeFiles
=
ns
->
getTapeFiles
(
s_userOnUserHost
,
archiveFilePath
));
ASSERT_EQ
(
1
,
tapeFiles
.
size
());
ASSERT_TRUE
(
tapeFile
==
tapeFiles
.
front
());
ASSERT_EQ
(
2
,
tapeFiles
.
size
());
ASSERT_TRUE
(
tapeFile1
==
tapeFiles
.
front
());
tapeFiles
.
pop_front
();
ASSERT_TRUE
(
tapeFile2
==
tapeFiles
.
front
());
}
}
// namespace unitTests
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment