-- | Check that the nodes reported by a name filter are sane.
prop_queryNode_filter :: Property
prop_queryNode_filter =
  forAll (choose (1, maxNodes)) $ \nodes ->
  forAll (genEmptyCluster nodes `suchThat`
          areNodeNamesSane) $ \cluster -> monadicIO $ do
    let node_list = map nodeName . Map.elems . fromContainer $
                    configNodes cluster
    count <- pick $ choose (1, nodes)
    fqdn_set <- pick . genSetHelper node_list $ Just count
    let fqdns = Set.elems fqdn_set
        names = map (head . sepSplit '.') fqdns
        flt = makeSimpleFilter "name" $ map Left names
    QueryResult _ fdata <-
      run (query cluster False (Query (ItemTypeOpCode QRNode)
                                ["name"] flt)) >>= resultProp
    _ <- stop $ conjoin
         [ counterexample "Invalid node names" $
           map (map rentryValue) fdata ==? map (\f -> [Just (showJSON f)]) fqdns
         ]
    return ()

-- ** Group queries
prop_queryNode_filter :: Property
prop_queryNode_filter =
  forAll (choose (1, maxNodes)) $ \nodes ->
  forAll (genEmptyCluster nodes `suchThat`
          areNodeNamesSane) $ \cluster -> monadicIO $ do
    let node_list = map nodeName . Map.elems . fromContainer $
                    configNodes cluster
    count <- pick $ choose (1, nodes)
    fqdn_set <- pick . genSetHelper node_list $ Just count
    let fqdns = Set.elems fqdn_set
        names = map (head . sepSplit '.') fqdns
        flt = makeSimpleFilter "name" $ map Left names
    QueryResult _ fdata <-
      run (query cluster False (Query (ItemTypeOpCode QRNode)
                                ["name"] flt)) >>= resultProp
    _ <- stop $ conjoin
         [ counterexample "Invalid node names" $
           map (map rentryValue) fdata ==? map (\f -> [Just (showJSON f)]) fqdns
         ]
    return ()

-- ** Group queries
prop_queryNode_filter =
  forAll (choose (1, maxNodes)) $ \nodes ->
  forAll (genEmptyCluster nodes `suchThat`
          areNodeNamesSane) $ \cluster -> monadicIO $ do
    let node_list = map nodeName . Map.elems . fromContainer $
                    configNodes cluster
    count <- pick $ choose (1, nodes)
    fqdn_set <- pick . genSetHelper node_list $ Just count
    let fqdns = Set.elems fqdn_set
        names = map (head . sepSplit '.') fqdns
        flt = makeSimpleFilter "name" $ map Left names
    QueryResult _ fdata <-
      run (query cluster False (Query (ItemTypeOpCode QRNode)
                                ["name"] flt)) >>= resultProp
    _ <- stop $ conjoin
         [ counterexample "Invalid node names" $
           map (map rentryValue) fdata ==? map (\f -> [Just (showJSON f)]) fqdns
         ]
    return ()

-- ** Group queries