.rdb file missing in test for `#GC6` "Read a string value"

Adding the results for the “Read a Key” test and “Read a string value” which shows that the .rdb file exists there, but not in the next test.

I log the files found in the -dir path to the console. You can see the .rdb file in the first test but not in the 2nd, resulting in FileNotFoundError

[tester::#JZ6] Running tests for Stage #JZ6 (RDB Persistence - Read a key)
[tester::#JZ6] Created RDB file with single key: "blueberry"
[tester::#JZ6] $ ./your_program.sh --dir /tmp/rdbfiles3032436844 --dbfilename mango.rdb
[your_program] [DEBUG] database:12: printing files: in /tmp/rdbfiles3032436844
[your_program] [DEBUG] database:17: mango.rdb
[your_program] [DEBUG] database:18: *** END PRINTING FILES ***
[your_program] [DEBUG] database:38: opening db: mango.rdb
[your_program] [DEBUG] database:59: store: {'blueberry': {'value': 'pineapple', 'expiry': None}}
[your_program] [DEBUG] main:15: database config: {'directory': '/tmp/rdbfiles3032436844', 'dbfilename': 'mango.rdb'}
[your_program] EOF
[your_program] [DEBUG] main:42: Server is listening on port 6379...
[tester::#JZ6] client: $ redis-cli KEYS *
[tester::#JZ6] client: Sent bytes: "*2\r\n$4\r\nKEYS\r\n$1\r\n*\r\n"
[your_program] [DEBUG] main:19: Accepted connection from ('::1', 50932, 0, 0)
[your_program] [DEBUG] main:27: Received b'*2\r\n$4\r\nKEYS\r\n$1\r\n*\r\n' from ('::1', 50932, 0, 0)
[your_program] [DEBUG] database:86: split_data: ['*2', '$4', 'KEYS', '$1', '*', '']
[your_program] [DEBUG] database:87: split_data[2]: KEYS
[your_program] [DEBUG] database:38: opening db: mango.rdb
[your_program] [DEBUG] database:59: store: {'blueberry': {'value': 'pineapple', 'expiry': None}}
[your_program] EOF
[your_program] [DEBUG] main:32: Sent b'*1\r\n$9\r\nblueberry\r\n' to ('::1', 50932, 0, 0)
[your_program] [DEBUG] main:33: database: {'blueberry': {'value': 'pineapple', 'expiry': None}}
[tester::#JZ6] client: Received bytes: "*1\r\n$9\r\nblueberry\r\n"
[tester::#JZ6] client: Received RESP array: ["blueberry"]
[tester::#JZ6] Received ["blueberry"]
[tester::#JZ6] Test passed.
[tester::#JZ6] Terminating program
[tester::#JZ6] Program terminated successfully

[tester::#ZG5] Running tests for Stage #ZG5 (RDB Persistence - RDB file config)
[tester::#ZG5] $ ./your_program.sh --dir /tmp/rdbfiles1184649393 --dbfilename grape.rdb
[your_program] [DEBUG] database:12: printing files: in /tmp/rdbfiles1184649393
[your_program] [DEBUG] database:18: *** END PRINTING FILES ***
[your_program] [DEBUG] database:38: opening db: grape.rdb
[your_program] Traceback (most recent call last):
[your_program]   File "<frozen runpy>", line 198, in _run_module_as_main
[your_program]   File "<frozen runpy>", line 88, in _run_code
[your_program]   File "/app/app/main.py", line 11, in <module>
[your_program]     db = Database(**{
[your_program]          ^^^^^^^^^^^^
[your_program]   File "/app/app/database.py", line 35, in __init__
[your_program]     self.open_db()
[your_program]   File "/app/app/database.py", line 40, in open_db
[your_program]     with open(db_full_path, "rb") as db:
[your_program]          ^^^^^^^^^^^^^^^^^^^^^^^^
[your_program] FileNotFoundError: [Errno 2] No such file or directory: '/tmp/rdbfiles1184649393/grape.rdb'
[tester::#ZG5] dial tcp [::1]:6379: connect: connection refused
[tester::#ZG5] Test failed
[tester::#ZG5] Terminating program
[tester::#ZG5] Program terminated successfully

@porcupine-578 This is actually expected behavior, as we’re testing whether your code can handle the case when the RDB file doesn’t exist.

Please refer to the note in Read a key #jz6:

  • The RDB file provided by --dir and --dbfilename might not exist. If the file doesn’t exist, your program must treat the database as empty.

Ah okay great, thank you for the quick reply!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.