Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiredis-test got FAILED when starting. #294

Closed
kevinan9 opened this issue Jan 7, 2015 · 6 comments
Closed

Hiredis-test got FAILED when starting. #294

kevinan9 opened this issue Jan 7, 2015 · 6 comments

Comments

@kevinan9
Copy link

kevinan9 commented Jan 7, 2015

#30 Returns error when host cannot be resolved: FAILED

and only one in all testings.

@badboy
Copy link
Contributor

badboy commented Jan 7, 2015

Can you be more specific? What did you run? What was the output? Which version?

@kevinan9
Copy link
Author

kevinan9 commented Jan 8, 2015

Okey,
I unzipped the source codes to ~/hiredis-master, the 'Make test' so I got a executable file 'hiredis-test'.
(' head CHANGELOG.md' >> ### 0.11.0, is it the version number?)
And when I run './hiredis-test', I got:
[kevinan@SH-todo-1412181719 ~/hiredis-master]$ ./hiredis-test
#1 Format command without interpolation: PASSED
#2 Format command with %s string interpolation: PASSED
#3 Format command with %s and an empty string: PASSED
#4 Format command with an empty string in between proper interpolations: PASSED
#5 Format command with %b string interpolation: PASSED
#6 Format command with %b and an empty string: PASSED
#7 Format command with literal %: PASSED
#8 Format command with printf-delegation (int): PASSED
#9 Format command with printf-delegation (char): PASSED
#10 Format command with printf-delegation (short): PASSED
#11 Format command with printf-delegation (long): PASSED
#12 Format command with printf-delegation (long long): PASSED
#13 Format command with printf-delegation (unsigned int): PASSED
#14 Format command with printf-delegation (unsigned char): PASSED
#15 Format command with printf-delegation (unsigned short): PASSED
#16 Format command with printf-delegation (unsigned long): PASSED
#17 Format command with printf-delegation (unsigned long long): PASSED
#18 Format command with printf-delegation (float): PASSED
#19 Format command with printf-delegation (double): PASSED
#20 Format command with invalid printf format: PASSED
#21 Format command by passing argc/argv without lengths: PASSED
#22 Format command by passing argc/argv with lengths: PASSED
#23 Error handling in reply parser: PASSED
#24 Memory cleanup in reply parser: PASSED
#25 Set error on nested multi bulks with depth > 7: PASSED
#26 Works with NULL functions for reply: PASSED
#27 Works when a single newline (\r\n) covers two calls to feed: PASSED
#28 Don't reset state after protocol error: PASSED
#29 Don't do empty allocation for empty multi bulk: PASSED
#30 Returns error when host cannot be resolved: FAILED
#31 Returns error when the port is not open: PASSED
#32 Returns error when the unix socket path doesn't accept connections: PASSED
#33 Don't fail when redisFree is passed a NULL value: PASSED
#34 Don't fail when freeReplyObject is passed a NULL value: PASSED

Testing against TCP connection (127.0.0.1:6379):
#35 Is able to deliver commands: PASSED
#36 Is a able to send commands verbatim: PASSED
#37 %s String interpolation works: PASSED
#38 %b String interpolation works: PASSED
#39 Binary reply length is correct: PASSED
#40 Can parse nil replies: PASSED
#41 Can parse integer replies: PASSED
#42 Can parse multi bulk replies: PASSED
#43 Can handle nested multi bulk replies: PASSED
#44 Returns I/O error when the connection is lost: PASSED
#45 Returns I/O error on socket timeout: PASSED
#46 Set error when an invalid timeout usec value is given to redisConnectWithTimeout: PASSED
#47 Set error when an invalid timeout sec value is given to redisConnectWithTimeout: PASSED
#48 Append format command: PASSED
#49 Throughput:
(1000x PING: 0.046s)
(1000x LRANGE with 500 elements: 0.237s)
(10000x PING (pipelined): 0.018s)
(10000x LRANGE with 500 elements (pipelined): 2.306s)

Testing against Unix socket connection (/tmp/redis.sock):
#50 Is able to deliver commands: PASSED
#51 Is a able to send commands verbatim: PASSED
#52 %s String interpolation works: PASSED
#53 %b String interpolation works: PASSED
#54 Binary reply length is correct: PASSED
#55 Can parse nil replies: PASSED
#56 Can parse integer replies: PASSED
#57 Can parse multi bulk replies: PASSED
#58 Can handle nested multi bulk replies: PASSED
#59 Returns I/O error when the connection is lost: PASSED
#60 Returns I/O error on socket timeout: PASSED
#61 Throughput:
(1000x PING: 0.038s)
(1000x LRANGE with 500 elements: 0.279s)
(10000x PING (pipelined): 0.018s)
(10000x LRANGE with 500 elements (pipelined): 2.383s)

Testing against inherited fd (/tmp/redis.sock):
Connecting to inherited fd 4
#62 Is able to deliver commands: PASSED
#63 Is a able to send commands verbatim: PASSED
#64 %s String interpolation works: PASSED
#65 %b String interpolation works: PASSED
#66 Binary reply length is correct: PASSED
#67 Can parse nil replies: PASSED
#68 Can parse integer replies: PASSED
#69 Can parse multi bulk replies: PASSED
#70 Can handle nested multi bulk replies: PASSED
*** 1 TESTS FAILED ***

@NanXiao
Copy link
Contributor

NanXiao commented Jan 8, 2015

The failed case is "Returns error when host cannot be resolved: FAILED", and the relevant code is:

static void test_blocking_connection_errors(void) {
    redisContext *c;

    test("Returns error when host cannot be resolved: ");
    c = redisConnect((char*)"idontexist.local", 6379);
    test_cond(c->err == REDIS_ERR_OTHER &&
        (strcmp(c->errstr,"Name or service not known") == 0 ||
         strcmp(c->errstr,"Can't resolve: idontexist.local") == 0 ||
         strcmp(c->errstr,"nodename nor servname provided, or not known") == 0 ||
         strcmp(c->errstr,"No address associated with hostname") == 0 ||
         strcmp(c->errstr,"no address associated with name") == 0));
    redisFree(c);
    ......
}

I think the cause is the c->errstr not match. Please use gdb to check what error string is returned.

@kevinan9
Copy link
Author

kevinan9 commented Jan 8, 2015

Yes, I add a line "strcmp(c->errstr,"Temporary failure in name resolution") == 0 || " into the relevant code, then it is ok, thanks.

@NanXiao
Copy link
Contributor

NanXiao commented Jan 8, 2015

@badboy: Personally, I don't think use "strcmp(c->errstr,"Name or service not known") == 0 ..." is a good method. Because it heavily depends on the specified system. If the string is changed, such as add or remove a space, the code also need to be changed.

@badboy
Copy link
Contributor

badboy commented Jan 8, 2015

Do you have a local dns resolver that handles your *.local domains?
Can you change idontexist.local to idontexist.test? (Per RFC 2606 we should use that anyway)
Does the error still persist?

mattsta added a commit that referenced this issue Jan 8, 2015
Suggested at
#294 (comment)

This change also makes the test stop hanging for 10 to 30 seconds
waiting for the resolver to timeout.  Now the resolver immediately
sees the hostname is bad and returns error without waiting for timeout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants