-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add more tests for partitioning
- Loading branch information
Andrew Jeddeloh
committed
May 18, 2018
1 parent
82a61c5
commit 3d44d10
Showing
10 changed files
with
1,397 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// Copyright 2018 CoreOS, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package partitions | ||
|
||
import ( | ||
"github.com/coreos/ignition/tests/register" | ||
"github.com/coreos/ignition/tests/types" | ||
) | ||
|
||
func init() { | ||
// Tests that have do not involve zeros | ||
register.Register(register.NegativeTest, ShouldNotExistNoWipeEntry()) | ||
register.Register(register.NegativeTest, DoesNotMatchNoWipeEntry()) | ||
register.Register(register.NegativeTest, ValidAndDoesNotMatchNoWipeEntry()) | ||
register.Register(register.NegativeTest, NotThereAndDoesNotMatchNoWipeEntry()) | ||
} | ||
|
||
func ShouldNotExistNoWipeEntry() types.Test { | ||
name := "Partition should not exist but wipePartitionEntry is false" | ||
in := types.GetBaseDisk() | ||
out := in | ||
config := `{ | ||
"ignition": {"version": "2.3.0-experimental"}, | ||
"storage": { | ||
"disks": [ | ||
{ | ||
"device": "$disk0", | ||
"partitions": [ | ||
{ | ||
"number": 9, | ||
"shouldExist": false | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}` | ||
|
||
return types.Test{ | ||
Name: name, | ||
In: in, | ||
Out: out, | ||
Config: config, | ||
} | ||
} | ||
|
||
func DoesNotMatchNoWipeEntry() types.Test { | ||
name := "Partition does not match and wipePartitionEntry is false" | ||
in := types.GetBaseDisk() | ||
out := in | ||
config := `{ | ||
"ignition": {"version": "2.3.0-experimental"}, | ||
"storage": { | ||
"disks": [ | ||
{ | ||
"device": "$disk0", | ||
"partitions": [ | ||
{ | ||
"number": 9, | ||
"size": 4096 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}` | ||
|
||
return types.Test{ | ||
Name: name, | ||
In: in, | ||
Out: out, | ||
Config: config, | ||
} | ||
} | ||
|
||
func ValidAndDoesNotMatchNoWipeEntry() types.Test { | ||
name := "Partition does not match and wipePartitionEntry is false but the first partition matches" | ||
in := types.GetBaseDisk() | ||
out := in | ||
config := `{ | ||
"ignition": {"version": "2.3.0-experimental"}, | ||
"storage": { | ||
"disks": [ | ||
{ | ||
"device": "$disk0", | ||
"partitions": [ | ||
{ | ||
"number": 1 | ||
}, | ||
{ | ||
"number": 9, | ||
"size": 4096 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}` | ||
|
||
return types.Test{ | ||
Name: name, | ||
In: in, | ||
Out: out, | ||
Config: config, | ||
} | ||
} | ||
|
||
func NotThereAndDoesNotMatchNoWipeEntry() types.Test { | ||
name := "Partition does not match and wipePartitionEntry is false but a partition matches not existing" | ||
in := types.GetBaseDisk() | ||
out := in | ||
config := `{ | ||
"ignition": {"version": "2.3.0-experimental"}, | ||
"storage": { | ||
"disks": [ | ||
{ | ||
"device": "$disk0", | ||
"partitions": [ | ||
{ | ||
"number": 10, | ||
"shouldExist": false | ||
}, | ||
{ | ||
"number": 9, | ||
"size": 4096 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}` | ||
|
||
return types.Test{ | ||
Name: name, | ||
In: in, | ||
Out: out, | ||
Config: config, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright 2018 CoreOS, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package partitions | ||
|
||
import ( | ||
"github.com/coreos/ignition/tests/register" | ||
"github.com/coreos/ignition/tests/types" | ||
) | ||
|
||
func init() { | ||
// Tests that involve zeros | ||
register.Register(register.NegativeTest, Partition9DoesNotFillDisk()) | ||
register.Register(register.NegativeTest, Partition9DoesNotStartCorrectly()) | ||
} | ||
|
||
func Partition9DoesNotFillDisk() types.Test { | ||
name := "Partition 9 is size 0 but does not fill the disk" | ||
in := types.GetBaseDisk() | ||
in[0].Partitions = append(in[0].Partitions, &types.Partition{ | ||
Number: 10, | ||
Length: 65536, | ||
}) | ||
out := in | ||
config := `{ | ||
"ignition": {"version": "2.3.0-experimental"}, | ||
"storage": { | ||
"disks": [ | ||
{ | ||
"device": "$disk0", | ||
"partitions": [ | ||
{ | ||
"number": 9, | ||
"size": 0 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}` | ||
|
||
return types.Test{ | ||
Name: name, | ||
In: in, | ||
Out: out, | ||
Config: config, | ||
} | ||
} | ||
|
||
func Partition9DoesNotStartCorrectly() types.Test { | ||
name := "Partition 9 does not start at the largest chunk" | ||
in := types.GetBaseDisk() | ||
//insert a gap before 9 | ||
tmp := in[0].Partitions[9-2-1] | ||
in[0].Partitions[9-2-1] = &types.Partition{ | ||
Number: 10, | ||
Length: 65536, | ||
} | ||
in[0].Partitions = append(in[0].Partitions, tmp) | ||
out := in | ||
config := `{ | ||
"ignition": {"version": "2.3.0-experimental"}, | ||
"storage": { | ||
"disks": [ | ||
{ | ||
"device": "$disk0", | ||
"partitions": [ | ||
{ | ||
"number": 9, | ||
"start": 0 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}` | ||
|
||
return types.Test{ | ||
Name: name, | ||
In: in, | ||
Out: out, | ||
Config: config, | ||
} | ||
} |
Oops, something went wrong.