Skip to content

Commit

Permalink
implement tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vordimous committed Nov 8, 2024
1 parent 950d29e commit 4dcdeda
Show file tree
Hide file tree
Showing 42 changed files with 475 additions and 276 deletions.
1 change: 0 additions & 1 deletion amqp.reflect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Listens on amqps port `7171` and will echo back whatever is sent to the server,

## Requirements

- jq, nc
- Compose compatible host
- cli-rhea

Expand Down
2 changes: 1 addition & 1 deletion asyncapi.http.kafka.proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ output:
List all the pets using `GET` request for the `/pets` endpoint

```bash
curl --location 'http://localhost:7114/pets' \
curl 'http://localhost:7114/pets' \
--header 'Accept: application/json'
```

Expand Down
2 changes: 1 addition & 1 deletion asyncapi.http.kafka.proxy/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ echo EXPECTED="$EXPECTED"
echo

# WHEN
OUTPUT=$(curl --location "http://localhost:$PORT/pets" \
OUTPUT=$(curl "http://localhost:$PORT/pets" \
--header 'Content-Type: application/json')
RESULT=$?
echo RESULT="$RESULT"
Expand Down
1 change: 0 additions & 1 deletion asyncapi.mqtt.proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Listens on mqtt port `7183` and will forward mqtt publish messages and proxies s

## Requirements

- jq, nc
- Compose compatible host
- mosquitto

Expand Down
2 changes: 1 addition & 1 deletion grpc.kafka.fanout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Listens on https port `7151` and fanout messages from `messages` topic in Kafka.

## Requirements

- jq, protoc
- protoc
- Compose compatible host
- [grpcurl](https://github.com/fullstorydev/grpcurl)

Expand Down
1 change: 0 additions & 1 deletion http.json.schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Listens on https port `7114` and will response back whatever is hosted in `nginx

## Requirements

- jq, nc
- Compose compatible host

## Setup
Expand Down
2 changes: 0 additions & 2 deletions http.jwt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ Listens on https port `7143` and will echo back whatever is sent to the server f

## Requirements

- jq, nc
- Compose compatible host
- jwt-cli
- curl

### Install jwt-cli client

Expand Down
2 changes: 1 addition & 1 deletion http.kafka.async/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ and `items-responses` topics in Kafka, asynchronously.

## Requirements

- jq, nc
- jq
- Compose compatible host\

## Setup
Expand Down
2 changes: 1 addition & 1 deletion http.kafka.async/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ services:
- |
echo -e "Creating kafka topic";
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-requests
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-responses --config cleanup.policy=compact
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-responses
echo -e "Successfully created the following topics:";
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --list;
Expand Down
10 changes: 5 additions & 5 deletions http.kafka.avro.json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ docker compose up -d
### Register Schema

```bash
curl 'http://localhost:8081/subjects/core-paymenthub-simple-pay-ipn-request-value/versions' \
curl 'http://localhost:8081/subjects/items-snapshots-value/versions' \
--header 'Content-Type: application/json' \
--data '{
"schema":
Expand Down Expand Up @@ -53,7 +53,7 @@ curl 'http://localhost:8081/subjects/items-snapshots-value/versions/latest'
`POST` request

```bash
curl -k -v -X POST http://localhost:7114/items -H 'Idempotency-Key: 1' -H 'Content-Type: application/json' -d '{"id": "123","status": "OK"}'
curl -k -v http://localhost:7114/items -H 'Idempotency-Key: 1' -H 'Content-Type: application/json' -d '{"id": "123","status": "OK"}'
```

output:
Expand All @@ -75,7 +75,7 @@ output:
`GET` request to fetch specific item.

```bash
curl -k -v http://localhost7114/items/1
curl -k http://localhost:7114/items/1
```

output:
Expand All @@ -96,7 +96,7 @@ output:
`POST` request.

```bash
curl -k -v -X POST http://localhost7114/items -H 'Idempotency-Key: 2' -H 'Content-Type: application/json' -d '{"id": 123,"status": "OK"}'
curl -k -v http://localhost:7114/items -H 'Idempotency-Key: 2' -H 'Content-Type: application/json' -d '{"id": 123,"status": "OK"}'
```

output:
Expand All @@ -118,7 +118,7 @@ output:
`GET` request to verify whether Invalid event is produced

```bash
curl -k -v http://localhost7114/items/2
curl -k -v http://localhost:7114/items/2
```

output:
Expand Down
3 changes: 1 addition & 2 deletions http.kafka.avro.json/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ services:
command:
- |
echo -e "Creating kafka topic";
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-requests
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-responses --config cleanup.policy=compact
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-snapshots --config cleanup.policy=compact
echo -e "Successfully created the following topics:";
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --list;
Expand Down
73 changes: 73 additions & 0 deletions http.kafka.avro.json/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh
set -x

EXIT=0

# create schema
curl 'http://localhost:8081/subjects/items-snapshots-value/versions' \
--header 'Content-Type: application/json' \
--data '{
"schema":
"{\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"string\"}],\"name\":\"Event\",\"namespace\":\"io.aklivity.example\",\"type\":\"record\"}",
"schemaType": "AVRO"
}'

# GIVEN
PORT="7114"
INPUT='{"id": "123", "status": "OK"}'
EXPECTED='{"id":"123","status":"OK"}'
echo \# Testing http.kafka.avro.json/valid
echo PORT="$PORT"
echo INPUT="$INPUT"
echo EXPECTED="$EXPECTED"
echo

# send message
curl -k http://localhost:7114/items -H 'Idempotency-Key: 1' -H 'Content-Type: application/json' -d "$INPUT"

# WHEN
OUTPUT=$(curl -k http://localhost:$PORT/items/1)
RESULT=$?
echo RESULT="$RESULT"

# THEN
echo OUTPUT="$OUTPUT"
echo EXPECTED="$EXPECTED"
echo
if [ "$RESULT" -eq 0 ] && [ "$OUTPUT" = "$EXPECTED" ]; then
echo
else
echo
EXIT=1
fi

# GIVEN
PORT="7114"
INPUT='{"id": 123,"status": "OK"}'
EXPECTED='404'
echo \# Testing http.kafka.avro.json/invalid
echo PORT="$PORT"
echo INPUT="$INPUT"
echo EXPECTED="$EXPECTED"
echo

# send message
curl -k http://localhost:7114/items -H 'Idempotency-Key: 2' -H 'Content-Type: application/json' -d "$INPUT"

# WHEN
OUTPUT=$(curl -w "%{http_code}" http://localhost:$PORT/items/2)
RESULT=$?
echo RESULT="$RESULT"

# THEN
echo OUTPUT="$OUTPUT"
echo EXPECTED="$EXPECTED"
echo
if [ "$RESULT" -eq 0 ] && [ "$OUTPUT" = "$EXPECTED" ]; then
echo
else
echo
EXIT=1
fi

exit $EXIT
1 change: 0 additions & 1 deletion http.kafka.cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Listens on http port `7114` or https port `7114` and will serve cached responses

## Requirements

- jq, nc
- Compose compatible host

## Setup
Expand Down
65 changes: 65 additions & 0 deletions http.kafka.cache/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh
set -x

EXIT=0

# GIVEN
PORT="7114"
EXPECTED="[]"
echo \# Testing http.kafka.cache/
echo PORT="$PORT"
echo INPUT="$INPUT"
echo EXPECTED="$EXPECTED"
echo

# WHEN
OUTPUT=$(curl http://localhost:$PORT/items)
RESULT=$?
echo RESULT="$RESULT"

# THEN
echo OUTPUT="$OUTPUT"
echo EXPECTED="$EXPECTED"
echo
if [ "$RESULT" -eq 0 ] && [ "$OUTPUT" = "$EXPECTED" ]; then
echo
else
echo
EXIT=1
fi


# GIVEN
PORT="7114"
INPUT='{"message":"Hello World"}'
EXPECTED='[{"message":"Hello World"}]'
echo \# Testing http.kafka.cache/
echo PORT="$PORT"
echo INPUT="$INPUT"
echo EXPECTED="$EXPECTED"
echo

echo "$INPUT" | docker compose -p zilla-http-kafka-cache exec -T kafkacat \
kafkacat -P \
-b kafka:29092 \
-t items-snapshots \
-k "5cf7a1d5-3772-49ef-86e7-ba6f2c7d7d07" \
-H "content-type=application/json"

# WHEN
OUTPUT=$(curl http://localhost:$PORT/items)
RESULT=$?
echo RESULT="$RESULT"

# THEN
echo OUTPUT="$OUTPUT"
echo EXPECTED="$EXPECTED"
echo
if [ "$RESULT" -eq 0 ] && [ "$OUTPUT" = "$EXPECTED" ]; then
echo
else
echo
EXIT=1
fi

exit $EXIT
9 changes: 4 additions & 5 deletions http.kafka.crud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ deletes and reads messages in `items-snapshots` log-compacted Kafka topic acting

## Requirements

- jq, nc
- Compose compatible host

## Setup
Expand Down Expand Up @@ -39,7 +38,7 @@ docker compose up -d
Note: You can remove `-H 'Idempotency-Key: 1'` to generate random key.

```bash
curl -k -v -X POST http://localhost7114/items -H 'Idempotency-Key: 1' -H 'Content-Type: application/json' -d '{"greeting":"Hello, world1"}'
curl -k -v -X POST http://localhost:7114/items -H 'Idempotency-Key: 1' -H 'Content-Type: application/json' -d '{"greeting":"Hello, world1"}'
```

output:
Expand All @@ -61,7 +60,7 @@ HTTP/2 204
`GET` request to fetch specific item.

```bash
curl -k -v http://localhost7114/items/1
curl -k -v http://localhost:7114/items/1
```

output:
Expand All @@ -81,7 +80,7 @@ output:
`PUT` request to update specific item.

```bash
curl -k -v -X PUT http://localhost7114/items/1 -H 'Content-Type: application/json' -d '{"greeting":"Hello, world2"}'
curl -k -v -X PUT http://localhost:7114/items/1 -H 'Content-Type: application/json' -d '{"greeting":"Hello, world2"}'
```

output:
Expand All @@ -103,7 +102,7 @@ HTTP/2 204
`DELETE` request to delete specific item.

```bash
curl -k -v -X DELETE http://localhost7114/items/1
curl -k -v -X DELETE http://localhost:7114/items/1
```

output:
Expand Down
34 changes: 34 additions & 0 deletions http.kafka.crud/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
set -x

EXIT=0

# GIVEN
PORT="7114"
INPUT='{"greeting":"Hello, world1"}'
EXPECTED='{"greeting":"Hello, world1"}'
echo \# Testing http.kafka.crud/
echo PORT="$PORT"
echo INPUT="$INPUT"
echo EXPECTED="$EXPECTED"
echo

curl -k -v -X POST http://localhost:$PORT/items -H 'Idempotency-Key: 1' -H 'Content-Type: application/json' -d "$INPUT"

# WHEN
OUTPUT=$(curl -k http://localhost:$PORT/items/1)
RESULT=$?
echo RESULT="$RESULT"

# THEN
echo OUTPUT="$OUTPUT"
echo EXPECTED="$EXPECTED"
echo
if [ "$RESULT" -eq 0 ] && [ "$OUTPUT" = "$EXPECTED" ]; then
echo
else
echo
EXIT=1
fi

exit $EXIT
7 changes: 2 additions & 5 deletions http.kafka.oneway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Listens on http port `7114` or https port `7114` and will produce messages to th

## Requirements

- jq, nc
- jq
- Compose compatible host

## Setup
Expand All @@ -26,10 +26,7 @@ docker compose up -d
Send a `POST` request with an event body.

```bash
curl -v \
-X "POST" http://localhost:7114/events \
-H "Content-Type: application/json" \
-d "{\"greeting\":\"Hello, world\"}"
curl -v http://localhost:7114/events -H "Content-Type: application/json" -d '{"greeting":"Hello, world"}'
```

output:
Expand Down
3 changes: 1 addition & 2 deletions http.kafka.oneway/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ services:
command:
- |
echo -e "Creating kafka topic";
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-requests
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic items-responses --config cleanup.policy=compact
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic events
echo -e "Successfully created the following topics:";
/opt/bitnami/kafka/bin/kafka-topics.sh --bootstrap-server kafka:29092 --list;
Expand Down
Loading

0 comments on commit 4dcdeda

Please sign in to comment.