Revision db079755
b/Ganeti/HTools/QC.hs | ||
---|---|---|
30 | 30 |
, testNode |
31 | 31 |
, testText |
32 | 32 |
, testOpCodes |
33 |
, testJobs |
|
33 | 34 |
, testCluster |
34 | 35 |
, testLoader |
35 | 36 |
) where |
... | ... | |
43 | 44 |
import qualified Data.Map |
44 | 45 |
import qualified Data.IntMap as IntMap |
45 | 46 |
import qualified Ganeti.OpCodes as OpCodes |
47 |
import qualified Ganeti.Jobs as Jobs |
|
46 | 48 |
import qualified Ganeti.HTools.CLI as CLI |
47 | 49 |
import qualified Ganeti.HTools.Cluster as Cluster |
48 | 50 |
import qualified Ganeti.HTools.Container as Container |
... | ... | |
176 | 178 |
liftM3 OpCodes.OpMigrateInstance arbitrary arbitrary arbitrary |
177 | 179 |
_ -> fail "Wrong opcode") |
178 | 180 |
|
181 |
instance Arbitrary Jobs.OpStatus where |
|
182 |
arbitrary = elements [minBound..maxBound] |
|
183 |
|
|
184 |
instance Arbitrary Jobs.JobStatus where |
|
185 |
arbitrary = elements [minBound..maxBound] |
|
186 |
|
|
179 | 187 |
-- * Actual tests |
180 | 188 |
|
181 | 189 |
-- | Make sure add is idempotent |
... | ... | |
659 | 667 |
[ run prop_OpCodes_serialization |
660 | 668 |
] |
661 | 669 |
|
670 |
-- | Check that (queued) job/opcode status serialization is idempotent |
|
671 |
prop_OpStatus_serialization os = |
|
672 |
case J.readJSON (J.showJSON os) of |
|
673 |
J.Error _ -> False |
|
674 |
J.Ok os' -> os == os' |
|
675 |
where _types = os::Jobs.OpStatus |
|
676 |
|
|
677 |
prop_JobStatus_serialization js = |
|
678 |
case J.readJSON (J.showJSON js) of |
|
679 |
J.Error _ -> False |
|
680 |
J.Ok js' -> js == js' |
|
681 |
where _types = js::Jobs.JobStatus |
|
682 |
|
|
683 |
testJobs = |
|
684 |
[ run prop_OpStatus_serialization |
|
685 |
, run prop_JobStatus_serialization |
|
686 |
] |
|
687 |
|
|
662 | 688 |
-- | Loader tests |
663 | 689 |
|
664 | 690 |
prop_Loader_lookupNode ktn inst node = |
b/Ganeti/Jobs.hs | ||
---|---|---|
70 | 70 |
| JOB_STATUS_CANCELING |
71 | 71 |
| JOB_STATUS_CANCELED |
72 | 72 |
| JOB_STATUS_ERROR |
73 |
| JOB_STATUS_GONE |
|
74 | 73 |
deriving (Eq, Enum, Ord, Bounded, Show) |
75 | 74 |
|
76 | 75 |
instance JSON JobStatus where |
... | ... | |
83 | 82 |
JOB_STATUS_CANCELED -> "canceled" |
84 | 83 |
JOB_STATUS_SUCCESS -> "success" |
85 | 84 |
JOB_STATUS_ERROR -> "error" |
86 |
JOB_STATUS_GONE -> "gone" -- Fake status |
|
87 | 85 |
readJSON s = case readJSON s of |
88 | 86 |
J.Ok "queued" -> J.Ok JOB_STATUS_QUEUED |
89 | 87 |
J.Ok "waiting" -> J.Ok JOB_STATUS_WAITLOCK |
b/test.hs | ||
---|---|---|
70 | 70 |
, ("Node", fast, testNode) |
71 | 71 |
, ("Text", fast, testText) |
72 | 72 |
, ("OpCodes", fast, testOpCodes) |
73 |
, ("Jobs", fast, testJobs) |
|
73 | 74 |
, ("Loader", fast, testLoader) |
74 | 75 |
, ("Cluster", slow, testCluster) |
75 | 76 |
] |
Also available in: Unified diff