Tarantool development patches archive
 help / color / mirror / Atom feed
From: Olga Arkhangelskaia <arkholga@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Olga Arkhangelskaia <arkholga@tarantool.org>
Subject: [tarantool-patches] [PATCH 3/3] Syslog destination test unix socket
Date: Fri, 13 Jul 2018 13:29:38 +0300	[thread overview]
Message-ID: <20180713102938.31897-4-arkholga@tarantool.org> (raw)
In-Reply-To: <20180713102938.31897-1-arkholga@tarantool.org>

Adds syslog destination unix test in app-tap.
Test redirects logs to newly created unix socket and sets appropriate
log level. If log receives the same level - test passes.
Usage: test-run.py syslog

Signed-off-by: Olga Arkhangelskaia <arkholga@tarantool.org>
---
 test/app-tap/syslog_socket.test.lua | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100755 test/app-tap/syslog_socket.test.lua

diff --git a/test/app-tap/syslog_socket.test.lua b/test/app-tap/syslog_socket.test.lua
new file mode 100755
index 000000000..bc65ffd5e
--- /dev/null
+++ b/test/app-tap/syslog_socket.test.lua
@@ -0,0 +1,33 @@
+#!/usr/bin/env tarantool
+
+local tap = require('tap')
+local socket = require('socket')
+local os = require('os')
+local test = tap.test("syslog_unix")
+
+test:plan(1)
+local function start_server(test, sock_addr)
+    test:diag("Create unix socket")
+    local destination = 'unix:'.. sock_addr
+    local unix_socket = socket('AF_UNIX', 'SOCK_DGRAM',0)
+    unix_socket:bind('unix/', sock_addr)
+    socket.tcp_connect('unix', sock_addr)
+    unix_socket:listen()
+    return unix_socket, destination
+end
+
+local function find_log_level (test, socket, destination)
+	local buf
+	local opt = 'syslog:server='..destination..',identity=tarantool'
+	box.cfg{log = opt, log_level = 7}
+	buf = socket:read(300)
+	test:ok(buf:match('log level 7'))
+end
+
+path = '/tmp/syslog_test.sock'
+sock, dst = start_server(test, path)
+
+test:test('syslog_unix',find_log_level(test, sock, dst))
+sock:close()
+os.remove(path)
+os.exit(test:check() == true)
-- 
2.14.3 (Apple Git-98)

  parent reply	other threads:[~2018-07-13 10:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 10:29 [tarantool-patches] [PATCH 0/3] Syslog destination Olga Arkhangelskaia
2018-07-13 10:29 ` [tarantool-patches] [PATCH 1/3] Configurable syslog destination Olga Arkhangelskaia
2018-07-13 13:12   ` Vladimir Davydov
2018-07-13 10:29 ` [tarantool-patches] [PATCH 2/3] Syslog remote destination test Olga Arkhangelskaia
2018-07-13 13:27   ` Vladimir Davydov
2018-07-13 10:29 ` Olga Arkhangelskaia [this message]
2018-07-13 13:34   ` [tarantool-patches] [PATCH 3/3] Syslog destination test unix socket Vladimir Davydov
2018-07-13 12:42 ` [tarantool-patches] [PATCH 0/3] Syslog destination Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180713102938.31897-4-arkholga@tarantool.org \
    --to=arkholga@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 3/3] Syslog destination test unix socket' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox