Skip to content
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

docs: Add Kinesis ingestion samples #1947

Merged
merged 10 commits into from
Mar 21, 2024
Prev Previous commit
Next Next commit
docs: Add test for updating existing ingestion settings and verify th…
…e actual results of topic creation and updating
  • Loading branch information
michaelpri10 committed Mar 7, 2024
commit e4c8a94a6fed9d3fe2fd4a6f4ba2369bd3d9b5f8
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void createTopicWithKinesisIngestionExample(
.setIngestionDataSourceSettings(ingestionDataSourceSettings)
.build());

System.out.println("Created topic with Kinesis ingestion settings: " + topic.getName());
System.out.println("Created topic with Kinesis ingestion settings: " + topic.getAllFields());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void updateTopicTypeExample(

Topic response = topicAdminClient.updateTopic(request);

System.out.println("Updated topic with Kinesis ingestion settings: " + topic.getName());
System.out.println("Updated topic with Kinesis ingestion settings: " + topic.getAllFields());
}
}
}
Expand Down
30 changes: 24 additions & 6 deletions samples/snippets/src/test/java/pubsub/AdminIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public class AdminIT {
private static final String consumerArn =
"arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name/"
+ "consumer/consumer-1:1111111111";
private static final String consumerArn2 =
"arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name/"
+ "consumer/consumer-2:2222222222";
private static final String awsRoleArn = "arn:aws:iam::111111111111:role/fake-role-name";
private static final String gcpServiceAccount =
"[email protected]";
Expand Down Expand Up @@ -287,8 +290,11 @@ public void testAdmin() throws Exception {
// Update topic type to Kinesis ingestion.
UpdateTopicTypeExample.updateTopicTypeExample(
projectId, topicId, streamArn, consumerArn, awsRoleArn, gcpServiceAccount);
assertThat(bout.toString())
.contains("Updated topic with Kinesis ingestion settings: " + topicName.toString());
assertThat(bout.toString()).contains("google.pubsub.v1.Topic.name=" + ingestionTopicName.toString());
assertThat(bout.toString()).contains(streamArn);
assertThat(bout.toString()).contains(consumerArn);
assertThat(bout.toString()).contains(awsRoleArn);
assertThat(bout.toString()).contains(gcpServiceAccount);

bout.reset();
// Test delete topic.
Expand All @@ -299,12 +305,24 @@ public void testAdmin() throws Exception {
// Test create topic with Kinesis ingestion settings.
CreateTopicWithKinesisIngestionExample.createTopicWithKinesisIngestionExample(
projectId, ingestionTopicId, streamArn, consumerArn, awsRoleArn, gcpServiceAccount);
assertThat(bout.toString())
.contains(
"Created topic with Kinesis ingestion settings: " + ingestionTopicName.toString());
assertThat(bout.toString()).contains("google.pubsub.v1.Topic.name=" + ingestionTopicName.toString());
assertThat(bout.toString()).contains(streamArn);
assertThat(bout.toString()).contains(consumerArn);
assertThat(bout.toString()).contains(awsRoleArn);
assertThat(bout.toString()).contains(gcpServiceAccount);

bout.reset();
// Test update existing Kinesis ingestion settings.
UpdateTopicTypeExample.updateTopicTypeExample(
projectId, ingestionTopicId, streamArn, consumerArn2, awsRoleArn, gcpServiceAccount);
assertThat(bout.toString()).contains("google.pubsub.v1.Topic.name=" + ingestionTopicName.toString());
assertThat(bout.toString()).contains(streamArn);
assertThat(bout.toString()).contains(consumerArn2);
assertThat(bout.toString()).contains(awsRoleArn);
assertThat(bout.toString()).contains(gcpServiceAccount);

bout.reset();
// Test delete ingestion topic.
// Test delete Kinesis ingestion topic.
DeleteTopicExample.deleteTopicExample(projectId, ingestionTopicId);
assertThat(bout.toString()).contains("Deleted topic.");
}
Expand Down