This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
Combine test coverage #3814
Merged
Merged
Combine test coverage #3814
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,21 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# coding=utf-8 | ||
|
||
set -veuo pipefail | ||
set -mveuo pipefail | ||
|
||
wait_for_pulp() { | ||
TIMEOUT=${1:-5} | ||
while [ "$TIMEOUT" -gt 0 ] | ||
do | ||
echo -n . | ||
sleep 1 | ||
TIMEOUT=$(($TIMEOUT - 1)) | ||
if [ $(http :8000/pulp/api/v3/status/ | jq '.database_connection.connected and .redis_connection.connected') = 'true' ] | ||
then | ||
echo | ||
return | ||
fi | ||
done | ||
echo | ||
return 1 | ||
} | ||
|
||
if [ "$TEST" = 'docs' ]; then | ||
pulp-manager runserver >> ~/django_runserver.log 2>&1 & | ||
sleep 5 | ||
cd docs | ||
make html | ||
set +euo pipefail | ||
return "$?" | ||
exit | ||
fi | ||
|
||
|
||
# check the commit message | ||
./.travis/check_commit.sh | ||
|
||
# Lint code. | ||
flake8 --config flake8.cfg || exit 1 | ||
flake8 --config flake8.cfg | ||
|
||
# Run unit tests. | ||
coverage run manage.py test ./pulpcore/tests/unit/ | ||
|
@@ -29,16 +46,24 @@ show_logs_and_return_non_zero() { | |
cat ~/reserved_worker-1.log | ||
return "${rc}" | ||
} | ||
|
||
# Start services | ||
rq worker -n 'resource_manager@%h' -w 'pulpcore.tasking.worker.PulpWorker' -c 'pulpcore.rqconfig' >> ~/resource_manager.log 2>&1 & | ||
rq worker -n 'reserved_resource_worker_1@%h' -w 'pulpcore.tasking.worker.PulpWorker' -c 'pulpcore.rqconfig' >> ~/reserved_worker-1.log 2>&1 & | ||
gunicorn pulpcore.tests.functional.content_with_coverage:server --bind 'localhost:8080' --worker-class 'aiohttp.GunicornWebWorker' -w 2 >> ~/content_app.log 2>&1 & | ||
pulp-manager runserver --noreload >> ~/django_runserver.log 2>&1 & | ||
wait_for_pulp 20 | ||
|
||
# Run functional tests | ||
pytest -v -r sx --color=yes --pyargs pulpcore.tests.functional || show_logs_and_return_non_zero | ||
pytest -v -r sx --color=yes --pyargs pulp_file.tests.functional || show_logs_and_return_non_zero | ||
codecov | ||
|
||
# Travis' scripts use unbound variables. This is problematic, because the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, this is only a problem because we used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know of a reason. |
||
# changes made to this script's environment appear to persist when Travis' | ||
# scripts execute. Perhaps this script is sourced by Travis? Regardless of why, | ||
# we need to reset the environment when this script finishes. | ||
# | ||
# We can't use `trap cleanup_function EXIT` or similar, because this script is | ||
# apparently sourced, and such a trap won't execute until the (buggy!) calling | ||
# script finishes. | ||
set +euo pipefail | ||
# Stop services to write coverage | ||
kill -SIGINT %?runserver | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. 👍 |
||
kill -SIGINT %?content_with_coverage | ||
kill -SIGINT %?reserved_resource_worker | ||
kill -SIGINT %?resource_manager | ||
wait || true | ||
|
||
coverage combine | ||
codecov |
This file contains 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,17 @@ | ||
import atexit | ||
bmbouter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import sys | ||
import coverage | ||
|
||
cov = coverage.Coverage() | ||
cov.start() | ||
|
||
|
||
def finalize_coverage(): | ||
print('writing coverage', file=sys.stderr) | ||
cov.stop() | ||
cov.save() | ||
|
||
|
||
atexit.register(finalize_coverage) | ||
|
||
from ...content import server # noqa |
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.
what about using wait_for_pulp here too? We've had issues in Travis runs with this exact issue but we never had
wait_for_pulp
!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.
Yes, there is room for improvement: In it's actual state
wait_for_pulp
checks the availability of the worker threads (and could also check the content app if it were present in thestatus
endpoint). So, it is not usable here unmodified.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.
OK we can leave this as is for now