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

changefeedccl: make mock pulsar sink synchronous #123228

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/ccl/changefeedccl/changefeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5941,6 +5941,9 @@ func TestChangefeedContinuousTelemetry(t *testing.T) {
for i := 0; i < 5; i++ {
beforeCreate := timeutil.Now()
sqlDB.Exec(t, fmt.Sprintf(`INSERT INTO foo VALUES (%d) RETURNING cluster_logical_timestamp()`, i))
// Read the event from the sink.
_, err := foo.Next()
require.NoError(t, err)
verifyLogsWithEmittedBytesAndMessages(t, jobID, beforeCreate.UnixNano(), interval.Nanoseconds(), false)
}
}
Expand Down Expand Up @@ -6007,12 +6010,20 @@ func TestChangefeedContinuousTelemetryDifferentJobs(t *testing.T) {
beforeInsert := timeutil.Now()
sqlDB.Exec(t, `INSERT INTO foo VALUES (1)`)
sqlDB.Exec(t, `INSERT INTO foo2 VALUES (1)`)
// Read the events from the sinks.
_, err := foo.Next()
require.NoError(t, err)
_, err = foo2.Next()
require.NoError(t, err)
verifyLogsWithEmittedBytesAndMessages(t, job1, beforeInsert.UnixNano(), interval.Nanoseconds(), false)
verifyLogsWithEmittedBytesAndMessages(t, job2, beforeInsert.UnixNano(), interval.Nanoseconds(), false)
require.NoError(t, foo.Close())

beforeInsert = timeutil.Now()
sqlDB.Exec(t, `INSERT INTO foo2 VALUES (2)`)
// Read the events from the sinks.
_, err = foo2.Next()
require.NoError(t, err)
verifyLogsWithEmittedBytesAndMessages(t, job2, beforeInsert.UnixNano(), interval.Nanoseconds(), false)
require.NoError(t, foo2.Close())
}
Expand Down Expand Up @@ -7538,8 +7549,7 @@ func TestChangefeedOnlyInitialScanCSV(t *testing.T) {
}
}

// TODO(#119289): re-enable pulsar
cdcTest(t, testFn, feedTestEnterpriseSinks, feedTestOmitSinks("pulsar"))
cdcTest(t, testFn, feedTestEnterpriseSinks)
}

func TestChangefeedOnlyInitialScanCSVSinkless(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion pkg/ccl/changefeedccl/testfeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2584,7 +2584,8 @@ type mockPulsarServer struct {

func makeMockPulsarServer() *mockPulsarServer {
return &mockPulsarServer{
msgCh: make(chan *pulsar.ProducerMessage, 2048),
// TODO(#118899): Make msgCh a buffered channel for async message sending.
msgCh: make(chan *pulsar.ProducerMessage),
}
}

Expand Down Expand Up @@ -2638,12 +2639,14 @@ func (p *mockPulsarProducer) SendAsync(
m *pulsar.ProducerMessage,
f func(pulsar.MessageID, *pulsar.ProducerMessage, error),
) {
log.Infof(ctx, "SendAsync start %d", len(p.pulsarServer.msgCh))
select {
case <-ctx.Done():
f(nil, m, ctx.Err())
case p.pulsarServer.msgCh <- m:
f(nil, m, nil)
}
log.Infof(ctx, "SendAsync end")
}

func (p *mockPulsarProducer) LastSequenceID() int64 {
Expand Down