-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-1878 Add mongodb+srv URIs to Atlas Connectivity tests #538
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 all commits
3e986fd
d7092c5
3391025
08b5053
da3f217
658eb17
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 |
---|---|---|
|
@@ -444,8 +444,29 @@ functions: | |
silent: true | ||
working_dir: "src" | ||
script: | | ||
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does) | ||
PYTHON_BINARY=${PYTHON_BINARY} ATLAS_REPL='${atlas_repl}' ATLAS_SHRD='${atlas_shrd}' ATLAS_FREE='${atlas_free}' ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' sh ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh | ||
cat <<EOT > prepare_atlas_connectivity.sh | ||
export ATLAS_FREE='${atlas_free}' | ||
export ATLAS_REPL='${atlas_repl}' | ||
export ATLAS_SHRD='${atlas_shrd}' | ||
export ATLAS_TLS11='${atlas_tls11}' | ||
export ATLAS_TLS12='${atlas_tls12}' | ||
export ATLAS_SRV_FREE='${atlas_srv_free}' | ||
export ATLAS_SRV_REPL='${atlas_srv_repl}' | ||
export ATLAS_SRV_SHRD='${atlas_srv_shrd}' | ||
export ATLAS_SRV_TLS11='${atlas_srv_tls11}' | ||
export ATLAS_SRV_TLS12='${atlas_srv_tls12}' | ||
EOT | ||
- command: shell.exec | ||
type: test | ||
params: | ||
working_dir: "src" | ||
script: | | ||
# Disable xtrace (just in case it was accidentally set). | ||
set +x | ||
. ./prepare_atlas_connectivity.sh | ||
rm -f ./prepare_atlas_connectivity.sh | ||
|
||
PYTHON_BINARY=${PYTHON_BINARY} bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh | ||
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. This is a more user friendly way to manage secrets. We load the env variables in secret (with 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. <3 it! |
||
|
||
"add aws auth variables to file": | ||
- command: shell.exec | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# Don't trace to avoid secrets showing up in the logs | ||
# Exit on error and enable trace. | ||
set -o errexit | ||
set -o xtrace | ||
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. We can do this safely. We just need to remember not to print or use the secret variables in the shell script. |
||
|
||
export JAVA_HOME=/opt/java/jdk8 | ||
|
||
|
@@ -15,27 +16,37 @@ if [ -z "$PYTHON_BINARY" ]; then | |
fi | ||
|
||
IMPL=$(${PYTHON_BINARY} -c "import platform, sys; sys.stdout.write(platform.python_implementation())") | ||
if [ $IMPL = "Jython" -o $IMPL = "PyPy" ]; then | ||
echo "Using Jython or PyPy" | ||
|
||
if [ $IMPL = "Jython" ]; then | ||
# The venv created by createvirtualenv is incompatible with Jython | ||
$PYTHON_BINARY -m virtualenv --never-download --no-wheel atlastest | ||
. atlastest/bin/activate | ||
trap "deactivate; rm -rf atlastest" EXIT HUP | ||
pip install certifi | ||
PYTHON=python | ||
else | ||
IS_PRE_279=$(${PYTHON_BINARY} -c "import sys; sys.stdout.write('1' if sys.version_info < (2, 7, 9) else '0')") | ||
# All other pythons work with createvirtualenv. | ||
. .evergreen/utils.sh | ||
createvirtualenv $PYTHON_BINARY atlastest | ||
fi | ||
trap "deactivate; rm -rf atlastest" EXIT HUP | ||
|
||
if [ $IMPL = "Jython" -o $IMPL = "PyPy" ]; then | ||
echo "Using Jython or PyPy" | ||
python -m pip install certifi | ||
else | ||
IS_PRE_279=$(python -c "import sys; sys.stdout.write('1' if sys.version_info < (2, 7, 9) else '0')") | ||
if [ $IS_PRE_279 = "1" ]; then | ||
echo "Using a Pre-2.7.9 CPython" | ||
$PYTHON_BINARY -m virtualenv --never-download --no-wheel atlastest | ||
. atlastest/bin/activate | ||
trap "deactivate; rm -rf atlastest" EXIT HUP | ||
pip install pyopenssl>=17.2.0 service_identity>18.1.0 | ||
PYTHON=python | ||
python -m pip install pyopenssl>=17.2.0 service_identity>18.1.0 | ||
else | ||
echo "Using CPython 2.7.9+" | ||
PYTHON=$PYTHON_BINARY | ||
fi | ||
fi | ||
|
||
echo "Running tests" | ||
$PYTHON test/atlas/test_connection.py | ||
echo "Running tests without dnspython" | ||
python test/atlas/test_connection.py | ||
|
||
# dnspython is incompatible with Jython so don't test that combination. | ||
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. |
||
if [ $IMPL != "Jython" ]; then | ||
python -m pip install dnspython | ||
echo "Running tests with dnspython" | ||
MUST_TEST_SRV="1" python test/atlas/test_connection.py | ||
fi |
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.
I think we can further optimize some of these invocations by switching to using
subprocess.exec
instead ofshell.exec
and then setting either theinclude_expansions_in_env
option or theadd_expansions_to_env
option to automatically set the appropriate environment variables. I suppose we don't need to do it right now, but being able to eventually eliminate the use of$PREPARE_SHELL
would be a huge improvement IMO.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.
Just to clarify, I am just suggesting this as a future optimization/refactor. Not saying that we need to do it in this PR. Would love to hear your thoughts on it @ShaneHarvey
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.
Cool idea! Can you open a ticket with this comment?
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.
https://jira.mongodb.org/browse/PYTHON-2481