Revision c42fbe28

b/src/Ganeti/Query/Group.hs
64 64
  , (FieldDefinition "ndparams" "NDParams" QFTOther "Node parameters",
65 65
     FieldConfig (\cfg ng -> rsNormal (getGroupNdParams cfg ng)), QffNormal)
66 66
  , (FieldDefinition "node_cnt" "Nodes" QFTNumber "Number of nodes",
67
     FieldConfig (\cfg -> rsNormal . length . getGroupNodes cfg . groupName),
67
     FieldConfig (\cfg -> rsNormal . length . getGroupNodes cfg . groupUuid),
68 68
     QffNormal)
69 69
  , (FieldDefinition "node_list" "NodeList" QFTOther "List of nodes",
70 70
     FieldConfig (\cfg -> rsNormal . map nodeName .
71
                          getGroupNodes cfg . groupName), QffNormal)
71
                          getGroupNodes cfg . groupUuid), QffNormal)
72 72
  , (FieldDefinition "pinst_cnt" "Instances" QFTNumber
73 73
       "Number of primary instances",
74 74
     FieldConfig
75
       (\cfg -> rsNormal . length . fst . getGroupInstances cfg . groupName),
75
       (\cfg -> rsNormal . length . fst . getGroupInstances cfg . groupUuid),
76 76
     QffNormal)
77 77
  , (FieldDefinition "pinst_list" "InstanceList" QFTOther
78 78
       "List of primary instances",
79 79
     FieldConfig (\cfg -> rsNormal . map instName . fst .
80
                          getGroupInstances cfg . groupName), QffNormal)
80
                          getGroupInstances cfg . groupUuid), QffNormal)
81 81
  ] ++
82 82
  map buildNdParamField allNDParamFields ++
83 83
  timeStampFields ++
b/test/hs/Test/Ganeti/Objects.hs
193 193
genEmptyCluster ncount = do
194 194
  nodes <- vector ncount
195 195
  version <- arbitrary
196
  let guuid = "00"
196
  grp <- arbitrary
197
  let guuid = groupUuid grp
197 198
      nodes' = zipWith (\n idx ->
198 199
                          let newname = nodeName n ++ "-" ++ show idx
199 200
                          in (newname, n { nodeGroup = guuid,
......
206 207
                                show (map fst nodes'))
207 208
                    else GenericContainer nodemap
208 209
      continsts = GenericContainer Map.empty
209
  grp <- arbitrary
210 210
  let contgroups = GenericContainer $ Map.singleton guuid grp
211 211
  serial <- arbitrary
212 212
  cluster <- resize 8 arbitrary
......
360 360
  -- timestamp fields
361 361
  ctime <- arbitrary
362 362
  mtime <- arbitrary
363
  uuid <- arbitrary
363
  uuid <- genFQDN `suchThat` (/= name)
364 364
  serial <- arbitrary
365 365
  tags <- Set.fromList <$> genTags
366 366
  let group = NodeGroup name members ndparams alloc_policy ipolicy diskparams
b/test/hs/Test/Ganeti/Query/Query.hs
36 36
import Data.List
37 37
import qualified Data.Map as Map
38 38
import Data.Maybe
39
import Text.JSON (JSValue(..))
39
import Text.JSON (JSValue(..), showJSON)
40 40

  
41 41
import Test.Ganeti.TestHelper
42 42
import Test.Ganeti.TestCommon
......
235 235
     (sortBy field_sort . map (\(f, _, _) -> f) $ Map.elems groupFieldsMap)
236 236
     (sortBy field_sort fdefs)
237 237

  
238
-- | Check that the node count reported by a group list is sane.
239
--
240
-- FIXME: also verify the node list, etc.
241
prop_queryGroup_nodeCount :: Property
242
prop_queryGroup_nodeCount =
243
  forAll (choose (0, maxNodes)) $ \nodes ->
244
  forAll (genEmptyCluster nodes) $ \cluster -> monadicIO $
245
  do
246
    QueryResult _ fdata <-
247
      run (query cluster False (Query (ItemTypeOpCode QRGroup)
248
                                ["node_cnt"] EmptyFilter)) >>= resultProp
249
    stop $ conjoin
250
      [ printTestCase "Invalid node count" $
251
        map (map rentryValue) fdata ==? [[Just (showJSON nodes)]]
252
      ]
253

  
238 254
-- ** Job queries
239 255

  
240 256
-- | Tests that querying any existing fields, via either query or
......
317 333
  , 'prop_queryGroup_Unknown
318 334
  , 'prop_queryGroup_types
319 335
  , 'case_queryGroup_allfields
336
  , 'prop_queryGroup_nodeCount
320 337
  , 'prop_queryJob_noUnknown
321 338
  , 'prop_queryJob_Unknown
322 339
  , 'prop_getRequestedNames

Also available in: Unified diff