-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pubsub): support new forms of topic ingestion (#11537)
* feat(pubsub): support new forms of topic ingestion * add test for kafka topics * rename msk state, remove output only field
- Loading branch information
Showing
2 changed files
with
314 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,75 @@ func TestTopic_IngestionCloudStorage(t *testing.T) { | |
} | ||
} | ||
|
||
func TestTopic_Ingestion(t *testing.T) { | ||
c, srv := newFake(t) | ||
defer c.Close() | ||
defer srv.Close() | ||
id := "test-topic-3p-ingestion" | ||
gcpSA := "[email protected]" | ||
azureIngestion := &IngestionDataSourceAzureEventHubs{ | ||
ResourceGroup: "fake-resource-group", | ||
Namespace: "fake-namespace", | ||
EventHub: "fake-event-hub", | ||
ClientID: "11111111-1111-1111-1111-111111111111", | ||
TenantID: "22222222-2222-2222-2222-222222222222", | ||
SubscriptionID: "33333333-3333-3333-3333-333333333333", | ||
GCPServiceAccount: gcpSA, | ||
} | ||
mskIngestion := &IngestionDataSourceAmazonMSK{ | ||
ClusterARN: "arn:aws:kafka:us-east-1:111111111111:cluster/fake-cluster-name/11111111-1111-1", | ||
Topic: "fake-msk-topic-name", | ||
AWSRoleARN: "arn:aws:iam::111111111111:role/fake-role-name", | ||
GCPServiceAccount: gcpSA, | ||
} | ||
confluentCloud := &IngestionDataSourceConfluentCloud{ | ||
BootstrapServer: "fake-bootstrap-server-id.us-south1.gcp.confluent.cloud:9092", | ||
ClusterID: "fake-cluster-id", | ||
Topic: "fake-confluent-topic-name", | ||
IdentityPoolID: "fake-pool-id", | ||
GCPServiceAccount: gcpSA, | ||
} | ||
want := TopicConfig{ | ||
IngestionDataSourceSettings: &IngestionDataSourceSettings{ | ||
Source: azureIngestion, | ||
}, | ||
} | ||
topic := mustCreateTopicWithConfig(t, c, id, &want) | ||
got, err := topic.Config(context.Background()) | ||
if err != nil { | ||
t.Fatalf("error getting topic config: %v", err) | ||
} | ||
want.State = TopicStateActive | ||
opt := cmpopts.IgnoreUnexported(TopicConfig{}) | ||
if !testutil.Equal(got, want, opt) { | ||
t.Errorf("got %v, want %v", got, want) | ||
} | ||
|
||
// Update ingestion settings to use MSK | ||
ctx := context.Background() | ||
settings := &IngestionDataSourceSettings{ | ||
Source: mskIngestion, | ||
} | ||
config2, err := topic.Update(ctx, TopicConfigToUpdate{IngestionDataSourceSettings: settings}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !testutil.Equal(config2.IngestionDataSourceSettings, settings, opt) { | ||
t.Errorf("\ngot %+v\nwant %+v", config2.IngestionDataSourceSettings, settings) | ||
} | ||
|
||
settings = &IngestionDataSourceSettings{ | ||
Source: confluentCloud, | ||
} | ||
config3, err := topic.Update(ctx, TopicConfigToUpdate{IngestionDataSourceSettings: settings}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !testutil.Equal(config3.IngestionDataSourceSettings, settings, opt) { | ||
t.Errorf("\ngot %+v\nwant %+v", config3.IngestionDataSourceSettings, settings) | ||
} | ||
} | ||
|
||
func TestListTopics(t *testing.T) { | ||
ctx := context.Background() | ||
c, srv := newFake(t) | ||
|