1
0
Fork 0

Bug fix/implement windows maintenance tests (#9763)

This commit is contained in:
Wilfried Goesgens 2019-08-21 12:42:29 +02:00 committed by Jan
parent 1e9ad7fbb9
commit 828e41601e
5 changed files with 10958 additions and 20 deletions

View File

@ -7,6 +7,9 @@ endforeach()
################################################################################
## IResearch
################################################################################
if (WINDOWS)
set(RCFILE Maintenance/json.rc)
endif ()
set(ARANGODB_TESTS_SOURCES
Agency/ActiveFailoverTest.cpp
@ -171,9 +174,7 @@ set(ARANGODB_TESTS_SOURCES
Maintenance/MaintenanceFeatureTest.cpp
Maintenance/MaintenanceRestHandlerTest.cpp
Maintenance/MaintenanceTest.cpp
Network/ConnectionPoolTest.cpp
Network/MethodsTest.cpp
Network/UtilsTest.cpp
${RCFILE}
Mocks/StorageEngineMock.cpp
Mocks/Servers.cpp
Pregel/typedbuffer.cpp

View File

@ -68,6 +68,42 @@ char const* dbs2Str =
#include "DBServer0003.json"
;
int loadResources(void) {return 0;}
#else // _WIN32
#include <Windows.h>
#include "jsonresource.h"
LPSTR planStr = nullptr;
LPSTR currentStr = nullptr;
LPSTR supervisionStr = nullptr;
LPSTR dbs0Str = nullptr;
LPSTR dbs1Str = nullptr;
LPSTR dbs2Str = nullptr;
LPSTR getResource(int which) {
HRSRC myResource = ::FindResource(NULL, MAKEINTRESOURCE(which), RT_RCDATA);
HGLOBAL myResourceData = ::LoadResource(NULL, myResource);
return (LPSTR) ::LockResource(myResourceData);
}
int loadResources(void) {
if ((planStr == nullptr) &&
(currentStr == nullptr) &&
(supervisionStr == nullptr) &&
(dbs0Str == nullptr) &&
(dbs1Str == nullptr) &&
(dbs2Str == nullptr)) {
planStr = getResource(IDS_PLAN);
currentStr = getResource(IDS_CURRENT);
dbs0Str = getResource(IDS_DBSERVER0001);
dbs1Str = getResource(IDS_DBSERVER0002);
dbs2Str = getResource(IDS_DBSERVER0003);
supervisionStr = getResource(IDS_SUPERVISION);
}
return 0;
}
#endif // _WIN32
std::map<std::string, std::string> matchShortLongIds(Node const& supervision) {
std::map<std::string, std::string> ret;
for (auto const& dbs : supervision("Health").children()) {
@ -291,6 +327,7 @@ class LogicalCollection;
class MaintenanceTestActionDescription : public ::testing::Test {
protected:
MaintenanceTestActionDescription() {
loadResources();
plan = createNode(planStr);
originalPlan = plan;
supervision = createNode(supervisionStr);
@ -324,8 +361,7 @@ TEST_F(MaintenanceTestActionDescription, retrieve_nonassigned_key_from_actiondes
try {
auto bogus = desc.get("bogus");
ASSERT_TRUE(bogus == "bogus");
} catch (std::out_of_range const& e) {
}
} catch (std::out_of_range const&) { }
std::string value;
auto res = desc.get("bogus", value);
ASSERT_TRUE(value.empty());
@ -339,8 +375,7 @@ TEST_F(MaintenanceTestActionDescription, retrieve_nonassigned_key_from_actiondes
try {
auto bogus = desc.get("bogus");
ASSERT_TRUE(bogus == "bogus");
} catch (std::out_of_range const& e) {
}
} catch (std::out_of_range const&) { }
std::string value;
auto res = desc.get("bogus", value);
ASSERT_TRUE(value == "bogus");
@ -434,6 +469,7 @@ TEST_F(MaintenanceTestActionDescription, retrieve_array_value_from_actiondescrip
class MaintenanceTestActionPhaseOne : public ::testing::Test {
protected:
int _dummy;
std::shared_ptr<arangodb::options::ProgramOptions> po;
arangodb::application_features::ApplicationServer as;
TestMaintenanceFeature feature;
@ -443,18 +479,19 @@ class MaintenanceTestActionPhaseOne : public ::testing::Test {
arangodb::MMFilesEngine engine; // arbitrary implementation that has index types registered
arangodb::StorageEngine* origStorageEngine;
MaintenanceTestActionPhaseOne()
: po(std::make_shared<arangodb::options::ProgramOptions>("test", std::string(),
std::string(),
"path")),
as(po, nullptr),
feature(as),
localNodes{{dbsIds[shortNames[0]], createNode(dbs0Str)},
{dbsIds[shortNames[1]], createNode(dbs1Str)},
{dbsIds[shortNames[2]], createNode(dbs2Str)}},
engine(as),
origStorageEngine(arangodb::EngineSelectorFeature::ENGINE) {
: _dummy(loadResources()),
po(std::make_shared<arangodb::options::ProgramOptions>("test", std::string(),
std::string(),
"path")),
as(po, nullptr),
feature(as),
localNodes{{dbsIds[shortNames[0]], createNode(dbs0Str)},
{dbsIds[shortNames[1]], createNode(dbs1Str)},
{dbsIds[shortNames[2]], createNode(dbs2Str)}},
engine(as),
origStorageEngine(arangodb::EngineSelectorFeature::ENGINE) {
arangodb::EngineSelectorFeature::ENGINE = &engine;
}
@ -836,5 +873,3 @@ TEST_F(MaintenanceTestActionPhaseOne, removed_follower_in_plan_must_be_dropped)
}
}
}
#endif

View File

@ -0,0 +1,23 @@
#!/bin/bash
# this script picks all json-header files, and dumps them into a windows RC file style file
echo > jsonresource.h
(
i=1
for JSON in *.json ; do
RCNAME="#define IDS_$(echo "${JSON}" |sed -e "s;.json;;" -e 's/\(.*\)/\U\1/') ${i}"
echo "${RCNAME}" >> jsonresource.h
i=$(($i + 1))
done
printf '#include "jsonresource.h"\r\n'
for JSON in *.json ; do
RCNAME="IDS_$(echo "${JSON}"|sed -e "s;.json;;" -e 's/\(.*\)/\U\1/')"
printf "${RCNAME} RCDATA\r\n{\r\n"
# first cut off the .h related syntax...
cat "${JSON}" |sed -e 's;^R"=($;;' -e 's;^)="$;;' | \
sed -e 's;";"";g' -e 's;^; ";' -e 's;$;",;'
# then escape quotes (by doubling them) and pre & post pend quotes.
printf '"\\0"\r\n}\r\n'
done
printf "\r\n}\r\n"
) > json.rc

10872
tests/Maintenance/json.rc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
#define IDS_CURRENT 1
#define IDS_DBSERVER0001 2
#define IDS_DBSERVER0002 3
#define IDS_DBSERVER0003 4
#define IDS_PLAN 5
#define IDS_SUPERVISION 6