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
a98e0fbc
Commit
a98e0fbc
authored
8 years ago
by
Eric Cano
Browse files
Options
Downloads
Patches
Plain Diff
Added a unit test in an attempt to reproduce the problem of #46.
parent
e2c46b75
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scheduler/SchedulerDatabaseTest.cpp
+114
-0
114 additions, 0 deletions
scheduler/SchedulerDatabaseTest.cpp
with
114 additions
and
0 deletions
scheduler/SchedulerDatabaseTest.cpp
+
114
−
0
View file @
a98e0fbc
...
...
@@ -29,6 +29,7 @@
#include
<exception>
#include
<gtest/gtest.h>
#include
<algorithm>
#include
<uuid/uuid.h>
namespace
unitTests
{
...
...
@@ -124,6 +125,119 @@ const cta::common::dataStructures::SecurityIdentity SchedulerDatabaseTest::s_adm
const
cta
::
common
::
dataStructures
::
SecurityIdentity
SchedulerDatabaseTest
::
s_userOnAdminHost
(
SchedulerDatabaseTest
::
s_user
,
SchedulerDatabaseTest
::
s_adminHost
);
const
cta
::
common
::
dataStructures
::
SecurityIdentity
SchedulerDatabaseTest
::
s_userOnUserHost
(
SchedulerDatabaseTest
::
s_user
,
SchedulerDatabaseTest
::
s_userHost
);
// unit test is disabled as it is pretty long to run.
TEST_P
(
SchedulerDatabaseTest
,
DISABLED_createManyArchiveJobs
)
{
using
namespace
cta
;
SchedulerDatabase
&
db
=
getDb
();
// Inject 1000 archive jobs to the db.
cta
::
common
::
dataStructures
::
ArchiveFileQueueCriteria
afqc
;
afqc
.
copyToPoolMap
.
insert
({
1
,
"tapePool"
});
afqc
.
fileId
=
0
;
afqc
.
mountPolicy
.
name
=
"mountPolicy"
;
afqc
.
mountPolicy
.
archivePriority
=
1
;
afqc
.
mountPolicy
.
archiveMinRequestAge
=
0
;
afqc
.
mountPolicy
.
retrievePriority
=
1
;
afqc
.
mountPolicy
.
retrieveMinRequestAge
=
0
;
afqc
.
mountPolicy
.
maxDrivesAllowed
=
10
;
afqc
.
mountPolicy
.
creationLog
=
{
"u"
,
"h"
,
time
(
nullptr
)};
afqc
.
mountPolicy
.
lastModificationLog
=
{
"u"
,
"h"
,
time
(
nullptr
)};
afqc
.
mountPolicy
.
comment
=
"comment"
;
const
size_t
filesToDo
=
100
;
for
(
size_t
i
=
0
;
i
<
filesToDo
;
i
++
)
{
cta
::
common
::
dataStructures
::
ArchiveRequest
ar
;
ar
.
archiveReportURL
=
""
;
ar
.
checksumType
=
""
;
ar
.
creationLog
=
{
"user"
,
"host"
,
time
(
nullptr
)};
uuid_t
fileUUID
;
uuid_generate
(
fileUUID
);
char
fileUUIDStr
[
37
];
uuid_unparse
(
fileUUID
,
fileUUIDStr
);
ar
.
diskFileID
=
fileUUIDStr
;
ar
.
diskFileInfo
.
path
=
std
::
string
(
"/uuid/"
)
+
fileUUIDStr
;
ar
.
diskFileInfo
.
owner
=
"user"
;
ar
.
diskFileInfo
.
group
=
"group"
;
// Attempt to create a no valid UTF8 string.
ar
.
diskFileInfo
.
recoveryBlob
=
std
::
string
(
"recoveryBlob"
)
+
"
\xc3\xb1
"
;
ar
.
fileSize
=
1000
;
ar
.
requester
=
{
"user"
,
"group"
};
ar
.
srcURL
=
std
::
string
(
"root:/"
)
+
ar
.
diskFileInfo
.
path
;
ar
.
storageClass
=
"storageClass"
;
afqc
.
fileId
=
i
;
db
.
queueArchive
(
"eosInstance"
,
ar
,
afqc
);
}
// Then load all archive jobs into memory
// Create mount.
auto
moutInfo
=
db
.
getMountInfo
();
cta
::
catalogue
::
TapeForWriting
tfw
;
tfw
.
tapePool
=
"tapePool"
;
tfw
.
vid
=
"vid"
;
auto
am
=
moutInfo
->
createArchiveMount
(
tfw
,
"drive"
,
"library"
,
"host"
,
time
(
nullptr
));
bool
done
=
false
;
size_t
count
=
0
;
while
(
!
done
)
{
auto
aj
=
am
->
getNextJob
();
if
(
aj
.
get
())
{
count
++
;
//std::cout << aj->archiveFile.diskFileInfo.path << std::endl;
aj
->
succeed
();
}
else
done
=
true
;
}
ASSERT_EQ
(
filesToDo
,
count
);
am
->
complete
(
time
(
nullptr
));
am
.
reset
(
nullptr
);
moutInfo
.
reset
(
nullptr
);
const
size_t
filesToDo2
=
1000
;
for
(
size_t
i
=
0
;
i
<
filesToDo2
;
i
++
)
{
cta
::
common
::
dataStructures
::
ArchiveRequest
ar
;
ar
.
archiveReportURL
=
""
;
ar
.
checksumType
=
""
;
ar
.
creationLog
=
{
"user"
,
"host"
,
time
(
nullptr
)};
uuid_t
fileUUID
;
uuid_generate
(
fileUUID
);
char
fileUUIDStr
[
37
];
uuid_unparse
(
fileUUID
,
fileUUIDStr
);
ar
.
diskFileID
=
fileUUIDStr
;
ar
.
diskFileInfo
.
path
=
std
::
string
(
"/uuid/"
)
+
fileUUIDStr
;
ar
.
diskFileInfo
.
owner
=
"user"
;
ar
.
diskFileInfo
.
group
=
"group"
;
// Attempt to create a no valid UTF8 string.
ar
.
diskFileInfo
.
recoveryBlob
=
std
::
string
(
"recoveryBlob"
)
+
"
\xc3\xb1
"
;
ar
.
fileSize
=
1000
;
ar
.
requester
=
{
"user"
,
"group"
};
ar
.
srcURL
=
std
::
string
(
"root:/"
)
+
ar
.
diskFileInfo
.
path
;
ar
.
storageClass
=
"storageClass"
;
afqc
.
fileId
=
i
;
db
.
queueArchive
(
"eosInstance"
,
ar
,
afqc
);
}
// Then load all archive jobs into memory (2nd pass)
// Create mount.
moutInfo
=
db
.
getMountInfo
();
am
=
moutInfo
->
createArchiveMount
(
tfw
,
"drive"
,
"library"
,
"host"
,
time
(
nullptr
));
done
=
false
;
count
=
0
;
while
(
!
done
)
{
auto
aj
=
am
->
getNextJob
();
if
(
aj
.
get
())
{
count
++
;
//std::cout << aj->archiveFile.diskFileInfo.path << std::endl;
aj
->
succeed
();
}
else
done
=
true
;
}
ASSERT_EQ
(
filesToDo2
,
count
);
am
->
complete
(
time
(
nullptr
));
am
.
reset
(
nullptr
);
moutInfo
.
reset
(
nullptr
);
}
#undef TEST_MOCK_DB
#ifdef TEST_MOCK_DB
static
cta
::
MockSchedulerDatabaseFactory
mockDbFactory
;
...
...
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