-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add samples and test for ingestion from Kafka sources (#1354)
- Loading branch information
1 parent
316883a
commit 820f986
Showing
4 changed files
with
328 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,123 @@ def test_create_topic_with_cloud_storage_ingestion( | |
publisher_client.delete_topic(request={"topic": topic_path}) | ||
|
||
|
||
def test_create_topic_with_aws_msk_ingestion( | ||
publisher_client: pubsub_v1.PublisherClient, capsys: CaptureFixture[str] | ||
) -> None: | ||
# The scope of `topic_path` is limited to this function. | ||
topic_path = publisher_client.topic_path(PROJECT_ID, TOPIC_ID) | ||
|
||
# Outside of automated CI tests, these values must be of actual AWS resources for the test to pass. | ||
cluster_arn = ( | ||
"arn:aws:kafka:us-east-1:111111111111:cluster/fake-cluster-name/11111111-1111-1" | ||
) | ||
msk_topic = "fake-msk-topic-name" | ||
aws_role_arn = "arn:aws:iam::111111111111:role/fake-role-name" | ||
gcp_service_account = ( | ||
"[email protected]" | ||
) | ||
|
||
try: | ||
publisher_client.delete_topic(request={"topic": topic_path}) | ||
except NotFound: | ||
pass | ||
|
||
publisher.create_topic_with_aws_msk_ingestion( | ||
PROJECT_ID, | ||
TOPIC_ID, | ||
cluster_arn, | ||
msk_topic, | ||
aws_role_arn, | ||
gcp_service_account, | ||
) | ||
|
||
out, _ = capsys.readouterr() | ||
assert f"Created topic: {topic_path} with AWS MSK Ingestion Settings" in out | ||
|
||
# Clean up resource created for the test. | ||
publisher_client.delete_topic(request={"topic": topic_path}) | ||
|
||
|
||
def test_create_topic_with_azure_event_hubs_ingestion( | ||
publisher_client: pubsub_v1.PublisherClient, capsys: CaptureFixture[str] | ||
) -> None: | ||
# The scope of `topic_path` is limited to this function. | ||
topic_path = publisher_client.topic_path(PROJECT_ID, TOPIC_ID) | ||
|
||
# Outside of automated CI tests, these values must be of actual Azure resources for the test to pass. | ||
resource_group = "fake-resource-group" | ||
namespace = "fake-namespace" | ||
event_hub = "fake-event-hub" | ||
client_id = "fake-client-id" | ||
tenant_id = "fake-tenant-id" | ||
subcription_id = "fake-subscription-id" | ||
gcp_service_account = ( | ||
"[email protected]" | ||
) | ||
|
||
try: | ||
publisher_client.delete_topic(request={"topic": topic_path}) | ||
except NotFound: | ||
pass | ||
|
||
publisher.create_topic_with_azure_event_hubs_ingestion( | ||
PROJECT_ID, | ||
TOPIC_ID, | ||
resource_group, | ||
namespace, | ||
event_hub, | ||
client_id, | ||
tenant_id, | ||
subcription_id, | ||
gcp_service_account, | ||
) | ||
|
||
out, _ = capsys.readouterr() | ||
assert ( | ||
f"Created topic: {topic_path} with Azure Event Hubs Ingestion Settings" in out | ||
) | ||
|
||
# Clean up resource created for the test. | ||
publisher_client.delete_topic(request={"topic": topic_path}) | ||
|
||
|
||
def test_create_topic_with_confluent_cloud_ingestion( | ||
publisher_client: pubsub_v1.PublisherClient, capsys: CaptureFixture[str] | ||
) -> None: | ||
# The scope of `topic_path` is limited to this function. | ||
topic_path = publisher_client.topic_path(PROJECT_ID, TOPIC_ID) | ||
|
||
# Outside of automated CI tests, these values must be of actual Confluent resources for the test to pass. | ||
bootstrap_server = "fake-bootstrap-server-id.us-south1.gcp.confluent.cloud:9092" | ||
cluster_id = "fake-cluster-id" | ||
confluent_topic = "fake-confluent-topic-name" | ||
identity_pool_id = "fake-identity-pool-id" | ||
gcp_service_account = ( | ||
"[email protected]" | ||
) | ||
|
||
try: | ||
publisher_client.delete_topic(request={"topic": topic_path}) | ||
except NotFound: | ||
pass | ||
|
||
publisher.create_topic_with_confluent_cloud_ingestion( | ||
PROJECT_ID, | ||
TOPIC_ID, | ||
bootstrap_server, | ||
cluster_id, | ||
confluent_topic, | ||
identity_pool_id, | ||
gcp_service_account, | ||
) | ||
|
||
out, _ = capsys.readouterr() | ||
assert f"Created topic: {topic_path} with Confluent Cloud Ingestion Settings" in out | ||
|
||
# Clean up resource created for the test. | ||
publisher_client.delete_topic(request={"topic": topic_path}) | ||
|
||
|
||
def test_update_topic_type( | ||
publisher_client: pubsub_v1.PublisherClient, capsys: CaptureFixture[str] | ||
) -> None: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters