-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2404 Update CSFLE spec tests for KMS providers 'azure' and 'gcp' #509
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
PYTHON-2404 Update CSFLE spec tests for KMS providers 'azure' and 'gcp' #509
Conversation
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.
Nice work, just two minor comments
test/test_encryption.py
Outdated
def run_test(self, provider_name): | ||
# Create data key. | ||
master_key = self.MASTER_KEYS[provider_name] | ||
if master_key is not None: |
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.
Aren't both calls to create_data_key
equivalent here since master_key=None
is valid?
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.
Good point.
kms_providers = {'aws': AWS_CREDS, | ||
'azure': AZURE_CREDS, | ||
'gcp': GCP_CREDS} | ||
self.client_encryption = ClientEncryption( |
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.
This overwrites the cls.client_encryption
that's created in setUpClass. Suggest renaming or moving this logic to setUpClass if possible.
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.
The prose tests explicitly ask for recreating this object for every test so I have simply removed this from setUpClass
- it had been left there in error.
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.
LGTM!
Interesting, this is an example of a transient network error to azure's KMS (timed out after 10 seconds):
|
Interesting to be able to observe the timeout on Azure! As per the spec, it doesn't seem like we should be adding any custom handling for that kind of an error so I suppose there is nothing to do there? I am also seeing the following in the test logs:
I will open a JIRA ticket to track this. |
@classmethod | ||
def tearDownClass(cls): | ||
cls.client.close() | ||
cls.vault.drop() |
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.
These two lines should be swapped. Dropping the vault collection reopens the client we just closed.
This will fixed the unclosed client issue:
[2020/11/04 00:08:54.758] Topology <Topology <TopologyDescription id: 5fa1f0698ad53cb215fa7405, topology_type: ReplicaSetWithPrimary, servers: [<ServerDescription ('localhost', 27017) server_type: RSPrimary, rtt: 0.000538420648610058>, <ServerDescription ('localhost', 27018) server_type: RSSecondary, rtt: 0.001056252019849808>, <ServerDescription ('localhost', 27019) server_type: RSArbiter, rtt: 0.0009123198919968762>]>> has THREADS RUNNING: [<PeriodicExecutor(name=pymongo_server_monitor_thread) object at 0x7ff450e41a90>, <PeriodicExecutor(name=pymongo_server_rtt_thread) object at 0x7ff450e41a50>, <PeriodicExecutor(name=pymongo_server_monitor_thread) object at 0x7ff450bfb350>, <PeriodicExecutor(name=pymongo_server_rtt_thread) object at 0x7ff450bfb250>, <PeriodicExecutor(name=pymongo_server_monitor_thread) object at 0x7ff450bfbc10>, <PeriodicExecutor(name=pymongo_server_rtt_thread) object at 0x7ff4524dbbd0>], created at:
...
[2020/11/04 00:08:54.758] File "/data/mci/1d06ce731bf44d878db71873b3380fd4/src/test/test_encryption.py", line 630, in setUpClass
[2020/11/04 00:08:54.758] cls.client = rs_or_single_client(event_listeners=[cls.listener])
No description provided.