-
Notifications
You must be signed in to change notification settings - Fork 126
Add utilities for running release tests #56
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
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4ff35f7
wip
angerson cee34ed
Prevent failure if directory does not exist
angerson 3f5a3cc
Add comments to venv test setup
angerson 46bbdaa
Fix mistaken dependency on Python 3.9
angerson d3603ee
Ignore log fails and fix bazel issue
angerson 7dc0d0a
Discard extra content if larger than 10MiB
angerson b8f60ea
Add test reqs and fix log squasher
angerson 419a339
Cleanup
angerson c659d8e
Squash different and dont install cuda-11-2, which seems to fix it
angerson 5013db3
Add CUDA libraries metapackages and dont overshorten logs
angerson f25ff7a
Fix broken log squasher
angerson f193459
Add missing nopip filters
angerson 66d4033
Add test list fetcher
angerson ca384bd
Always pass and be quiet
angerson d36e1b3
Try faster file search
angerson 37ca4ef
Fix test requirements versions
angerson bf4069e
fix broken grep call
angerson 080fd48
Ignore grep failures properly
angerson 46fe135
Include relative filename in testcase name
angerson a6f6663
Split on TensorFlow path specifically
angerson 9bf2091
Meaningless commit to reset the check list
angerson 3f9b2b2
Fix log squasher
angerson 799629f
More deduplication for test logs
angerson 5a3271e
Fix deduplication
angerson f13e577
fix typo
angerson a28f691
Add extglob
angerson 39dda1d
Add messy note about log source
angerson c152bd7
much shorter?
angerson 23af240
Greatly simplify the log squasher
angerson 66037a2
Add another note
angerson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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 |
---|---|---|
|
@@ -32,11 +32,36 @@ build --copt=-mavx --host_copt=-mavx | |
# See https://docs.bazel.build/versions/main/skylark/performance.html#performance-profiling | ||
build --profile=/tf/pkg/profile.json | ||
|
||
# Store the execution log binary in the mounted artifact directory. | ||
# This log is recommended to debug missing cache hit on the same machine and on different machines. | ||
# See more at step 2 and 3c in: | ||
# https://docs.bazel.build/versions/main/remote-caching-debug.html | ||
build --execution_log_binary_file=/tf/pkg/exec_cpu.log | ||
|
||
# Use the NVCC toolchain to compile for manylinux2010 | ||
build [email protected]_manylinux2010-cuda11.2-cudnn8.1-tensorrt7.2_config_cuda//crosstool:toolchain | ||
|
||
# The following test-related settings are experimental. | ||
|
||
test --build_tests_only --keep_going --test_output=errors --verbose_failures=true | ||
test --local_test_jobs=HOST_CPUS | ||
test --flaky_test_attempts=3 --test_size_filters=small,medium | ||
test --test_env=LD_LIBRARY_PATH | ||
test --test_lang_filters=py | ||
|
||
# "nonpip" tests are regular py_test tests. | ||
test:nonpip --test_tag_filters=-no_oss,-oss_serial,-gpu,-tpu,-benchmark-test,-v1only | ||
test:nonpip --build_tag_filters=-no_oss,-oss_serial,-gpu,-tpu,-benchmark-test,-v1only | ||
test:nonpip -- //tensorflow/... -//tensorflow/python/integration_testing/... -//tensorflow/compiler/tf2tensorrt/... -//tensorflow/compiler/xrt/... -//tensorflow/core/tpu/... -//tensorflow/lite/... | ||
|
||
# "pip tests" run a similar suite of tests the "nonpip" tests, but do something | ||
# odd to attempt to validate the quality of the pip package. The wheel is | ||
# installed into a virtual environment, and then that venv is used to run all | ||
# bazel tests with a special flag "--define=no_tensorflow_py_deps=true", which | ||
# drops all the bazel dependencies for each py_test; this makes all the tests | ||
# use the wheel's TensorFlow installation instead of the one made available | ||
# through bazel. This must be done in a different root directory, //bazel_pip/..., | ||
# because "import tensorflow" run from the root directory would instead import | ||
# the folder instead of the venv package. | ||
test:pip --action_env PYTHON_BIN_PATH="/bazel_pip/bin/python3" | ||
test:pip --action_env PYTHON_LIB_PATH="/bazel_pip/lib/python3/site-packages" | ||
test:pip --python_path="/bazel_pip/bin/python3" | ||
# Yes, we don't exclude the gpu tests on pip for some reason. | ||
test:pip --test_tag_filters=-nopip,-no_pip,-no_oss,-oss_serial,-v1only | ||
test:pip --build_tag_filters=-nopip,-no_pip,-no_oss,-oss_serial,-v1only | ||
test:pip --define=no_tensorflow_py_deps=true | ||
test:pip -- //bazel_pip/tensorflow/... -//bazel_pip/tensorflow/python/integration_testing/... -//bazel_pip/tensorflow/compiler/tf2tensorrt/... -//bazel_pip/tensorflow/compiler/xrt/... -//bazel_pip/tensorflow/core/tpu/... -//bazel_pip/tensorflow/lite/... |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# Usage: get_test_list.sh OUTPUT BAZEL_TEST_COMMAND... | ||
# Writes the list of tests that would be run from BAZEL_TEST_COMMAND to OUTPUT. | ||
# Hides all extra output and always exits with success for now. | ||
OUTPUT=$1 | ||
shift | ||
"$@" --check_tests_up_to_date 2>/dev/null | sort -u | awk '{print $1}' | grep "^//" | tee $OUTPUT |
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
20 changes: 20 additions & 0 deletions
20
tf_sig_build_dockerfiles/devel.usertools/setup_venv_test.sh
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
# Run this from inside the tensorflow github directory. | ||
# Usage: setup_venv_test.sh venv_and_symlink_name "glob pattern for one wheel file" | ||
# Example: setup_venv_test.sh bazel_pip "/tf/pkg/*.whl" | ||
# | ||
# This will create a venv with that wheel file installed in it, and a symlink | ||
# in ./venv_and_symlink_name/tensorflow to ./tensorflow. We use this for the | ||
# "pip" tests. | ||
|
||
python -m venv /$1 | ||
mkdir -p $1 | ||
rm -f ./$1/tensorflow | ||
ln -s $(ls /$1/lib) /$1/lib/python3 | ||
ln -s ../tensorflow $1/tensorflow | ||
# extglob is necessary for @(a|b) pattern matching | ||
# see "extglob" in the bash manual page ($ man bash) | ||
bash -O extglob -c "/$1/bin/pip install $2" | ||
/$1/bin/pip install -r /usertools/test.requirements.txt |
64 changes: 64 additions & 0 deletions
64
tf_sig_build_dockerfiles/devel.usertools/squash_testlogs.py
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Usage: squash_testlogs.py START_DIRECTORY OUTPUT_FILE | ||
# | ||
# Example: squash_testlogs.py /tf/pkg/testlogs /tf/pkg/merged.xml | ||
# | ||
# Recursively find all the JUnit test.xml files in one directory, and merge any | ||
# of them that contain failures into one file. The TensorFlow DevInfra team | ||
# uses this to generate a simple overview of an entire pip and nonpip test | ||
# invocation, since the normal logs that Bazel creates are too large for the | ||
# internal invocation viewer. | ||
import glob | ||
import os | ||
import sys | ||
from junitparser import JUnitXml | ||
from lxml import etree | ||
import subprocess | ||
import re | ||
|
||
result = JUnitXml() | ||
try: | ||
files = subprocess.check_output(["grep", "-rlE", '(failures|errors)="[1-9]', sys.argv[1]]) | ||
except subprocess.CalledProcessError as e: | ||
print("No failures found to log!") | ||
exit(0) | ||
|
||
# For test cases, only show the ones that failed that have text (a log) | ||
seen = set() | ||
|
||
for f in files.strip().splitlines(): | ||
# Include only "test.xml" files, as "attempt_x" files repeat the same thing. | ||
if not f.endswith(b"test.xml"): | ||
continue | ||
# Just ignore any failures, they're probably not important | ||
try: | ||
r = JUnitXml.fromfile(f) | ||
except Exception as e: | ||
print("Ignoring this XML parse failure in {}: ".format(f), str(e)) | ||
|
||
for testsuite in r: | ||
# Remove empty testcases | ||
for p in testsuite._elem.xpath('.//testcase'): | ||
if not len(p): | ||
testsuite._elem.remove(p) | ||
# Convert "testsuite > testcase,system-out" to "testsuite > testcase" | ||
for p in testsuite._elem.xpath('.//system-out'): | ||
for c in p.getparent().xpath('.//error | .//failure'): | ||
c.text = p.text | ||
p.getparent().remove(p) | ||
# Include a note about | ||
for p in testsuite._elem.xpath('.//error | .//failure'): | ||
short_name = re.search(r'/(bazel_pip|tensorflow)/.*', f.decode("utf-8")).group(0) | ||
p.text += f"\nNOTE: From /{short_name}" | ||
if "bazel_pip" in short_name: | ||
p.text += "\nNOTE: This was a pip test. Remove 'bazel_pip' to find the real target." | ||
# Remove this testsuite if it doesn't have anything in it any more | ||
if len(testsuite) == 0: | ||
r._elem.remove(testsuite._elem) | ||
if len(r) > 0: | ||
result += r | ||
|
||
os.makedirs(os.path.dirname(sys.argv[2]), exist_ok=True) | ||
result.update_statistics() | ||
result.write(sys.argv[2]) |
6 changes: 6 additions & 0 deletions
6
tf_sig_build_dockerfiles/devel.usertools/test.requirements.txt
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Test dependencies for pip tests | ||
grpcio ~= 1.42.0 | ||
portpicker ~= 1.4.0 | ||
scipy ~= 1.5.4 | ||
jax ~= 0.2.18 | ||
jaxlib ~= 0.1.70 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think that this will work in same root dir?
https://github.com/tensorflow/tensorflow/pull/50163/files#diff-364cf915db9af8a15c691cddfdb7a5808e927715ada650b01911e74d1e2ba944R187
It is a little bit old so I don't remember if it worked or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end, until the cache reproducibility is verified, it could be really useful if we could find a solution to run in source python tests on pip installed wheels. Do you think that there is a quick workaround to implement also this modality?