Skip to content

[WIP] Feature/kafka #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: updates/docs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ jobs:
run: |
go test ./test/... -config pebble.yml

kafkaTest:
needs: build
name: Kafka tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Python Dependencies for Conformance
run: pip install requests numpy kafka-python
- name: Download grip
uses: actions/download-artifact@v4
with:
name: gripBin
- name: Kafka Test
run: |
chmod +x grip
make start-kafka
./grip server -c ./test/kafka.yml &
sleep 5
python conformance/run_kafka.py


badgerTest:
needs: build
Expand Down
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,52 @@ start-mysql:
start-gripper-test:
@cd ./gripper/test-graph && ./gripper-table -m swapi/table.map &

start-kafka:
@docker rm -f kafka > /dev/null 2>&1 || echo
docker run -d --name kafka \
-p 9092:9092 \
-e KAFKA_ENABLE_KRAFT=yes \
-e KAFKA_KRAFT_CLUSTER_ID=abcdefghijklmnopqrstuv== \
-e KAFKA_CFG_NODE_ID=1 \
-e KAFKA_CFG_PROCESS_ROLES=controller,broker \
-e KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@localhost:9093 \
-e KAFKA_CFG_LISTENERS=CONTROLLER://:9093,INTERNAL://:9092 \
-e KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://localhost:9092 \
-e KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:SASL_PLAINTEXT,CONTROLLER:PLAINTEXT \
-e KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL \
-e KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER \
-e KAFKA_CFG_SUPER_USERS=User:admin \
-e KAFKA_CLIENT_USERS=admin \
-e KAFKA_CLIENT_PASSWORDS=adminpassword \
-e KAFKA_CFG_SASL_ENABLED_MECHANISMS=PLAIN \
-e KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL=PLAIN \
bitnami/kafka:latest
printf '%s\n' \
'security.protocol=SASL_PLAINTEXT' \
'sasl.mechanism=PLAIN' \
'sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="adminpassword";' \
> sasl-config.properties
docker cp sasl-config.properties kafka:/tmp/sasl-config.properties
@echo "Waiting for Kafka to become ready..."
@until docker exec kafka kafka-topics.sh \
--list \
--bootstrap-server localhost:9092 \
--command-config /tmp/sasl-config.properties > /dev/null 2>&1; do \
echo "Still waiting..."; \
sleep 2; \
done
docker exec kafka kafka-topics.sh \
--create \
--topic gripHistory \
--bootstrap-server localhost:9092 \
--partitions 1 \
--replication-factor 1 \
--command-config /tmp/sasl-config.properties
docker exec kafka kafka-topics.sh \
--list \
--bootstrap-server localhost:9092 \
--command-config /tmp/sasl-config.properties

# ---------------------
# Website
# ---------------------
Expand All @@ -154,3 +200,4 @@ website-dev:
# Other
# ---------------------
.PHONY: test rocksdb website

4 changes: 2 additions & 2 deletions cmd/delete/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package delete
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"

"github.com/bmeg/grip/gripql"
Expand Down Expand Up @@ -57,7 +57,7 @@ comma delimited --edges or --vertices arguments are also supported ex:
defer jsonFile.Close()

// Read the JSON file
byteValue, err := ioutil.ReadAll(jsonFile)
byteValue, err := io.ReadAll(jsonFile)
if err != nil {
log.Errorf("Failed to read file: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/mapping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mapping

import (
"fmt"
"io/ioutil"
"io"
"os"

"github.com/bmeg/grip/gripql"
Expand Down Expand Up @@ -75,7 +75,7 @@ var postCmd = &cobra.Command{
var graphs []*gripql.Graph
var err error
if jsonFile == "-" {
bytes, err := ioutil.ReadAll(os.Stdin)
bytes, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
Expand All @@ -98,7 +98,7 @@ var postCmd = &cobra.Command{
var graphs []*gripql.Graph
var err error
if jsonFile == "-" {
bytes, err := ioutil.ReadAll(os.Stdin)
bytes, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/schema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package schema

import (
"fmt"
"io/ioutil"
"io"
"os"

"github.com/bmeg/grip/gripql"
Expand Down Expand Up @@ -82,7 +82,7 @@ var postCmd = &cobra.Command{
var graphs []*gripql.Graph
var err error
if jsonFile == "-" {
bytes, err := ioutil.ReadAll(os.Stdin)
bytes, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
Expand All @@ -98,15 +98,15 @@ var postCmd = &cobra.Command{
if err != nil {
return err
}
log.Debug("Posted schema: %s", g.Graph)
log.Debugf("Posted schema: %s", g.Graph)
}
}

if yamlFile != "" {
var graphs []*gripql.Graph
var err error
if jsonFile == "-" {
bytes, err := ioutil.ReadAll(os.Stdin)
bytes, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
Expand Down Expand Up @@ -135,7 +135,7 @@ var postCmd = &cobra.Command{
if err != nil {
return err
}
log.Debug("Posted schema: %s", g.Graph)
log.Debugf("Posted schema: %s", g.Graph)
}
}
if yamlSchemaPath != "" {
Expand All @@ -149,7 +149,7 @@ var postCmd = &cobra.Command{
if err != nil {
return err
}
log.Debug("Posted schema: %s", g.Graph)
log.Debugf("Posted schema: %s", g.Graph)
}
}
return nil
Expand Down
Loading
Loading