Skip to content

Commit 864dd65

Browse files
authored
fix: Fix hang in test destination plugin. (#19970)
The StreamBatchWriter has a slightly different interface for its client, and the mocked method implementations didn't consume their input channels. As a result, in tests, the syncs got stuck, because sends on those channels would never be consumed.
1 parent 0e7ddb3 commit 864dd65

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

plugins/destination/test/client/client.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,29 +204,37 @@ func newClientForStreamingBatchWriter(c *Client) streamingbatchwriter.Client {
204204
}
205205

206206
func (c *ClientForStreamingBatchWriter) DeleteRecords(ctx context.Context, msgs <-chan *message.WriteDeleteRecord) error {
207+
for range msgs {
208+
}
207209
return nil
208210
}
209-
func (c *ClientForStreamingBatchWriter) MigrateTable(context.Context, <-chan *message.WriteMigrateTable) error {
211+
func (c *ClientForStreamingBatchWriter) MigrateTable(ctx context.Context, msgs <-chan *message.WriteMigrateTable) error {
210212
if c.spec.ErrorOnMigrate {
211213
return ErrOnMigrate
212214
}
213215
if c.spec.ExitOnMigrate {
214216
os.Exit(1)
215217
}
218+
for range msgs {
219+
}
216220
return nil
217221
}
218222

219-
func (c *ClientForStreamingBatchWriter) DeleteStale(context.Context, <-chan *message.WriteDeleteStale) error {
223+
func (c *ClientForStreamingBatchWriter) DeleteStale(ctx context.Context, msgs <-chan *message.WriteDeleteStale) error {
224+
for range msgs {
225+
}
220226
return nil
221227
}
222228

223-
func (c *ClientForStreamingBatchWriter) WriteTable(context.Context, <-chan *message.WriteInsert) error {
229+
func (c *ClientForStreamingBatchWriter) WriteTable(ctx context.Context, msgs <-chan *message.WriteInsert) error {
224230
if c.spec.ErrorOnInsert {
225231
return ErrOnInsert
226232
}
227233
if c.spec.ExitOnInsert {
228234
os.Exit(1)
229235
}
236+
for range msgs {
237+
}
230238
return nil
231239
}
232240

0 commit comments

Comments
 (0)