Skip to content

PYTHON-3461 Test FaaS (AWS Lambda) Behavior Per Driver #1310

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
merged 30 commits into from
Aug 11, 2023

Conversation

blink1073
Copy link
Member

No description provided.

@blink1073 blink1073 marked this pull request as ready for review July 19, 2023 14:21
@blink1073 blink1073 requested a review from ShaneHarvey July 19, 2023 14:22
@@ -3264,6 +3308,12 @@ buildvariants:
batchtime: 20160 # Use a batchtime of 14 days as suggested by the CSFLE test README
- testazurekms-fail-task

- name: rhel8-test-lambda
display_name: AWS Lambda handler tests
run_on: rhel87-large
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to use rhel87-large? Or can we use rhel87-small instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small works

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are failing with:

 [2023/07/19 14:46:54.303] Lambda function ARN: arn:aws:lambda:us-east-1:579766882180:function:dbx-python-lambda-e1244092-MongoDBFunction-3wLFo93jPKfd
 [2023/07/19 14:46:54.303] ++ aws lambda invoke --function-name arn:aws:lambda:us-east-1:579766882180:function:dbx-python-lambda-e1244092-MongoDBFunction-3wLFo93jPKfd --log-type Tail lambda-invoke-standard.json
 [2023/07/19 14:47:09.209] {
 [2023/07/19 14:47:09.209]     "StatusCode": 200,
 [2023/07/19 14:47:09.209]     "FunctionError": "Unhandled",
 [2023/07/19 14:47:09.209]     "LogResult": "...",
 [2023/07/19 14:47:09.209]     "ExecutedVersion": "$LATEST"
 [2023/07/19 14:47:09.209] }
 [2023/07/19 14:47:09.306] {"errorMessage": "The \"dnspython\" module must be installed to use mongodb+srv:// URIs. To fix this error install pymongo again:\n /var/lang/bin/python3.9 -m pip install pymongo>=4.3", "errorType": "ConfigurationError", "requestId": "", "stackTrace": ["  File \"/var/lang/lib/python3.9/importlib/__init__.py\", line 127, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n", "  File \"<frozen importlib._bootstrap>\", line 1030, in _gcd_import\n", "  File \"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n", "  File \"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n", "  File \"<frozen importlib._bootstrap>\", line 680, in _load_unlocked\n", "  File \"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n", "  File \"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n", "  File \"/var/task/app.py\", line 99, in <module>\n    client = MongoClient(os.environ[\"MONGODB_URI\"], event_listeners=listeners)\n", "  File \"/var/task/pymongo/mongo_client.py\", line 748, in __init__\n    res = uri_parser.parse_uri(\n", "  File \"/var/task/pymongo/uri_parser.py\", line 470, in parse_uri\n    raise ConfigurationError(\n"]}

Could we make it so that this kind of error causes the EVG task to fail?

As for why this is happening, the dnspython package (and any other python dependencies) actually needs to be vendored into the lambda app package: https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-dependencies

@blink1073
Copy link
Member Author

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I think we should wait until your driver-tools fix is merged.

@@ -98,7 +98,7 @@ functions:
# If this was a patch build, doing a fresh clone would not actually test the patch
cp -R ${PROJECT_DIRECTORY}/ $DRIVERS_TOOLS
else
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
git clone -b DRIVERS-2384 https://github.com/blink1073/drivers-evergreen-tools.git $DRIVERS_TOOLS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this branch to make it so the task fails when a function fails?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and some clean up as well. I agree we should wait for that PR to be merged

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed the tests are still failing:

[2023/07/25 16:49:46.758] ++ cat lambda_output.txt
[2023/07/25 16:49:46.759] {"errorMessage": "", "errorType": "AssertionError", "requestId": "", "stackTrace": ["  File \"/var/lang/lib/python3.9/importlib/__init__.py\", line 127, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n", "  File \"<frozen importlib._bootstrap>\", line 1030, in _gcd_import\n", "  File \"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n", "  File \"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n", "  File \"<frozen importlib._bootstrap>\", line 680, in _load_unlocked\n", "  File \"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n", "  File \"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n", "  File \"/var/task/app.py\", line 26, in <module>\n    assert has_bson_c()\n"]}{
[2023/07/25 16:49:46.759]     "StatusCode": 200,
[2023/07/25 16:49:46.759]     "FunctionError": "Unhandled",

https://spruce.mongodb.com/task/mongo_python_driver_rhel8_test_lambda_test_aws_lambda_deployed_patch_c6a6ea60663ce37cbd5128f1a83bc46e54fb2071_64bfdac42a60edb3ead68153_23_07_25_14_23_00/logs?execution=5

@blink1073
Copy link
Member Author

Just noticed the tests are still failing

Yes, I'm still working on installing the local version of pymongo vs the one from pypi.

@blink1073
Copy link
Member Author

Moved to draft pending mongodb-labs/drivers-evergreen-tools#331

@blink1073 blink1073 marked this pull request as ready for review August 11, 2023 13:49
@blink1073 blink1073 requested a review from a team as a code owner August 11, 2023 13:49
@blink1073 blink1073 requested a review from ShaneHarvey August 11, 2023 13:49
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@blink1073 blink1073 merged commit 28b1121 into mongodb:master Aug 11, 2023
@blink1073 blink1073 deleted the PYTHON-3461 branch August 11, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants