-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-3071 [DevOps] Merge and improve resync_specs.sh #839
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
Changes from 11 commits
a125591
9d5ce61
b5ea8d3
6d13fd9
d93e021
612f091
c0680da
df8bda1
70a5c63
83b784b
316d051
c7e291e
0ded415
31e60cf
f050e4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#!/bin/bash | ||
# exit when any command fails | ||
set -e | ||
PYMONGO=$(dirname $PWD) | ||
SPECS=${MDB_SPECS:-~/Work/specifications} | ||
|
||
help (){ | ||
echo "Usage: resync_specs.sh [-bcsp] spec" | ||
echo "Required arguments:" | ||
echo " spec determines which folder the spec tests will be copied from." | ||
echo "Optional flags:" | ||
echo " -b is used to add a string to the blocklist for that next run. Can be used" | ||
echo " any number of times on a single command to block multiple patterns." | ||
echo " You can use any regex pattern (it is passed to 'grep -Ev')." | ||
echo " -c is used to set a branch or commit that will be checked out in the" | ||
echo " specifications repo before copying." | ||
echo " -s is used to set a unique path to the specs repo for that specific" | ||
echo " run." | ||
echo "Notes:" | ||
echo "You can export the environment variable MDB_SPECS to set the specs" | ||
echo " repo similar to -s, but this will persist between runs until you " | ||
echo "unset it." | ||
} | ||
|
||
# Parse flag args | ||
BRANCH="" | ||
BLOCKLIST='.*\.yml' | ||
while getopts 'b:c:s:' flag; do | ||
case "${flag}" in | ||
b) BLOCKLIST+="|"$OPTARG"" | ||
;; | ||
c) BRANCH="${OPTARG}" | ||
;; | ||
s) SPECS="${OPTARG}" | ||
;; | ||
*) help; exit 0 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
if [ -z $BRANCH ] | ||
then | ||
git -C $SPECS checkout $BRANCH | ||
fi | ||
|
||
# Ensure the JSON files are up to date. | ||
cd $SPECS/source | ||
make | ||
cd - | ||
# cpjson2 unified-test-format/tests/invalid unified-test-format/invalid | ||
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. cpjson2 -> cpjson 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. Done. |
||
# * param1: Path to spec tests dir in specifications repo | ||
# * param2: Path to where the corresponding tests live in Python. | ||
cpjson () { | ||
find "$PYMONGO"/test/$2 -type f -delete | ||
cd "$SPECS"/source/$1 | ||
find . -name '*.json' | grep -Ev "${BLOCKLIST}" | cpio -pdm \ | ||
$PYMONGO/test/$2 | ||
printf "\nIgnored files for ${PWD}" | ||
printf "\n%s\n" "$(diff <(find . -name '*.json' | sort) \ | ||
<(find . -name '*.json' | grep -Ev "${BLOCKLIST}" | sort))" | \ | ||
sed -e '/^[0-9]/d' | sed -e 's|< ./||g' | ||
} | ||
|
||
for spec in "$@" | ||
do | ||
case "$spec" in | ||
bson*corpus) | ||
cpjson bson-corpus/tests/ bson_corpus | ||
;; | ||
max*staleness) | ||
cpjson max-staleness/tests/ max_staleness | ||
;; | ||
connection*string) | ||
cpjson connection-string/tests/ connection_string/test | ||
;; | ||
change*streams) | ||
cpjson change-streams/tests/ change_streams/ | ||
;; | ||
cmap|CMAP) | ||
cpjson connection-monitoring-and-pooling/tests cmap | ||
;; | ||
command*monitoring) | ||
cpjson command-monitoring/tests command_monitoring | ||
;; | ||
crud|CRUD) | ||
cpjson crud/tests/ crud | ||
;; | ||
load*balancer) | ||
cpjson load-balancers/tests load_balancer | ||
;; | ||
initial-dns-seedlist-discovery|srv_seedlist) | ||
cpjson initial-dns-seedlist-discovery/tests/ srv_seedlist | ||
;; | ||
old_srv_seedlist) | ||
cpjson initial-dns-seedlist-discovery/tests srv_seedlist | ||
;; | ||
retryable*reads) | ||
cpjson retryable-reads/tests/ retryable_reads | ||
;; | ||
retryable*writes) | ||
cpjson retryable-writes/tests/ retryable_writes | ||
;; | ||
sdam|SDAM) | ||
cpjson server-discovery-and-monitoring/tests/errors \ | ||
discovery_and_monitoring/errors | ||
cpjson server-discovery-and-monitoring/tests/rs \ | ||
discovery_and_monitoring/rs | ||
cpjson server-discovery-and-monitoring/tests/sharded \ | ||
discovery_and_monitoring/sharded | ||
cpjson server-discovery-and-monitoring/tests/single \ | ||
discovery_and_monitoring/single | ||
cpjson server-discovery-and-monitoring/tests/integration \ | ||
discovery_and_monitoring_integration | ||
cpjson server-discovery-and-monitoring/tests/load-balanced \ | ||
discovery_and_monitoring/load-balanced | ||
;; | ||
sdam*monitoring) | ||
cpjson server-discovery-and-monitoring/tests/monitoring sdam_monitoring | ||
;; | ||
server*selection) | ||
cpjson server-selection/tests/ server_selection | ||
;; | ||
sessions) | ||
cpjson sessions/tests/ sessions | ||
;; | ||
transactions|transactions-convenient-api) | ||
cpjson transactions/tests/ transactions | ||
cpjson transactions-convenient-api/tests/ transactions-convenient-api | ||
;; | ||
unified) | ||
cpjson unified-test-format/tests/ unified-test-format/ | ||
;; | ||
uri|uri*options) | ||
cpjson uri-options/tests uri_options | ||
;; | ||
versioned-api) | ||
cpjson versioned-api/tests versioned-api | ||
;; | ||
*) | ||
echo "Do not know how to resync spec tests for '${spec}'" | ||
help | ||
;; | ||
esac | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,20 @@ just make your changes to the inline documentation of the appropriate | |
branch and submit a `pull request <https://help.github.com/articles/using-pull-requests>`_. | ||
You might also use the GitHub `Edit <https://github.com/blog/844-forking-with-the-edit-button>`_ | ||
button. | ||
|
||
Re-sync Spec Tests | ||
----------------- | ||
|
||
If you would like to re-sync the copy of the specification tests in the | ||
PyMongo repository with that which is inside the `specifications repo | ||
<https://github.com/mongodb/specifications>`_, please | ||
use the script provided in ``.evergreen/resync-specs.sh``. It allows a | ||
variety of flag arguments (which you can find by typing ``./resync-specs.sh --help`` | ||
) and also the spec arguments, which must come last and which determine what | ||
folders will be copied from and to. It supports | ||
filtering using regex patterns, and it will show you which files it ignored | ||
when using this feature so you can ensure you are not leaving any important | ||
tests behind. | ||
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. It would be more helpful to document how to setup and use the script. Like this (but fixed up so it actually works):
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. Done. |
||
This is primarily helpful if you are implementing a new feature in PyMongo | ||
that has spec tests already implemented, or if you are attempting to | ||
validate new spec tests in PyMongo. |
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.
PWD is the current working directory which isn't necessarily the repo root. Instead we should use the path to this file itself:
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.
If you run it inside the .evergreen folder as
./resync-specs.sh
then it fails because$(dirname $(dirname $0))
resolves to.
.Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry this should work: