8000 Bug fix/implement windows maintenance tests by dothebart · Pull Request #9763 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Bug fix/implement windows maintenance tests #9763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ endforeach()
################################################################################
## IResearch
################################################################################
if (WINDOWS)
set(RCFILE Maintenance/json.rc)
endif ()

set(ARANGODB_TESTS_SOURCES
Agency/ActiveFailoverTest.cpp
Expand Down 8000 Expand Up @@ -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
Expand Down
69 changes: 52 additions & 17 deletions tests/Maintenance/MaintenanceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
< 10000 /td> 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()) {
Expand Down Expand Up @@ -291,6 +327,7 @@ class LogicalCollection;
class MaintenanceTestActionDescription : public ::testing::Test {
protected:
MaintenanceTestActionDescription() {
loadResources();
plan = createNode(planStr);
originalPlan = plan;
supervision = createNode(supervisionStr);
Expand Down Expand Up @@ -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());
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -836,5 +873,3 @@ TEST_F(MaintenanceTestActionPhaseOne, removed_follower_in_plan_must_be_dropped)
}
}
}

#endif
23 changes: 23 additions & 0 deletions tests/Maintenance/generateRcFile.sh
Original file line number Diff line number Diff line change
@@ -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
Loading
0