Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+48
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
IF(TARGET svcAlmClient AND TARGET svcTabServer)
|
||||
|
||||
####################################
|
||||
# Message Test
|
||||
####################################
|
||||
|
||||
SET(SRCS_TEST_ALM
|
||||
alm_tests.cpp
|
||||
)
|
||||
SET(HDRS_TEST_ALM
|
||||
alm_tests.h
|
||||
)
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(almTests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
# Testing FunctionTopic Functionality (FTC)
|
||||
ADD_EXECUTABLE(almTests ${SRCS_TEST_ALM} ${HDRS_TEST_ALM})
|
||||
TARGET_LINK_LIBRARIES(almTests
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
RTI::nddscpp2
|
||||
svcAlmClient
|
||||
svcCoreClient
|
||||
svcEemServer
|
||||
svcPpmServer
|
||||
LtsCommandLineParser
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
)
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV TARGETS almTests DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_alm.props DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
+335
@@ -0,0 +1,335 @@
|
||||
/**
|
||||
* Msg Function Topic Module Test
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "alm_tests.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
/* ----------------------------------------------------------------------------------
|
||||
* HOW TO RUN THE TESTS
|
||||
* ----------------------------------------------------------------------------------
|
||||
*
|
||||
* Preconditions: Nothing
|
||||
*
|
||||
* Start services: (SV)
|
||||
* ./svcExerciseEventManagement -e 42
|
||||
* ./almTests -t 1 -e 42 // Configure Alarms with participantId=0, send EEM-Event and receive Alarm
|
||||
* ./almTests -t 2 -e 42 // Configure Alarms with participantId-List, send EEM-Event and receive Alarm
|
||||
* ./almTests -t 3 -e 42 // Configure Alarms with vulnerability > 0, send EEM-Event and receive Alarm
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
namespace AlarmManagement
|
||||
{
|
||||
AlmTests::AlmTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_testId(0)
|
||||
, m_bTestsSuccessful(true)
|
||||
, m_logger(getLogger("AlmTests"))
|
||||
, m_participantIndex(0)
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
AlmTests::~AlmTests()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
bool AlmTests::init(int domainId, int testId, int operatorId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "init begin";
|
||||
|
||||
m_testId = testId;
|
||||
m_operatorId = operatorId;
|
||||
m_participantIndex = 0;
|
||||
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Any));
|
||||
if (!m_ddsConnector->init())
|
||||
return false;
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
m_ftcAlm = AlarmManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
bool bRet = m_ftcAlm->enableAll();
|
||||
|
||||
m_dtcAlm = AlarmManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_dtcAlm->enableAll();
|
||||
|
||||
m_dtsEem = ExerciseEventManagement::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsEem->enableAll();
|
||||
|
||||
m_dtsPpm = ParticipantManagement::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsPpm->enableAll();
|
||||
|
||||
return bRet;
|
||||
} // init
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
|
||||
if (m_testId <= 1) // Send FTC ConfigureAlarms and EEM Event
|
||||
{
|
||||
QTimer::singleShot(0, this, &AlmTests::tryConfigureAlarms);
|
||||
QTimer::singleShot(100, this, &AlmTests::trySendEvent);
|
||||
QTimer::singleShot(200, this, &AlmTests::checkAlarm);
|
||||
}
|
||||
if (m_testId == 2)
|
||||
{
|
||||
QTimer::singleShot(0, this, &AlmTests::tryCreateParticipant);
|
||||
QTimer::singleShot(100, this, &AlmTests::tryCreateParticipant);
|
||||
QTimer::singleShot(200, this, &AlmTests::tryConfigureAlarmsList);
|
||||
QTimer::singleShot(300, this, &AlmTests::trySendEvent);
|
||||
QTimer::singleShot(400, this, &AlmTests::checkAlarm);
|
||||
}
|
||||
if (m_testId == 3)
|
||||
{
|
||||
QTimer::singleShot(0, this, &AlmTests::tryCreateParticipant);
|
||||
QTimer::singleShot(100, this, &AlmTests::tryCreateParticipant);
|
||||
QTimer::singleShot(200, this, &AlmTests::tryConfigureAlarmsList);
|
||||
QTimer::singleShot(300, this, &AlmTests::trySendEvent);
|
||||
QTimer::singleShot(400, this, &AlmTests::checkAlarm);
|
||||
}
|
||||
QTimer::singleShot(5000, this, &AlmTests::failExit);
|
||||
} // startTest
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::tryConfigureAlarms()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send createRequest Operator Message";
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> alarms;
|
||||
alarms.resize(2);
|
||||
|
||||
alarms[0].setMarker(true);
|
||||
alarms[0].messageWindow(true);
|
||||
alarms[0].vulnerabilityState(-1);
|
||||
alarms[0].eventTypeId(ProjectDataManagement::EventType_def::Hit);
|
||||
|
||||
alarms[1].setMarker(true);
|
||||
alarms[1].messageWindow(true);
|
||||
alarms[1].vulnerabilityState(0);
|
||||
alarms[1].eventTypeId(ProjectDataManagement::EventType_def::EnterNuclear);
|
||||
|
||||
std::vector<int32_t> participantIds;
|
||||
participantIds.push_back(0);
|
||||
bool globalEvent = true;
|
||||
bool remove = false;
|
||||
|
||||
if (!m_ftcAlm->configureAlarmsRequest(ConfigureAlarmsRequest(alarms, m_operatorId, participantIds, globalEvent, remove), this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
} // tryConfigureAlarms
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::tryCreateParticipant()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to create Participant index = " << m_participantIndex;
|
||||
ParticipantManagement::Participant participant;
|
||||
switch (m_participantIndex)
|
||||
{
|
||||
case 0:
|
||||
participant.id(1);
|
||||
participant.superiorId(0);
|
||||
participant.inferiorIds().resize(2);
|
||||
participant.inferiorIds().at(0) = 2;
|
||||
participant.inferiorIds().at(1) = 3;
|
||||
participant.partyId(5);
|
||||
break;
|
||||
case 1:
|
||||
participant.id(2);
|
||||
participant.superiorId(1);
|
||||
participant.inferiorIds().resize(2);
|
||||
participant.inferiorIds().at(0) = 4;
|
||||
participant.inferiorIds().at(1) = 5;
|
||||
participant.partyId(5);
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Publishing Participant";
|
||||
if (!m_dtsPpm->publish(participant))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error publish Participant";
|
||||
failExit();
|
||||
}
|
||||
m_participantIndex++;
|
||||
} // tryCreateParticipant
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::tryConfigureAlarmsList()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send createRequest Operator Message";
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> alarms;
|
||||
alarms.resize(2);
|
||||
|
||||
alarms[0].setMarker(true);
|
||||
alarms[0].messageWindow(true);
|
||||
alarms[0].eventTypeId(ProjectDataManagement::EventType_def::Hit);
|
||||
alarms[0].vulnerabilityState(-1);
|
||||
|
||||
alarms[1].setMarker(true);
|
||||
alarms[1].messageWindow(true);
|
||||
alarms[1].vulnerabilityState(-1);
|
||||
alarms[1].eventTypeId(ProjectDataManagement::EventType_def::WeaponAssignment);
|
||||
|
||||
std::vector<int32_t> participantIds;
|
||||
participantIds.push_back(1);
|
||||
participantIds.push_back(2);
|
||||
bool globalEvent = true;
|
||||
bool remove = false;
|
||||
|
||||
if (!m_ftcAlm->configureAlarmsRequest(ConfigureAlarmsRequest(alarms, m_operatorId, participantIds, globalEvent, remove), this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
} // tryConfigureAlarmsList
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::trySendEvent()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send ParticipantEvent";
|
||||
|
||||
ExerciseEventManagement::Event pe;
|
||||
|
||||
// publish new Event data here
|
||||
pe.id(100);
|
||||
//pe.aesItemId(5);
|
||||
pe.eventTypeId(ProjectDataManagement::EventType_def::Hit); // same as eventTypeId in ConfigureAlarms
|
||||
pe.participantId(2);
|
||||
pe.equipmentNumber(55);
|
||||
pe.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
//pe.friendlyFire(1);
|
||||
//pe.vulnerability(0);
|
||||
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("FriendlyFire")] = QJsonValue(true);
|
||||
|
||||
QString properties = QString::fromUtf8(QJsonDocument(obj).toJson());
|
||||
pe.properties(properties.toStdString());
|
||||
DEBUG_LOG(m_logger) << "Publishing EEM Event";
|
||||
if (!m_dtsEem->publish(pe))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error publish EEM Event";
|
||||
failExit();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onConfigureAlarmsReply, error = " << replyObject.error();
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error ConfigureAlarms - aborting";
|
||||
failExit();
|
||||
}
|
||||
} // onConfigureAlarmsReply
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::checkAlarm()
|
||||
{
|
||||
INFO_LOG(m_logger) << "checkAlarm";
|
||||
m_dtcAlm->waitForHistoricalDataNotification();
|
||||
qint32 id = 0;
|
||||
AlarmManagement::Notification notification = m_dtcAlm->notification(id);
|
||||
INFO_LOG(m_logger) << "Recived AlarmManagement::Notification: " << notification
|
||||
<< " testId: " << m_testId;
|
||||
|
||||
switch (m_testId)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
INFO_LOG(m_logger) << "ExitSuccess";
|
||||
ExitSuccess();
|
||||
break;
|
||||
default:
|
||||
// nothing
|
||||
INFO_LOG(m_logger) << "failExit";
|
||||
failExit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::failExit()
|
||||
{
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
} // failExit
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AlmTests::ExitSuccess()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "SUCCESS";
|
||||
m_bTestsSuccessful = true;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
} // ExitSuccess
|
||||
|
||||
} // namespace
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption({ QStringList() << QLatin1String("t") << QLatin1String("testId")
|
||||
, QLatin1String("TestId.")
|
||||
, QLatin1String("Default: 0 (all tests)")
|
||||
, QLatin1String("0")
|
||||
});
|
||||
addOption({ QStringList() << QLatin1String("o") << QLatin1String("operatorId")
|
||||
, QLatin1String("OperatorId.")
|
||||
, QLatin1String("Default: 10")
|
||||
, QLatin1String("10")
|
||||
});
|
||||
|
||||
}
|
||||
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : 0; }
|
||||
int operatorId() const { return isSet(QLatin1String("o")) ? value(QLatin1String("o")).toInt() : 10; }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("ALM", "log4cxx_alm.props");
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
int iRet = -1;
|
||||
{
|
||||
std::unique_ptr<AlarmManagement::AlmTests> almTests(new AlarmManagement::AlmTests);
|
||||
|
||||
if (!almTests->init(options.domainId(), options.testId(), options.operatorId()))
|
||||
return iRet;
|
||||
|
||||
almTests->startTest();
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
|
||||
iRet = almTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "%d\n", iRet);
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
}
|
||||
|
||||
return iRet;
|
||||
} // main
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* ModuleTests for Msg
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/alm_ftc.h>
|
||||
#include <AlarmManagement/alm_ftc_types.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <ExerciseEventManagement/eem_dts.h>
|
||||
#include <ParticipantManagement/ppm_dts.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
class AlmTests : public QObject
|
||||
, protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AlmTests(QObject *parent = nullptr);
|
||||
~AlmTests();
|
||||
|
||||
bool init(int domainId, int testId, int operatorId);
|
||||
|
||||
bool testsSuccessful() const
|
||||
{
|
||||
return m_bTestsSuccessful;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
void startTest();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void tryConfigureAlarms();
|
||||
void tryConfigureAlarmsList();
|
||||
void trySendEvent();
|
||||
void tryCreateParticipant();
|
||||
void failExit();
|
||||
void ExitSuccess();
|
||||
|
||||
protected:
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private:
|
||||
void checkAlarm();
|
||||
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_ftcAlm;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtcAlm;
|
||||
std::shared_ptr<ExerciseEventManagement::Interface::Dts> m_dtsEem;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dts> m_dtsPpm;
|
||||
|
||||
int m_testId;
|
||||
bool m_bTestsSuccessful;
|
||||
int m_operatorId;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_participantIndex;
|
||||
|
||||
};
|
||||
|
||||
} // namespace AlarmManagement
|
||||
@@ -0,0 +1,86 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: AlarmManagement
|
||||
###########################################################
|
||||
|
||||
#log4j.logger.ALM=WARN
|
||||
#log4j.logger.ALM.main=WARN
|
||||
#log4j.logger.ALM.DbAdmin=WARN
|
||||
#log4j.logger.ALM.DdsHandler=WARN
|
||||
#log4j.logger.ALM.HandlerConfigureAlarms=DEBUG
|
||||
#log4j.logger.ALM.HandlerParticipant=DEBUG
|
||||
#log4j.logger.ALM.MainHandler=DEBUG
|
||||
#log4j.logger.ALM.Settings=WARN
|
||||
#log4j.logger.ALM.Publisher=WARN
|
||||
#log4j.logger.ALM.Fts=WARN
|
||||
|
||||
# File
|
||||
###########################################################
|
||||
log4j.appender.file=Lts::RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
Reference in new issue
Block a user