@@ -245,10 +245,6 @@ func TestIntegration_ManagedWriter(t *testing.T) {
245
245
t .Parallel ()
246
246
testPendingStream (ctx , t , mwClient , bqClient , dataset )
247
247
})
248
- t .Run ("SchemaEvolution" , func (t * testing.T ) {
249
- t .Parallel ()
250
- testSchemaEvolution (ctx , t , mwClient , bqClient , dataset )
251
- })
252
248
t .Run ("SimpleCDC" , func (t * testing.T ) {
253
249
t .Parallel ()
254
250
testSimpleCDC (ctx , t , mwClient , bqClient , dataset )
@@ -267,6 +263,56 @@ func TestIntegration_ManagedWriter(t *testing.T) {
267
263
})
268
264
}
269
265
266
+ func TestIntegration_SchemaEvolution (t * testing.T ) {
267
+
268
+ testcases := []struct {
269
+ desc string
270
+ clientOpts []option.ClientOption
271
+ writerOpts []WriterOption
272
+ }{
273
+ {
274
+ desc : "Simplex_Committed" ,
275
+ writerOpts : []WriterOption {
276
+ WithType (CommittedStream ),
277
+ },
278
+ },
279
+ {
280
+ desc : "Simplex_Default" ,
281
+ writerOpts : []WriterOption {
282
+ WithType (DefaultStream ),
283
+ },
284
+ },
285
+ {
286
+ desc : "Multiplex_Default" ,
287
+ clientOpts : []option.ClientOption {
288
+ WithMultiplexing (),
289
+ WithMultiplexPoolLimit (2 ),
290
+ },
291
+ writerOpts : []WriterOption {
292
+ WithType (DefaultStream ),
293
+ },
294
+ },
295
+ }
296
+
297
+ for _ , tc := range testcases {
298
+ mwClient , bqClient := getTestClients (context .Background (), t , tc .clientOpts ... )
299
+ defer mwClient .Close ()
300
+ defer bqClient .Close ()
301
+
302
+ dataset , cleanup , err := setupTestDataset (context .Background (), t , bqClient , "asia-east1" )
303
+ if err != nil {
304
+ t .Fatalf ("failed to init test dataset: %v" , err )
305
+ }
306
+ defer cleanup ()
307
+
308
+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
309
+ defer cancel ()
310
+ t .Run (tc .desc , func (t * testing.T ) {
311
+ testSchemaEvolution (ctx , t , mwClient , bqClient , dataset , tc .writerOpts ... )
312
+ })
313
+ }
314
+ }
315
+
270
316
func testDefaultStream (ctx context.Context , t * testing.T , mwClient * Client , bqClient * bigquery.Client , dataset * bigquery.Dataset ) {
271
317
testTable := dataset .Table (tableIDs .New ())
272
318
if err := testTable .Create (ctx , & bigquery.TableMetadata {Schema : testdata .SimpleMessageSchema }); err != nil {
@@ -1094,7 +1140,7 @@ func testInstrumentation(ctx context.Context, t *testing.T, mwClient *Client, bq
1094
1140
}
1095
1141
}
1096
1142
1097
- func testSchemaEvolution (ctx context.Context , t * testing.T , mwClient * Client , bqClient * bigquery.Client , dataset * bigquery.Dataset ) {
1143
+ func testSchemaEvolution (ctx context.Context , t * testing.T , mwClient * Client , bqClient * bigquery.Client , dataset * bigquery.Dataset , opts ... WriterOption ) {
1098
1144
testTable := dataset .Table (tableIDs .New ())
1099
1145
if err := testTable .Create (ctx , & bigquery.TableMetadata {Schema : testdata .SimpleMessageSchema }); err != nil {
1100
1146
t .Fatalf ("failed to create test table %s: %v" , testTable .FullyQualifiedName (), err )
@@ -1104,11 +1150,9 @@ func testSchemaEvolution(ctx context.Context, t *testing.T, mwClient *Client, bq
1104
1150
descriptorProto := protodesc .ToDescriptorProto (m .ProtoReflect ().Descriptor ())
1105
1151
1106
1152
// setup a new stream.
1107
- ms , err := mwClient .NewManagedStream (ctx ,
1108
- WithDestinationTable (TableParentFromParts (testTable .ProjectID , testTable .DatasetID , testTable .TableID )),
1109
- WithSchemaDescriptor (descriptorProto ),
1110
- WithType (CommittedStream ),
1111
- )
1153
+ opts = append (opts , WithDestinationTable (TableParentFromParts (testTable .ProjectID , testTable .DatasetID , testTable .TableID )))
1154
+ opts = append (opts , WithSchemaDescriptor (descriptorProto ))
1155
+ ms , err := mwClient .NewManagedStream (ctx , opts ... )
1112
1156
if err != nil {
1113
1157
t .Fatalf ("NewManagedStream: %v" , err )
1114
1158
}
@@ -1154,7 +1198,7 @@ func testSchemaEvolution(ctx context.Context, t *testing.T, mwClient *Client, bq
1154
1198
// this subjects us to a possible race, as the backend that services GetWriteStream isn't necessarily the
1155
1199
// one in charge of the stream, and thus may report ready early.
1156
1200
for {
1157
- resp , err := ms .AppendRows (ctx , [][]byte {latestRow }, WithOffset ( curOffset ) )
1201
+ resp , err := ms .AppendRows (ctx , [][]byte {latestRow })
1158
1202
if err != nil {
1159
1203
t .Errorf ("got error on dupe append: %v" , err )
1160
1204
break
@@ -1181,7 +1225,7 @@ func testSchemaEvolution(ctx context.Context, t *testing.T, mwClient *Client, bq
1181
1225
t .Errorf ("failed to marshal evolved message: %v" , err )
1182
1226
}
1183
1227
// Send an append with an evolved schema
1184
- res , err := ms .AppendRows (ctx , [][]byte {b }, WithOffset ( curOffset ), UpdateSchemaDescriptor (descriptorProto ))
1228
+ res , err := ms .AppendRows (ctx , [][]byte {b }, UpdateSchemaDescriptor (descriptorProto ))
1185
1229
if err != nil {
1186
1230
t .Errorf ("failed evolved append: %v" , err )
1187
1231
}
0 commit comments