Skip to content

Commit

Permalink
Merge pull request #5922 from confluentinc/18092024
Browse files Browse the repository at this point in the history
wip
  • Loading branch information
vdesabou authored Sep 24, 2024
2 parents 171d76b + 64672bf commit a66f5bc
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:

"🚀 ccloud/fm-aws-cloudwatch-logs-source ccloud/fm-aws-s3-sink ccloud/fm-aws-s3-source ccloud/fm-azure-event-hubs-source ccloud/fm-azure-service-bus-source ccloud/fm-databricks-delta-lake-sink ccloud/fm-gcp-gcs-sink ccloud/fm-gcp-gcs-source ccloud/fm-aws-dynamodb-sink ccloud/fm-azure-data-lake-storage-gen2-sink ccloud/fm-azure-functions-sink ccloud/fm-azure-synapse-analytics-sink ccloud/fm-azure-cosmosdb-sink ccloud/fm-azure-cosmosdb-source ccloud/fully-managed-datadog-metrics-sink",

"🚀 ccloud/fm-salesforce-cdc-source ccloud/fm-salesforce-platform-events-sink ccloud/fm-salesforce-pushtopics-source ccloud/fm-salesforce-sobject-sink ccloud/fm-snowflake-sink ccloud/fm-gcp-pubsub-source ccloud/fm-gcp-spanner-sink ccloud/fm-aws-cloudwatch-metrics-sink ccloud/fm-gcp-bigquery-legacy-sink ccloud/fm-gcp-bigquery-v2-sink ccloud/fm-github-source ccloud/fm-jira-source ccloud/fm-gcp-cloud-functions-sink ccloud/fm-gcp-bigtable-sink ccloud/fm-pagerduty-sink ccloud/fm-azure-log-analytics-sink",
"🚀 ccloud/fm-salesforce-cdc-source ccloud/fm-salesforce-platform-events-sink ccloud/fm-salesforce-pushtopics-source ccloud/fm-salesforce-sobject-sink ccloud/fm-snowflake-sink ccloud/fm-gcp-pubsub-source ccloud/fm-gcp-spanner-sink ccloud/fm-aws-cloudwatch-metrics-sink ccloud/fm-gcp-bigquery-legacy-sink ccloud/fm-gcp-bigquery-v2-sink ccloud/fm-github-source ccloud/fm-jira-source ccloud/fm-gcp-cloud-functions-legacy-sink ccloud/fm-gcp-cloud-functions-gen2-sink ccloud/fm-gcp-bigtable-sink ccloud/fm-pagerduty-sink ccloud/fm-azure-log-analytics-sink",

"🚀 ccloud/fm-aws-kinesis-source ccloud/fm-aws-redshift-sink ccloud/fm-aws-sqs-source ccloud/fm-aws-lambda-sink ccloud/fm-azure-blob-storage-sink ccloud/fm-azure-blob-storage-source ccloud/fm-azure-cognitive-search-sink ccloud/fm-mongodb-atlas-source ccloud/fm-mongodb-atlas-sink ccloud/fm-salesforce-bulkapi-source ccloud/fm-salesforce-bulkapi-2-0-source ccloud/custom-connector-connect-aws-s3-sink",

Expand Down
22 changes: 11 additions & 11 deletions ccloud/fm-gcp-bigtable-sink/fully-managed-gcp-bigtable-sink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ cd -

bootstrap_ccloud_environment

log "Creating big_query_stats topic"
log "Creating big_query_cloud_stats topic"
set +e
playground topic delete --topic big_query_stats
playground topic delete --topic big_query_cloud_stats
sleep 3
playground topic create --topic big_query_stats
playground topic create --topic big_query_cloud_stats
set -e

log "Doing gsutil authentication"
Expand All @@ -56,9 +56,9 @@ docker run -i --volumes-from gcloud-config google/cloud-sdk:latest gcloud bigtab


function cleanup_cloud_resources {
log "Delete GCP BigTable table kafka_big_query_stats"
log "Delete GCP BigTable table kafka_big_query_cloud_stats"
check_if_continue
docker run -i --volumes-from gcloud-config google/cloud-sdk:latest cbt -project $GCP_PROJECT -instance $GCP_BIGTABLE_INSTANCE deletetable kafka_big_query_stats
docker run -i --volumes-from gcloud-config google/cloud-sdk:latest cbt -project $GCP_PROJECT -instance $GCP_BIGTABLE_INSTANCE deletetable kafka_big_query_cloud_stats

log "Delete GCP BigTable instance $GCP_BIGTABLE_INSTANCE"
check_if_continue
Expand All @@ -71,8 +71,8 @@ EOF
trap cleanup_cloud_resources EXIT


log "Sending messages to topic big_query_stats"
playground topic produce -t big_query_stats --nb-messages 1 --forced-value '{"users": {"name":"Bob","friends": "1000"}}' --key "simple-key-1" << 'EOF'
log "Sending messages to topic big_query_cloud_stats"
playground topic produce -t big_query_cloud_stats --nb-messages 1 --forced-value '{"users": {"name":"Bob","friends": "1000"}}' --key "simple-key-1" << 'EOF'
{
"type": "record",
"name": "myrecord",
Expand All @@ -97,10 +97,10 @@ playground topic produce -t big_query_stats --nb-messages 1 --forced-value '{"us
]
}
EOF
playground topic produce -t big_query_stats --nb-messages 1 --forced-value '{"users": {"name":"Jess","friends": "10000"}}' --key "simple-key-2" << 'EOF'
playground topic produce -t big_query_cloud_stats --nb-messages 1 --forced-value '{"users": {"name":"Jess","friends": "10000"}}' --key "simple-key-2" << 'EOF'
{"type":"record","name":"myrecord","fields":[{"name":"users","type":{"name":"columnfamily","type":"record","fields":[{"name":"name","type":"string"},{"name":"friends","type":"string"}]}}]}
EOF
playground topic produce -t big_query_stats --nb-messages 1 --forced-value '{"users": {"name":"John","friends": "10000"}}' --key "simple-key-3" << 'EOF'
playground topic produce -t big_query_cloud_stats --nb-messages 1 --forced-value '{"users": {"name":"John","friends": "10000"}}' --key "simple-key-3" << 'EOF'
{"type":"record","name":"myrecord","fields":[{"name":"users","type":{"name":"columnfamily","type":"record","fields":[{"name":"name","type":"string"},{"name":"friends","type":"string"}]}}]}
EOF

Expand All @@ -118,7 +118,7 @@ playground connector create-or-update --connector $connector_name << EOF
"kafka.auth.mode": "KAFKA_API_KEY",
"kafka.api.key": "$CLOUD_KEY",
"kafka.api.secret": "$CLOUD_SECRET",
"topics": "big_query_stats",
"topics": "big_query_cloud_stats",
"gcp.bigtable.credentials.json" : "$GCP_KEYFILE_CONTENT",
"gcp.bigtable.instance.id": "$GCP_BIGTABLE_INSTANCE",
"gcp.bigtable.project.id": "$GCP_PROJECT",
Expand All @@ -144,7 +144,7 @@ then
docker run -i -v ${GCP_KEYFILE}:/tmp/keyfile.json --name gcloud-config google/cloud-sdk:latest gcloud auth activate-service-account --project ${GCP_PROJECT} --key-file /tmp/keyfile.json

log "Verify data is in GCP BigTable"
docker run -i --volumes-from gcloud-config google/cloud-sdk:latest cbt -project $GCP_PROJECT -instance $GCP_BIGTABLE_INSTANCE read kafka_big_query_stats > /tmp/result.log 2>&1
docker run -i --volumes-from gcloud-config google/cloud-sdk:latest cbt -project $GCP_PROJECT -instance $GCP_BIGTABLE_INSTANCE read kafka_big_query_cloud_stats > /tmp/result.log 2>&1
cat /tmp/result.log
grep "Bob" /tmp/result.log
fi
Expand Down
39 changes: 39 additions & 0 deletions ccloud/fm-gcp-cloud-functions-gen2-sink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Fully Managed Google Cloud Functions Gen 2 Sink connector



## Objective

Quickly test [Fully Managed Google Cloud Functions Gen 2 Sink](https://docs.confluent.io/cloud/current/connectors/cc-google-cloud-functions-gen2-sink.html) connector.


* Active Google Cloud Platform (GCP) account with authorization to create resources

## Google Cloud Functions Setup

* Navigate to the [Google Cloud Console](https://console.cloud.google.com/)

* Go to the [Cloud Functions](https://console.cloud.google.com/functions) tab.

![Cloud functions setup](Screenshot1.png)

* Create a new function. Use the default code that is provided.

![Cloud functions setup](Screenshot2.png)

Note down the project id, the region (example `us-central1`), and the function name (example `function-1`) as they will be used later.

N.B: make sure service account has `Cloud Run Invoker` role.

## Prerequisites

See [here](https://kafka-docker-playground.io/#/how-to-use?id=%f0%9f%8c%a4%ef%b8%8f-confluent-cloud-examples)


## How to run

Simply run:

```bash
$ just use <playground run> command and search for fully-managed-google-cloud-functions<use tab key to activate fzf completion (see https://kafka-docker-playground.io/#/cli?id=%e2%9a%a1-setup-completion), otherwise use full path, or correct relative path> <GCP_FUNCTION_REGION> <GCP_FUNCTION_FUNCTION> .sh in this folder
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${DIR}/../../scripts/utils.sh
if [ -z "$GCP_PROJECT" ]
then
logerror "GCP_PROJECT is not set. Export it as environment variable or pass it as argument"
exit 1
fi

GCP_FUNCTION_REGION=${1:-europe-west2}
GCP_FUNCTION_FUNCTION=${2:-function-gen2}

cd ../../ccloud/fm-gcp-cloud-functions-gen2-sink
GCP_KEYFILE="${DIR}/keyfile.json"
if [ ! -f ${GCP_KEYFILE} ] && [ -z "$GCP_KEYFILE_CONTENT" ]
then
logerror "ERROR: either the file ${GCP_KEYFILE} is not present or environment variable GCP_KEYFILE_CONTENT is not set!"
exit 1
else
if [ -f ${GCP_KEYFILE} ]
then
GCP_KEYFILE_CONTENT=$(cat keyfile.json | jq -aRs . | sed 's/^"//' | sed 's/"$//')
else
log "Creating ${GCP_KEYFILE} based on environment variable GCP_KEYFILE_CONTENT"
echo -e "$GCP_KEYFILE_CONTENT" | sed 's/\\"/"/g' > ${GCP_KEYFILE}
fi
fi
cd -

log "Doing gsutil authentication"
set +e
docker rm -f gcloud-config
set -e
docker run -i -v ${GCP_KEYFILE}:/tmp/keyfile.json --name gcloud-config google/cloud-sdk:latest gcloud auth activate-service-account --project ${GCP_PROJECT} --key-file /tmp/keyfile.json

bootstrap_ccloud_environment



set +e
playground topic delete --topic functions-gen2-messages
sleep 3
playground topic create --topic functions-gen2-messages
set -e


log "Produce test data to the functions-gen2-messages topic in Kafka"
playground topic produce -t functions-gen2-messages --nb-messages 10 --forced-value '{"f1":"value%g"}' << 'EOF'
{
"type": "record",
"name": "myrecord",
"fields": [
{
"name": "f1",
"type": "string"
}
]
}
EOF

connector_name="GoogleCloudFunctionsGen2Sink_$USER"
set +e
playground connector delete --connector $connector_name > /dev/null 2>&1
set -e

log "Creating fully managed connector"
playground connector create-or-update --connector $connector_name << EOF
{
"connector.class": "GoogleCloudFunctionsGen2Sink",
"name": "$connector_name",
"kafka.auth.mode": "KAFKA_API_KEY",
"kafka.api.key": "$CLOUD_KEY",
"kafka.api.secret": "$CLOUD_SECRET",
"topics": "functions-gen2-messages",
"gcf.name": "$GCP_FUNCTION_FUNCTION",
"gcf.project.id": "$GCP_PROJECT",
"gcf.region.name": "$GCP_FUNCTION_REGION",
"gcp.credentials.json" : "$GCP_KEYFILE_CONTENT",
"input.data.format" : "AVRO",
"tasks.max" : "1"
}
EOF
wait_for_ccloud_connector_up $connector_name 180

sleep 10


connectorId=$(get_ccloud_connector_lcc $connector_name)

log "Verifying topic success-$connectorId"
playground topic consume --topic success-$connectorId --min-expected-messages 10 --timeout 60

log "Do you want to delete the fully managed connector $connector_name ?"
check_if_continue

playground connector delete --connector $connector_name
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Fully Managed Google Cloud Functions Sink connector
# Fully Managed Google Cloud Functions (Legacy) Sink connector



## Objective

Quickly test [Fully Managed Google Cloud Functions Sink](https://docs.confluent.io/cloud/current/connectors/cc-google-functions-sink.html#google-cloud-functions-sink-connector-for-ccloud) connector.
Quickly test [Fully Managed Google Cloud Functions (Legacy) Sink](https://docs.confluent.io/cloud/current/connectors/cc-google-functions-sink.html) connector.


* Active Google Cloud Platform (GCP) account with authorization to create resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fi
GCP_FUNCTION_REGION=${1:-europe-west2}
GCP_FUNCTION_FUNCTION=${2:-function-1}

cd ../../ccloud/fm-gcp-cloud-functions-legacy-sink
GCP_KEYFILE="${DIR}/keyfile.json"
if [ ! -f ${GCP_KEYFILE} ] && [ -z "$GCP_KEYFILE_CONTENT" ]
then
Expand All @@ -26,6 +27,7 @@ else
echo -e "$GCP_KEYFILE_CONTENT" | sed 's/\\"/"/g' > ${GCP_KEYFILE}
fi
fi
cd -

bootstrap_ccloud_environment

Expand Down
8 changes: 8 additions & 0 deletions ccloud/fm-gcp-cloud-functions-legacy-sink/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash



DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${DIR}/../../scripts/utils.sh

maybe_delete_ccloud_environment
2 changes: 2 additions & 0 deletions ccloud/replicator/connect-onprem-to-cloud-avro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ playground start-environment --environment ccloud --docker-compose-override-file

log "Creating topic in Confluent Cloud (auto.create.topics.enable=false)"
set +e
playground topic delete --topic products-avro
sleep 3
playground topic create --topic products-avro
set -e

Expand Down
3 changes: 2 additions & 1 deletion docs/content-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/bigquery.png" width="15"> [Google BigQuery (Legacy) Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-bigquery-legacy-sink) :ccloud/fm-gcp-bigquery-legacy-sink:
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/bigquery.png" width="15"> [Google BigQuery V2 Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-bigquery-v2-sink) :ccloud/fm-gcp-bigquery-v2-sink:
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/gcp_bigtable.png" width="15"> [Google Cloud BigTable Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-bigtable-sink) :ccloud/fm-gcp-bigtable-sink:
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/cloud_functions.png" width="15"> [Google Cloud Functions Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-cloud-functions-sink) :ccloud/fm-gcp-cloud-functions-sink:
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/cloud_functions.png" width="15"> [Google Cloud Functions Legacy Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-cloud-functions-legacy-sink) :ccloud/fm-gcp-cloud-functions-legacy-sink:
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/cloud_functions.png" width="15"> [Google Cloud Functions Gen 2 Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-cloud-functions-gen2-sink) :ccloud/fm-gcp-cloud-functions-gen2-sink:
* <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/spanner.png" width="15"> [Google Cloud Spanner Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-spanner-sink) :ccloud/fm-gcp-spanner-sink:
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/gcs.png" width="15"> [Google Cloud Storage Sink](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-gcs-sink) :ccloud/fm-gcp-gcs-sink:
- <img src="https://github.com/vdesabou/kafka-docker-playground/raw/master/images/icons/gcs.png" width="15"> [Google Cloud Storage Source](https://github.com/vdesabou/kafka-docker-playground/tree/master/ccloud/fm-gcp-gcs-source) :ccloud/fm-gcp-gcs-source:
Expand Down

0 comments on commit a66f5bc

Please sign in to comment.