Skip to content
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-2800 Add Atlas connectivity tests for MongoDB Serverless #669

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .evergreen/config.yml
Expand Up @@ -450,11 +450,13 @@ functions:
export ATLAS_SHRD='${atlas_shrd}'
export ATLAS_TLS11='${atlas_tls11}'
export ATLAS_TLS12='${atlas_tls12}'
export ATLAS_SERVERLESS='${atlas_serverless}'
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}'
export ATLAS_SRV_SERVERLESS='${atlas_srv_serverless}'
EOT
- command: shell.exec
type: test
Expand Down
10 changes: 9 additions & 1 deletion test/atlas/test_connection.py
Expand Up @@ -38,11 +38,13 @@
"ATLAS_FREE": os.environ.get("ATLAS_FREE"),
"ATLAS_TLS11": os.environ.get("ATLAS_TLS11"),
"ATLAS_TLS12": os.environ.get("ATLAS_TLS12"),
"ATLAS_SERVERLESS": os.environ.get("ATLAS_SERVERLESS"),
"ATLAS_SRV_REPL": os.environ.get("ATLAS_SRV_REPL"),
"ATLAS_SRV_SHRD": os.environ.get("ATLAS_SRV_SHRD"),
"ATLAS_SRV_FREE": os.environ.get("ATLAS_SRV_FREE"),
"ATLAS_SRV_TLS11": os.environ.get("ATLAS_SRV_TLS11"),
"ATLAS_SRV_TLS12": os.environ.get("ATLAS_SRV_TLS12"),
"ATLAS_SRV_SERVERLESS": os.environ.get("ATLAS_SRV_SERVERLESS"),
}

# Set this variable to true to run the SRV tests even when dnspython is not
Expand Down Expand Up @@ -77,6 +79,9 @@ def test_tls_11(self):
def test_tls_12(self):
connect(URIS['ATLAS_TLS12'])

def test_serverless(self):
connect(URIS['ATLAS_SERVERLESS'])

def connect_srv(self, uri):
connect(uri)
self.assertIn('mongodb+srv://', uri)
Expand All @@ -102,6 +107,10 @@ def test_srv_tls_11(self):
def test_srv_tls_12(self):
self.connect_srv(URIS['ATLAS_SRV_TLS12'])

@unittest.skipUnless(HAS_DNS or MUST_TEST_SRV, 'SRV requires dnspython')
def test_srv_serverless(self):
self.connect_srv(URIS['ATLAS_SRV_SERVERLESS'])

def test_uniqueness(self):
"""Ensure that we don't accidentally duplicate the test URIs."""
uri_to_names = defaultdict(list)
Expand All @@ -114,6 +123,5 @@ def test_uniqueness(self):
'duplicate values: %s' % (duplicates,))



if __name__ == '__main__':
unittest.main()