integration test should remove unsealed files

This commit is contained in:
aarshkshah1992 2021-05-21 16:15:08 +05:30
parent 73f7825fbb
commit 207f0d901a

View File

@ -28,52 +28,54 @@ import (
// TestPieceProviderReadPiece verifies that the ReadPiece method works correctly // TestPieceProviderReadPiece verifies that the ReadPiece method works correctly
// only uses miner and does NOT use any remote worker. // only uses miner and does NOT use any remote worker.
func TestPieceProviderSimpleNoRemoteWorker(t *testing.T) { func TestPieceProviderSimpleNoRemoteWorker(t *testing.T) {
// Set up sector storage manager
runTest := func(t *testing.T, alreadyUnsealed bool) { sealerCfg := SealerConfig{
// Set up sector storage manager ParallelFetchLimit: 10,
sealerCfg := SealerConfig{ AllowAddPiece: true,
ParallelFetchLimit: 10, AllowPreCommit1: true,
AllowAddPiece: true, AllowPreCommit2: true,
AllowPreCommit1: true, AllowCommit: true,
AllowPreCommit2: true, AllowUnseal: true,
AllowCommit: true,
AllowUnseal: true,
}
ppt := newPieceProviderTestHarness(t, sealerCfg, abi.RegisteredSealProof_StackedDrg8MiBV1)
defer ppt.shutdown(t)
// Create some padded data that aligns with the piece boundaries.
pieceData := generatePieceData(8 * 127 * 1024 * 8)
size := abi.UnpaddedPieceSize(len(pieceData))
ppt.addPiece(t, pieceData)
// pre-commit 1
preCommit1 := ppt.preCommit1(t)
// pre-commit 2
ppt.preCommit2(t, preCommit1)
// If we want to test what happens when the data must be unsealed
// (ie there is not an unsealed copy already available)
if !alreadyUnsealed {
// Remove the unsealed copy from local storage
ppt.removeAllUnsealedSectorFiles(t)
}
// Read the piece
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
!alreadyUnsealed, pieceData)
} }
t.Run("already unsealed", func(t *testing.T) { ppt := newPieceProviderTestHarness(t, sealerCfg, abi.RegisteredSealProof_StackedDrg8MiBV1)
runTest(t, true) defer ppt.shutdown(t)
})
t.Run("requires unseal", func(t *testing.T) {
runTest(t, false)
})
}
// Create some padded data that aligns with the piece boundaries.
pieceData := generatePieceData(8 * 127 * 1024 * 8)
size := abi.UnpaddedPieceSize(len(pieceData))
ppt.addPiece(t, pieceData)
// read piece
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
false, pieceData)
// pre-commit 1
preCommit1 := ppt.preCommit1(t)
// read piece
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
false, pieceData)
// pre-commit 2
ppt.preCommit2(t, preCommit1)
// read piece
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
false, pieceData)
// finalize -> nil here will remove unsealed file
ppt.finalizeSector(t, nil)
// Read the piece -> will have to unseal
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
true, pieceData)
// read the piece -> will not have to unseal
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
false, pieceData)
}
func TestReadPieceRemoteWorkers(t *testing.T) { func TestReadPieceRemoteWorkers(t *testing.T) {
logging.SetAllLoggers(logging.LevelDebug) logging.SetAllLoggers(logging.LevelDebug)
@ -116,9 +118,15 @@ func TestReadPieceRemoteWorkers(t *testing.T) {
// pre-commit 1 // pre-commit 1
pC1 := ppt.preCommit1(t) pC1 := ppt.preCommit1(t)
// Read the piece -> no need to unseal
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), pd1size,
false, pd1)
// pre-commit 2 // pre-commit 2
ppt.preCommit2(t, pC1) ppt.preCommit2(t, pC1)
// Read the piece -> no need to unseal
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), pd1size,
false, pd1)
// finalize the sector so we declare to the index we have the sealed file // finalize the sector so we declare to the index we have the sealed file
// so the unsealing worker can later look it up and fetch it if needed // so the unsealing worker can later look it up and fetch it if needed