From f7fe18a9484f07f7fcda293397665cdccd2b23a6 Mon Sep 17 00:00:00 2001 From: Chris Wilcox Date: Thu, 18 Mar 2021 09:20:54 -0700 Subject: [PATCH] test: add test run for emulated testing --- noxfile.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 72b387570..8360e5c17 100644 --- a/noxfile.py +++ b/noxfile.py @@ -33,6 +33,7 @@ # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ "unit", + "system_emulated", "system", "cover", "lint", @@ -110,13 +111,38 @@ def unit(session): """Run the unit test suite.""" default(session) +@nox.session(python="3.8") +def system_emulated(session): + import subprocess + + try: + subprocess.call(["gcloud", '--version']) + except OSError: + session.skip("gcloud not found but required for emulator support") + + hostport = "localhost:8789" + p = subprocess.Popen([ + "gcloud", "beta", "emulators", "bigtable", "start", + "--host-port", hostport + ]) + + system(session, emulator=hostport) + + # Stop Emulator + p.send_signal(1) @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) -def system(session): +def system(session, emulator=False): """Run the system test suite.""" system_test_path = os.path.join("tests", "system.py") system_test_folder_path = os.path.join("tests", "system") + if emulator: + os.environ["BIGTABLE_EMULATOR_HOST"] = emulator + elif os.environ.get("BIGTABLE_EMULATOR_HOST"): + del os.environ["BIGTABLE_EMULATOR_HOST"] + + # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": session.skip("RUN_SYSTEM_TESTS is set to false, skipping")