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 434F320764 for ; Fri, 6 Sep 2019 09:45:02 -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 HdwcBf2_E8bM for ; Fri, 6 Sep 2019 09:45:02 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 88BA52071C for ; Fri, 6 Sep 2019 09:45:01 -0400 (EDT) Date: Fri, 6 Sep 2019 16:44:44 +0300 From: Alexander Turenko Subject: [tarantool-patches] Re: [PATCH v2 2/2] say: take getaddrinfo() errors into account Message-ID: <20190906134443.kc5anat2t3q26l3o@tkn_work_nb> References: <3603f7507651b37ddd549a8c247709cc7ff43f44.1561469272.git.roman.habibov@tarantool.org> <20190723145249.5xwc2td6omphwwzw@tkn_work_nb> <20190828213431.3yd4kwcahe2oizgs@tkn_work_nb> <8E98F721-601F-436D-8F0A-5E399D8F7CAB@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8E98F721-601F-436D-8F0A-5E399D8F7CAB@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: Roman Khabibov Cc: tarantool-patches@freelists.org > >> +-- > >> +-- gh-4138: check getaddrinfo() error and panic after that. > >> +-- > >> +code=[[ > >> +local socket = require('socket') > >> +local log = require('log') > >> +local fio = require('fio') > >> + > >> +path = fio.pathjoin(fio.cwd(), 'log_unix_socket_test.sock') > >> +unix_socket = socket('AF_UNIX', 'SOCK_DGRAM', 0) > >> +unix_socket:bind('unix/', path) > >> + > >> +opt = string.format("syslog:server=non_exists_hostname:%s,identity=tarantool", path) > >> +box.cfg{log = opt, log_nonblock=true} > > > > log_nonblock is not needed here, so it is better to remove it. > Removed. Still no. > > box.cfg{log = 'syslog:server=non_exists_hostname:3301'} is enough, not need to > > form a file path, no need identity, no need requiring socket, log and fio. > > > > The test passes even before the patch, so what it is intended to test? I > > think we should write a test that verifies stderr output to find all log > > messages we expect to appear in the case: > > > > Linux: > > > > | SystemError getaddrinfo: Temporary failure in name resolution: Input/output error > > | SystemError syslog logger: Input/output error: Input/output error > > | failed to initialize logging subsystem > > > > gai_strerror() message corresponds to EAI_AGAIN. > > > > Mac OS: > > > > | SystemError getaddrinfo: nodename nor servname provided, or not known: Input/output error > > | SystemError syslog logger: Input/output error: Input/output error > > | failed to initialize logging subsystem > > > > gai_strerror() message corresponds to EAI_NONAME. > > > > I propose to call ffi.C.gai_strerror() right from a test to form two > > error messages and verify that the actual input match one of them. > > > > If it is hard to catch stderr, then let's proceed w/o this test. However > > I think it is doable. > > > > I also propose to test error messages in the similar way (using > > ffi.C.gai_strerror(GAI_AGAIN) and ffi.C.gai_strerror(GAI_NONAME)) in > > test cases in second patch of the patchset. > We discussed that with Vova and we decided, that it is too difficult. > It is better, to waste not time for this test. Test for PANIC is enough. I don't see any reason to add a test case that checks that tarantool exits in the case: it was so before the commit and nothing is changed except the error message. I propose to delete the test case. > >> + /* gh-4138: Check getaddrinfo() error. */ > >> + isnt(coio_getaddrinfo("non_exists_hostname", port, NULL, &i, 1), 0, > >> + "getaddrinfo error"); > > > > I would say 'getaddrinfo retval' instead 'getaddrinfo error'. I don't insist, but remind about that here if it was missed by a mistake. > >> + isnt(strstr(diag_get()->last->errmsg, "getaddrinfo"), NULL, > >> + "getaddrinfo error message"); > >> + > > > > I propose to verify the entire error message using > > gai_strerror(GAI_AGAIN) and gai_strerror(GAI_NONAME)—just as proposed > > above for a log message. > I have not found the way, how to carry this macros/enum from the libc header to Lua. It is possible to add them into socket.c, but anyway it is not worth to do this just for a test. Let's check for certain error messages (not for just 'getaddrinfo: ' prefix).