mirror of https://github.com/mongodb/mongo
SERVER-47590 Add undodb Resmoke Subcommand
This commit is contained in:
parent
4b32770c6e
commit
29b8db7147
|
|
@ -3,22 +3,12 @@
|
|||
|
||||
import os.path
|
||||
import sys
|
||||
import time
|
||||
|
||||
# Get relative imports to work when the package is not installed on the PYTHONPATH.
|
||||
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
|
||||
from buildscripts.resmokelib import parser
|
||||
import buildscripts.resmokelib.cli as cli
|
||||
|
||||
|
||||
def main():
|
||||
"""Execute Main function for resmoke."""
|
||||
__start_time = time.time()
|
||||
subcommand = parser.parse_command_line(sys.argv[1:], start_time=__start_time)
|
||||
subcommand.execute()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
cli.main(sys.argv)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
"""Command-line entry-point into resmoke."""
|
||||
|
||||
import time
|
||||
from buildscripts.resmokelib import parser
|
||||
|
||||
|
||||
def main(argv):
|
||||
"""
|
||||
Execute Main function for resmoke.
|
||||
|
||||
:param argv: sys.argv
|
||||
:return: None
|
||||
"""
|
||||
__start_time = time.time()
|
||||
subcommand = parser.parse_command_line(argv[1:], start_time=__start_time)
|
||||
subcommand.execute()
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
"""Parser for command line arguments."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shlex
|
||||
import sys
|
||||
|
||||
import argparse
|
||||
|
||||
from buildscripts.resmokelib import undodb
|
||||
|
||||
from . import config as _config
|
||||
from . import configure_resmoke
|
||||
from . import commands
|
||||
|
|
@ -15,7 +16,7 @@ _BENCHMARK_ARGUMENT_TITLE = "Benchmark/Benchrun test options"
|
|||
_EVERGREEN_ARGUMENT_TITLE = "Evergreen options"
|
||||
|
||||
|
||||
def _make_parser():
|
||||
def _add_subcommands():
|
||||
"""Create and return the command line arguments parser."""
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest="command")
|
||||
|
|
@ -25,6 +26,7 @@ def _make_parser():
|
|||
_add_list_suites(subparsers)
|
||||
_add_find_suites(subparsers)
|
||||
_add_hang_analyzer(subparsers)
|
||||
undodb.add_subcommand(subparsers)
|
||||
|
||||
return parser
|
||||
|
||||
|
|
@ -575,7 +577,7 @@ def _parse(sys_args):
|
|||
"""Parse the CLI args."""
|
||||
|
||||
# Split out this function for easier testing.
|
||||
parser = _make_parser()
|
||||
parser = _add_subcommands()
|
||||
parsed_args = parser.parse_args(sys_args)
|
||||
|
||||
return (parser, parsed_args)
|
||||
|
|
@ -596,6 +598,9 @@ def parse_command_line(sys_args, **kwargs):
|
|||
elif subcommand == 'hang-analyzer':
|
||||
subcommand_obj = commands.hang_analyzer.HangAnalyzer(parsed_args)
|
||||
|
||||
if subcommand_obj is None:
|
||||
subcommand_obj = undodb.subcommand(subcommand, parsed_args)
|
||||
|
||||
if subcommand_obj is None:
|
||||
raise RuntimeError(
|
||||
f"Resmoke configuration has invalid subcommand: {subcommand}. Try '--help'")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
"""Interactions with the undodb tool-suite."""
|
||||
from typing import Optional
|
||||
|
||||
from buildscripts.resmokelib.commands import interface
|
||||
|
||||
_HELP = """
|
||||
Info on how to install undodb.
|
||||
"""
|
||||
|
||||
_MESSAGE = """
|
||||
You must manually download install the undodb package.
|
||||
|
||||
UndoDB is only supported on linux platforms. It will not work on macOS or Windows.
|
||||
|
||||
1. Download the tarball from Google Drive.
|
||||
|
||||
https://drive.google.com/open?id=18dx1hHRrPgc27TtvvCe9rLXSYx_rKjzq
|
||||
|
||||
You must be logged into your MongoDB/10gen google account to access this link.
|
||||
This file has MongoDB's private undodb key-server parameters baked into it,
|
||||
so do not share this file outside of the company.
|
||||
|
||||
2. Untar and install:
|
||||
|
||||
tar xzf undodb-*.tgz
|
||||
cd undodb-*
|
||||
sudo make install
|
||||
|
||||
There is good README help in the undodb directory if you have questions.
|
||||
There is also extensive documentation at https://docs.undo.io.
|
||||
|
||||
Please also refer to William Schultz's intro talk for a getting started primer:
|
||||
|
||||
https://mongodb.zoom.com/rec/share/5eBrDqHJ7k5If6uX9Fn7Wo0sGKT6T6a8gydK-_QOxBkaEyZzwv6Yf4tjTB4cS0f1
|
||||
|
||||
"""
|
||||
|
||||
_COMMAND = "undodb"
|
||||
|
||||
|
||||
def add_subcommand(subparsers) -> None:
|
||||
"""
|
||||
Add 'undodb' subcommand.
|
||||
|
||||
:param subparsers: argparse parser to add to
|
||||
:return: None
|
||||
"""
|
||||
parser = subparsers.add_parser(_COMMAND, help=_HELP)
|
||||
# Accept arbitrary args like 'resmoke.py undodb foobar', but ignore them.
|
||||
parser.add_argument("args", nargs="*")
|
||||
|
||||
|
||||
def subcommand(command: str, parsed_args) -> Optional[interface.Subcommand]:
|
||||
"""
|
||||
Return UndoDb if command is one we recognize.
|
||||
|
||||
:param command: The first arg to resmoke.py (e.g. resmoke.py run => command = run).
|
||||
:param parsed_args: Additional arguments parsed as a result of the `parser.parse` call.
|
||||
:return: Callback if the command is for undodb else none.
|
||||
"""
|
||||
if command != _COMMAND:
|
||||
return None
|
||||
return UndoDb(parsed_args)
|
||||
|
||||
|
||||
class UndoDb(interface.Subcommand):
|
||||
"""Interact with UndoDB."""
|
||||
|
||||
def __init__(self, _):
|
||||
"""Constructor."""
|
||||
pass
|
||||
|
||||
def execute(self) -> None:
|
||||
"""
|
||||
Work your magic.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
print(_MESSAGE)
|
||||
Loading…
Reference in New Issue