Revision b5a93c73

b/qa/qa_cluster.py
690 690
      (cur_policy, cur_specs) = TestClusterSetISpecs(new_vals, fail=not good,
691 691
                                                     old_values=cur_state)
692 692

  
693
    # Get the ipolicy command
694
    mnode = qa_config.GetMasterNode()
695
    initcmd = GetCommandOutput(mnode.primary, "gnt-cluster show-ispecs-cmd")
696
    modcmd = ["gnt-cluster", "modify"]
697
    opts = initcmd.split()
698
    assert opts[0:2] == ["gnt-cluster", "init"]
699
    for k in range(2, len(opts) - 1):
700
      if opts[k].startswith("--ipolicy-"):
701
        assert k + 2 <= len(opts)
702
        modcmd.extend(opts[k:k + 2])
703
    # Re-apply the ipolicy (this should be a no-op)
704
    AssertCommand(modcmd)
705
    new_initcmd = GetCommandOutput(mnode.primary, "gnt-cluster show-ispecs-cmd")
706
    AssertEqual(initcmd, new_initcmd)
707

  
693 708

  
694 709
def TestClusterInfo():
695 710
  """gnt-cluster info"""
b/qa/qa_group.py
79 79
  AssertCommand(["gnt-group", "remove", group1])
80 80

  
81 81

  
82
def _TestGroupModifyISpecs(groupname):
83
  std_defaults = constants.IPOLICY_DEFAULTS[constants.ISPECS_STD]
84
  min_v = std_defaults[constants.ISPEC_MEM_SIZE] * 10
85
  max_v = min_v * 10
86

  
87
  # Get the ipolicy command (from the cluster config)
88
  mnode = qa_config.GetMasterNode()
89
  addcmd = GetCommandOutput(mnode.primary, utils.ShellQuoteArgs([
90
    "gnt-group", "show-ispecs-cmd", "--include-defaults", groupname,
91
    ]))
92
  modcmd = ["gnt-group", "modify"]
93
  opts = addcmd.split()
94
  assert opts[0:2] == ["gnt-group", "add"]
95
  for k in range(2, len(opts) - 1):
96
    if opts[k].startswith("--ipolicy-"):
97
      assert k + 2 <= len(opts)
98
      modcmd.extend(opts[k:k + 2])
99
  modcmd.append(groupname)
100
  # Apply the ipolicy to the group and verify the result
101
  AssertCommand(modcmd)
102
  new_addcmd = GetCommandOutput(mnode.primary, utils.ShellQuoteArgs([
103
    "gnt-group", "show-ispecs-cmd", groupname,
104
    ]))
105
  AssertEqual(addcmd, new_addcmd)
106

  
107
  AssertCommand(["gnt-group", "modify", "--specs-mem-size",
108
                 "min=%s,max=%s,std=0" % (min_v, max_v), groupname], fail=True)
109
  AssertCommand(["gnt-group", "modify", "--specs-mem-size",
110
                 "min=%s,max=%s" % (min_v, max_v), groupname])
111
  AssertCommand(["gnt-group", "modify", "--specs-mem-size",
112
                 "min=default,max=default", groupname])
113

  
114

  
115
def _TestGroupModifyIPolicy(groupname):
116
  _TestGroupModifyISpecs(groupname)
117
  AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
118
                 "3.5", groupname])
119
  AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
120
                 "default", groupname])
121

  
122

  
82 123
def TestGroupModify():
83 124
  """gnt-group modify"""
84 125
  (group1, ) = qa_utils.GetNonexistentGroups(1)
85 126

  
86 127
  AssertCommand(["gnt-group", "add", group1])
87 128

  
88
  std_defaults = constants.IPOLICY_DEFAULTS[constants.ISPECS_STD]
89
  min_v = std_defaults[constants.ISPEC_MEM_SIZE] * 10
90
  max_v = min_v * 10
91

  
92 129
  try:
130
    _TestGroupModifyIPolicy(group1)
93 131
    AssertCommand(["gnt-group", "modify", "--alloc-policy", "unallocable",
94 132
                   "--node-parameters", "oob_program=/bin/false", group1])
95 133
    AssertCommand(["gnt-group", "modify",
96 134
                   "--alloc-policy", "notvalid", group1], fail=True)
97
    AssertCommand(["gnt-group", "modify", "--specs-mem-size",
98
                   "min=%s,max=%s,std=0" % (min_v, max_v), group1], fail=True)
99
    AssertCommand(["gnt-group", "modify", "--specs-mem-size",
100
                   "min=%s,max=%s" % (min_v, max_v), group1])
101
    AssertCommand(["gnt-group", "modify", "--specs-mem-size",
102
                   "min=default,max=default", group1])
103
    AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
104
                   "3.5", group1])
105
    AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
106
                   "default", group1])
107 135
    AssertCommand(["gnt-group", "modify",
108 136
                   "--node-parameters", "spindle_count=10", group1])
109 137
    if qa_config.TestEnabled("htools"):

Also available in: Unified diff