Add plugin worker integration tests for erasure coding (#8450)
* test: add plugin worker integration harness * test: add erasure coding detection integration tests * test: add erasure coding execution integration tests * ci: add plugin worker integration workflow * test: extend fake volume server for vacuum and balance * test: expand erasure coding detection topologies * test: add large erasure coding detection topology * test: add vacuum plugin worker integration tests * test: add volume balance plugin worker integration tests * ci: run plugin worker tests per worker * fixes * erasure coding: stop after placement failures * erasure coding: record hasMore when early stopping * erasure coding: relax large topology expectations
This commit is contained in:
49
test/plugin_workers/volume_fixtures.go
Normal file
49
test/plugin_workers/volume_fixtures.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package pluginworkers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
)
|
||||
|
||||
// WriteTestVolumeFiles creates a minimal .dat/.idx pair for the given volume.
|
||||
func WriteTestVolumeFiles(t *testing.T, baseDir string, volumeID uint32, datSize int) (string, string) {
|
||||
t.Helper()
|
||||
|
||||
if err := os.MkdirAll(baseDir, 0755); err != nil {
|
||||
t.Fatalf("create volume dir: %v", err)
|
||||
}
|
||||
|
||||
datPath := filepath.Join(baseDir, volumeFilename(volumeID, ".dat"))
|
||||
idxPath := filepath.Join(baseDir, volumeFilename(volumeID, ".idx"))
|
||||
|
||||
data := make([]byte, datSize)
|
||||
rng := rand.New(rand.NewSource(99))
|
||||
_, _ = rng.Read(data)
|
||||
if err := os.WriteFile(datPath, data, 0644); err != nil {
|
||||
t.Fatalf("write dat file: %v", err)
|
||||
}
|
||||
|
||||
entry := make([]byte, types.NeedleMapEntrySize)
|
||||
idEnd := types.NeedleIdSize
|
||||
offsetEnd := idEnd + types.OffsetSize
|
||||
sizeEnd := offsetEnd + types.SizeSize
|
||||
|
||||
types.NeedleIdToBytes(entry[:idEnd], types.NeedleId(1))
|
||||
types.OffsetToBytes(entry[idEnd:offsetEnd], types.ToOffset(0))
|
||||
types.SizeToBytes(entry[offsetEnd:sizeEnd], types.Size(datSize))
|
||||
|
||||
if err := os.WriteFile(idxPath, entry, 0644); err != nil {
|
||||
t.Fatalf("write idx file: %v", err)
|
||||
}
|
||||
|
||||
return datPath, idxPath
|
||||
}
|
||||
|
||||
func volumeFilename(volumeID uint32, ext string) string {
|
||||
return fmt.Sprintf("%d%s", volumeID, ext)
|
||||
}
|
||||
Reference in New Issue
Block a user