Skip to content

Commit

Permalink
tests/*: add test for resizing an existing partition
Browse files Browse the repository at this point in the history
  • Loading branch information
sohankunkerkar committed Sep 15, 2020
1 parent 7111e00 commit 91919b0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/negative/partitions/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
}
}
37 changes: 37 additions & 0 deletions tests/positive/partitions/creation-mb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
}
}

0 comments on commit 91919b0

Please sign in to comment.