Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ Running System Tests
run all the tests.

- System tests may be run against the emulator. To do this, set the
``DATASTORE_EMULATOR_HOST`` environment variable.
``DATASTORE_EMULATOR_HOST`` environment variable. Alternatively,
system tests with the emulator can run with
`nox -e emulator-system-PYTHON_VERSION`

- System tests will be run against an actual project and
so you'll need to provide some environment variables to facilitate
Expand Down
46 changes: 46 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import os
import pathlib
import shutil
import signal
import subprocess

import nox

Expand Down Expand Up @@ -91,6 +93,50 @@ def cover(session):
session.run("coverage", "erase")


@nox.session(name="emulator-system", python=ALL_INTERPRETERS)
def emulator_system(session):
"""Run the system test suite."""
# Only run the emulator tests manually.
Comment thread
sorced-jim marked this conversation as resolved.
if not session.interactive:
return

constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
system_test_folder_path = os.path.join("tests", "system")

# Install all test dependencies, then install this package into the
# virtualenv's dist-packages.
session.install("pytest")
session.install("google-cloud-testutils")
for local_dep in LOCAL_DEPS:
session.install(local_dep)
session.install(".", "-c", constraints_path)

# TODO: It would be better to allow the emulator to bind to any port and pull
# the port from stderr.
emulator_args = [
"gcloud",
"emulators",
"firestore",
"start",
"--database-mode=datastore-mode",
"--host-port=localhost:8092",
]
emulator = subprocess.Popen(emulator_args, stderr=subprocess.PIPE)
# Run py.test against the system tests.
session.run(
"py.test",
"--quiet",
system_test_folder_path,
*session.posargs,
env={"DATASTORE_EMULATOR_HOST": "localhost:8092"},
)
session.run("curl", "-d", "", "localhost:8092/shutdown", external=True)
emulator.terminate()
emulator.wait(timeout=2)


def run_black(session, use_check=False):
args = ["black"]
if use_check:
Expand Down