Skip to content

Commit

Permalink
Merge pull request #56 from codecrafters-io/redis-repl
Browse files Browse the repository at this point in the history
Update Stage 3 (INFO replication on Replica) test.
  • Loading branch information
ryan-gang authored Feb 11, 2024
2 parents 427ff15 + f1c1609 commit 9699430
Show file tree
Hide file tree
Showing 28 changed files with 369 additions and 320 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 10:51:24.791)
[stage-7] $ redis-cli get grapes (sent at 10:51:24.791, key should not be expired)
[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 "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 10:51:24.893, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 16:26:05.774, 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:36926->127.0.0.1:6379: read: connection reset by peer
[stage-2] read tcp 127.0.0.1:47322->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 10:45:55.221)
[stage-7] $ redis-cli get grapes (sent at 10:45:55.221, key should not be expired)
[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 "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 10:45:55.322, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 16:27:33.954, 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/rdbfiles2453435298 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles4245072751 --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 10:46:00.269)
[stage-7] $ redis-cli get grapes (sent at 10:46:00.269, key should not be expired)
[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 "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 10:46:00.370, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 16:32:15.993, 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/rdbfiles2663685552 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3880749550 --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/rdbfiles2112653960 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles4179904341 --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 10:48:17.472)
[stage-7] $ redis-cli get grapes (sent at 10:48:17.472, key should not be expired)
[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 "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 10:48:17.573, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 16:27:39.012, 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/rdbfiles4213548725 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles2385476531 --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/rdbfiles2764557421 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles537073336 --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/rdbfiles357388602 --dbfilename banana.rdb
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3077309834 --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/rdbfiles604186444 --dbfilename pear.rdb
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3755854538 --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 10:51:27.722)
[stage-7] $ redis-cli get grapes (sent at 10:51:27.722, key should not be expired)
[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 "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 10:51:27.823, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 16:26:11.838, 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/rdbfiles4154756338 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3200217314 --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/rdbfiles2588948210 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3726916059 --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/rdbfiles1250161541 --dbfilename banana.rdb
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles514194738 --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/rdbfiles2275471340 --dbfilename pear.rdb
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles418699697 --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/rdbfiles3718936964 --dbfilename apple.rdb
[stage-12] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles1938215963 --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 10:46:07.415)
[stage-7] $ redis-cli get grapes (sent at 10:46:07.415, key should not be expired)
[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 "apples"
[stage-7] Sleeping for 101ms
[stage-7] $ redis-cli get grapes (sent at 10:46:07.516, key should be expired)
[stage-7] $ redis-cli get grapes (sent at 16:26:25.307, 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/rdbfiles1326260254 --dbfilename banana.rdb
[stage-8] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles4038037800 --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/rdbfiles1089935667 --dbfilename blueberry.rdb
[stage-9] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles817889673 --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/rdbfiles184674477 --dbfilename banana.rdb
[stage-10] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles3156628814 --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/rdbfiles3073674735 --dbfilename pear.rdb
[stage-11] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles189452306 --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/rdbfiles2582547524 --dbfilename apple.rdb
[stage-12] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles486173548 --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/rdbfiles356209747 --dbfilename apple.rdb
[stage-13] $ ./spawn_redis_server.sh --dir /tmp/rdbfiles2461329809 --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 9699430

Please sign in to comment.