|
| 1 | +# Development |
| 2 | + |
| 3 | +To test `Avrora` with real Confluent Schema Registry it is recommended to use |
| 4 | +official demo project. |
| 5 | + |
| 6 | +## 1. Setup Confluent demo project |
| 7 | + |
| 8 | +```console |
| 9 | +$ git clone git clone git@github.com:confluentinc/cp-demo.git |
| 10 | +$ cd cp-demo |
| 11 | +$ git checkout -b 7.5.1-post origin/7.5.1-post |
| 12 | +``` |
| 13 | + |
| 14 | +Apply the following patch to minimize the setup and keep the bare-minimum. |
| 15 | + |
| 16 | +> [!NOTE] |
| 17 | +> You may see some errors and warnings, but you could ignore them, for example: |
| 18 | +> |
| 19 | +> Error response from daemon: No such container: connect |
| 20 | +> WARNING: Expected to find at least 6 subjects in Schema Registry but found... |
| 21 | +
|
| 22 | +```diff |
| 23 | +diff --git a/scripts/start.sh b/scripts/start.sh |
| 24 | +index 50b5b41a..535b7a0e 100755 |
| 25 | +--- a/scripts/start.sh |
| 26 | ++++ b/scripts/start.sh |
| 27 | +@@ -5,6 +5,8 @@ source ${DIR}/helper/functions.sh |
| 28 | + source ${DIR}/env.sh |
| 29 | + |
| 30 | + #------------------------------------------------------------------------------- |
| 31 | ++# Disable visualization by default |
| 32 | ++VIZ=false |
| 33 | + |
| 34 | + # Do preflight checks |
| 35 | + preflight_checks || exit |
| 36 | +@@ -15,7 +17,7 @@ ${DIR}/stop.sh |
| 37 | + CLEAN=${CLEAN:-false} |
| 38 | + |
| 39 | + # Build Kafka Connect image with connector plugins |
| 40 | +-build_connect_image |
| 41 | ++# build_connect_image |
| 42 | + |
| 43 | + # Set the CLEAN variable to true if cert doesn't exist |
| 44 | + if ! [[ -f "${DIR}/security/controlCenterAndKsqlDBServer-ca1-signed.crt" ]] || ! check_num_certs; then |
| 45 | +@@ -86,75 +88,82 @@ docker-compose exec kafka1 kafka-configs \ |
| 46 | + |
| 47 | + |
| 48 | + # Bring up more containers |
| 49 | +-docker-compose up --no-recreate -d schemaregistry connect control-center |
| 50 | ++# FIXME |
| 51 | ++# docker-compose up --no-recreate -d schemaregistry connect control-center |
| 52 | ++docker-compose up --no-recreate -d schemaregistry |
| 53 | + |
| 54 | + echo |
| 55 | + echo -e "Create topics in Kafka cluster:" |
| 56 | + docker-compose exec tools bash -c "/tmp/helper/create-topics.sh" || exit 1 |
| 57 | + |
| 58 | + # Verify Kafka Connect Worker has started |
| 59 | +-MAX_WAIT=240 |
| 60 | +-echo -e "\nWaiting up to $MAX_WAIT seconds for Connect to start" |
| 61 | +-retry $MAX_WAIT host_check_up connect || exit 1 |
| 62 | ++# FIXME |
| 63 | ++# MAX_WAIT=240 |
| 64 | ++# echo -e "\nWaiting up to $MAX_WAIT seconds for Connect to start" |
| 65 | ++# retry $MAX_WAIT host_check_up connect || exit 1 |
| 66 | + |
| 67 | + #------------------------------------------------------------------------------- |
| 68 | + |
| 69 | +-echo -e "\nStart streaming from the Wikipedia SSE source connector:" |
| 70 | +-${DIR}/connectors/submit_wikipedia_sse_config.sh || exit 1 |
| 71 | ++# FIXME |
| 72 | ++# echo -e "\nStart streaming from the Wikipedia SSE source connector:" |
| 73 | ++# ${DIR}/connectors/submit_wikipedia_sse_config.sh || exit 1 |
| 74 | + |
| 75 | +-# Verify connector is running |
| 76 | +-MAX_WAIT=120 |
| 77 | +-echo |
| 78 | +-echo "Waiting up to $MAX_WAIT seconds for connector to be in RUNNING state" |
| 79 | +-retry $MAX_WAIT check_connector_status_running "wikipedia-sse" || exit 1 |
| 80 | ++# # Verify connector is running |
| 81 | ++# MAX_WAIT=120 |
| 82 | ++# echo |
| 83 | ++# echo "Waiting up to $MAX_WAIT seconds for connector to be in RUNNING state" |
| 84 | ++# retry $MAX_WAIT check_connector_status_running "wikipedia-sse" || exit 1 |
| 85 | + |
| 86 | +-# Verify wikipedia.parsed topic is populated and schema is registered |
| 87 | +-MAX_WAIT=120 |
| 88 | +-echo |
| 89 | +-echo -e "Waiting up to $MAX_WAIT seconds for subject wikipedia.parsed-value (for topic wikipedia.parsed) to be registered in Schema Registry" |
| 90 | +-retry $MAX_WAIT host_check_schema_registered || exit 1 |
| 91 | ++# # Verify wikipedia.parsed topic is populated and schema is registered |
| 92 | ++# MAX_WAIT=120 |
| 93 | ++# echo |
| 94 | ++# echo -e "Waiting up to $MAX_WAIT seconds for subject wikipedia.parsed-value (for topic wikipedia.parsed) to be registered in Schema Registry" |
| 95 | ++# retry $MAX_WAIT host_check_schema_registered || exit 1 |
| 96 | + |
| 97 | + #------------------------------------------------------------------------------- |
| 98 | + |
| 99 | +-# Verify Confluent Control Center has started |
| 100 | +-MAX_WAIT=300 |
| 101 | +-echo |
| 102 | +-echo "Waiting up to $MAX_WAIT seconds for Confluent Control Center to start" |
| 103 | +-retry $MAX_WAIT host_check_up control-center || exit 1 |
| 104 | ++# # Verify Confluent Control Center has started |
| 105 | ++# FIXME |
| 106 | ++# MAX_WAIT=300 |
| 107 | ++# echo |
| 108 | ++# echo "Waiting up to $MAX_WAIT seconds for Confluent Control Center to start" |
| 109 | ++# retry $MAX_WAIT host_check_up control-center || exit 1 |
| 110 | + |
| 111 | +-echo -e "\nConfluent Control Center modifications:" |
| 112 | +-${DIR}/helper/control-center-modifications.sh |
| 113 | +-echo |
| 114 | ++# echo -e "\nConfluent Control Center modifications:" |
| 115 | ++# ${DIR}/helper/control-center-modifications.sh |
| 116 | ++# echo |
| 117 | + |
| 118 | + |
| 119 | + #------------------------------------------------------------------------------- |
| 120 | + |
| 121 | +-# Start more containers |
| 122 | +-docker-compose up --no-recreate -d ksqldb-server ksqldb-cli restproxy |
| 123 | ++# FIXME |
| 124 | ++# # Start more containers |
| 125 | ++# docker-compose up --no-recreate -d ksqldb-server ksqldb-cli restproxy |
| 126 | + |
| 127 | +-# Verify ksqlDB server has started |
| 128 | +-echo |
| 129 | +-echo |
| 130 | +-MAX_WAIT=120 |
| 131 | +-echo -e "\nWaiting up to $MAX_WAIT seconds for ksqlDB server to start" |
| 132 | +-retry $MAX_WAIT host_check_up ksqldb-server || exit 1 |
| 133 | ++# # Verify ksqlDB server has started |
| 134 | ++# echo |
| 135 | ++# echo |
| 136 | ++# MAX_WAIT=120 |
| 137 | ++# echo -e "\nWaiting up to $MAX_WAIT seconds for ksqlDB server to start" |
| 138 | ++# retry $MAX_WAIT host_check_up ksqldb-server || exit 1 |
| 139 | + |
| 140 | +-echo -e "\nRun ksqlDB queries:" |
| 141 | +-${DIR}/ksqlDB/run_ksqlDB.sh |
| 142 | ++# echo -e "\nRun ksqlDB queries:" |
| 143 | ++# ${DIR}/ksqlDB/run_ksqlDB.sh |
| 144 | + |
| 145 | + if [[ "$VIZ" == "true" ]]; then |
| 146 | + build_viz || exit 1 |
| 147 | + fi |
| 148 | + |
| 149 | +-echo -e "\nStart additional consumers to read from topics WIKIPEDIANOBOT, WIKIPEDIA_COUNT_GT_1" |
| 150 | +-${DIR}/consumers/listen_WIKIPEDIANOBOT.sh |
| 151 | +-${DIR}/consumers/listen_WIKIPEDIA_COUNT_GT_1.sh |
| 152 | ++# FIXME |
| 153 | ++# echo -e "\nStart additional consumers to read from topics WIKIPEDIANOBOT, WIKIPEDIA_COUNT_GT_1" |
| 154 | ++# ${DIR}/consumers/listen_WIKIPEDIANOBOT.sh |
| 155 | ++# ${DIR}/consumers/listen_WIKIPEDIA_COUNT_GT_1.sh |
| 156 | + |
| 157 | +-echo |
| 158 | +-echo |
| 159 | +-echo "Start the Kafka Streams application wikipedia-activity-monitor" |
| 160 | +-docker-compose up --no-recreate -d streams-demo |
| 161 | +-echo "..." |
| 162 | ++# echo |
| 163 | ++# echo |
| 164 | ++# echo "Start the Kafka Streams application wikipedia-activity-monitor" |
| 165 | ++# docker-compose up --no-recreate -d streams-demo |
| 166 | ++# echo "..." |
| 167 | + |
| 168 | + |
| 169 | + #------------------------------------------------------------------------------- |
| 170 | +``` |
| 171 | + |
| 172 | +Save it with name `cp-demo.patch` and run the following command. |
| 173 | + |
| 174 | +```console |
| 175 | +$ git apply cp-demo.patch |
| 176 | +``` |
| 177 | + |
| 178 | +To ensure HTTP(S) connectivity with the generated certificate, |
| 179 | +add the schema registry to your system's hosts file: |
| 180 | + |
| 181 | +```console |
| 182 | +$ sudo sh -c 'echo "0.0.0.0 schemaregistry" >> /etc/hosts' |
| 183 | +``` |
| 184 | + |
| 185 | +## 2. Get certificates |
| 186 | + |
| 187 | +Copy the certificate from the Docker container to your local machine and |
| 188 | +convert the PEM certificate to a DER-encoded format. |
| 189 | + |
| 190 | +```console |
| 191 | +$ docker cp schemaregistry:/etc/kafka/secrets/snakeoil-ca-1.crt . |
| 192 | +$ openssl x509 -in snakeoil-ca-1.crt -outform DER -out snakeoil-ca-1.der |
| 193 | +``` |
| 194 | + |
| 195 | +## 3. Check Schema Registry connectivity |
| 196 | + |
| 197 | +Test the connection to the Schema Registry using the `Avrora.HTTPClient` |
| 198 | +with the converted certificate. Run the following code in your console. |
| 199 | + |
| 200 | +```elixir |
| 201 | +# Setup the URL and read the certificate |
| 202 | +url = "https://superUser:superUser@schemaregistry:8085/subjects" |
| 203 | +cert = File.read!(Path.expand("./snakeoil-ca-1.der")) |
| 204 | + |
| 205 | +# Make a get request to the Schema Registry it should output `{:ok, []}` |
| 206 | +# (because no data was populated in patched `start.sh` script) |
| 207 | +Avrora.HTTPClient.get(url, [ssl_options: [verify: :verify_peer, cacerts: [cert]]]) |
| 208 | +``` |
0 commit comments