integration test should remove unsealed files
This commit is contained in:
parent
73f7825fbb
commit
207f0d901a
46
extern/sector-storage/piece_provider_test.go
vendored
46
extern/sector-storage/piece_provider_test.go
vendored
@ -28,8 +28,6 @@ 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) {
|
||||||
|
|
||||||
runTest := func(t *testing.T, alreadyUnsealed bool) {
|
|
||||||
// Set up sector storage manager
|
// Set up sector storage manager
|
||||||
sealerCfg := SealerConfig{
|
sealerCfg := SealerConfig{
|
||||||
ParallelFetchLimit: 10,
|
ParallelFetchLimit: 10,
|
||||||
@ -48,32 +46,36 @@ func TestPieceProviderSimpleNoRemoteWorker(t *testing.T) {
|
|||||||
size := abi.UnpaddedPieceSize(len(pieceData))
|
size := abi.UnpaddedPieceSize(len(pieceData))
|
||||||
ppt.addPiece(t, pieceData)
|
ppt.addPiece(t, pieceData)
|
||||||
|
|
||||||
|
// read piece
|
||||||
|
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
|
||||||
|
false, pieceData)
|
||||||
|
|
||||||
// pre-commit 1
|
// pre-commit 1
|
||||||
preCommit1 := ppt.preCommit1(t)
|
preCommit1 := ppt.preCommit1(t)
|
||||||
|
|
||||||
|
// read piece
|
||||||
|
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
|
||||||
|
false, pieceData)
|
||||||
|
|
||||||
// pre-commit 2
|
// pre-commit 2
|
||||||
ppt.preCommit2(t, preCommit1)
|
ppt.preCommit2(t, preCommit1)
|
||||||
|
|
||||||
// If we want to test what happens when the data must be unsealed
|
// read piece
|
||||||
// (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,
|
ppt.readPiece(t, storiface.UnpaddedByteIndex(0), size,
|
||||||
!alreadyUnsealed, pieceData)
|
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)
|
||||||
|
|
||||||
t.Run("already unsealed", func(t *testing.T) {
|
|
||||||
runTest(t, true)
|
|
||||||
})
|
|
||||||
t.Run("requires unseal", func(t *testing.T) {
|
|
||||||
runTest(t, false)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user