raid_test.go 818 B

12345678910111213141516171819202122232425262728293031323334
  1. package raid_test
  2. import (
  3. "fmt"
  4. "testing"
  5. "imuslab.com/arozos/mod/disk/raid"
  6. )
  7. func TestCreateRAIDDevice(t *testing.T) {
  8. //Create an empty Manager
  9. manager, _ := raid.NewRaidManager(raid.Options{})
  10. // Make sure the loop0 and loop1 devies are mounted with automount.sh
  11. devName, _ := raid.GetNextAvailableMDDevice()
  12. raidLevel := 1
  13. raidDeviceIds := []string{"/dev/loop0", "/dev/loop1"}
  14. spareDeviceIds := []string{}
  15. //Format the drives
  16. for _, partion := range raidDeviceIds {
  17. fmt.Printf("Wiping partition: " + partion)
  18. manager.WipeDisk(partion)
  19. }
  20. // Call the function being tested
  21. err := manager.CreateRAIDDevice(devName, raidLevel, raidDeviceIds, spareDeviceIds)
  22. if err != nil {
  23. t.Errorf("Unexpected error: %v", err)
  24. }
  25. fmt.Println("RAID array created")
  26. }