From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 7FF34271E2 for ; Fri, 13 Jul 2018 06:29:53 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ftnllINbArW8 for ; Fri, 13 Jul 2018 06:29:53 -0400 (EDT) Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [217.69.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 406B62706E for ; Fri, 13 Jul 2018 06:29:53 -0400 (EDT) From: Olga Arkhangelskaia Subject: [tarantool-patches] [PATCH 3/3] Syslog destination test unix socket Date: Fri, 13 Jul 2018 13:29:38 +0300 Message-Id: <20180713102938.31897-4-arkholga@tarantool.org> In-Reply-To: <20180713102938.31897-1-arkholga@tarantool.org> References: <20180713102938.31897-1-arkholga@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Olga Arkhangelskaia 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 --- 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)