createTestLTXFileWithTimestamp creates a minimal LTX file with a specific timestamp.
(t testing.TB, client litestream.ReplicaClient, level int, minTXID, maxTXID ltx.TXID, ts time.Time)
| 601 | |
| 602 | // createTestLTXFileWithTimestamp creates a minimal LTX file with a specific timestamp. |
| 603 | func createTestLTXFileWithTimestamp(t testing.TB, client litestream.ReplicaClient, level int, minTXID, maxTXID ltx.TXID, ts time.Time) { |
| 604 | t.Helper() |
| 605 | |
| 606 | var buf bytes.Buffer |
| 607 | enc, err := ltx.NewEncoder(&buf) |
| 608 | if err != nil { |
| 609 | t.Fatal(err) |
| 610 | } |
| 611 | |
| 612 | if err := enc.EncodeHeader(ltx.Header{ |
| 613 | Version: ltx.Version, |
| 614 | Flags: ltx.HeaderFlagNoChecksum, |
| 615 | PageSize: 4096, |
| 616 | Commit: 1, |
| 617 | MinTXID: minTXID, |
| 618 | MaxTXID: maxTXID, |
| 619 | Timestamp: ts.UnixMilli(), |
| 620 | }); err != nil { |
| 621 | t.Fatal(err) |
| 622 | } |
| 623 | |
| 624 | // Write a dummy page |
| 625 | if err := enc.EncodePage(ltx.PageHeader{Pgno: 1}, make([]byte, 4096)); err != nil { |
| 626 | t.Fatal(err) |
| 627 | } |
| 628 | |
| 629 | if err := enc.Close(); err != nil { |
| 630 | t.Fatal(err) |
| 631 | } |
| 632 | |
| 633 | if _, err := client.WriteLTXFile(context.Background(), level, minTXID, maxTXID, io.NopCloser(&buf)); err != nil { |
| 634 | t.Fatal(err) |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | type earlyReturnCompactionClient struct { |
| 639 | litestream.ReplicaClient |
no test coverage detected