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
94f971d1
Commit
94f971d1
authored
Sep 25, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogDB): добавил простые тесты
parent
97931dd2
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
156 additions
and
6 deletions
+156
-6
configure.ac
configure.ac
+2
-0
LogDB.cc
extensions/LogDB/LogDB.cc
+5
-3
LogDB.h
extensions/LogDB/LogDB.h
+1
-0
Makefile.am
extensions/LogDB/tests/Makefile.am
+14
-0
logdb-tests-conf.xml
extensions/LogDB/tests/logdb-tests-conf.xml
+4
-0
logdb-tests.at
extensions/LogDB/tests/logdb-tests.at
+3
-0
tests.sh
extensions/LogDB/tests/tests.sh
+104
-0
testsuite.at
extensions/LogDB/tests/testsuite.at
+7
-0
uniset2-logdb
extensions/LogDB/tests/uniset2-logdb
+2
-0
uniset2-logdb-adm
extensions/LogDB/tests/uniset2-logdb-adm
+2
-0
uniset2-test-logserver
extensions/LogDB/tests/uniset2-test-logserver
+2
-0
uniset2-logdb-adm
extensions/LogDB/uniset2-logdb-adm
+8
-2
Makefile.am
extensions/Makefile.am
+1
-1
testsuite.at
testsuite/testsuite.at
+1
-0
No files found.
configure.ac
View file @
94f971d1
...
@@ -339,6 +339,7 @@ if test ${buildtests} = true; then
...
@@ -339,6 +339,7 @@ if test ${buildtests} = true; then
AC_CONFIG_TESTDIR(extensions/UNetUDP/tests)
AC_CONFIG_TESTDIR(extensions/UNetUDP/tests)
AC_CONFIG_TESTDIR(extensions/SharedMemory/tests)
AC_CONFIG_TESTDIR(extensions/SharedMemory/tests)
AC_CONFIG_TESTDIR(extensions/IOControl/tests)
AC_CONFIG_TESTDIR(extensions/IOControl/tests)
AC_CONFIG_TESTDIR(extensions/LogDB/tests)
TESTSUITE_DIR="\$(top_builddir)/testsuite"
TESTSUITE_DIR="\$(top_builddir)/testsuite"
AC_SUBST(TESTSUITE_DIR)
AC_SUBST(TESTSUITE_DIR)
...
@@ -501,6 +502,7 @@ AC_CONFIG_FILES([Makefile
...
@@ -501,6 +502,7 @@ AC_CONFIG_FILES([Makefile
extensions/tests/MBSlaveTest/Makefile
extensions/tests/MBSlaveTest/Makefile
extensions/tests/MQPerfTest/Makefile
extensions/tests/MQPerfTest/Makefile
extensions/LogDB/Makefile
extensions/LogDB/Makefile
extensions/LogDB/tests/Makefile
testsuite/Makefile
testsuite/Makefile
wrappers/Makefile
wrappers/Makefile
wrappers/python/lib/Makefile
wrappers/python/lib/Makefile
...
...
extensions/LogDB/LogDB.cc
View file @
94f971d1
...
@@ -383,11 +383,13 @@ void LogDB::help_print()
...
@@ -383,11 +383,13 @@ void LogDB::help_print()
cout
<<
"logservers: "
<<
endl
;
cout
<<
"logservers: "
<<
endl
;
cout
<<
"--prefix-ls-check-connection-sec sec - Период проверки соединения с логсервером"
<<
endl
;
cout
<<
"--prefix-ls-check-connection-sec sec - Период проверки соединения с логсервером"
<<
endl
;
cout
<<
"--prefix-ls-read-buffer-size num - Размер буфера для чтения сообщений от логсервера.
Deault
: 10001"
<<
endl
;
cout
<<
"--prefix-ls-read-buffer-size num - Размер буфера для чтения сообщений от логсервера.
По умолчанию
: 10001"
<<
endl
;
cout
<<
"http: "
<<
endl
;
cout
<<
"http: "
<<
endl
;
cout
<<
"--prefix-httpserver-max-queued num - Размер очереди запросов к http серверу. Default: 100"
<<
endl
;
cout
<<
"--prefix-httpserver-host ip - IP на котором слушает http сервер. По умолчанию: localhost"
<<
endl
;
cout
<<
"--prefix-httpserver-max-threads num - Разрешённое количество потоков для http-сервера. Default: 3"
<<
endl
;
cout
<<
"--prefix-httpserver-port num - Порт на котором принимать запросы. По умолчанию: 8080"
<<
endl
;
cout
<<
"--prefix-httpserver-max-queued num - Размер очереди запросов к http серверу. По умолчанию: 100"
<<
endl
;
cout
<<
"--prefix-httpserver-max-threads num - Разрешённое количество потоков для http-сервера. По умолчанию: 3"
<<
endl
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
LogDB
::
run
(
bool
async
)
void
LogDB
::
run
(
bool
async
)
...
...
extensions/LogDB/LogDB.h
View file @
94f971d1
...
@@ -165,6 +165,7 @@ namespace uniset
...
@@ -165,6 +165,7 @@ namespace uniset
\todo web: генерировать html-страничку со списком подключения к логам с использованием готового шаблона
\todo web: генерировать html-страничку со списком подключения к логам с использованием готового шаблона
\todo db: сделать в RESET API команду включения или отключения запись логов в БД, для управления "на ходу"
\todo db: сделать в RESET API команду включения или отключения запись логов в БД, для управления "на ходу"
\todo Продумать и реализовать тесты
\todo Продумать и реализовать тесты
\todo rest: Добавить функцию получения значений внутренних переменных и настроек (для отладки LogDB)
*/
*/
class
LogDB
:
class
LogDB
:
public
EventLoopServer
public
EventLoopServer
...
...
extensions/LogDB/tests/Makefile.am
0 → 100644
View file @
94f971d1
if
HAVE_TESTS
include
$(top_builddir)/testsuite/testsuite-common.mk
check-local
:
atconfig package.m4 $(TESTSUITE)
$(SHELL)
$(TESTSUITE)
$(TESTSUITEFLAGS)
clean-local
:
rm
-rf
$(CLEANFILES)
rm
-rf
$(COVERAGE_REPORT_DIR)
include
$(top_builddir)/include.mk
endif
extensions/LogDB/tests/logdb-tests-conf.xml
0 → 100644
View file @
94f971d1
<?xml version="1.0" encoding="utf-8"?>
<LogDB
name=
"LogDB"
>
<logserver
name=
"logserver1"
ip=
"localhost"
port=
"3333"
cmd=
""
description=
"Лог сервер процесса управления N1"
/>
</LogDB>
extensions/LogDB/tests/logdb-tests.at
0 → 100644
View file @
94f971d1
AT_SETUP([LogDB tests])
AT_CHECK([$abs_top_builddir/testsuite/at-test-launch.sh $abs_top_builddir/extensions/LogDB/tests tests.sh],[0],[ignore],[ignore])
AT_CLEANUP
extensions/LogDB/tests/tests.sh
0 → 100755
View file @
94f971d1
#!/bin/sh
trap
''
HUP INT QUIT PIPE TERM
RET
=
0
LOGSERVER_PID
=
LOGDB_PID
=
dbfile
=
"logdb-tests.db"
http_host
=
"localhost"
http_port
=
8888
function
atexit
()
{
trap
- EXIT
[
-n
"
$LOGSERVER_PID
"
]
&&
kill
-9
$LOGSERVER_PID
2>/dev/null
[
-n
"
$LOGDB_PID
"
]
&&
kill
-9
$LOGDB_PID
2>/dev/null
sleep
3
rm
-f
"
$dbfile
*"
exit
$RET
}
trap
atexit EXIT
function
create_test_db
()
{
./uniset2-logdb-adm create
-f
$dbfile
}
function
logdb_run_logserver
()
{
./uniset2-test-logserver
-i
localhost
-p
3333
-d
500 1>/dev/null 2>/dev/null &
LOGSERVER_PID
=
$!
return
$?
}
function
logdb_run
()
{
./uniset2-logdb
--logdb-single-confile
logdb-tests-conf.xml
\
--logdb-dbfile
$dbfile
\
--logdb-db-buffer-size
5
\
--logdb-httpserver-host
$http_host
\
--logdb-httpserver-port
$http_port
\
--logdb-ls-check-connection-sec
1
\
--logdb-db-max-records
20000 &
LOGDB_PID
=
$!
return
$?
}
function
logdb_error
()
{
printf
"%20s: ERROR: %s
\n
"
"
$1
"
"
$2
"
}
# ------------------------------------------------------------------------------------------
function
logdb_test_count
()
{
CNT
=
$(
echo
'SELECT count(*) from logs;'
| sqlite3
$dbfile
)
[
"
$CNT
"
!=
"0"
]
&&
return
0
logdb_error
"test_count"
"count of logs should be > 0"
return
1
}
function
logdb_test_http_count
()
{
REQ
=
$(
curl
-s
--request
GET
"http://
$http_host
:
$http_port
/api/v01/logdb/count"
)
echo
$REQ
|
grep
-q
'"count":'
&&
return
0
logdb_error
"test_http_count"
"get count of records fail"
return
1
}
function
logdb_test_http_list
()
{
REQ
=
$(
curl
-s
--request
GET
"http://
$http_host
:
$http_port
/api/v01/logdb/list"
)
echo
$REQ
|
grep
-q
'logserver1'
&&
return
0
logdb_error
"test_http_list"
"get list must contain 'logserver1'"
return
1
}
# ------------------------------------------------------------------------------------------
function
logdb_run_all_tests
()
{
logdb_run_logserver
||
return
1
sleep
3
logdb_run
||
return
1
sleep
5
# =========== ТЕСТЫ ============
logdb_test_count
||
RET
=
1
logdb_test_http_count
||
RET
=
1
logdb_test_http_list
||
RET
=
1
}
create_test_db
||
exit
1
logdb_run_all_tests
||
exit
1
exit
$RET
extensions/LogDB/tests/testsuite.at
0 → 100644
View file @
94f971d1
m4_include(package.m4)
AT_COLOR_TESTS
AT_INIT([Loggb tests])
m4_include(logdb-tests.at)
extensions/LogDB/tests/uniset2-logdb
0 → 120000
View file @
94f971d1
../uniset2-logdb
\ No newline at end of file
extensions/LogDB/tests/uniset2-logdb-adm
0 → 120000
View file @
94f971d1
../uniset2-logdb-adm
\ No newline at end of file
extensions/LogDB/tests/uniset2-test-logserver
0 → 120000
View file @
94f971d1
../../../Utilities/ULog/uniset2-test-logserver
\ No newline at end of file
extensions/LogDB/uniset2-logdb-adm
View file @
94f971d1
...
@@ -6,7 +6,7 @@ usage()
...
@@ -6,7 +6,7 @@ usage()
echo
"Usage:
${
0
##*/
}
command [arguments]"
echo
"Usage:
${
0
##*/
}
command [arguments]"
echo
"Commands:"
echo
"Commands:"
echo
" help - this mesage"
echo
" help - this mesage"
echo
" create
dbfile - create database
"
echo
" create
[-f|--force] dbfile - create database. (force - remove if exists)
"
echo
" load dbfile [logname1:]logfile1.log [logname2:]logfile2.log... - load logs to database"
echo
" load dbfile [logname1:]logfile1.log [logname2:]logfile2.log... - load logs to database"
echo
" logfile - log file"
echo
" logfile - log file"
echo
" [lognameX] - log name for db. Default: name of logfile"
echo
" [lognameX] - log name for db. Default: name of logfile"
...
@@ -21,12 +21,18 @@ usage()
...
@@ -21,12 +21,18 @@ usage()
if
[
"
$1
"
==
"create"
]
;
then
if
[
"
$1
"
==
"create"
]
;
then
shift
shift
force
=
[
"
$1
"
==
"-f"
]
&&
force
=
1
&&
shift
[
"
$1
"
==
"--force"
]
&&
force
=
1
&&
shift
dbfile
=
"
$1
"
dbfile
=
"
$1
"
[
-z
"
$dbfile
"
]
&&
usage
&&
exit
1
[
-z
"
$dbfile
"
]
&&
usage
&&
exit
1
[
-
a
"
$dbfile
"
]
&&
echo
"
$dbfile
already exists.."
&&
exit
1
[
-
n
"
$force
"
]
&&
[
-a
"
$dbfile
"
]
&&
rm
-f
"
$dbfile
"
[
-a
"
$dbfile
"
]
&&
echo
"
$dbfile
already exists.."
&&
exit
1
sqlite3
$dbfile
<<
"_EOF_"
sqlite3
$dbfile
<<
"_EOF_"
...
...
extensions/Makefile.am
View file @
94f971d1
...
@@ -6,7 +6,7 @@ if HAVE_EXTENTIONS
...
@@ -6,7 +6,7 @@ if HAVE_EXTENTIONS
SUBDIRS
=
lib include SharedMemory SharedMemory/tests IOControl IOControl/tests LogicProcessor LogicProcessor/tests
\
SUBDIRS
=
lib include SharedMemory SharedMemory/tests IOControl IOControl/tests LogicProcessor LogicProcessor/tests
\
ModbusMaster ModbusSlave SMViewer UniNetwork UNetUDP UNetUDP/tests
\
ModbusMaster ModbusSlave SMViewer UniNetwork UNetUDP UNetUDP/tests
\
DBServer-MySQL DBServer-SQLite DBServer-PostgreSQL MQTTPublisher
\
DBServer-MySQL DBServer-SQLite DBServer-PostgreSQL MQTTPublisher
\
RRDServer tests ModbusMaster/tests ModbusSlave/tests LogDB
RRDServer tests ModbusMaster/tests ModbusSlave/tests LogDB
LogDB/tests
pkgconfigdir
=
$(libdir)
/pkgconfig
pkgconfigdir
=
$(libdir)
/pkgconfig
pkgconfig_DATA
=
libUniSet2Extensions.pc
pkgconfig_DATA
=
libUniSet2Extensions.pc
...
...
testsuite/testsuite.at
View file @
94f971d1
...
@@ -12,3 +12,4 @@ m4_include(../extensions/ModbusSlave/tests/mbslave-tests.at)
...
@@ -12,3 +12,4 @@ m4_include(../extensions/ModbusSlave/tests/mbslave-tests.at)
m4_include(../extensions/UNetUDP/tests/unetudp-tests.at)
m4_include(../extensions/UNetUDP/tests/unetudp-tests.at)
m4_include(../extensions/ModbusMaster/tests/mbmaster-tests.at)
m4_include(../extensions/ModbusMaster/tests/mbmaster-tests.at)
m4_include(../extensions/IOControl/tests/iocontrol-tests.at)
m4_include(../extensions/IOControl/tests/iocontrol-tests.at)
m4_include(../extensions/LogDB/tests/logdb-tests.at)
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