JD2022-TU1/main/extern/UbiServices/custom/testsIntegration/diagTool.h

214 lines
4.8 KiB
C++

////////////////////////////////////////////////////////////////////////////////
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
#include <vector>
#include <memory>
#define PROTOTYPING_ENGINE
//#define DIAG_TOOL_ENABLE_BLOCKING_WAIT
//#define DIAG_TOOL_ENABLE_WIDE_REPORT
#if defined(PROTOTYPING_ENGINE)
#if !defined(US_DLL_API)
#define US_TEMP_US_DLL_API
#define US_DLL_API
#endif
struct EnvironmentTarget
{
enum Enum
{
UAT,
CERT2,
PROD,
EndOfEnum
};
inline static const char* getString(Enum value)
{
switch (value)
{
case UAT: return "UAT";
case CERT2: return "CERT";
case PROD: return "PROD";
default:
break;
}
return "INVALID_ENUM_VALUE";
}
};
struct Proxy
{
enum Enum
{
Off,
On,
EndOfEnum
};
};
struct Protocol
{
enum Enum
{
HTTP,
HTTPS,
EndOfEnum
};
};
// https://mdc-web-tomcat17.ubisoft.org/confluence/display/ubiservdoc/UbiServices+Overview#UbiServicesOverview-Entrypoints
struct EntryPoint
{
enum Enum
{
Google,
RAW_Public, // Client
RAW_API, // Client
RAW_Deleg_COM, // Server
RAW_Deleg_ONBE, // Server
RAW_S2S_COM, // Server
RAW_S2S_ONBE, // Server
RAW_Admin_COM, // Client
RAW_Admin_ONBE, // Client
AWS_Public,
AWS_ImPublic, // Client
AWS_API,
AWS_Deleg_COM,
AWS_S2S_COM,
AWS_Admin_COM,
MSR_Public,
MSR_API,
MSR_Deleg_COM,
MSR_S2S_COM,
MSR_Admin_COM,
EndOfEnum
};
static const char* const GetLabel(Enum value);
static bool IsRequiredForClient(Enum value);
static const EntryPoint::Enum ALL[EntryPoint::EndOfEnum];
};
struct TestResult
{
enum Enum
{
NotApplicable,
Pending,
OK,
Error,
Timeout_Engine,
Timeout_SDK,
EndOfEnum
};
static const char* const GetLabel(TestResult::Enum value);
};
struct ColumnName
{
enum Enum
{
HTTPS_ProxyOff,
HTTPS_ProxyOn,
HTTP_ProxyOff,
HTTP_ProxyOn,
EndOfEnum
};
};
struct TestId
{
TestId(EntryPoint::Enum entry = EntryPoint::EndOfEnum,
ColumnName::Enum column = ColumnName::EndOfEnum,
EnvironmentTarget::Enum env = EnvironmentTarget::EndOfEnum)
: m_entry(entry)
, m_column(column)
, m_env(env)
{
}
std::string GetTitle() const;
EntryPoint::Enum m_entry;
ColumnName::Enum m_column;
EnvironmentTarget::Enum m_env;
};
//======================================================================================================================
class ConnectivityDiagEngine
{
public:
class Notification
{
public:
Notification(const TestId& id, TestResult::Enum result)
: m_id(id)
, m_result(result)
{
}
TestId m_id;
TestResult::Enum m_result;
};
ConnectivityDiagEngine(const std::string& appId, const std::string& proxyName = "msr-net-bcproxy.ubisoft.org", unsigned int proxyPort = 3128);
~ConnectivityDiagEngine();
bool ExecuteTestsAsync(const std::vector<Proxy::Enum>& proxy, const std::vector<EnvironmentTarget::Enum>& environments, const std::vector<Protocol::Enum>& protocols);
bool ExecuteTestsAsync(const std::vector<Proxy::Enum>& proxy, const std::vector<EnvironmentTarget::Enum>& environments, const std::vector<Protocol::Enum>& protocols,
const std::vector<EntryPoint::Enum>& endpointsProxyOff, const std::vector<EntryPoint::Enum>& endpointsProxyOn);
bool ExecuteTestsAsync(Proxy::Enum proxy, EnvironmentTarget::Enum environment, Protocol::Enum protocol);
bool ExecuteTestsAsync(Proxy::Enum proxy, EnvironmentTarget::Enum environment, Protocol::Enum protocol, const std::vector<EntryPoint::Enum>& endpoints);
#if defined(DIAG_TOOL_ENABLE_BLOCKING_WAIT)
bool WaitCompletion();
#endif
bool PollCompletion();
bool IsPollingTimeOut();
void ReleaseResults();
void PrintSummary() const;
#if defined(DIAG_TOOL_ENABLE_WIDE_REPORT)
void PrintReport() const;
#endif
void PrintReportGoogle() const;
void PrintReport(Protocol::Enum protocol) const;
void PrintDetails() const;
void PrintPublicIp();
size_t GetErrorCount() const;
std::string ReadLog() const;
std::string ReadReport() const;
public:
std::vector<Notification> m_notifications;
private:
class InternalLogic;
std::unique_ptr<InternalLogic> m_pimpl;
};
#if defined(US_TEMP_US_DLL_API)
#undef US_TEMP_US_DLL_API
#undef US_DLL_API
#endif
#endif