integration test should remove unsealed files

This commit is contained in:
aarshkshah1992 2021-05-21 16:15:08 +05:30
parent 536d7c4275
commit fb29f782df

View File

@ -28,8 +28,6 @@ import (
// TestPieceProviderReadPiece verifies that the ReadPiece method works correctly
// only uses miner and does NOT use any remote worker.
func TestPieceProviderSimpleNoRemoteWorker(t *testing.T) {
runTest := func(t *testing.T, alreadyUnsealed bool) {
// Set up sector storage manager
sealerCfg := SealerConfig{
ParallelFetchLimit: 10,
@ -48,32 +46,36 @@ func TestPieceProviderSimpleNoRemoteWorker(t *testing.T) {
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)
// 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
// read piece
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
!alreadyUnsealed, pieceData)
}
false, pieceData)
t.Run("already unsealed", func(t *testing.T) {
runTest(t, true)
})
t.Run("requires unseal", func(t *testing.T) {
runTest(t, false)
})
}
// 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) {
logging.SetAllLoggers(logging.LevelDebug)
@ -116,9 +118,15 @@ func TestReadPieceRemoteWorkers(t *testing.T) {
// pre-commit 1
pC1 := ppt.preCommit1(t)
// Read the piece -> no need to unseal
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), pd1size,
false, pd1)
// pre-commit 2
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
// so the unsealing worker can later look it up and fetch it if needed