Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
a6485982
Commit
a6485982
authored
Nov 06, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(SM): немного переделал тест на "потерю сообщений"
parent
ce4fa6e8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
248 additions
and
62 deletions
+248
-62
start_fg_testlost.sh
extensions/SharedMemory/start_fg_testlost.sh
+1
-1
LostPassiveTestProc.cc
extensions/tests/SMemoryTest/LostPassiveTestProc.cc
+93
-0
LostPassiveTestProc.h
extensions/tests/SMemoryTest/LostPassiveTestProc.h
+33
-0
LostTestProc.cc
extensions/tests/SMemoryTest/LostTestProc.cc
+56
-54
LostTestProc.h
extensions/tests/SMemoryTest/LostTestProc.h
+8
-5
Makefile.am
extensions/tests/SMemoryTest/Makefile.am
+1
-1
losttestproc.src.xml
extensions/tests/SMemoryTest/losttestproc.src.xml
+26
-0
sm-lostmessage-test.cc
extensions/tests/SMemoryTest/sm-lostmessage-test.cc
+16
-1
start_fg_losttest.sh
extensions/tests/SMemoryTest/start_fg_losttest.sh
+12
-0
uniset2.files
uniset2.files
+2
-0
No files found.
extensions/SharedMemory/start_fg_testlost.sh
View file @
a6485982
...
...
@@ -6,7 +6,7 @@ ulimit -Sc 10000000000
./uniset2-start.sh
-f
./uniset2-smemory
--smemory-id
SharedMemory
\
--confile
test-lost.xml
--datfile
test-lost.xml
--ulog-add-levels
crit,warn,system,level1
\
--sm-log-add-levels
any
$*
--sm-run-logserver
--activate-timeout
320000
--sm-log-add-levels
any
$*
--sm-run-logserver
--activat
or-run-httpserver
--activat
e-timeout
320000
#--pulsar-id DO_C --pulsar-iotype DO --pulsar-msec 100
...
...
extensions/tests/SMemoryTest/LostPassiveTestProc.cc
0 → 100644
View file @
a6485982
#include <iomanip>
#include "Exceptions.h"
#include "LostPassiveTestProc.h"
// -----------------------------------------------------------------------------
using
namespace
std
;
using
namespace
UniSetTypes
;
// -----------------------------------------------------------------------------
LostPassiveTestProc
::
LostPassiveTestProc
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
confnode
)
:
LostTestProc_SK
(
id
,
confnode
)
{
auto
conf
=
uniset_conf
();
UniXML
::
iterator
cit
(
confnode
);
string
f_field
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"filter-field"
,
cit
.
getProp
(
"filterField"
));
string
f_value
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"filter-value"
,
cit
.
getProp
(
"filterValue"
));
xmlNode
*
snode
=
conf
->
getXMLSensorsSection
();
if
(
!
snode
)
throw
SystemError
(
myname
+
"(init): Not found <sensors> section?!"
);
UniXML
::
iterator
it
(
snode
);
if
(
!
it
.
goChildren
()
)
throw
SystemError
(
myname
+
"(init): Section <sensors> empty?!"
);
for
(
;
it
;
it
++
)
{
if
(
!
UniSetTypes
::
check_filter
(
it
,
f_field
,
f_value
)
)
continue
;
if
(
it
.
getProp
(
"iotype"
)
!=
"AI"
)
continue
;
slist
.
emplace
(
it
.
getIntProp
(
"id"
),
0
);
}
setMaxSizeOfMessageQueue
(
slist
.
size
()
*
2
+
500
);
smTestID
=
slist
.
begin
()
->
first
;
}
// -----------------------------------------------------------------------------
LostPassiveTestProc
::~
LostPassiveTestProc
()
{
}
// -----------------------------------------------------------------------------
bool
LostPassiveTestProc
::
emptyQueue
()
{
return
(
countMessages
()
==
0
);
}
// -----------------------------------------------------------------------------
long
LostPassiveTestProc
::
checkValue
(
ObjectId
sid
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mut
);
auto
s
=
slist
.
find
(
sid
);
if
(
s
==
slist
.
end
()
)
{
ostringstream
err
;
err
<<
myname
<<
"(checkValue): NOT FOUND?!! sensor ID="
<<
sid
;
throw
UniSetTypes
::
SystemError
(
err
.
str
());
}
return
s
->
second
;
}
// -----------------------------------------------------------------------------
LostPassiveTestProc
::
LostPassiveTestProc
()
{
cerr
<<
": init failed!!!!!!!!!!!!!!!"
<<
endl
;
throw
UniSetTypes
::
Exception
(
myname
+
"(init): FAILED.."
);
}
// -----------------------------------------------------------------------------
void
LostPassiveTestProc
::
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{
for
(
const
auto
&
s
:
slist
)
askSensor
(
s
.
first
,
cmd
);
}
// -----------------------------------------------------------------------------
void
LostPassiveTestProc
::
sensorInfo
(
const
SensorMessage
*
sm
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mut
);
auto
s
=
slist
.
find
(
sm
->
id
);
if
(
s
==
slist
.
end
()
)
{
mycrit
<<
myname
<<
"(sensorInfo): ERROR: message from UNKNOWN SENSOR sm->id="
<<
sm
->
id
<<
endl
;
UniSetTypes
::
SimpleInfo_var
i
=
getInfo
();
mycrit
<<
i
->
info
<<
endl
;
std
::
abort
();
}
s
->
second
=
sm
->
value
;
}
// -----------------------------------------------------------------------------
extensions/tests/SMemoryTest/LostPassiveTestProc.h
0 → 100644
View file @
a6485982
// -----------------------------------------------------------------------------
#ifndef LostPassiveTestProc_H_
#define LostPassiveTestProc_H_
// -----------------------------------------------------------------------------
#include <unordered_map>
#include "Debug.h"
#include "LostTestProc_SK.h"
// -----------------------------------------------------------------------------
/* Пассивный процесс, который только заказывает датчики, но не выставляет */
class
LostPassiveTestProc
:
public
LostTestProc_SK
{
public
:
LostPassiveTestProc
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
confnode
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"LostPassiveTestProc"
)
);
virtual
~
LostPassiveTestProc
();
bool
emptyQueue
();
long
checkValue
(
UniSetTypes
::
ObjectId
sid
);
protected
:
LostPassiveTestProc
();
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
override
;
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
;
std
::
mutex
mut
;
std
::
unordered_map
<
UniSetTypes
::
ObjectId
,
long
>
slist
;
private
:
};
// -----------------------------------------------------------------------------
#endif // LostPassiveTestProc_H_
// -----------------------------------------------------------------------------
extensions/tests/SMemoryTest/LostTestProc.cc
View file @
a6485982
...
...
@@ -6,36 +6,8 @@ using namespace std;
using
namespace
UniSetTypes
;
// -----------------------------------------------------------------------------
LostTestProc
::
LostTestProc
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
confnode
)
:
Lost
TestProc_SK
(
id
,
confnode
)
Lost
PassiveTestProc
(
id
,
confnode
)
{
auto
conf
=
uniset_conf
();
UniXML
::
iterator
cit
(
confnode
);
string
f_field
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"filter-field"
,
cit
.
getProp
(
"filterField"
));
string
f_value
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"filter-value"
,
cit
.
getProp
(
"filterValue"
));
xmlNode
*
snode
=
conf
->
getXMLSensorsSection
();
if
(
!
snode
)
throw
SystemError
(
myname
+
"(init): Not found <sensors> section?!"
);
UniXML
::
iterator
it
(
snode
);
if
(
!
it
.
goChildren
()
)
throw
SystemError
(
myname
+
"(init): Section <sensors> empty?!"
);
for
(
;
it
;
it
++
)
{
if
(
!
UniSetTypes
::
check_filter
(
it
,
f_field
,
f_value
)
)
continue
;
if
(
it
.
getProp
(
"iotype"
)
!=
"AI"
)
continue
;
slist
.
emplace
(
it
.
getIntProp
(
"id"
),
0
);
}
setMaxSizeOfMessageQueue
(
slist
.
size
()
+
500
);
vmonit
(
ncycle
);
vmonit
(
waitEmpty
);
}
...
...
@@ -44,6 +16,11 @@ LostTestProc::~LostTestProc()
{
}
// -----------------------------------------------------------------------------
void
LostTestProc
::
setChildPassiveProc
(
const
std
::
shared_ptr
<
LostPassiveTestProc
>&
lp
)
{
child
=
lp
;
}
// -----------------------------------------------------------------------------
LostTestProc
::
LostTestProc
()
{
cerr
<<
": init failed!!!!!!!!!!!!!!!"
<<
endl
;
...
...
@@ -73,26 +50,6 @@ void LostTestProc::sysCommand( const UniSetTypes::SystemMessage* sm )
}
}
// -----------------------------------------------------------------------------
void
LostTestProc
::
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{
for
(
const
auto
&
s
:
slist
)
askSensor
(
s
.
first
,
cmd
);
}
// -----------------------------------------------------------------------------
void
LostTestProc
::
sensorInfo
(
const
SensorMessage
*
sm
)
{
auto
s
=
slist
.
find
(
sm
->
id
);
if
(
s
==
slist
.
end
()
)
{
mycrit
<<
myname
<<
"(sensorInfo): ERROR: message from UNKNOWN SENSOR sm->id="
<<
sm
->
id
<<
endl
;
UniSetTypes
::
SimpleInfo_var
i
=
getInfo
();
mycrit
<<
i
->
info
<<
endl
;
std
::
abort
();
}
s
->
second
=
sm
->
value
;
}
// -----------------------------------------------------------------------------
string
LostTestProc
::
getMonitInfo
()
{
ostringstream
inf
;
...
...
@@ -104,16 +61,23 @@ void LostTestProc::timerInfo( const TimerMessage* tm )
{
if
(
tm
->
id
==
tmCheck
)
{
if
(
countMessages
()
>
0
)
if
(
countMessages
()
>
0
)
{
mylog1
<<
myname
<<
": [WAIT]: count of messages "
<<
countMessages
()
<<
endl
;
waitEmpty
=
true
;
return
;
}
if
(
child
&&
!
child
->
emptyQueue
()
)
{
mylog1
<<
myname
<<
": [WAIT]: wait empty queue for "
<<
child
->
getName
()
<<
endl
;
waitEmpty
=
true
;
return
;
}
waitEmpty
=
false
;
myinfo
<<
myname
<<
": [OK]: empty queue.
UPDATE
VALUE... "
<<
endl
;
myinfo
<<
myname
<<
": [OK]: empty queue.
CHECK
VALUE... "
<<
endl
;
for
(
auto
&&
s
:
slist
)
{
try
...
...
@@ -121,19 +85,57 @@ void LostTestProc::timerInfo( const TimerMessage* tm )
long
smValue
=
ui
->
getValue
(
s
.
first
);
if
(
smValue
!=
s
.
second
)
{
cerr
<<
myname
<<
"(check): ERROR!! smValue="
<<
smValue
<<
" != "
<<
s
.
second
<<
endl
;
cerr
<<
myname
<<
"(check): ERROR!! s
id="
<<
s
.
first
<<
" s
mValue="
<<
smValue
<<
" != "
<<
s
.
second
<<
endl
;
UniSetTypes
::
SimpleInfo_var
i
=
getInfo
();
cerr
<<
i
->
info
<<
endl
;
std
::
abort
();
}
// cerr << "sm_value=" << smValue << " save " << (in_sensor_s+1) << endl;
if
(
child
)
{
long
childValue
=
child
->
checkValue
(
s
.
first
);
if
(
smValue
!=
childValue
)
{
cerr
<<
myname
<<
"(check): ERROR!! sid="
<<
s
.
first
<<
" smValue="
<<
smValue
<<
" != "
<<
childValue
<<
" FOR CHILD: "
<<
child
->
getName
()
<<
endl
;
UniSetTypes
::
SimpleInfo_var
i
=
getInfo
();
cerr
<<
i
->
info
<<
endl
;
cerr
<<
"=============== CHILD INFO: =============="
<<
endl
;
UniSetTypes
::
SimpleInfo_var
i2
=
child
->
getInfo
();
cerr
<<
i2
->
info
<<
endl
;
// cerr << "JSON: " << endl;
// Poco::URI::QueryParameters p;
// auto j = httpGet(p);
// cerr << j.dump() << endl;
// cerr << "-------------------------" << endl;
// auto j2 = child->httpGet(p);
// cerr << j2.dump() << endl;
std
::
abort
();
}
}
}
catch
(
std
::
exception
&
ex
)
{
mycrit
<<
myname
<<
"(check): "
<<
ex
.
what
()
<<
endl
;
}
}
myinfo
<<
myname
<<
": [OK]: UPDATE VALUE... "
<<
endl
;
for
(
auto
&&
s
:
slist
)
{
try
{
// Выставляем новое значение
ui
->
setValue
(
s
.
first
,
s
.
second
+
1
);
// проверяем что сохранилось
smValue
=
ui
->
getValue
(
s
.
first
);
long
smValue
=
ui
->
getValue
(
s
.
first
);
if
(
ui
->
getValue
(
s
.
first
)
!=
(
s
.
second
+
1
)
)
{
...
...
extensions/tests/SMemoryTest/LostTestProc.h
View file @
a6485982
...
...
@@ -4,18 +4,22 @@
// -----------------------------------------------------------------------------
#include <unordered_map>
#include "Debug.h"
#include "Lost
TestProc_SK
.h"
#include "Lost
PassiveTestProc
.h"
// -----------------------------------------------------------------------------
/* Цель: поймать расхождение значения в SM и в in_-переменной в процессе.
* Тест: Каждые checkTime проверяем текущее значение в SM и в процессе, меняем в SM и опять проверяем.
*
* Заодно если инициализирован child то проверяем что у него тоже все входы совпадают со значениями в SM.
*/
class
LostTestProc
:
public
Lost
TestProc_SK
public
Lost
PassiveTestProc
{
public
:
LostTestProc
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
confnode
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"LostTestProc"
)
);
virtual
~
LostTestProc
();
void
setChildPassiveProc
(
const
std
::
shared_ptr
<
LostPassiveTestProc
>&
lp
);
protected
:
LostTestProc
();
...
...
@@ -26,14 +30,13 @@ class LostTestProc:
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
;
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
)
override
;
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
override
;
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
;
virtual
std
::
string
getMonitInfo
()
override
;
std
::
unordered_map
<
UniSetTypes
::
ObjectId
,
long
>
slist
;
size_t
ncycle
=
{
0
};
bool
waitEmpty
=
{
false
};
std
::
shared_ptr
<
LostPassiveTestProc
>
child
;
private
:
};
// -----------------------------------------------------------------------------
...
...
extensions/tests/SMemoryTest/Makefile.am
View file @
a6485982
...
...
@@ -25,7 +25,7 @@ sm_lostmessage_test_CPPFLAGS = -I$(top_builddir)/include \
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/SharedMemory
\
$(SIGC_CFLAGS)
$(POCO_CFLAGS)
sm_lostmessage_test_SOURCES
=
LostTestProc_SK.cc LostTestProc.cc sm-lostmessage-test.cc
sm_lostmessage_test_SOURCES
=
LostTestProc_SK.cc LostTestProc.cc
LostPassiveTestProc.cc
sm-lostmessage-test.cc
clean-local
:
...
...
extensions/tests/SMemoryTest/losttestproc.src.xml
0 → 100644
View file @
a6485982
<?xml version="1.0" encoding="utf-8"?>
<!--
name - название класса
msgcount - сколько сообщений обрабатывается за один раз
sleep_msec - пауза между итерациями в работе процесса
type
====
in - входные регистры (только для чтения)
out - выходные регистры (запись)
-->
<LostTestProc>
<settings>
<set
name=
"class-name"
val=
"LostTestProc"
/>
<set
name=
"msg-count"
val=
"30"
/>
<set
name=
"sleep-msec"
val=
"150"
/>
</settings>
<variables>
<item
name=
"checkTime"
type=
"int"
default=
"200"
min=
"0"
comment=
"check Working time"
const=
"1"
public=
"1"
/>
</variables>
<smap>
</smap>
<msgmap>
</msgmap>
</LostTestProc>
extensions/tests/SMemoryTest/sm-lostmessage-test.cc
View file @
a6485982
...
...
@@ -25,6 +25,14 @@ int main(int argc, const char** argv)
int
num
=
conf
->
getArgPInt
(
"--numproc"
,
1
);
int
max
=
10
;
if
(
num
>
max
)
{
cerr
<<
"'num' must be < "
<<
max
<<
endl
;
return
1
;
}
for
(
int
i
=
1
;
i
<=
num
;
i
++
)
{
ostringstream
s
;
...
...
@@ -32,8 +40,15 @@ int main(int argc, const char** argv)
cout
<<
"..create "
<<
s
.
str
()
<<
endl
;
auto
tp
=
make_shared
<
LostTestProc
>
(
conf
->
getObjectID
(
s
.
str
()));
// tp->init_dlog(dlog());
act
->
add
(
tp
);
ostringstream
sp
;
sp
<<
"TestProc"
<<
(
i
+
max
);
cout
<<
"..create passive "
<<
sp
.
str
()
<<
endl
;
auto
child
=
make_shared
<
LostPassiveTestProc
>
(
conf
->
getObjectID
(
sp
.
str
()));
tp
->
setChildPassiveProc
(
child
);
act
->
add
(
child
);
}
SystemMessage
sm
(
SystemMessage
::
StartUp
);
...
...
extensions/tests/SMemoryTest/start_fg_losttest.sh
View file @
a6485982
...
...
@@ -18,6 +18,18 @@ ${START} -f ./sm-lostmessage-test --confile ./test-lost.xml \
--TestProc3-filter-value
3
\
--TestProc3-sleep-msec
50
\
--TestProc3-log-add-levels
$LOGLEVEL
\
--TestProc11-filter-field
losttest
\
--TestProc11-filter-value
1
\
--TestProc11-sleep-msec
50
\
--TestProc11-log-add-levels
$LOGLEVEL
\
--TestProc12-filter-field
losttest
\
--TestProc12-filter-value
2
\
--TestProc12-sleep-msec
50
\
--TestProc12-log-add-levels
$LOGLEVEL
\
--TestProc13-filter-field
losttest
\
--TestProc13-filter-value
3
\
--TestProc13-sleep-msec
50
\
--TestProc13-log-add-levels
$LOGLEVEL
\
--ulog-add-levels
crit
$*
# --uniset-abort-script ./abort-script-example.sh
#--ulog-add-levels crit,warn,info
...
...
uniset2.files
View file @
a6485982
...
...
@@ -194,6 +194,8 @@ extensions/tests/SMemoryTest/TestProc.h
extensions/tests/SMemoryTest/testproc.src.xml
extensions/tests/SMemoryTest/LostTestProc.cc
extensions/tests/SMemoryTest/LostTestProc.h
extensions/tests/SMemoryTest/LostPassiveTestProc.cc
extensions/tests/SMemoryTest/LostPassiveTestProc.h
extensions/tests/SMemoryTest/losttestproc.src.xml
extensions/tests/SMemoryTest/sm-lostmessage-test.cc
extensions/tests/SMemoryTest/Makefile.am
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment