Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Adding bigtable-emulator tox environment.#2322
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,21 +25,27 @@ | ||
| import psutil | ||
| from google.cloud.environment_vars import BIGTABLE_EMULATOR | ||
| from google.cloud.environment_vars import GCD_DATASET | ||
| from google.cloud.environment_vars import GCD_HOST | ||
| from google.cloud.environment_vars import PUBSUB_EMULATOR | ||
| from run_system_test import run_module_tests | ||
| BIGTABLE = 'bigtable' | ||
| DATASTORE = 'datastore' | ||
| PUBSUB = 'pubsub' | ||
| PACKAGE_INFO = { | ||
| 'datastore': (GCD_DATASET, GCD_HOST), | ||
| 'pubsub': (PUBSUB_EMULATOR,) | ||
| BIGTABLE: (BIGTABLE_EMULATOR,), | ||
| DATASTORE: (GCD_DATASET, GCD_HOST), | ||
| PUBSUB: (PUBSUB_EMULATOR,), | ||
| } | ||
| EXTRA = { | ||
| 'datastore': ('--no-legacy',), | ||
| DATASTORE: ('--no-legacy',), | ||
| } | ||
| _DS_READY_LINE = '[datastore] Dev App Server is now running.\n' | ||
| _PS_READY_LINE_PREFIX = '[pubsub] INFO: Server started, listening on ' | ||
| _BT_READY_LINE_PREFIX = '[bigtable] Cloud Bigtable emulator running on ' | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| def get_parser(): | ||
| @@ -51,8 +57,8 @@ def get_parser(): | ||
| parser = argparse.ArgumentParser( | ||
| description='Run google-cloud system tests against local emulator.') | ||
| parser.add_argument('--package', dest='package', | ||
| choices=('datastore', 'pubsub'), | ||
| default='datastore', help='Package to be tested.') | ||
| choices=sorted(PACKAGE_INFO.keys()), | ||
| default=DATASTORE, help='Package to be tested.') | ||
| return parser | ||
| @@ -95,16 +101,18 @@ def datastore_wait_ready(popen): | ||
| emulator_ready = popen.stderr.readline() == _DS_READY_LINE | ||
| def pubsub_wait_ready(popen): | ||
| """Wait until the pubsub emulator is ready to use. | ||
| def wait_ready_prefix(popen, prefix): | ||
| """Wait until the a process encounters a line with matching prefix. | ||
| :type popen: :class:`subprocess.Popen` | ||
| :param popen: An open subprocess to interact with. | ||
| :type prefix: str | ||
| :param prefix: The prefix to match | ||
| """ | ||
| emulator_ready = False | ||
| while not emulator_ready: | ||
| emulator_ready = popen.stderr.readline().startswith( | ||
| _PS_READY_LINE_PREFIX) | ||
| emulator_ready = popen.stderr.readline().startswith(prefix) | ||
| def wait_ready(package, popen): | ||
| @@ -117,14 +125,16 @@ def wait_ready(package, popen): | ||
| :param popen: An open subprocess to interact with. | ||
| :raises: :class:`KeyError` if the ``package`` is not among | ||
| ``datastore``, ``pubsub``. | ||
| ``datastore``, ``pubsub`` or ``bigtable``. | ||
| """ | ||
| if package == 'datastore': | ||
| if package == DATASTORE: | ||
| datastore_wait_ready(popen) | ||
| elif package == 'pubsub': | ||
| pubsub_wait_ready(popen) | ||
| elif package == PUBSUB: | ||
| wait_ready_prefix(popen, _PS_READY_LINE_PREFIX) | ||
| elif package == BIGTABLE: | ||
| wait_ready_prefix(popen, _BT_READY_LINE_PREFIX) | ||
| else: | ||
| raise KeyError('') | ||
| raise KeyError('Package not supported', package) | ||
| def cleanup(pid): | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.