Skip to content

Commit 6d48a2b

Browse files
chore: test scripts, docs (#323)
* changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * docs: update python contributing guide Adds details about blacken, updates version for system tests, and shows how to pass through pytest arguments. Source-Author: Chris Cotter <cjcotter@google.com> Source-Date: Mon Feb 8 17:13:36 2021 -0500 Source-Repo: googleapis/synthtool Source-Sha: 4679e7e415221f03ff2a71e3ffad75b9ec41d87e Source-Link: googleapis/synthtool@4679e7e * build(python): enable flakybot on library unit and system tests Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Source-Date: Wed Feb 17 14:10:46 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: d17674372e27fb8f23013935e794aa37502071aa Source-Link: googleapis/synthtool@d176743 * test: install pyopenssl for mtls testing Source-Author: arithmetic1728 <58957152+arithmetic1728@users.noreply.github.com> Source-Date: Tue Mar 2 12:27:56 2021 -0800 Source-Repo: googleapis/synthtool Source-Sha: 0780323da96d5a53925fe0547757181fe76e8f1e Source-Link: googleapis/synthtool@0780323 Co-authored-by: Craig Labenz <craig.labenz@gmail.com>
1 parent dcb7d2e commit 6d48a2b

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

packages/google-cloud-firestore/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ docs.metadata
5151

5252
# Virtual environment
5353
env/
54+
55+
# Test logs
5456
coverage.xml
55-
sponge_log.xml
57+
*sponge_log.xml
5658

5759
# System test environment variables.
5860
system_tests/local_test_setup

packages/google-cloud-firestore/.kokoro/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ python3 -m pip uninstall --yes --quiet nox-automation
4343
python3 -m pip install --upgrade --quiet nox
4444
python3 -m nox --version
4545

46+
# If this is a continuous build, send the test log to the FlakyBot.
47+
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
48+
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
49+
cleanup() {
50+
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
51+
$KOKORO_GFILE_DIR/linux_amd64/flakybot
52+
}
53+
trap cleanup EXIT HUP
54+
fi
55+
4656
# If NOX_SESSION is set, it only runs the specified session,
4757
# otherwise run all the sessions.
4858
if [[ -n "${NOX_SESSION:-}" ]]; then

packages/google-cloud-firestore/CONTRIBUTING.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
7070
- To test your changes, run unit tests with ``nox``::
7171

7272
$ nox -s unit-2.7
73-
$ nox -s unit-3.7
73+
$ nox -s unit-3.8
7474
$ ...
7575

76+
- Args to pytest can be passed through the nox command separated by a `--`. For
77+
example, to run a single test::
78+
79+
$ nox -s unit-3.8 -- -k <name of test>
80+
7681
.. note::
7782

7883
The unit tests and system tests are described in the
@@ -93,8 +98,12 @@ On Debian/Ubuntu::
9398
************
9499
Coding Style
95100
************
101+
- We use the automatic code formatter ``black``. You can run it using
102+
the nox session ``blacken``. This will eliminate many lint errors. Run via::
103+
104+
$ nox -s blacken
96105

97-
- PEP8 compliance, with exceptions defined in the linter configuration.
106+
- PEP8 compliance is required, with exceptions defined in the linter configuration.
98107
If you have ``nox`` installed, you can test that you have not introduced
99108
any non-compliant code via::
100109

@@ -133,13 +142,18 @@ Running System Tests
133142

134143
- To run system tests, you can execute::
135144

136-
$ nox -s system-3.7
145+
# Run all system tests
146+
$ nox -s system-3.8
137147
$ nox -s system-2.7
138148

149+
# Run a single system test
150+
$ nox -s system-3.8 -- -k <name of test>
151+
152+
139153
.. note::
140154

141155
System tests are only configured to run under Python 2.7 and
142-
Python 3.7. For expediency, we do not run them in older versions
156+
Python 3.8. For expediency, we do not run them in older versions
143157
of Python 3.
144158

145159
This alone will not run the tests. You'll need to change some local

packages/google-cloud-firestore/noxfile.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def default(session):
102102
session.run(
103103
"py.test",
104104
"--quiet",
105+
f"--junitxml=unit_{session.python}_sponge_log.xml",
105106
"--cov=google/cloud",
106107
"--cov=tests/unit",
107108
"--cov-append",
@@ -131,6 +132,9 @@ def system(session):
131132
# Sanity check: Only run tests if the environment variable is set.
132133
if not os.environ.get("FIRESTORE_APPLICATION_CREDENTIALS", ""):
133134
session.skip("Credentials must be set via environment variable")
135+
# Install pyopenssl for mTLS testing.
136+
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
137+
session.install("pyopenssl")
134138

135139
system_test_exists = os.path.exists(system_test_path)
136140
system_test_folder_exists = os.path.exists(system_test_folder_path)
@@ -150,9 +154,21 @@ def system(session):
150154

151155
# Run py.test against the system tests.
152156
if system_test_exists:
153-
session.run("py.test", "--verbose", system_test_path, *session.posargs)
157+
session.run(
158+
"py.test",
159+
"--quiet",
160+
f"--junitxml=system_{session.python}_sponge_log.xml",
161+
system_test_path,
162+
*session.posargs,
163+
)
154164
if system_test_folder_exists:
155-
session.run("py.test", "--verbose", system_test_folder_path, *session.posargs)
165+
session.run(
166+
"py.test",
167+
"--quiet",
168+
f"--junitxml=system_{session.python}_sponge_log.xml",
169+
system_test_folder_path,
170+
*session.posargs,
171+
)
156172

157173

158174
@nox.session(python=DEFAULT_PYTHON_VERSION)

packages/google-cloud-firestore/synth.metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"git": {
2020
"name": "synthtool",
2121
"remote": "https://github.com/googleapis/synthtool.git",
22-
"sha": "33366574ffb9e11737b3547eb6f020ecae0536e8"
22+
"sha": "0780323da96d5a53925fe0547757181fe76e8f1e"
2323
}
2424
}
2525
],

0 commit comments

Comments
 (0)