##// END OF EJS Templates
Implements test execute() method...
Implements test execute() method For each iteration of the test, this method generates available operations according to states of the variables, and execute an operation that has been chosen randomly.

File last commit:

r1120:07d7d7f01c19
r1174:0c07405da56c
Show More
AmdaServer.cpp
99 lines | 3.1 KiB | text/x-c | CppLexer
Alexandre Leroux
Creates AMDAServer class...
r1111 #include "AmdaServer.h"
Alexandre Leroux
Adds "hybrid" server mode...
r1118 #include "AmdaDefs.h"
Alexandre Leroux
Creates AMDAServer class...
r1111 Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer")
Alexandre Leroux
Creates AMDA implementations (default and AMDA test)
r1112 namespace {
Alexandre Leroux
Adds "hybrid" server mode...
r1118 /// URL of the default AMDA server
const auto AMDA_DEFAULT_SERVER_URL = QStringLiteral("amda.irap.omp.eu");
/// URL of the AMDA test server
const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu");
Alexandre Leroux
Adds "local server" mode...
r1120 /// Port used for local server
const auto AMDA_LOCAL_SERVER_PORT = 6543;
/// URL of the local server
const auto AMDA_LOCAL_SERVER_URL
= QString{"localhost:%1"}.arg(QString::number(AMDA_LOCAL_SERVER_PORT));
Alexandre Leroux
Creates AMDA implementations (default and AMDA test)
r1112 /// Default AMDA server
struct AmdaDefaultServer : public AmdaServer {
public:
QString name() const override { return QStringLiteral("AMDA (default)"); }
Alexandre Leroux
Adds "hybrid" server mode...
r1118 QString url(const QVariantHash &properties) const override
{
Q_UNUSED(properties);
return AMDA_DEFAULT_SERVER_URL;
}
Alexandre Leroux
Creates AMDA implementations (default and AMDA test)
r1112 };
/// Alternative AMDA server (tests)
struct AmdaTestServer : public AmdaServer {
public:
QString name() const override { return QStringLiteral("AMDA (test)"); }
Alexandre Leroux
Adds "hybrid" server mode...
r1118 QString url(const QVariantHash &properties) const override
{
Q_UNUSED(properties);
return AMDA_TEST_SERVER_URL;
}
};
/// Hybrid AMDA server: use both of default and test server.
/// The server used is relative to each product for which to retrieve url, according to its "server"
/// property
struct AmdaHybridServer : public AmdaServer {
public:
QString name() const override { return QStringLiteral("AMDA (hybrid)"); }
QString url(const QVariantHash &properties) const override
{
// Reads "server" property to determine which server url to use
auto server = properties.value(AMDA_SERVER_KEY).toString();
return server == QString{"amdatest"} ? AMDA_TEST_SERVER_URL : AMDA_DEFAULT_SERVER_URL;
}
Alexandre Leroux
Creates AMDA implementations (default and AMDA test)
r1112 };
Alexandre Leroux
Adds "local server" mode...
r1120 /// Local AMDA server: use local python server to simulate AMDA requests
struct AmdaLocalServer : public AmdaServer {
public:
QString name() const override { return AMDA_LOCAL_SERVER_URL; }
QString url(const QVariantHash &properties) const override
{
Q_UNUSED(properties);
return AMDA_LOCAL_SERVER_URL;
}
};
Alexandre Leroux
Determines AMDA server at compile time
r1113 /// @return an AMDA server instance created from the name of the server passed in parameter. If the
/// name does not match any known server, a default server instance is created
std::unique_ptr<AmdaServer> createInstance(const QString &server)
{
if (server == QString{"amdatest"}) {
return std::make_unique<AmdaTestServer>();
}
Alexandre Leroux
Adds "hybrid" server mode...
r1118 else if (server == QString{"hybrid"}) {
return std::make_unique<AmdaHybridServer>();
}
Alexandre Leroux
Adds "local server" mode...
r1120 else if (server == QString{"localhost"}) {
return std::make_unique<AmdaLocalServer>();
}
Alexandre Leroux
Determines AMDA server at compile time
r1113 else {
if (server != QString{"default"}) {
qCWarning(LOG_AmdaServer())
<< QObject::tr("Unknown server '%1': default AMDA server will be used").arg(server);
}
return std::make_unique<AmdaDefaultServer>();
}
}
Alexandre Leroux
Creates AMDA implementations (default and AMDA test)
r1112 } // namespace
Alexandre Leroux
Creates AMDAServer class...
r1111 AmdaServer &AmdaServer::instance()
{
Alexandre Leroux
Determines AMDA server at compile time
r1113 // Creates instance depending on the SCIQLOP_AMDA_SERVER value at compile time
static auto instance = createInstance(SCIQLOP_AMDA_SERVER);
return *instance;
Alexandre Leroux
Creates AMDAServer class...
r1111 }