Skip to content

Commit bebfec2

Browse files
committed
microcloud/cmd/microcloud: Add unit test for minimum ceph disks
Signed-off-by: Max Asnaashari <[email protected]>
1 parent 76afe6a commit bebfec2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

microcloud/cmd/microcloud/preseed_test.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,27 @@ func (s *preseedSuite) Test_preseedValidateInvalid() {
103103
addErr: false,
104104
err: errors.New("At least 3 systems must specify ceph storage disks"),
105105
},
106+
{
107+
desc: "Minimum ceph direct selection (3) with more systems (4)",
108+
subnet: "10.0.0.1/24",
109+
systems: []System{
110+
{Name: "n1", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
111+
{Name: "n2", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
112+
{Name: "n3", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
113+
{Name: "n4"}},
114+
addErr: false,
115+
err: nil,
116+
},
117+
{
118+
desc: "Multiple disks on the same system don't count towards the minimum quota:",
119+
subnet: "10.0.0.1/24",
120+
systems: []System{
121+
{Name: "n1", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
122+
{Name: "n2", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}, {Path: "def2"}}}},
123+
{Name: "n3"}},
124+
addErr: false,
125+
err: errors.New("At least 3 systems must specify ceph storage disks"),
126+
},
106127
{
107128
desc: "Incomplete zfs direct selection",
108129
subnet: "10.0.0.1/24",
@@ -232,7 +253,11 @@ func (s *preseedSuite) Test_preseedValidateInvalid() {
232253
}
233254

234255
err := p.validate("n1", true)
235-
s.EqualError(err, c.err.Error())
256+
if c.err == nil {
257+
s.NoError(err)
258+
} else {
259+
s.EqualError(err, c.err.Error())
260+
}
236261

237262
s.T().Logf("%s in add mode", c.desc)
238263
err = p.validate("n0", false)

0 commit comments

Comments
 (0)