Skip to content

Commit

Permalink
Merge pull request #57 from codecrafters-io/redis-repl
Browse files Browse the repository at this point in the history
Fixes to Redis Replication Extension tests.
  • Loading branch information
ryan-gang authored Feb 12, 2024
2 parents 9699430 + 4f485b3 commit 1917bfa
Show file tree
Hide file tree
Showing 36 changed files with 357 additions and 289 deletions.
2 changes: 1 addition & 1 deletion internal/stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func normalizeTesterOutput(testerOutput []byte) []byte {
"tcp_port": {regexp.MustCompile("read tcp 127.0.0.1:\\d+->127.0.0.1:6379: read: connection reset by peer")},
" tmp_dir ": {regexp.MustCompile(" /private/var/folders/[^ ]+ "), regexp.MustCompile(" /tmp/[^ ]+ ")},
"timestamp": {regexp.MustCompile("\\d{2}:\\d{2}:\\d{2}\\.\\d{3}")},
"replication_id": {regexp.MustCompile(".*FULLRESYNC [A-Za-z0-9]+ 0 received.")},
"replication_id": {regexp.MustCompile("FULLRESYNC [A-Za-z0-9]+ 0 received.")},
"wait_timeout": {regexp.MustCompile("WAIT command returned after [0-9]+ ms")},
}

Expand Down
6 changes: 3 additions & 3 deletions internal/test_helpers/fixtures/expiry/pass
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ Debug = true
[stage-7] Running tests for Stage #7: expiry
[stage-7] $ ./spawn_redis_server.sh
[stage-7] $ redis-cli set grapes apples px 100
[stage-7] Received OK (at 16:26:05.673)
[stage-7] $ redis-cli get grapes (sent at 16:26:05.673, key should not be expired)
[stage-7] Received OK (at 17:06:05.841)
[stage-7] $ redis-cli get grapes (sent at 17:06:05.841, key should not be expired)
[stage-7] Received "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 16:26:05.774, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 17:06:05.942, key should be expired)
[stage-7] Test passed.
[stage-7] Terminating program
[stage-7] Program terminated successfully
2 changes: 1 addition & 1 deletion internal/test_helpers/fixtures/ping-pong/eof
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Debug = true
[stage-2] $ redis-cli ping
[stage-2] Reading response...
[stage-2] Hint: 'connection reset by peer' usually means that your program closed the connection before sending a complete response.
[stage-2] read tcp 127.0.0.1:47322->127.0.0.1:6379: read: connection reset by peer
[stage-2] read tcp 127.0.0.1:40934->127.0.0.1:6379: read: connection reset by peer
[stage-2] Test failed
[stage-2] Terminating program
[stage-2] Program terminated successfully
8 changes: 4 additions & 4 deletions internal/test_helpers/fixtures/rdb-config/pass
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ Debug = true
[stage-7] Running tests for Stage #7: expiry
[stage-7] $ ./spawn_redis_server.sh
[stage-7] $ redis-cli set grapes apples px 100
[stage-7] Received OK (at 16:27:33.853)
[stage-7] $ redis-cli get grapes (sent at 16:27:33.853, key should not be expired)
[stage-7] Received OK (at 17:05:04.110)
[stage-7] $ redis-cli get grapes (sent at 17:05:04.110, key should not be expired)
[stage-7] Received "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 16:27:33.954, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 17:05:04.211, key should be expired)
[stage-7] Test passed.
[stage-7] Terminating program
[stage-7] Program terminated successfully

[stage-8] Running tests for Stage #8: rdb-config
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles4245072751 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3427354740 --dbfilename banana.rdb
[stage-8] $ redis-cli CONFIG GET dir
[stage-8] Test passed.
[stage-8] Terminating program
Expand Down
10 changes: 5 additions & 5 deletions internal/test_helpers/fixtures/rdb-read-key/pass
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,25 @@ Debug = true
[stage-7] Running tests for Stage #7: expiry
[stage-7] $ ./spawn_redis_server.sh
[stage-7] $ redis-cli set grapes apples px 100
[stage-7] Received OK (at 16:32:15.892)
[stage-7] $ redis-cli get grapes (sent at 16:32:15.892, key should not be expired)
[stage-7] Received OK (at 17:08:26.941)
[stage-7] $ redis-cli get grapes (sent at 17:08:26.941, key should not be expired)
[stage-7] Received "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 16:32:15.993, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 17:08:27.042, key should be expired)
[stage-7] Test passed.
[stage-7] Terminating program
[stage-7] Program terminated successfully

[stage-8] Running tests for Stage #8: rdb-config
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3880749550 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles2544575897 --dbfilename banana.rdb
[stage-8] $ redis-cli CONFIG GET dir
[stage-8] Test passed.
[stage-8] Terminating program
[stage-8] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-9] Running tests for Stage #9: rdb-read-key
[stage-9] Created RDB file with single key: "pear"
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles4179904341 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles2889088137 --dbfilename blueberry.rdb
[stage-9] $ redis-cli KEYS *
[stage-9] Test passed.
[stage-9] Terminating program
Expand Down
14 changes: 7 additions & 7 deletions internal/test_helpers/fixtures/rdb-read-multiple-keys/pass
Original file line number Diff line number Diff line change
Expand Up @@ -69,41 +69,41 @@ Debug = true
[stage-7] Running tests for Stage #7: expiry
[stage-7] $ ./spawn_redis_server.sh
[stage-7] $ redis-cli set grapes apples px 100
[stage-7] Received OK (at 16:27:38.910)
[stage-7] $ redis-cli get grapes (sent at 16:27:38.910, key should not be expired)
[stage-7] Received OK (at 17:06:37.814)
[stage-7] $ redis-cli get grapes (sent at 17:06:37.814, key should not be expired)
[stage-7] Received "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 16:27:39.012, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 17:06:37.915, key should be expired)
[stage-7] Test passed.
[stage-7] Terminating program
[stage-7] Program terminated successfully

[stage-8] Running tests for Stage #8: rdb-config
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles2385476531 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3228425667 --dbfilename banana.rdb
[stage-8] $ redis-cli CONFIG GET dir
[stage-8] Test passed.
[stage-8] Terminating program
[stage-8] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-9] Running tests for Stage #9: rdb-read-key
[stage-9] Created RDB file with single key: "pear"
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles537073336 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles1346244657 --dbfilename blueberry.rdb
[stage-9] $ redis-cli KEYS *
[stage-9] Test passed.
[stage-9] Terminating program
[stage-9] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-10] Running tests for Stage #10: rdb-read-string-value
[stage-10] Created RDB file with single key-value pair: strawberry="apple"
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3077309834 --dbfilename banana.rdb
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles1308470631 --dbfilename banana.rdb
[stage-10] $ redis-cli GET strawberry
[stage-10] Test passed.
[stage-10] Terminating program
[stage-10] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-11] Running tests for Stage #11: rdb-read-multiple-keys
[stage-11] Created RDB file with 5 keys: ["orange" "blueberry" "strawberry" "pineapple" "banana"]
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3755854538 --dbfilename pear.rdb
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles1518517472 --dbfilename pear.rdb
[stage-11] $ redis-cli KEYS *
[stage-11] Test passed.
[stage-11] Terminating program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,49 @@ Debug = true
[stage-7] Running tests for Stage #7: expiry
[stage-7] $ ./spawn_redis_server.sh
[stage-7] $ redis-cli set grapes apples px 100
[stage-7] Received OK (at 16:26:11.736)
[stage-7] $ redis-cli get grapes (sent at 16:26:11.736, key should not be expired)
[stage-7] Received OK (at 17:06:08.785)
[stage-7] $ redis-cli get grapes (sent at 17:06:08.785, key should not be expired)
[stage-7] Received "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 16:26:11.838, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 17:06:08.886, key should be expired)
[stage-7] Test passed.
[stage-7] Terminating program
[stage-7] Program terminated successfully

[stage-8] Running tests for Stage #8: rdb-config
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3200217314 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles360452185 --dbfilename banana.rdb
[stage-8] $ redis-cli CONFIG GET dir
[stage-8] Test passed.
[stage-8] Terminating program
[stage-8] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-9] Running tests for Stage #9: rdb-read-key
[stage-9] Created RDB file with single key: "pear"
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3726916059 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles973568596 --dbfilename blueberry.rdb
[stage-9] $ redis-cli KEYS *
[stage-9] Test passed.
[stage-9] Terminating program
[stage-9] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-10] Running tests for Stage #10: rdb-read-string-value
[stage-10] Created RDB file with single key-value pair: strawberry="apple"
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles514194738 --dbfilename banana.rdb
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles997733393 --dbfilename banana.rdb
[stage-10] $ redis-cli GET strawberry
[stage-10] Test passed.
[stage-10] Terminating program
[stage-10] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-11] Running tests for Stage #11: rdb-read-multiple-keys
[stage-11] Created RDB file with 5 keys: ["orange" "blueberry" "strawberry" "pineapple" "banana"]
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles418699697 --dbfilename pear.rdb
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles369671918 --dbfilename pear.rdb
[stage-11] $ redis-cli KEYS *
[stage-11] Test passed.
[stage-11] Terminating program
[stage-11] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-12] Running tests for Stage #12: rdb-read-multiple-string-values
[stage-12] Created RDB file with key-value pairs: "orange"="grape", "mango"="pear", "grape"="blueberry", "pear"="pineapple"
[stage-12] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles1938215963 --dbfilename apple.rdb
[stage-12] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles4056080642 --dbfilename apple.rdb
[stage-12] $ redis-cli GET orange
[stage-12] $ redis-cli GET mango
[stage-12] $ redis-cli GET grape
Expand Down
18 changes: 9 additions & 9 deletions internal/test_helpers/fixtures/rdb-read-value-with-expiry/pass
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,49 @@ Debug = true
[stage-7] Running tests for Stage #7: expiry
[stage-7] $ ./spawn_redis_server.sh
[stage-7] $ redis-cli set grapes apples px 100
[stage-7] Received OK (at 16:26:25.205)
[stage-7] $ redis-cli get grapes (sent at 16:26:25.205, key should not be expired)
[stage-7] Received OK (at 17:06:22.245)
[stage-7] $ redis-cli get grapes (sent at 17:06:22.245, key should not be expired)
[stage-7] Received "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 16:26:25.307, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 17:06:22.346, key should be expired)
[stage-7] Test passed.
[stage-7] Terminating program
[stage-7] Program terminated successfully

[stage-8] Running tests for Stage #8: rdb-config
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles4038037800 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3286858633 --dbfilename banana.rdb
[stage-8] $ redis-cli CONFIG GET dir
[stage-8] Test passed.
[stage-8] Terminating program
[stage-8] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-9] Running tests for Stage #9: rdb-read-key
[stage-9] Created RDB file with single key: "pear"
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles817889673 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3373171157 --dbfilename blueberry.rdb
[stage-9] $ redis-cli KEYS *
[stage-9] Test passed.
[stage-9] Terminating program
[stage-9] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-10] Running tests for Stage #10: rdb-read-string-value
[stage-10] Created RDB file with single key-value pair: strawberry="apple"
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3156628814 --dbfilename banana.rdb
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles235023805 --dbfilename banana.rdb
[stage-10] $ redis-cli GET strawberry
[stage-10] Test passed.
[stage-10] Terminating program
[stage-10] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-11] Running tests for Stage #11: rdb-read-multiple-keys
[stage-11] Created RDB file with 5 keys: ["orange" "blueberry" "strawberry" "pineapple" "banana"]
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles189452306 --dbfilename pear.rdb
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3548981705 --dbfilename pear.rdb
[stage-11] $ redis-cli KEYS *
[stage-11] Test passed.
[stage-11] Terminating program
[stage-11] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-12] Running tests for Stage #12: rdb-read-multiple-string-values
[stage-12] Created RDB file with key-value pairs: "orange"="grape", "mango"="pear", "grape"="blueberry", "pear"="pineapple"
[stage-12] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles486173548 --dbfilename apple.rdb
[stage-12] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles510463612 --dbfilename apple.rdb
[stage-12] $ redis-cli GET orange
[stage-12] $ redis-cli GET mango
[stage-12] $ redis-cli GET grape
Expand All @@ -121,7 +121,7 @@ Debug = true
[stage-12] Error terminating program: 'program failed to exit in 2 seconds after receiving sigterm'

[stage-13] Running tests for Stage #13: rdb-read-value-with-expiry
[stage-13] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles2461329809 --dbfilename apple.rdb
[stage-13] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles2932128110 --dbfilename apple.rdb
[stage-13] $ redis-cli GET pineapple
[stage-13] $ redis-cli GET raspberry
[stage-13] $ redis-cli GET blueberry
Expand Down
Loading

0 comments on commit 1917bfa

Please sign in to comment.