Commit 21bf2e2e authored by Andrea Spadaccini's avatar Andrea Spadaccini

PEP8 for QA

- Makefile.am: added QA directory to the paths checked by pep8
- qa/: fixed the reported errors
- Makefile.am: also, added qa_group.py to qa_scripts
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 6eedd356
......@@ -454,6 +454,7 @@ qa_scripts = \
qa/qa_daemon.py \
qa/qa_env.py \
qa/qa_error.py \
qa/qa_group.py \
qa/qa_instance.py \
qa/qa_node.py \
qa/qa_os.py \
......@@ -767,6 +768,17 @@ lint_python_code = \
$(DOCPP) \
$(PYTHON_BOOTSTRAP)
pep8_python_code = \
ganeti \
ganeti/http/server.py \
$(dist_sbin_SCRIPTS) \
$(dist_tools_PYTHON) \
$(pkglib_python_scripts) \
$(BUILD_BASH_COMPLETION) \
$(DOCPP) \
$(PYTHON_BOOTSTRAP) \
qa
test/daemon-util_unittest.bash: daemons/daemon-util
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
......@@ -1087,7 +1099,7 @@ lint: $(BUILT_SOURCES)
echo '"pep8" not found during configure' >&2; \
else \
$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
$(lint_python_code); \
$(pep8_python_code); \
fi
$(PYLINT) $(LINT_OPTS) $(lint_python_code)
cd $(top_srcdir)/qa && \
......
......@@ -54,7 +54,7 @@ def _FormatHeader(line, end=72):
"""
line = "---- " + line + " "
line += "-" * (end-len(line))
line += "-" * (end - len(line))
line = line.rstrip()
return line
......
......@@ -40,6 +40,7 @@ from qa_utils import AssertEqual, AssertCommand, GetCommandOutput
#: cluster verify command
_CLUSTER_VERIFY = ["gnt-cluster", "verify"]
def _RemoveFileFromAllNodes(filename):
"""Removes a file from all nodes.
......@@ -231,14 +232,14 @@ def TestClusterReservedLvs():
(False, _CLUSTER_VERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
(False, ["lvcreate", "-L1G", "-nqa-test", "xenvg"]),
(True, _CLUSTER_VERIFY),
(True, _CLUSTER_VERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs",
"xenvg/qa-test,.*/other-test"]),
(False, _CLUSTER_VERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs", ".*/qa-.*"]),
(False, _CLUSTER_VERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
(True, _CLUSTER_VERIFY),
(True, _CLUSTER_VERIFY),
(False, ["lvremove", "-f", "xenvg/qa-test"]),
(False, _CLUSTER_VERIFY),
]:
......@@ -251,19 +252,19 @@ def TestClusterModifyBe():
# mem
(False, ["gnt-cluster", "modify", "-B", "memory=256"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 256$'"]),
(True, ["gnt-cluster", "modify", "-B", "memory=a"]),
(True, ["gnt-cluster", "modify", "-B", "memory=a"]),
(False, ["gnt-cluster", "modify", "-B", "memory=128"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 128$'"]),
# vcpus
(False, ["gnt-cluster", "modify", "-B", "vcpus=4"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]),
(True, ["gnt-cluster", "modify", "-B", "vcpus=a"]),
(True, ["gnt-cluster", "modify", "-B", "vcpus=a"]),
(False, ["gnt-cluster", "modify", "-B", "vcpus=1"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]),
# auto_balance
(False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]),
(True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]),
(True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]),
(False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]),
]:
......@@ -274,6 +275,7 @@ def TestClusterModifyBe():
if bep:
AssertCommand(["gnt-cluster", "modify", "-B", bep])
def TestClusterInfo():
"""gnt-cluster info"""
AssertCommand(["gnt-cluster", "info"])
......@@ -306,7 +308,7 @@ def TestClusterRenewCrypto():
["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"],
]
for i in conflicting:
AssertCommand(cmd+i, fail=True)
AssertCommand(cmd + i, fail=True)
# Invalid RAPI certificate
cmd = ["gnt-cluster", "renew-crypto", "--force",
......
......@@ -42,7 +42,7 @@ def TestGanetiCommands():
"""Test availibility of Ganeti commands.
"""
cmds = ( ["gnt-backup", "--version"],
cmds = (["gnt-backup", "--version"],
["gnt-cluster", "--version"],
["gnt-debug", "--version"],
["gnt-instance", "--version"],
......@@ -76,7 +76,7 @@ def TestIcmpPing():
seccmd = [pingsecondary, "-e"]
for i in nodes:
pricmd.append(i["primary"])
if i.has_key("secondary"):
if "secondary" in i:
seccmd.append(i["secondary"])
pristr = utils.ShellQuoteArgs(pricmd)
......
......@@ -23,6 +23,7 @@
"""
class Error(Exception):
"""An error occurred during Q&A testing.
......
......@@ -275,7 +275,7 @@ def TestOutOfBand():
# Power off on master without options should fail
AssertCommand(["gnt-node", "power", "-f", "off", master_name], fail=True)
# With force master it should still fail
AssertCommand(["gnt-node", "power", "-f", "--ignore-status", "off",
AssertCommand(["gnt-node", "power", "-f", "--ignore-status", "off",
master_name],
fail=True)
......@@ -302,7 +302,7 @@ def TestOutOfBand():
AssertCommand(["gnt-node", "health"], fail=True)
# Correct Data, exit 0
_UpdateOobFile(data_path, serializer.DumpJson({ "powered": True }))
_UpdateOobFile(data_path, serializer.DumpJson({"powered": True}))
AssertCommand(["gnt-node", "power", "status", node_name])
_AssertOobCall(verify_path, "power-status %s" % full_node_name)
......@@ -315,7 +315,6 @@ def TestOutOfBand():
AssertCommand(["gnt-node", "health"])
# Those commands should fail as they expect no data regardless of exit 0
AssertCommand(["gnt-node", "power", "on", node_name], fail=True)
_AssertOobCall(verify_path, "power-on %s" % full_node_name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment