Skip to content

Commit

Permalink
Fix TestACKSentAfterFsync by creating 'var' directory and adjusting t…
Browse files Browse the repository at this point in the history
…he event handler construction
  • Loading branch information
Dylan Terry committed Oct 1, 2024
1 parent 1b08ee2 commit 4fa8f67
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions replication/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,29 @@ func (t *testSyncerSuite) TestACKSentAfterFsync() {
// Define binlogDir and timeout
binlogDir := "./var"
os.RemoveAll(binlogDir)
err := os.MkdirAll(binlogDir, 0755)
require.NoError(t.T(), err)
timeout := 5 * time.Second

// Create channels for signaling
fsyncedChan := make(chan struct{}, 1)
ackedChan := make(chan struct{}, 1)

// Custom handler returning TestWriteCloser
handler := func(binlogFilename string) (io.WriteCloser, error) {
file, err := os.OpenFile(path.Join(binlogDir, binlogFilename), os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return nil, err
}
return &TestWriteCloser{

Check failure on line 123 in replication/backup_test.go

View workflow job for this annotation

GitHub Actions / Tests with MySQL 8.0.37

undefined: TestWriteCloser

Check failure on line 123 in replication/backup_test.go

View workflow job for this annotation

GitHub Actions / Tests with MySQL 8.4.0

undefined: TestWriteCloser

Check failure on line 123 in replication/backup_test.go

View workflow job for this annotation

GitHub Actions / Tests Go 1.22 on ubuntu-22.04

undefined: TestWriteCloser

Check failure on line 123 in replication/backup_test.go

View workflow job for this annotation

GitHub Actions / Tests Go 1.22 on ubuntu-20.04

undefined: TestWriteCloser

Check failure on line 123 in replication/backup_test.go

View workflow job for this annotation

GitHub Actions / Tests Go 1.21 on ubuntu-22.04

undefined: TestWriteCloser

Check failure on line 123 in replication/backup_test.go

View workflow job for this annotation

GitHub Actions / Tests Go 1.21 on ubuntu-20.04

undefined: TestWriteCloser
file: file,
syncCalled: fsyncedChan,
}, nil
}

// Set up the BackupEventHandler with fsyncedChan
backupHandler := &BackupEventHandler{
handler: func(binlogFilename string) (io.WriteCloser, error) {
return os.OpenFile(path.Join(binlogDir, binlogFilename), os.O_CREATE|os.O_WRONLY, 0644)
},
handler: handler,
fsyncedChan: fsyncedChan,
}

Expand All @@ -131,7 +143,7 @@ func (t *testSyncerSuite) TestACKSentAfterFsync() {
pos := mysql.Position{Name: "", Pos: uint32(0)}
go func() {
// Start backup (this will block until timeout)
err := t.b.StartBackupWithHandler(pos, timeout, backupHandler.handler)
err := t.b.StartBackupWithHandler(pos, timeout, handler)
require.NoError(t.T(), err)
}()

Expand Down

0 comments on commit 4fa8f67

Please sign in to comment.