Skip to content
Snippets Groups Projects
Commit 21bf2e2e authored by Andrea Spadaccini's avatar Andrea Spadaccini
Browse files

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