[tarantool-patches] Re: [PATCH v2 2/2] say: take getaddrinfo() errors into account

Alexander Turenko alexander.turenko at tarantool.org
Fri Sep 6 16:44:44 MSK 2019


> >> +--
> >> +-- 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).




More information about the Tarantool-patches mailing list