Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-ganeti
Commits
7bc82927
Commit
7bc82927
authored
15 years ago
by
Iustin Pop
Browse files
Options
Downloads
Patches
Plain Diff
Add some very trivial Instance tests
This is more of an exercise in QuickCheck than strong testing.
parent
9cf4267a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Ganeti/HTools/QC.hs
+35
-13
35 additions, 13 deletions
Ganeti/HTools/QC.hs
test.hs
+8
-0
8 additions, 0 deletions
test.hs
with
43 additions
and
13 deletions
Ganeti/HTools/QC.hs
+
35
−
13
View file @
7bc82927
...
@@ -49,42 +49,62 @@ instance Arbitrary Node.Node where
...
@@ -49,42 +49,62 @@ instance Arbitrary Node.Node where
-- | Make sure add is idempotent
-- | Make sure add is idempotent
prop_PeerMap_addIdempotent
pmap
key
elem
=
prop_PeerMap_addIdempotent
pmap
key
elem
=
fn
puniq
==
fn
(
fn
puniq
)
fn
puniq
==
fn
(
fn
puniq
)
where
fn
=
PeerMap
.
add
key
elem
where
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
puniq
=
PeerMap
.
accumArray
const
pmap
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
key
::
PeerMap
.
Key
,
elem
::
PeerMap
.
Elem
)
key
::
PeerMap
.
Key
,
elem
::
PeerMap
.
Elem
)
fn
=
PeerMap
.
add
key
elem
puniq
=
PeerMap
.
accumArray
const
pmap
-- | Make sure remove is idempotent
-- | Make sure remove is idempotent
prop_PeerMap_removeIdempotent
pmap
key
=
prop_PeerMap_removeIdempotent
pmap
key
=
fn
puniq
==
fn
(
fn
puniq
)
fn
puniq
==
fn
(
fn
puniq
)
where
fn
=
PeerMap
.
remove
key
where
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
key
::
PeerMap
.
Key
)
fn
=
PeerMap
.
remove
key
puniq
=
PeerMap
.
accumArray
const
pmap
puniq
=
PeerMap
.
accumArray
const
pmap
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
key
::
PeerMap
.
Key
)
-- | Make sure a missing item returns 0
-- | Make sure a missing item returns 0
prop_PeerMap_findMissing
pmap
key
=
prop_PeerMap_findMissing
pmap
key
=
PeerMap
.
find
key
(
PeerMap
.
remove
key
puniq
)
==
0
PeerMap
.
find
key
(
PeerMap
.
remove
key
puniq
)
==
0
where
fn
=
PeerMap
.
remove
key
where
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
key
::
PeerMap
.
Key
)
puniq
=
PeerMap
.
accumArray
const
pmap
puniq
=
PeerMap
.
accumArray
const
pmap
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
key
::
PeerMap
.
Key
)
-- | Make sure an added item is found
-- | Make sure an added item is found
prop_PeerMap_addFind
pmap
key
elem
=
prop_PeerMap_addFind
pmap
key
elem
=
PeerMap
.
find
key
(
PeerMap
.
add
key
elem
puniq
)
==
elem
PeerMap
.
find
key
(
PeerMap
.
add
key
elem
puniq
)
==
elem
where
puniq
=
PeerMap
.
accumArray
const
pmap
where
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
_types
=
(
pmap
::
PeerMap
.
PeerMap
,
key
::
PeerMap
.
Key
,
elem
::
PeerMap
.
Elem
)
key
::
PeerMap
.
Key
,
elem
::
PeerMap
.
Elem
)
puniq
=
PeerMap
.
accumArray
const
pmap
-- | Manual check that maxElem returns the maximum indeed, or 0 for null
-- | Manual check that maxElem returns the maximum indeed, or 0 for null
prop_PeerMap_maxElem
pmap
=
prop_PeerMap_maxElem
pmap
=
PeerMap
.
maxElem
puniq
==
if
null
puniq
then
0
PeerMap
.
maxElem
puniq
==
if
null
puniq
then
0
else
(
maximum
.
snd
.
unzip
)
puniq
else
(
maximum
.
snd
.
unzip
)
puniq
where
where
_types
=
pmap
::
PeerMap
.
PeerMap
puniq
=
PeerMap
.
accumArray
const
pmap
puniq
=
PeerMap
.
accumArray
const
pmap
_types
=
pmap
::
PeerMap
.
PeerMap
-- Simple instance tests, we only have setter/getters
prop_Instance_setIdx
inst
idx
=
Instance
.
idx
(
Instance
.
setIdx
inst
idx
)
==
idx
where
_types
=
(
inst
::
Instance
.
Instance
,
idx
::
Types
.
Idx
)
prop_Instance_setName
inst
name
=
Instance
.
name
(
Instance
.
setName
inst
name
)
==
name
where
_types
=
(
inst
::
Instance
.
Instance
,
name
::
String
)
prop_Instance_setPri
inst
pdx
=
Instance
.
pnode
(
Instance
.
setPri
inst
pdx
)
==
pdx
where
_types
=
(
inst
::
Instance
.
Instance
,
pdx
::
Types
.
Ndx
)
prop_Instance_setSec
inst
sdx
=
Instance
.
snode
(
Instance
.
setSec
inst
sdx
)
==
sdx
where
_types
=
(
inst
::
Instance
.
Instance
,
sdx
::
Types
.
Ndx
)
prop_Instance_setBoth
inst
pdx
sdx
=
Instance
.
pnode
si
==
pdx
&&
Instance
.
snode
si
==
sdx
where
_types
=
(
inst
::
Instance
.
Instance
,
pdx
::
Types
.
Ndx
,
sdx
::
Types
.
Ndx
)
si
=
Instance
.
setBoth
inst
pdx
sdx
-- | Check that an instance add with too high memory or disk will be rejected
prop_Node_addPri
node
inst
=
(
Instance
.
mem
inst
>=
Node
.
f_mem
node
||
prop_Node_addPri
node
inst
=
(
Instance
.
mem
inst
>=
Node
.
f_mem
node
||
Instance
.
dsk
inst
>=
Node
.
f_dsk
node
)
&&
Instance
.
dsk
inst
>=
Node
.
f_dsk
node
)
&&
(
not
$
Node
.
failN1
node
)
(
not
$
Node
.
failN1
node
)
...
@@ -92,6 +112,8 @@ prop_Node_addPri node inst = (Instance.mem inst >= Node.f_mem node ||
...
@@ -92,6 +112,8 @@ prop_Node_addPri node inst = (Instance.mem inst >= Node.f_mem node ||
isNothing
(
Node
.
addPri
node
inst
)
isNothing
(
Node
.
addPri
node
inst
)
where
_types
=
(
node
::
Node
.
Node
,
inst
::
Instance
.
Instance
)
where
_types
=
(
node
::
Node
.
Node
,
inst
::
Instance
.
Instance
)
-- | Check that an instance add with too high memory or disk will be rejected
prop_Node_addSec
node
inst
pdx
=
prop_Node_addSec
node
inst
pdx
=
(
Instance
.
mem
inst
>=
(
Node
.
f_mem
node
-
Node
.
r_mem
node
)
||
(
Instance
.
mem
inst
>=
(
Node
.
f_mem
node
-
Node
.
r_mem
node
)
||
Instance
.
dsk
inst
>=
Node
.
f_dsk
node
)
&&
Instance
.
dsk
inst
>=
Node
.
f_dsk
node
)
&&
...
...
This diff is collapsed.
Click to expand it.
test.hs
+
8
−
0
View file @
7bc82927
...
@@ -21,6 +21,14 @@ main = do
...
@@ -21,6 +21,14 @@ main = do
,
run
prop_PeerMap_findMissing
,
run
prop_PeerMap_findMissing
]
]
runTests
"Instance"
options
[
run
prop_Instance_setIdx
,
run
prop_Instance_setName
,
run
prop_Instance_setPri
,
run
prop_Instance_setSec
,
run
prop_Instance_setBoth
]
runTests
"Node"
options
runTests
"Node"
options
[
run
prop_Node_addPri
[
run
prop_Node_addPri
,
run
prop_Node_addSec
,
run
prop_Node_addSec
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment