Skip to content

Commit

Permalink
chore: debug and ssuch
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Letang <[email protected]>
  • Loading branch information
jeremyletang committed Jul 8, 2024
1 parent 4e2961c commit 128f1b9
Show file tree
Hide file tree
Showing 2 changed files with 218 additions and 30 deletions.
14 changes: 11 additions & 3 deletions datanode/networkhistory/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var (
)

func TestMain(t *testing.M) {
dirs := map[string]string{}
outerCtx, cancelOuterCtx := context.WithCancel(context.Background())
defer cancelOuterCtx()

Expand Down Expand Up @@ -184,6 +185,10 @@ func TestMain(t *testing.M) {
panic(fmt.Errorf("failed to create snapshot: %w", err))
}

dirs["dir1"] = ss.Directory
// fmt.Printf("unpublished: %v\n", ss.Directory)
// os.Exit(1)

waitForSnapshotToComplete2(ss, snapshotService.Flush)

snapshots = append(snapshots, ss)
Expand Down Expand Up @@ -211,6 +216,7 @@ func TestMain(t *testing.M) {
panic(fmt.Errorf("failed to create snapshot:%w", err))
}

dirs["dir2"] = lastSnapshot.Directory
waitForSnapshotToComplete2(lastSnapshot, snapshotService.Flush)
snapshots = append(snapshots, lastSnapshot)
md5Hash, err := Md5Hash(lastSnapshot.UnpublishedSnapshotDataDirectory())
Expand Down Expand Up @@ -268,6 +274,7 @@ func TestMain(t *testing.M) {
panic(fmt.Errorf("failed to create snapshot:%w", err))
}

dirs["dir3"] = lastSnapshot.Directory
waitForSnapshotToComplete2(lastSnapshot, snapshotService.Flush)
snapshots = append(snapshots, lastSnapshot)
md5Hash, err := Md5Hash(lastSnapshot.UnpublishedSnapshotDataDirectory())
Expand Down Expand Up @@ -378,7 +385,8 @@ func TestMain(t *testing.M) {
log.Infof("%s", goldenSourceHistorySegment[3000].HistorySegmentID)
log.Infof("%s", goldenSourceHistorySegment[4000].HistorySegmentID)
log.Infof("%s", goldenSourceHistorySegment[5000].HistorySegmentID)

fmt.Printf("DIRECTORIES: %v\n", dirs)
os.Exit(1)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[1000].HistorySegmentID, "QmQX6n82ex2XDh1tWL1gCv2viDttUwRSdyG1XaekYfLpJk", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[2000].HistorySegmentID, "QmaWdp5RPui6ePszzPvk48e7FxHmPGx2VMpbXD2NTgtFMT", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[2500].HistorySegmentID, "QmRmAX4AfQ9xAdLN8GjVCBmDH7Cm6q1ts7TBF9UjLdjMG9", snapshots)
Expand Down Expand Up @@ -1553,7 +1561,7 @@ func getSnapshotIntervalToHistoryTableDeltaSummary(ctx context.Context,

func waitForSnapshotToComplete(sf segment.Unpublished) {
for {
time.Sleep(10 * time.Millisecond)
time.Sleep(5 * time.Millisecond)
// wait for snapshot current file
_, err := os.Stat(sf.UnpublishedSnapshotDataDirectory())
if err != nil {
Expand Down Expand Up @@ -1581,7 +1589,7 @@ func waitForSnapshotToComplete(sf segment.Unpublished) {

func waitForSnapshotToComplete2(sf segment.Unpublished, flush func()) {
for {
time.Sleep(10 * time.Millisecond)
time.Sleep(5 * time.Millisecond)
// wait for snapshot current file
_, err := os.Stat(sf.UnpublishedSnapshotDataDirectory())
if err != nil {
Expand Down
Loading

0 comments on commit 128f1b9

Please sign in to comment.