I’ve implemented ‘Read a key’, but te tests fail
Hi @UdeshyaDhungana, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.
Hi @andy1li ,
This turned out to be my own fault. However, I came across connection refused
error
remote: [tester::#JZ6] Running tests for Stage #JZ6 (RDB Persistence - Read a key)
remote: [tester::#JZ6] Created RDB file with a single key: ["apple"]
remote: [tester::#JZ6] Hexdump of RDB file contents:
remote: [tester::#JZ6] Idx | Hex | ASCII
remote: [tester::#JZ6] -----+-------------------------------------------------+-----------------
remote: [tester::#JZ6] 0000 | 52 45 44 49 53 30 30 31 31 fa 09 72 65 64 69 73 | REDIS0011..redis
remote: [tester::#JZ6] 0010 | 2d 76 65 72 05 37 2e 32 2e 30 fa 0a 72 65 64 69 | -ver.7.2.0..redi
remote: [tester::#JZ6] 0020 | 73 2d 62 69 74 73 c0 40 fe 00 fb 01 00 00 05 61 | s-bits.@.......a
remote: [tester::#JZ6] 0030 | 70 70 6c 65 04 70 65 61 72 ff b5 5b bb a8 bb f0 | pple.pear..[....
remote: [tester::#JZ6] 0040 | 0c 1d 0a | ...
remote: [tester::#JZ6]
remote: [tester::#JZ6] $ ./your_program.sh --dir /tmp/rdbfiles2215156312 --dbfilename orange.rdb
remote: [your_program] Saved metadata: redis-ver = 7.2.0
remote: [tester::#JZ6] client: $ redis-cli KEYS *
remote: [tester::#JZ6] client: Sent bytes: "*2\r\n$4\r\nKEYS\r\n$1\r\n*\r\n"
remote: [your_program] Size: 1[ apple,
remote: [your_program] ]
remote: [tester::#JZ6] client: Received bytes: "*1\r\n$5\r\napple\r\n"
remote: [tester::#JZ6] client: Received RESP array: ["apple"]
remote: [tester::#JZ6] Received ["apple"]
remote: [tester::#JZ6] Test passed.
remote: [tester::#JZ6] Terminating program
remote: [tester::#JZ6] Program terminated successfully
remote:
remote: [tester::#ZG5] Running tests for Stage #ZG5 (RDB Persistence - RDB file config)
remote: [tester::#ZG5] $ ./your_program.sh --dir /tmp/rdbfiles3550974591 --dbfilename pear.rdb
remote: [tester::#ZG5] dial tcp [::1]:6379: connect: connection refused
remote: [tester::#ZG5] Test failed
remote: [tester::#ZG5] Terminating program
remote: [tester::#ZG5] Program terminated successfully
Can you please help me with this?
Absolutely! Debugging will be much easier if I can run it directly. Would you mind uploading your code to GitHub and sharing the link?
Thanks for sharing the link! I’ll take a look and get back to you by the end of the week.
@andy1li Do you have any updates on this?
@UdeshyaDhungana, your code needs to handle the case where the RDB file provided by --dir
and --dbfilename
does not exist.
Here’s a log confirming that the RDB file could be missing:
int init_db(ConfigOptions* c) {
...
char* full_rdb_path = malloc(sizeof(char) * (strlen(c->dir) + strlen(c->dbfilename) + 1));
strcpy(full_rdb_path, c->dir);
strcat(full_rdb_path, "/");
strcat(full_rdb_path, c->dbfilename);
+ if (access(full_rdb_path, F_OK) == -1) {
+ fprintf(stderr, "RDB file does not exist at %s\n", full_rdb_path);
+ }
@andy1li thanks!!!
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.