Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Test Orchestrator (astrolabe) #2

Conversation

prashantmital
Copy link
Contributor

@prashantmital prashantmital commented Feb 20, 2020

Still needs:

  • CLI endpoint to run a single spec test file
  • mongod/mongos log retrieval functionality (wait until Atlas logs are current for driver ops; download them in a folder hierarchy that makes it easy to find the logs corresponding to a specific test; zip this file for upload to S3 after EVG run) (moved to follow-on work, see Add post test log retrieval functionality #4)
  • cluster cleanup functionality (delete clusters once a test run is complete and logs for it have been downloaded to the EVG host)
  • Logging using Python's stdlib logging module (this includes INFO level logs instead of the current print statements that make it easier to follow the progress of a test run)

@prashantmital prashantmital force-pushed the feature/Test-Orchestrator branch from 1b5f6c8 to b68df26 Compare February 20, 2020 01:00
@prashantmital

This comment has been minimized.

@prashantmital prashantmital force-pushed the feature/Test-Orchestrator branch 2 times, most recently from f6c46ab to de9bece Compare February 20, 2020 02:48
@prashantmital prashantmital changed the title Feature: add Test Orchestrator (astrolabe) [WIP] Feature: add Test Orchestrator (astrolabe) Feb 20, 2020
@prashantmital prashantmital force-pushed the feature/Test-Orchestrator branch from bd270c9 to aefe8b6 Compare February 22, 2020 01:00
Copy link

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review. I think it would be a good idea to add logging (via stdlib logging) to the cli methods that will be used in evergreen.

astrolabe/commands.py Outdated Show resolved Hide resolved
astrolabe/commands.py Outdated Show resolved Hide resolved
setup.py Outdated
@@ -40,6 +40,7 @@
'pymongo>=3.10,<4',
'dnspython>=1.16,<2',
'pyyaml>=5,<6',
'tabulate>=0.8,<0.9',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What feature does this library provide? Do we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It provides a quick way to convert a list of lists into a textual table of various styles. In our case, we want the rst format to be able to include the resulting table into docs. While the docs part is not yet done, take a look at the docgen.py file for a closer look.
To see it in action install the package and do astrolabe info environment-variables or astrolabe info default-values.

atlasclient/utils.py Outdated Show resolved Hide resolved
astrolabe/cli.py Outdated Show resolved Hide resolved
astrolabe/commands.py Outdated Show resolved Hide resolved
astrolabe/utils.py Outdated Show resolved Hide resolved
@prashantmital
Copy link
Contributor Author

prashantmital commented Feb 22, 2020

Sorry for the epic code churn in that last commit @ShaneHarvey. The next time you take a look, things should be a lot easier to understand.

@prashantmital prashantmital force-pushed the feature/Test-Orchestrator branch from 021687c to 7cb5d82 Compare February 26, 2020 20:06
@prashantmital prashantmital changed the title [WIP] Feature: add Test Orchestrator (astrolabe) Feature: Test Orchestrator (astrolabe) Feb 27, 2020
astrolabe/cli.py Outdated Show resolved Hide resolved
astrolabe/spec_runner.py Outdated Show resolved Hide resolved
driver_workload = json.dumps(self.spec.driverWorkload)
worker_subprocess = subprocess.Popen([
sys.executable, self.config.workload_executor, connection_string,
driver_workload], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we PIPE the output, we need to continuously read the worker_subprocess output (via worker_subprocess.stdout.read(..)) or else we risk blocking the child process when the pipe fills up.

See the note in subprocess.wait:

This will deadlock when using stdout=PIPE or stderr=PIPE and the child process generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data. Use Popen.communicate() when using pipes to avoid that.

https://docs.python.org/3/library/subprocess.html#subprocess.Popen.wait

A simpler option might be to redirect the worker_subprocess output to a file. Then we can open and read the file after the process exits.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear: there's no risk of deadlock in the current approach. The risk is that the child process can fill up the pipe with output and then it will block until we call worker_subprocess.communicate() down below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point. I have opened #9 for this.

Copy link
Member

@mbroadst mbroadst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with two small nits

astrolabe/cli.py Outdated
help='Salt for generating unique hashes.')

XUNITOUTPUT_OPTION = click.option(
'--xunit-output', type=click.STRING, default="xunit-output",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are some of these OPTNAMES.XXX and others inline strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ones which can be displayed/tabulated using astrolabe info <...> are the ones that are specified using a OPTNAMES.XXX. Options with inline strings are not tabulated in the same manner and are not required to be (in my estimation).

coll = client.get_database(
self.spec.driverWorkload.database).get_collection(
self.spec.driverWorkload.collection)
coll.drop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to potentially catch ns not found? or is that not a problem for python?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyMongo ignores this error on drop() so no special handling is required.

cluster_config = final_config.clusterConfiguration
process_args = final_config.processArgs

if not cluster_config and not process_args:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we consider doing validation much earlier, so you can bail before any I/O if need be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. In general, we just need a lot more validation of the test specification. I have opened #10 to do this.

@prashantmital prashantmital force-pushed the feature/Test-Orchestrator branch from f50b38e to f9d738f Compare March 6, 2020 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants