Skip to content

Commit

Permalink
Update cloudEventExample and add QoL changes
Browse files Browse the repository at this point in the history
QoL changes:
  - script in docker-compose dir to copy, rename file and replace
    placeholder of sql schema from generator to docker-compose
    sql_scripts
  - script in pgsql generator to copy yang models from teiv
  - added docker container that produces a kafka event to add
    data to TEIV

Issue-ID: SMO-???
Change-Id: Id0f94f79efbc2928a5d278bc7e0fc9f077aac5d4
Signed-off-by: JvD_Ericsson <[email protected]>
  • Loading branch information
JvD-Ericsson committed Sep 3, 2024
1 parent aa98f28 commit bc0ead4
Show file tree
Hide file tree
Showing 9 changed files with 1,976 additions and 1,228 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! /bin/bash
#
# ============LICENSE_START=======================================================
# Copyright (C) 2024 Ericsson
# Modifications Copyright (C) 2024 OpenInfra Foundation Europe
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
#
KAFKA_NAMESPACE="${1:-teiv}"
KAFKA_TOPIC="${2:-topology-inventory-ingestion}"
KAFKA_POD_NAME="${3:-kafka-0}"
FILE_DUPLICATION_FACTOR="${4:-1}" # How many times to use the same CloudEvent file
FOLDER_OF_CLOUDEVENTS="${5:-/events}" # All files in this folder are written to kafka
# number of generated files == number of files in the $FOLDER_OF_CLOUDEVENTS * $FILE_DUPLICATION_FACTOR

echo "Producing messages to Kafka topic '$KAFKA_TOPIC'..."

# Loop to produce multiple messages
for ((i=0; i<$FILE_DUPLICATION_FACTOR; i++)); do
for file in "$FOLDER_OF_CLOUDEVENTS"/*; do
if [ -f "$file" ]; then
# Replace the new line characters with a space and write to kafka
sed ':a;N;$!ba;s/\n/ /g' "$file" | \
kafka-console-producer --broker-list kafka:9092 --topic "$KAFKA_TOPIC" \
--property parse.headers=true --property headers.key.separator=::: --property headers.delimiter=,,, --property parse.key=false
fi
done
echo "$((i+1))/$FILE_DUPLICATION_FACTOR rounds completed"
done

echo "Message production completed."
Loading

0 comments on commit bc0ead4

Please sign in to comment.