mirror of https://github.com/mongodb/mongo
SERVER-76796 Enable more lint warnings and fix them
This commit is contained in:
parent
127a96b933
commit
babf160654
13
.pylintrc
13
.pylintrc
|
|
@ -13,15 +13,12 @@ variable-rgx=[a-z_][a-z0-9_]{1,50}$
|
|||
|
||||
[MESSAGES CONTROL]
|
||||
# C0103 - invalid-name - Fix variable names to match convention
|
||||
# C0200 - consider-using-enumerate - Prefer enumerate() when you need index and value from an iterable
|
||||
# C0201 - consider-iterating-dictionary
|
||||
# C0206 - consider-using-dict-items - Need to explicitly specify .keys() or .items() in a dictionary iteration
|
||||
# C0207 - use-maxsplit-arg - Use maxsplit arg in split() calls
|
||||
# C0209 - consider-using-f-string - Need to convert most format strings (using both % and .format) to f""-style strings
|
||||
# C0301 - line-too-long - some of the type annotations are longer then 100 columns
|
||||
# C0325 - superfluous-parens - Superfluous parens, easy to fix
|
||||
# C0330 - bad-continuation - ignore conflicts produced by yapf formatting
|
||||
# C1803 - use-implicit-booleaness-not-comparison
|
||||
# C2801 - unnecessary-dunder-call - Prefer a builtin call instead of a dunder method
|
||||
# C3001 - unnecessary-lambda-assignment - Prefer def over lambda
|
||||
|
||||
|
|
@ -36,12 +33,10 @@ variable-rgx=[a-z_][a-z0-9_]{1,50}$
|
|||
|
||||
# R0204 - redefined-variable-type
|
||||
# R0205 - useless-object-inheritance - See PM-1380
|
||||
# R0402 - consider-using-from-import - Use better convention for module import
|
||||
# R0801 - duplicate-code - See PM-1380
|
||||
# R0903 - too-few-public-methods - pylint does not always know best
|
||||
# R1705 - no-else-return - sometimes an unnecessary else helps readability
|
||||
# R1710 - inconsistent-return-statements
|
||||
# R1714 - consider-using-in - Use 'x in [...]' instead
|
||||
# R1720 - no-else-raise - See PM-1380
|
||||
# R1728 - consider-using-generator - Use a generator instead of creating an in-memory list
|
||||
# R1730 - consider-using-min-builtin - Lots of situations where min() can be used to eliminate an if block
|
||||
|
|
@ -64,7 +59,6 @@ variable-rgx=[a-z_][a-z0-9_]{1,50}$
|
|||
# W0621 - redefined-outer-name - Overriding variable name
|
||||
# W0640 - cell-var-from-loop
|
||||
# W0719 - broad-exception-raised - Should use a more precise exception than `Exception`
|
||||
# W1406 - redundant-u-string-prefix
|
||||
# W1505 - deprecated-method - See PM-1380
|
||||
# W1514 - unspecified-encoding - Need to add 'encoding="utf-8"' to most open() operations
|
||||
# W3101 - missing-timeout - Add an explicit timeout to some sync functions
|
||||
|
|
@ -76,12 +70,8 @@ disable=
|
|||
broad-exception-raised,
|
||||
cell-var-from-loop,
|
||||
consider-using-dict-items,
|
||||
consider-using-enumerate,
|
||||
consider-using-f-string,
|
||||
consider-using-from-import,
|
||||
consider-using-generator,
|
||||
consider-using-in,
|
||||
consider-iterating-dictionary,
|
||||
consider-using-max-builtin,
|
||||
consider-using-min-builtin,
|
||||
consider-using-with,
|
||||
|
|
@ -113,7 +103,6 @@ disable=
|
|||
no-name-in-module,
|
||||
protected-access,
|
||||
raise-missing-from,
|
||||
redundant-u-string-prefix,
|
||||
redefined-outer-name,
|
||||
subprocess-run-check,
|
||||
super-init-not-called,
|
||||
|
|
@ -140,10 +129,8 @@ disable=
|
|||
unused-argument,
|
||||
use-dict-literal,
|
||||
use-list-literal,
|
||||
use-implicit-booleaness-not-comparison,
|
||||
used-before-assignment,
|
||||
useless-object-inheritance,
|
||||
useless-suppression,
|
||||
wrong-import-order
|
||||
enable=useless-suppression
|
||||
|
||||
|
|
|
|||
|
|
@ -1190,7 +1190,7 @@ class Analyzer:
|
|||
# We filter ourself our of the list of components.
|
||||
self.black_duck_components = [
|
||||
comp for comp in self.black_duck_components
|
||||
if not (comp.name == "MongoDB" or comp.name == "WiredTiger")
|
||||
if not (comp.name in ["MongoDB", "WiredTiger"])
|
||||
]
|
||||
|
||||
# Remove duplicate Black Duck components. We only care about the component with highest version number
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from typing import Set, List, Optional
|
|||
|
||||
import yaml
|
||||
|
||||
import buildscripts.util.runcommand as runcommand
|
||||
from buildscripts.util import runcommand
|
||||
|
||||
ENTERPRISE_MODULE_NAME = "enterprise"
|
||||
ASAN_SIGNATURE = "detect_leaks=1"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import yaml
|
|||
sys.path.append(os.path.normpath(os.path.join(os.path.abspath(__file__), '../../..')))
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
import buildscripts.idl.lib as lib
|
||||
from buildscripts.idl import lib
|
||||
from buildscripts.idl.idl import parser
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -925,7 +925,7 @@ def _bind_expression(expr, allow_literal_string=True):
|
|||
node.export = True
|
||||
|
||||
# bool
|
||||
if (expr.literal == "true") or (expr.literal == "false"):
|
||||
if expr.literal in ["true", "false"]:
|
||||
node.expr = expr.literal
|
||||
return node
|
||||
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ class ParserContext(object):
|
|||
if not self._is_node_type(node, node_name, "scalar"):
|
||||
return False
|
||||
|
||||
if not (node.value == "true" or node.value == "false"):
|
||||
if not node.value in ["true", "false"]:
|
||||
self._add_node_error(
|
||||
node, ERROR_ID_IS_NODE_VALID_BOOL,
|
||||
"Illegal bool value for '%s', expected either 'true' or 'false'." % node_name)
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ class BackendServer:
|
|||
if "transitive_edges" in req_body.keys() and req_body["transitive_edges"] is True:
|
||||
for node in selected_nodes:
|
||||
for libdep in dependency_graph[str(node)]:
|
||||
if str(libdep) in nodes.keys():
|
||||
if str(libdep) in nodes:
|
||||
add_link_to_graph_data(node, libdep,
|
||||
dependents_graph[libdep][str(node)])
|
||||
|
||||
|
|
|
|||
|
|
@ -111,9 +111,7 @@ class Linter:
|
|||
def _check_and_strip_comments(self):
|
||||
in_multi_line_comment = False
|
||||
|
||||
for linenum in range(len(self.raw_lines)):
|
||||
clean_line = self.raw_lines[linenum]
|
||||
|
||||
for linenum, clean_line in enumerate(self.raw_lines):
|
||||
# Users can write NOLINT different ways
|
||||
# // NOLINT
|
||||
# // Some explanation NOLINT
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ if __name__ == "__main__" and __package__ is None:
|
|||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
import buildscripts.powercycle_setup.cli as cli
|
||||
from buildscripts.powercycle_setup import cli
|
||||
|
||||
cli.main(sys.argv)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ if __name__ == "__main__" and __package__ is None:
|
|||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
import buildscripts.resmokelib.cli as cli
|
||||
from buildscripts.resmokelib import cli
|
||||
|
||||
|
||||
def entrypoint():
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def get_dumpers(root_logger: logging.Logger, dbg_output: str):
|
|||
if sys.platform.startswith("linux"):
|
||||
dbg = GDBDumper(root_logger, dbg_output)
|
||||
jstack = JstackDumper()
|
||||
elif sys.platform == "win32" or sys.platform == "cygwin":
|
||||
elif sys.platform in ["win32", "cygwin"]:
|
||||
dbg = WindowsDumper(root_logger, dbg_output)
|
||||
jstack = JstackWindowsDumper()
|
||||
elif sys.platform == "darwin":
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class HangAnalyzer(Subcommand):
|
|||
self.root_logger.info("OS: %s", platform.platform())
|
||||
|
||||
try:
|
||||
if sys.platform == "win32" or sys.platform == "cygwin":
|
||||
if sys.platform in ["win32", "cygwin"]:
|
||||
self.root_logger.info("Windows Distribution: %s", platform.win32_ver())
|
||||
else:
|
||||
self.root_logger.info("Linux Distribution: %s", distro.linux_distribution())
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ def _get_lister():
|
|||
"""Return _ProcessList object for OS."""
|
||||
if sys.platform.startswith("linux"):
|
||||
ps = _LinuxProcessList()
|
||||
elif sys.platform == "win32" or sys.platform == "cygwin":
|
||||
elif sys.platform in ["win32", "cygwin"]:
|
||||
ps = _WindowsProcessList()
|
||||
elif sys.platform == "darwin":
|
||||
ps = _DarwinProcessList()
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class PowercycleCommand(Subcommand):
|
|||
@staticmethod
|
||||
def is_windows() -> bool:
|
||||
""":return: True if running on Windows."""
|
||||
return sys.platform == "win32" or sys.platform == "cygwin"
|
||||
return sys.platform in ["win32", "cygwin"]
|
||||
|
||||
@staticmethod
|
||||
def _call(cmd):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import textwrap
|
|||
if __name__ == "__main__" and __package__ is None:
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
_IS_WINDOWS = sys.platform == "win32" or sys.platform == "cygwin"
|
||||
_IS_WINDOWS = sys.platform in ["win32", "cygwin"]
|
||||
|
||||
_SSH_CONNECTION_ERRORS = [
|
||||
"Connection refused",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import time
|
|||
from buildscripts.resmokelib.powercycle.lib.process_control import ProcessControl
|
||||
from buildscripts.resmokelib.powercycle.lib import execute_cmd
|
||||
|
||||
_IS_WINDOWS = sys.platform == "win32" or sys.platform == "cygwin"
|
||||
_IS_WINDOWS = sys.platform in ["win32", "cygwin"]
|
||||
|
||||
|
||||
def _try_import(module, name=None):
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ from buildscripts.resmokelib.powercycle import powercycle_config, powercycle_con
|
|||
from buildscripts.resmokelib.powercycle.lib.services import WindowsService, PosixService
|
||||
from buildscripts.resmokelib.utils.filesystem import build_hygienic_bin_path
|
||||
|
||||
_IS_WINDOWS = sys.platform == "win32" or sys.platform == "cygwin"
|
||||
_IS_WINDOWS = sys.platform in ["win32", "cygwin"]
|
||||
_IS_LINUX = sys.platform.startswith("linux")
|
||||
_IS_DARWIN = sys.platform == "darwin"
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ def dump_stacks_and_exit(signum, frame): # pylint: disable=unused-argument
|
|||
LOGGER.info("Dumping stacks!")
|
||||
|
||||
sb = []
|
||||
frames = sys._current_frames() # pylint: disable=protected-access
|
||||
frames = sys._current_frames()
|
||||
sb.append("Total threads: {}\n".format(len(frames)))
|
||||
sb.append("")
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ def dump_stacks_and_exit(signum, frame): # pylint: disable=unused-argument
|
|||
|
||||
if _IS_WINDOWS:
|
||||
exit_handler()
|
||||
os._exit(1) # pylint: disable=protected-access
|
||||
os._exit(1)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
|
|
@ -1060,7 +1060,7 @@ def crash_server_or_kill_mongod(task_config, crash_canary, local_ops, script_nam
|
|||
LOGGER.info("%s in %d seconds", message_prefix, crash_wait_time)
|
||||
time.sleep(crash_wait_time)
|
||||
|
||||
if task_config.crash_method == "internal" or task_config.crash_method == "kill":
|
||||
if task_config.crash_method in ["internal", "kill"]:
|
||||
crash_cmd = "crash_server" if task_config.crash_method == "internal" else "kill_mongod"
|
||||
crash_func = local_ops.shell
|
||||
remote_python = get_remote_python()
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ class SetupMultiversion(Subcommand):
|
|||
" this error, please reach out in #server-testing slack channel.")
|
||||
exit(1)
|
||||
try:
|
||||
import buildscripts.resmokelib.multiversionconstants as multiversionconstants
|
||||
from buildscripts.resmokelib import multiversionconstants
|
||||
except ImportError:
|
||||
self.logger.error("Could not import `buildscripts.resmokelib.multiversionconstants`.")
|
||||
self.logger.error(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from typing import Dict, List
|
|||
import yaml
|
||||
|
||||
import buildscripts.resmokelib.utils.filesystem as fs
|
||||
import buildscripts.resmokelib.logging.loggers as loggers
|
||||
from buildscripts.resmokelib.logging import loggers
|
||||
from buildscripts.resmokelib import config as _config, errors, utils
|
||||
from buildscripts.resmokelib.testing import suite as _suite
|
||||
from buildscripts.resmokelib.utils import load_yaml_file
|
||||
|
|
@ -358,7 +358,7 @@ class MatrixSuiteConfig(SuiteConfigInterface):
|
|||
"""Get the mapping object for a given suite name and directory to search for suite mappings."""
|
||||
all_matrix_suites = cls.get_all_mappings(suites_dir)
|
||||
|
||||
if suite_name in all_matrix_suites.keys():
|
||||
if suite_name in all_matrix_suites:
|
||||
return all_matrix_suites[suite_name]
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import threading
|
|||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type
|
||||
|
||||
import buildscripts.resmokelib.config as config
|
||||
import buildscripts.resmokelib.utils.registry as registry
|
||||
from buildscripts.resmokelib import config
|
||||
from buildscripts.resmokelib.utils import registry
|
||||
from buildscripts.resmokelib import errors
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib
|
||||
from buildscripts.resmokelib.testing.fixtures.interface import _FIXTURES
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"""External fixture for executing JSTests against."""
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
|
||||
|
||||
class ExternalFixture(interface.Fixture):
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from typing import List
|
|||
import pymongo
|
||||
import pymongo.errors
|
||||
|
||||
import buildscripts.resmokelib.utils.registry as registry
|
||||
from buildscripts.resmokelib.utils import registry
|
||||
|
||||
_VERSIONS = {} # type: ignore
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import pymongo
|
|||
import pymongo.errors
|
||||
import pymongo.write_concern
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
|
||||
|
||||
def compare_timestamp(timestamp1, timestamp2):
|
||||
|
|
@ -240,12 +240,14 @@ class ReplicaSetFixture(interface.ReplFixture):
|
|||
# (potentially) higher config version. We should not receive these codes
|
||||
# indefinitely.
|
||||
# pylint: disable=too-many-boolean-expressions
|
||||
if (err.code != ReplicaSetFixture._NEW_REPLICA_SET_CONFIGURATION_INCOMPATIBLE
|
||||
and err.code != ReplicaSetFixture._CURRENT_CONFIG_NOT_COMMITTED_YET
|
||||
and err.code != ReplicaSetFixture._CONFIGURATION_IN_PROGRESS
|
||||
and err.code != ReplicaSetFixture._NODE_NOT_FOUND
|
||||
and err.code != ReplicaSetFixture._INTERRUPTED_DUE_TO_REPL_STATE_CHANGE
|
||||
and err.code != ReplicaSetFixture._INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
if err.code not in [
|
||||
ReplicaSetFixture._NEW_REPLICA_SET_CONFIGURATION_INCOMPATIBLE,
|
||||
ReplicaSetFixture._CURRENT_CONFIG_NOT_COMMITTED_YET,
|
||||
ReplicaSetFixture._CONFIGURATION_IN_PROGRESS,
|
||||
ReplicaSetFixture._NODE_NOT_FOUND,
|
||||
ReplicaSetFixture._INTERRUPTED_DUE_TO_REPL_STATE_CHANGE,
|
||||
ReplicaSetFixture._INTERRUPTED_DUE_TO_STORAGE_CHANGE
|
||||
]:
|
||||
msg = ("Operation failure while setting up the "
|
||||
"replica set fixture: {}").format(err)
|
||||
self.logger.error(msg)
|
||||
|
|
@ -484,7 +486,7 @@ class ReplicaSetFixture(interface.ReplFixture):
|
|||
|
||||
return running
|
||||
|
||||
def get_primary(self, timeout_secs=30): # pylint: disable=arguments-differ
|
||||
def get_primary(self, timeout_secs=30):
|
||||
"""Return the primary from a replica set."""
|
||||
if not self.all_nodes_electable:
|
||||
# The primary is always the first element of the 'nodes' list because all other members
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""Fixture with multiple replica sets for executing JSTests against."""
|
||||
|
||||
import os.path
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
|
||||
|
||||
class ShardMergeFixture(interface.MultiClusterFixture): # pylint: disable=too-many-instance-attributes
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import shutil
|
|||
import pymongo
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import with_naive_retry
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import yaml
|
|||
import pymongo
|
||||
import pymongo.errors
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
import buildscripts.resmokelib.testing.fixtures.external as external
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
from buildscripts.resmokelib.testing.fixtures import external
|
||||
|
||||
|
||||
class ShardedClusterFixture(interface.Fixture):
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import yaml
|
|||
import pymongo
|
||||
import pymongo.errors
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
|
||||
|
||||
class MongoDFixture(interface.Fixture):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import os.path
|
|||
import pymongo
|
||||
import pymongo.write_concern
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import os.path
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import with_naive_retry
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import signal
|
||||
|
||||
import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures import interface
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -323,12 +323,11 @@ class _InitialSyncThread(threading.Thread):
|
|||
# (potentially) higher config version. We should not receive these codes
|
||||
# indefinitely.
|
||||
# pylint: disable=too-many-boolean-expressions
|
||||
if (err.code != self._NEW_REPLICA_SET_CONFIGURATION_INCOMPATIBLE
|
||||
and err.code != self._CURRENT_CONFIG_NOT_COMMITTED_YET
|
||||
and err.code != self._CONFIGURATION_IN_PROGRESS
|
||||
and err.code != self._NODE_NOT_FOUND
|
||||
and err.code != self._INTERRUPTED_DUE_TO_REPL_STATE_CHANGE
|
||||
and err.code != self._INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
if err.code not in (self._NEW_REPLICA_SET_CONFIGURATION_INCOMPATIBLE,
|
||||
self._CURRENT_CONFIG_NOT_COMMITTED_YET,
|
||||
self._CONFIGURATION_IN_PROGRESS, self._NODE_NOT_FOUND,
|
||||
self._INTERRUPTED_DUE_TO_REPL_STATE_CHANGE,
|
||||
self._INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
msg = (
|
||||
"Operation failure while adding tag for node on port {} in fixture {}: {}"
|
||||
).format(sync_node.port, fixture.replset_name, err)
|
||||
|
|
@ -432,8 +431,8 @@ class _InitialSyncThread(threading.Thread):
|
|||
conn.admin.command(cmd)
|
||||
break
|
||||
except pymongo.errors.OperationFailure as err:
|
||||
if (err.code != self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE
|
||||
and err.code != self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
if err.code not in (self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE,
|
||||
self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
raise
|
||||
msg = (
|
||||
"Interrupted while waiting for node on port {} in set {} to reach primary state, retrying: {}"
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ class BackgroundInitialSyncTestCase(jsfile.DynamicJSTestCase):
|
|||
sync_node_conn.admin.command(cmd)
|
||||
break
|
||||
except pymongo.errors.OperationFailure as err:
|
||||
if (err.code != self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE
|
||||
and err.code != self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
if err.code not in (self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE,
|
||||
self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
raise
|
||||
msg = (
|
||||
"Interrupted while waiting for node to reach secondary state, retrying: {}"
|
||||
|
|
@ -224,8 +224,8 @@ class IntermediateInitialSyncTestCase(jsfile.DynamicJSTestCase):
|
|||
sync_node_conn.admin.command(cmd)
|
||||
break
|
||||
except pymongo.errors.OperationFailure as err:
|
||||
if (err.code != self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE
|
||||
and err.code != self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
if err.code not in (self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE,
|
||||
self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
raise
|
||||
msg = ("Interrupted while waiting for node to reach secondary state, retrying: {}"
|
||||
).format(err)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase):
|
|||
for secondary in self.fixture.get_secondaries():
|
||||
# Disable the "rsSyncApplyStop" failpoint on the secondary to have it resume applying
|
||||
# oplog entries.
|
||||
self._hook._disable_rssyncapplystop(secondary) # pylint: disable=protected-access
|
||||
self._hook._disable_rssyncapplystop(secondary)
|
||||
|
||||
# Wait a little bit for the secondary to start apply oplog entries so that we are more
|
||||
# likely to kill the mongod process while it is partway into applying a batch.
|
||||
|
|
@ -350,8 +350,8 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase):
|
|||
]))
|
||||
break
|
||||
except pymongo.errors.OperationFailure as err:
|
||||
if (err.code != self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE
|
||||
and err.code != self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
if err.code not in (self.INTERRUPTED_DUE_TO_REPL_STATE_CHANGE,
|
||||
self.INTERRUPTED_DUE_TO_STORAGE_CHANGE):
|
||||
self.logger.exception(
|
||||
"mongod on port %d failed to reach state SECONDARY after %d seconds",
|
||||
secondary.port, fixture.ReplFixture.AWAIT_REPL_TIMEOUT_FOREVER_MINS * 60)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class ResmokeSymbolizerConfig(NamedTuple):
|
|||
|
||||
:return: True if on Windows
|
||||
"""
|
||||
return sys.platform == "win32" or sys.platform == "cygwin"
|
||||
return sys.platform in ("win32", "cygwin")
|
||||
|
||||
@staticmethod
|
||||
def is_macos() -> bool:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import math
|
|||
|
||||
from buildscripts.resmokelib import config
|
||||
|
||||
_IS_WINDOWS = sys.platform == "win32" or sys.platform == "cygwin"
|
||||
_IS_WINDOWS = sys.platform in ("win32", "cygwin")
|
||||
|
||||
if _IS_WINDOWS:
|
||||
import ctypes
|
||||
|
|
@ -277,7 +277,7 @@ class Archival(object):
|
|||
return 1, str(err), 0
|
||||
|
||||
# Round up the size of the archive.
|
||||
size_mb = int(math.ceil(float(file_list_size(temp_file)) / (1024 * 1024))) # pylint: disable=c-extension-no-member
|
||||
size_mb = int(math.ceil(float(file_list_size(temp_file)) / (1024 * 1024)))
|
||||
self._upload_queue.put(
|
||||
UploadArgs(self.archival_json_file, display_name, temp_file, "application/x-gzip",
|
||||
s3_bucket, s3_path, True))
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ class Scheduler(sched.scheduler):
|
|||
# only has a resolution of ~15ms. We therefore use the `is` operator to remove the correct
|
||||
# event from the list.
|
||||
with self._lock:
|
||||
# Disable warning, since we're deleting elements from a queue while traversing it
|
||||
# pylint: disable=C0200
|
||||
for i in range(len(self._queue)):
|
||||
if self._queue[i] is event:
|
||||
del self._queue[i]
|
||||
|
|
|
|||
|
|
@ -30,19 +30,19 @@ class TestLoggerPipe(unittest.TestCase):
|
|||
|
||||
def test_strips_trailing_whitespace(self):
|
||||
calls = self._get_log_calls(b" a ")
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, u" a")])
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, " a")])
|
||||
|
||||
def test_strips_trailing_newlines(self):
|
||||
calls = self._get_log_calls(b"a\r\n")
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, u"a")])
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, "a")])
|
||||
|
||||
def test_handles_invalid_utf8(self):
|
||||
calls = self._get_log_calls(b"a\x80b")
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, u"a\ufffdb")])
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, "a\ufffdb")])
|
||||
|
||||
def test_escapes_null_bytes(self):
|
||||
calls = self._get_log_calls(b"a\0b")
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, u"a\\0b")])
|
||||
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, "a\\0b")])
|
||||
|
||||
|
||||
class TestFormatLineForLogging(unittest.TestCase):
|
||||
|
|
@ -51,28 +51,28 @@ class TestFormatLineForLogging(unittest.TestCase):
|
|||
|
||||
line_output = _pipe.LoggerPipe._format_line_for_logging(line)
|
||||
|
||||
self.assertEqual([u" a"], line_output)
|
||||
self.assertEqual([" a"], line_output)
|
||||
|
||||
def test_strips_trailing_newlines(self):
|
||||
line = b"a\r\n"
|
||||
|
||||
line_output = _pipe.LoggerPipe._format_line_for_logging(line)
|
||||
|
||||
self.assertEqual([u"a"], line_output)
|
||||
self.assertEqual(["a"], line_output)
|
||||
|
||||
def test_handles_invalid_utf8(self):
|
||||
line = b"a\x80b"
|
||||
|
||||
line_output = _pipe.LoggerPipe._format_line_for_logging(line)
|
||||
|
||||
self.assertEqual([u"a\ufffdb"], line_output)
|
||||
self.assertEqual(["a\ufffdb"], line_output)
|
||||
|
||||
def test_escapes_null_bytes(self):
|
||||
line = b"a\0b"
|
||||
|
||||
line_output = _pipe.LoggerPipe._format_line_for_logging(line)
|
||||
|
||||
self.assertEqual([u"a\\0b"], line_output)
|
||||
self.assertEqual(["a\\0b"], line_output)
|
||||
|
||||
def test_long_lines_are_split(self):
|
||||
line = b"a" * 4_000_000
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@ import unittest
|
|||
import collections
|
||||
|
||||
import buildscripts.resmokelib.config
|
||||
import buildscripts.resmokelib.parser as parser
|
||||
import buildscripts.resmokelib.selector as selector
|
||||
import buildscripts.resmokelib.utils.globstar as globstar
|
||||
|
||||
# pylint: disable=protected-access
|
||||
from buildscripts.resmokelib import parser
|
||||
from buildscripts.resmokelib import selector
|
||||
from buildscripts.resmokelib.utils import globstar
|
||||
|
||||
FIXTURE_PREFIX = "buildscripts/tests/selftest_fixtures"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import os
|
|||
import unittest
|
||||
from mock import MagicMock, Mock, patch, call
|
||||
import evergreen
|
||||
import buildscripts.resmokelib.undodb.fetch as fetch
|
||||
from buildscripts.resmokelib.undodb import fetch
|
||||
|
||||
|
||||
class TestFetch(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ import os
|
|||
|
||||
DISALLOWED_ROOT = "buildscripts"
|
||||
ALLOWED_IMPORTS = [
|
||||
"buildscripts.resmokelib.testing.fixtures",
|
||||
"buildscripts.resmokelib.testing.fixtures.external",
|
||||
"buildscripts.resmokelib.testing.fixtures.interface",
|
||||
"buildscripts.resmokelib.testing.fixtures.fixturelib",
|
||||
"buildscripts.resmokelib.multiversionconstants",
|
||||
"buildscripts.resmokelib.utils",
|
||||
"buildscripts.resmokelib.utils.registry",
|
||||
]
|
||||
FIXTURE_PATH = os.path.normpath("buildscripts/resmokelib/testing/fixtures")
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class TestExceptionExtractor(unittest.TestCase):
|
|||
assert exception_extractor.active is True
|
||||
assert exception_extractor.exception_detected is False
|
||||
assert list(exception_extractor.current_exception) == expected_current_exception
|
||||
assert exception_extractor.get_exception() == []
|
||||
assert not exception_extractor.get_exception()
|
||||
|
||||
def test_no_extraction(self):
|
||||
logs = [
|
||||
|
|
@ -58,7 +58,7 @@ class TestExceptionExtractor(unittest.TestCase):
|
|||
assert exception_extractor.active is False
|
||||
assert exception_extractor.exception_detected is False
|
||||
assert list(exception_extractor.current_exception) == expected_current_exception
|
||||
assert exception_extractor.get_exception() == []
|
||||
assert not exception_extractor.get_exception()
|
||||
|
||||
def test_successful_extraction_truncate_first(self):
|
||||
logs = ["START"] + ["not captured"
|
||||
|
|
|
|||
Loading…
Reference in New Issue