Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
HEP
HEPnOS
Commits
70c35581
Commit
70c35581
authored
Feb 21, 2020
by
Matthieu Dorier
Browse files
improved tests for async engine
parent
24dc1b19
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/DataStoreImpl.hpp
View file @
70c35581
...
...
@@ -320,55 +320,7 @@ class DataStoreImpl {
}
return
key
;
}
#if 0
void storeMultiple(unsigned long db_index,
const std::vector<std::string>& keys,
const std::vector<std::string>& values) {
// Create the product id
const auto& db = m_databases.dbs[db_index];
try {
db.put_multi(keys, values);
} catch(sdskv::exception& ex) {
throw Exception("Error occured when calling sdskv::database::put (SDSKV error=" +std::to_string(ex.error()) + ")");
}
}
size_t nextKeys(uint8_t level, const std::string& containerName,
const std::string& lower,
std::vector<std::string>& keys, size_t maxKeys) const {
int ret;
if(level == 0) return 0; // cannot iterate at object level
// hash the name to get the provider id
long unsigned db_idx = 0;
uint64_t h = hashString(containerName);
ch_placement_find_closest(m_databases.chi, h, 1, &db_idx);
// make an entry for the lower bound
auto lb_entry = buildKey(level, containerName, lower);
// get provider and database
const auto& db = m_databases.dbs[db_idx];
// ignore keys that don't have the same level or the same prefix
std::string prefix(2+containerName.size(), '\0');
prefix[0] = level;
if(containerName.size() != 0) {
std::memcpy(&prefix[1], containerName.data(), containerName.size());
prefix[prefix.size()-1] = '/';
} else {
prefix.resize(1);
}
// issue an sdskv_list_keys
std::vector<std::string> entries(maxKeys, std::string(1024,'\0'));
try {
db.list_keys(lb_entry, prefix, entries);
} catch(sdskv::exception& ex) {
throw Exception("Error occured when calling sdskv::database::list_keys (SDSKV error="+std::string(ex.what()) + ")");
}
keys.resize(0);
for(const auto& entry : entries) {
keys.emplace_back(&entry[1], entry.size()-1);
}
return keys.size();
}
#endif
///////////////////////////////////////////////////////////////////////////
// DataSet access functions
///////////////////////////////////////////////////////////////////////////
...
...
test/RunSetTest.cpp
View file @
70c35581
...
...
@@ -167,3 +167,21 @@ void RunSetTest::testCreateSubRuns() {
CPPUNIT_ASSERT
(
73
==
sr
.
number
());
}
}
void
RunSetTest
::
testAsync
()
{
auto
root
=
datastore
->
root
();
DataSet
mds
=
root
.
createDataSet
(
"matthieu_async"
);
CPPUNIT_ASSERT
(
mds
.
valid
());
hepnos
::
AsyncEngine
async
(
*
datastore
,
1
);
for
(
unsigned
i
=
0
;
i
<
10
;
i
++
)
{
Run
r
=
mds
.
createRun
(
async
,
i
);
CPPUNIT_ASSERT
(
r
.
valid
());
}
async
.
wait
();
for
(
unsigned
i
=
0
;
i
<
10
;
i
++
)
{
CPPUNIT_ASSERT
(
mds
[
i
].
valid
());
}
}
test/RunSetTest.hpp
View file @
70c35581
...
...
@@ -15,6 +15,7 @@ class RunSetTest : public CppUnit::TestFixture
CPPUNIT_TEST
(
testBeginEnd
);
CPPUNIT_TEST
(
testLowerUpperBounds
);
CPPUNIT_TEST
(
testCreateSubRuns
);
CPPUNIT_TEST
(
testAsync
);
CPPUNIT_TEST_SUITE_END
();
public:
...
...
@@ -28,6 +29,7 @@ class RunSetTest : public CppUnit::TestFixture
void
testBeginEnd
();
void
testLowerUpperBounds
();
void
testCreateSubRuns
();
void
testAsync
();
};
#endif
test/RunTest.cpp
View file @
70c35581
...
...
@@ -160,3 +160,22 @@ void RunTest::testLowerUpperBounds() {
}
}
void
RunTest
::
testAsync
()
{
auto
root
=
datastore
->
root
();
DataSet
mds
=
root
.
createDataSet
(
"matthieu_async"
);
Run
r
=
mds
.
createRun
(
1
);
hepnos
::
AsyncEngine
async
(
*
datastore
,
1
);
for
(
unsigned
i
=
0
;
i
<
10
;
i
++
)
{
SubRun
sr
=
r
.
createSubRun
(
async
,
i
);
CPPUNIT_ASSERT
(
sr
.
valid
());
}
async
.
wait
();
for
(
unsigned
i
=
0
;
i
<
10
;
i
++
)
{
SubRun
sr
=
r
[
i
];
CPPUNIT_ASSERT
(
sr
.
valid
());
}
}
test/RunTest.hpp
View file @
70c35581
...
...
@@ -15,6 +15,7 @@ class RunTest : public CppUnit::TestFixture
CPPUNIT_TEST
(
testFind
);
CPPUNIT_TEST
(
testBeginEnd
);
CPPUNIT_TEST
(
testLowerUpperBounds
);
CPPUNIT_TEST
(
testAsync
);
CPPUNIT_TEST_SUITE_END
();
public:
...
...
@@ -28,6 +29,7 @@ class RunTest : public CppUnit::TestFixture
void
testFind
();
void
testBeginEnd
();
void
testLowerUpperBounds
();
void
testAsync
();
};
#endif
test/SubRunTest.cpp
View file @
70c35581
...
...
@@ -157,3 +157,22 @@ void SubRunTest::testLowerUpperBounds() {
}
}
void
SubRunTest
::
testAsync
()
{
auto
root
=
datastore
->
root
();
DataSet
mds
=
root
.
createDataSet
(
"matthieu_async"
);
Run
r
=
mds
.
createRun
(
1
);
SubRun
sr
=
r
.
createSubRun
(
3
);
hepnos
::
AsyncEngine
async
(
*
datastore
,
1
);
for
(
unsigned
i
=
0
;
i
<
10
;
i
++
)
{
Event
e
=
sr
.
createEvent
(
async
,
i
);
CPPUNIT_ASSERT
(
e
.
valid
());
}
async
.
wait
();
for
(
unsigned
i
=
0
;
i
<
10
;
i
++
)
{
Event
e
=
sr
[
i
];
CPPUNIT_ASSERT
(
e
.
valid
());
}
}
test/SubRunTest.hpp
View file @
70c35581
...
...
@@ -15,6 +15,7 @@ class SubRunTest : public CppUnit::TestFixture
CPPUNIT_TEST
(
testFind
);
CPPUNIT_TEST
(
testBeginEnd
);
CPPUNIT_TEST
(
testLowerUpperBounds
);
CPPUNIT_TEST
(
testAsync
);
CPPUNIT_TEST_SUITE_END
();
public:
...
...
@@ -28,6 +29,7 @@ class SubRunTest : public CppUnit::TestFixture
void
testFind
();
void
testBeginEnd
();
void
testLowerUpperBounds
();
void
testAsync
();
};
#endif
Write
Preview
Markdown
is supported
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