Skip to content

Commit ff576c4

Browse files
committed
chore: setup local testing
1 parent 888a11f commit ff576c4

File tree

5 files changed

+52
-23
lines changed

5 files changed

+52
-23
lines changed

Makefile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ test_concurrent_requests_with_kafka: build
2525
CODECRAFTERS_TEST_CASES_JSON="[{\"slug\":\"nh4\",\"tester_log_prefix\":\"stage-C1\",\"title\":\"Stage #C1: Multiple sequential requests from client\"}, {\"slug\":\"sk0\",\"tester_log_prefix\":\"stage-C2\",\"title\":\"Stage #C2: Multiple concurrent requests from client\"}]" \
2626
dist/main.out
2727

28-
test_all:
29-
make test_base_with_kafka
30-
make test_concurrent_requests_with_kafka
31-
make test_describe_topic_partitions_with_kafka
32-
make test_fetch_with_kafka
33-
3428
test_fetch_with_kafka: build
3529
CODECRAFTERS_REPOSITORY_DIR=./internal/test_helpers/pass_all \
3630
CODECRAFTERS_TEST_CASES_JSON="[{\"slug\":\"gs0\",\"tester_log_prefix\":\"stage-F1\",\"title\":\"Stage #F1: API Version with Fetch Key\"}, {\"slug\":\"dh6\",\"tester_log_prefix\":\"stage-F2\",\"title\":\"Stage #F2: Fetch with no topics\"}, {\"slug\":\"hn6\",\"tester_log_prefix\":\"stage-F3\",\"title\":\"Stage #F3: Fetch with unknown topic\"}, {\"slug\":\"cm4\",\"tester_log_prefix\":\"stage-F4\",\"title\":\"Stage #F4: Fetch with empty topic\"}, {\"slug\":\"eg2\",\"tester_log_prefix\":\"stage-F5\",\"title\":\"Stage #F5: Single Fetch from Disk\"}, {\"slug\":\"fd8\",\"tester_log_prefix\":\"stage-F6\",\"title\":\"Stage #F6: Multi Fetch from Disk\"}]" \
3731
dist/main.out
3832

39-
debug: build
40-
CODECRAFTERS_REPOSITORY_DIR=./internal/test_helpers/pass_all \
41-
CODECRAFTERS_TEST_CASES_JSON="[{\"slug\":\"ar4\",\"tester_log_prefix\":\"stage-P7\",\"title\":\"Stage #P7: Produce with multiple topics\"}]" \
42-
dist/main.out
43-
4433
test_produce_with_kafka: build
4534
CODECRAFTERS_REPOSITORY_DIR=./internal/test_helpers/pass_all \
4635
CODECRAFTERS_TEST_CASES_JSON="[{\"slug\":\"um3\",\"tester_log_prefix\":\"stage-P1\",\"title\":\"Stage #P1: Add Produce API to APIVersions\"}, {\"slug\":\"ck2\",\"tester_log_prefix\":\"stage-P2\",\"title\":\"Stage #P2: Produce with unknown topic\"}, {\"slug\":\"dp1\",\"tester_log_prefix\":\"stage-P3\",\"title\":\"Stage #P3: Produce with known topic\"}, {\"slug\":\"ps7\",\"tester_log_prefix\":\"stage-P4\",\"title\":\"Stage #P4: Produce with know topics 2\"}, {\"slug\":\"sb8\",\"tester_log_prefix\":\"stage-P5\",\"title\":\"Stage #P5: Produce multiple messages\"}, {\"slug\":\"mf2\",\"tester_log_prefix\":\"stage-P6\",\"title\":\"Stage #P6: Produce with multiple partitions\"}, {\"slug\":\"ar4\",\"tester_log_prefix\":\"stage-P7\",\"title\":\"Stage #P7: Produce with multiple topics\"}]" \
4736
dist/main.out
4837

38+
test_all:
39+
make test_base_with_kafka
40+
make test_concurrent_requests_with_kafka
41+
make test_describe_topic_partitions_with_kafka
42+
make test_fetch_with_kafka
43+
make test_produce_with_kafka
44+
4945
test:
5046
TESTER_DIR=$(shell pwd) go test -v ./internal/ -failfast --count=1
5147

internal/test_helpers/course_definition.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,10 +915,53 @@ stages:
915915
marketing_md: |-
916916
In this stage, you'll implement the Fetch response for a topic with multiple messages, reading them from disk.
917917
918+
# Producing Messages
919+
918920
- slug: "um3"
921+
primary_extension_slug: "producing-messages"
922+
name: "Include Produce in APIVersions"
923+
difficulty: easy
924+
marketing_md: |-
925+
In this stage, you'll add the Produce API to the APIVersions response.
926+
919927
- slug: "ck2"
928+
primary_extension_slug: "producing-messages"
929+
name: "Produce to an invalid topic"
930+
difficulty: medium
931+
marketing_md: |-
932+
In this stage, you'll implement the Produce response for an invalid topic.
933+
920934
- slug: "dp1"
935+
primary_extension_slug: "producing-messages"
936+
name: "Respond to Produce requests"
937+
difficulty: medium
938+
marketing_md: |-
939+
In this stage, you'll implement the Produce response for a valid topic.
940+
921941
- slug: "ps7"
942+
primary_extension_slug: "producing-messages"
943+
name: "Produce a single record"
944+
difficulty: hard
945+
marketing_md: |-
946+
In this stage, you'll implement producing a single record to disk.
947+
922948
- slug: "sb8"
949+
primary_extension_slug: "producing-messages"
950+
name: "Produce multiple records"
951+
difficulty: hard
952+
marketing_md: |-
953+
In this stage, you'll implement producing multiple records.
954+
923955
- slug: "mf2"
924-
- slug: "ar4"
956+
primary_extension_slug: "producing-messages"
957+
name: "Produce to multiple partitions"
958+
difficulty: hard
959+
marketing_md: |-
960+
In this stage, you'll implement producing to multiple partitions.
961+
962+
- slug: "ar4"
963+
primary_extension_slug: "producing-messages"
964+
name: "Produce to multiple topics"
965+
difficulty: hard
966+
marketing_md: |-
967+
In this stage, you'll implement producing to multiple topics.

internal/test_helpers/pass_all/your_program.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@
66
# sudo chown -R user:group ./kafka-latest
77
# rm -rf /tmp/kafka-logs /tmp/zookeeper /tmp/kraft-combined-logs
88
SCRIPT_DIR=$(dirname "$(realpath "$0")")
9-
/usr/local/kafka-latest/bin/kafka-server-start.sh $@ > /dev/null
10-
# /Users/ryang/Developer/tmp/kafka/kafka_2.13-4.0.0/bin/kafka-server-start.sh $@ > /dev/null
9+
/usr/local/kafka-latest/bin/kafka-server-start.sh $@ > /dev/null

local_testing/Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ RUN sudo mv kafka_2.13-4.0.0-SNAPSHOT/ /usr/local/kafka-latest
2828
ENV PATH=$PATH:/usr/local/kafka-latest/bin
2929
RUN rm kafka_2.13-4.0.0-SNAPSHOT.tgz
3030

31-
# RUN wget --progress=dot:giga https://media.githubusercontent.com/media/codecrafters-io/build-your-own-kafka/add-latest-kafka-release/kafka_2.13-4.0.0.tgz
32-
# RUN tar -xzf kafka_2.13-4.0.0.tgz
33-
# RUN sudo mv kafka_2.13-4.0.0/ /usr/local/kafka-latest
34-
# ENV PATH=$PATH:/usr/local/kafka-latest/bin
35-
# RUN rm kafka_2.13-4.0.0.tgz
36-
3731
# Starting from Go 1.20, the go standard library is no longer compiled.
3832
# Setting GODEBUG to "installgoroot=all" restores the old behavior
3933
RUN GODEBUG="installgoroot=all" go install std

local_testing/test.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ cd "$(dirname "$0")/.."
77

88
# Build and run
99
docker build -t local-kafka-tester -f local_testing/Dockerfile .
10-
# Run make test
11-
# docker run --rm -it -v $(pwd):/app local-git-tester make test
1210
# Generate fixtures
1311
# docker run --rm -it -e CODECRAFTERS_RECORD_FIXTURES=true -v $(pwd):/app local-kafka-tester make test
14-
# Run test_all/
1512
docker run --rm -it -v $(pwd):/app local-kafka-tester make test

0 commit comments

Comments
 (0)