diff --git a/tests/negative/partitions/simple.go b/tests/negative/partitions/simple.go index 23b3959b4..15fc26673 100644 --- a/tests/negative/partitions/simple.go +++ b/tests/negative/partitions/simple.go @@ -25,6 +25,7 @@ func init() { register.Register(register.NegativeTest, DoesNotMatchNoWipeEntry()) register.Register(register.NegativeTest, ValidAndDoesNotMatchNoWipeEntry()) register.Register(register.NegativeTest, NotThereAndDoesNotMatchNoWipeEntry()) + register.Register(register.NegativeTest, NoResizePartitionWithMisMatchConfig()) } func ShouldNotExistNoWipeEntry() types.Test { @@ -157,3 +158,39 @@ func NotThereAndDoesNotMatchNoWipeEntry() types.Test { ConfigMinVersion: configMinVersion, } } + +// NoResizePartitionWithMisMatchConfig verifies that the existing partition can't +// be resized if one of the fields of the config doesn't match. +func NoResizePartitionWithMisMatchConfig() types.Test { + name := "partition.resizePartition.mismatch.config" + in := types.GetBaseDisk() + out := types.GetBaseDisk() + out[0].Partitions[9-6-1].Length = 12943360 + 65536 + config := `{ + "ignition": { + "version": "$version" + }, + "storage": { + "disks": [{ + "device": "$disk0", + "wipeTable": false, + "partitions": [{ + "label": "ROOT", + "number": 9, + "sizeMiB": 6352, + "startMiB": 100, + "resize": true + } + ] + }] + } + }` + + return types.Test{ + Name: name, + In: in, + Out: out, + Config: config, + ConfigMinVersion: "3.2.0-experimental", + } +} diff --git a/tests/positive/partitions/creation-mb.go b/tests/positive/partitions/creation-mb.go index 35c85db4d..ca209199d 100644 --- a/tests/positive/partitions/creation-mb.go +++ b/tests/positive/partitions/creation-mb.go @@ -26,6 +26,7 @@ func init() { register.Register(register.PositiveTest, WipeAndCreateNewPartitionsMiB()) register.Register(register.PositiveTest, AppendPartitionsMiB()) register.Register(register.PositiveTest, ResizeRootMiB()) + register.Register(register.PositiveTest, ResizeExistingPartitionsMiB()) } func CreatePartitionMiB() types.Test { @@ -328,3 +329,39 @@ func ResizeRootMiB() types.Test { ConfigMinVersion: "3.0.0", } } + +// ResizeExistingPartitionsMiB verifies that the existing partition can +// be resized if `resize` field is set to true and partition matches in +// all respects except size. +func ResizeExistingPartitionsMiB() types.Test { + name := "partition.resizeExistingPartition" + in := types.GetBaseDisk() + out := types.GetBaseDisk() + out[0].Partitions[9-6-1].Length = 12943360 + 65536 + config := `{ + "ignition": { + "version": "$version" + }, + "storage": { + "disks": [{ + "device": "$disk0", + "wipeTable": false, + "partitions": [{ + "label": "ROOT", + "number": 9, + "sizeMiB": 6352, + "resize": true + } + ] + }] + } + }` + + return types.Test{ + Name: name, + In: in, + Out: out, + Config: config, + ConfigMinVersion: "3.2.0-experimental", + } +}