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

System tests fail under emulator in clean environment #463

Closed
tseaver opened this issue Sep 29, 2021 · 0 comments · Fixed by #464
Closed

System tests fail under emulator in clean environment #463

tseaver opened this issue Sep 29, 2021 · 0 comments · Fixed by #464
Assignees
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: process A process-related concern. May include testing, release, or the like.

Comments

@tseaver
Copy link
Contributor

tseaver commented Sep 29, 2021

Similar to googleapis/python-bigtable#431.

When the environment variable for the Firestore emulator is set, the client should disable any fallback lookups of credentials or project ID: they aren't needed for running under the emulator. At the moment, however:

$ env | grep CRED || echo "No credentials in environment"
No credentials in environment
$ env | grep PROJ || echo "No project in environment"
No project in environment
# Emulator running in separate shell -- no default creds available
$ which gcloud || echo "No gcloud"
No gcloud
$ export FIRESTORE_EMULATOR_HOST=localhost:8072
$ nox -s system -- -x
nox > Running session system-3.7
nox > Creating virtual environment (virtualenv) using python3.7 in .nox/system-3-7
nox > python -m pip install --pre grpcio
nox > python -m pip install mock pytest google-cloud-testutils pytest-asyncio -c /home/tseaver/projects/agendaless/Google/src/python-firestore/testing/constraints-3.7.txt
nox > python -m pip install -e . -c /home/tseaver/projects/agendaless/Google/src/python-firestore/testing/constraints-3.7.txt
nox > py.test --verbose --junitxml=system_3.7_sponge_log.xml tests/system -x
============================= test session starts ==============================
platform linux -- Python 3.7.12, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/tseaver/projects/agendaless/Google/src/python-firestore/.nox/system-3-7/bin/python
cachedir: .pytest_cache
rootdir: /home/tseaver/projects/agendaless/Google/src/python-firestore
plugins: asyncio-0.15.1
collected 94 items                                                             

tests/system/test_system.py::test_collections ERROR                      [  1%]

==================================== ERRORS ====================================
______________________ ERROR at setup of test_collections ______________________

    @pytest.fixture(scope="module")
    def client():
        credentials, project = _get_credentials_and_project()
>       yield firestore.Client(project=project, credentials=credentials)

tests/system/test_system.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
google/cloud/firestore_v1/client.py:99: in __init__
    client_options=client_options,
google/cloud/firestore_v1/base_client.py:129: in __init__
    _http=None,
.nox/system-3-7/lib/python3.7/site-packages/google/cloud/client.py:316: in __init__
    _ClientProjectMixin.__init__(self, project=project, credentials=credentials)
.nox/system-3-7/lib/python3.7/site-packages/google/cloud/client.py:264: in __init__
    project = self._determine_default(project)
.nox/system-3-7/lib/python3.7/site-packages/google/cloud/client.py:283: in _determine_default
    return _determine_default_project(project)
.nox/system-3-7/lib/python3.7/site-packages/google/cloud/_helpers.py:152: in _determine_default_project
    _, project = google.auth.default()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

scopes = None, request = None, quota_project_id = None, default_scopes = None

    def default(scopes=None, request=None, quota_project_id=None, default_scopes=None):
        """Gets the default credentials for the current environment.
        ...
>       raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
E       google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

.nox/system-3-7/lib/python3.7/site-packages/google/auth/_default.py:488: DefaultCredentialsError
...
=============================== 1 error in 6.43s ===============================
nox > Command py.test --verbose --junitxml=system_3.7_sponge_log.xml tests/system -x failed with exit code 1
nox > Session system-3.7 failed.
@tseaver tseaver added the type: process A process-related concern. May include testing, release, or the like. label Sep 29, 2021
@tseaver tseaver self-assigned this Sep 29, 2021
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Sep 29, 2021
tseaver added a commit that referenced this issue Sep 29, 2021
Also, move tests for emulator host to 'test_base_client'.

Closes #463.
tseaver added a commit that referenced this issue Sep 30, 2021
Add Github workflow to run systests under emulator.

Avoid default credential/project lookup under emulator

Closes #463.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: process A process-related concern. May include testing, release, or the like.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant