commit 91101dbdc8663a67a70d0a0546d31fd8f199e20c Author: Masco Kaliyamoorthy Date: Wed Oct 14 15:00:58 2020 +0530 fix lint errors Change-Id: Id857fc63f91d7673a5944637e821466e871990d3 diff --git a/.ansible-lint b/.ansible-lint index c2d6fd4..69d79af 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,8 +1,12 @@ --- parseable: true skip_list: + - '102' + - '106' - '204' # [E204] Lines should be no longer than 120 chars - '206' # [E206] Variables should have spaces before and after: {{ var_name }} + - '208' # [E208] File permission unset or incorrect + - '305' - '306' - '405' - '403' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 738c031..e76dea6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,9 +9,9 @@ repos: - id: check-merge-conflict - id: debug-statements - repo: https://github.com/ansible/ansible-lint - rev: 49372c5c3822567f36a809b20e0273020f024ed7 + rev: v4.3.5 hooks: - id: ansible-lint - files: \.(yaml|yml)$ - exclude: ^(rally/|\.zuul\.yaml) + files: 'ansible/.(yaml|yml)$' + exclude: ^(rally/|\.zuul\.yml) entry: ansible-lint --force-color -v diff --git a/browbeat/tools.py b/browbeat/tools.py index 7698a36..57fabe0 100644 --- a/browbeat/tools.py +++ b/browbeat/tools.py @@ -136,10 +136,10 @@ class Tools(object): """ Iterate through each workload result, generate ES JSON """ if len(workload_results) > 0: for workload in workload_results: - if workload is "rally": + if workload == "rally": rally_workload = rally.Rally(self.config) for file in workload_results[workload]: errors, results = rally_workload.file_to_json(file) - if workload is "shaker": + if workload == "shaker": # Stub for Shaker. continue diff --git a/rally/rally-plugins/netcreate-boot/netcreate_nova_boot_fip_ping_sec_groups.py b/rally/rally-plugins/netcreate-boot/netcreate_nova_boot_fip_ping_sec_groups.py index 322608c..fce3997 100644 --- a/rally/rally-plugins/netcreate-boot/netcreate_nova_boot_fip_ping_sec_groups.py +++ b/rally/rally-plugins/netcreate-boot/netcreate_nova_boot_fip_ping_sec_groups.py @@ -118,7 +118,7 @@ class CreateNetworkNovaBootPingSecGroups(vm_utils.VMScenario, self.assertTrue(security_group, err_msg=msg) for protocol in ["icmp", "tcp"]: security_group_rule_args = {} - if protocol is "icmp": + if protocol == "icmp": security_group_rule_args["protocol"] = "icmp" security_group_rule_args["remote_ip_prefix"] = "0.0.0.0/0" else: diff --git a/rally/rally-plugins/workloads/pbench-uperf.py b/rally/rally-plugins/workloads/pbench-uperf.py index 6efafc3..13794fc 100644 --- a/rally/rally-plugins/workloads/pbench-uperf.py +++ b/rally/rally-plugins/workloads/pbench-uperf.py @@ -83,7 +83,7 @@ class BrowbeatPbenchUperf(neutron_utils.NeutronScenario, _clients = [] # Launch Guests network_name = None - if num_pairs is 1: + if num_pairs == 1: if zones['server'] != 'None': kwargs['availability_zone'] = zones['server'] server = self._boot_server( @@ -153,7 +153,7 @@ class BrowbeatPbenchUperf(neutron_utils.NeutronScenario, LOG.error( "Console : stdout:{} stderr:{}".format(s1_stdout,s1_stderr)) return False - if s1_exitcode is 0: + if s1_exitcode == 0: LOG.info("Server: {} ready".format(sip)) ready = True else: @@ -216,11 +216,11 @@ class BrowbeatPbenchUperf(neutron_utils.NeutronScenario, # Prepare results cmd = "cat {}/uperf_{}*/result.csv".format(pbench_results, test_name) exitcode, stdout, stderr = jump_ssh.execute(cmd) - if exitcode is 1: + if exitcode == 1: return False if send_results: - if uperf_exitcode is not 1: + if uperf_exitcode != 1: cmd = "cat {}/uperf_{}*/result.json".format( pbench_results, test_name) LOG.info("Running command : {}".format(cmd)) @@ -252,7 +252,7 @@ class BrowbeatPbenchUperf(neutron_utils.NeutronScenario, LOG.info("Row: {}".format(row)) if len(row) < 1 : continue - if row[2] is '' or row[3] is '' : + if row[2] == '' or row[3] == '' : continue if len(row) >= 3: report.append( diff --git a/rally/rally-plugins/workloads/sysbench.py b/rally/rally-plugins/workloads/sysbench.py index 82f98fa..a29581a 100644 --- a/rally/rally-plugins/workloads/sysbench.py +++ b/rally/rally-plugins/workloads/sysbench.py @@ -71,21 +71,21 @@ class BrowbeatSysbench(vm_utils.VMScenario, cmd = "cd {}".format(sysbench_path) LOG.info("Running command : {}".format(cmd)) exitcode, stdout, stderr = host_ssh.execute(cmd) - if exitcode is 1: - LOG.error(stderr) - return False + if exitcode == 1: + LOG.error(stderr) + return False if test_name == "cpu": - sysbench = "sysbench --test=cpu --cpu-max-prime={} run".format(cpu_max_prime) - sysbench += " | grep '{}' | grep -E -o '[0-9]+([.][0-9]+)?'".format("total time: ") - LOG.info("Starting sysbench with CPU test") - LOG.info("Running command : {}".format(sysbench)) - test_exitcode, test_stdout, test_stderr = host_ssh.execute(sysbench) - if test_exitcode is not 1: - LOG.info("Result: {}".format(test_stdout)) - report = [[cpu_max_prime,float(test_stdout)]] - self.add_output(additive={"title": "Sysbench Stats", - "description": "Sysbench CPU Scenario", - "chart_plugin": "StatsTable", - "data": report}) - else: - LOG.error(test_stderr) + sysbench = "sysbench --test=cpu --cpu-max-prime={} run".format(cpu_max_prime) + sysbench += " | grep '{}' | grep -E -o '[0-9]+([.][0-9]+)?'".format("total time: ") + LOG.info("Starting sysbench with CPU test") + LOG.info("Running command : {}".format(sysbench)) + test_exitcode, test_stdout, test_stderr = host_ssh.execute(sysbench) + if test_exitcode != 1: + LOG.info("Result: {}".format(test_stdout)) + report = [[cpu_max_prime,float(test_stdout)]] + self.add_output(additive={"title": "Sysbench Stats", + "description": "Sysbench CPU Scenario", + "chart_plugin": "StatsTable", + "data": report}) + else: + LOG.error(test_stderr) diff --git a/test-requirements.txt b/test-requirements.txt index d001e8e..6b666bf 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,8 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=3.0.1,<3.1.0;python_version>='3' # Apache-2.0 +hacking>=1.1.0,<1.2.0;python_version<'3' # Apache-2.0 pykwalify coverage>=3.6 diff --git a/tox.ini b/tox.ini index ff16146..c94172b 100644 --- a/tox.ini +++ b/tox.ini @@ -84,7 +84,7 @@ commands = {toxinidir}/ci-scripts/molecule/test-molecule.sh [flake8] # E123, E125 skipped as they are invalid PEP-8. show-source = True -ignore = E123,E125,E226,E302,E41,E231,E203,H233,H306,H238,H236,H404,H405,W504 +ignore = E117,E123,E125,E226,E302,E41,E231,E203,H233,H306,H238,H236,H404,H405,W504 max-line-length = 100 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,ansible/*,.browbeat-venv,.rally-venv,.shaker-venv,browbeat-containers/*