2017-01-03 12:29:14 +01:00
|
|
|
package ignition
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/coreos/ignition/config/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIngnitionRaid(t *testing.T) {
|
|
|
|
testIgnition(t, `
|
2017-03-06 13:23:04 +01:00
|
|
|
data "ignition_raid" "foo" {
|
2017-01-03 12:29:14 +01:00
|
|
|
name = "foo"
|
|
|
|
level = "raid10"
|
|
|
|
devices = ["/foo"]
|
|
|
|
spares = 42
|
|
|
|
}
|
2017-03-06 13:23:04 +01:00
|
|
|
|
|
|
|
data "ignition_config" "test" {
|
2017-01-03 12:29:14 +01:00
|
|
|
arrays = [
|
2017-03-06 13:23:04 +01:00
|
|
|
"${data.ignition_raid.foo.id}",
|
2017-01-03 12:29:14 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
`, func(c *types.Config) error {
|
|
|
|
if len(c.Storage.Arrays) != 1 {
|
|
|
|
return fmt.Errorf("arrays, found %d", len(c.Storage.Arrays))
|
|
|
|
}
|
|
|
|
|
|
|
|
a := c.Storage.Arrays[0]
|
|
|
|
if a.Name != "foo" {
|
|
|
|
return fmt.Errorf("name, found %q", a.Name)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(a.Devices) != 1 || a.Devices[0] != "/foo" {
|
2017-01-13 23:31:44 +01:00
|
|
|
return fmt.Errorf("devices, found %v", a.Devices)
|
2017-01-03 12:29:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if a.Level != "raid10" {
|
|
|
|
return fmt.Errorf("level, found %q", a.Level)
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.Spares != 42 {
|
|
|
|
return fmt.Errorf("spares, found %q", a.Spares)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|