-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add endpoints and authentication details (including SigV4) as parameters to E2E test script #461
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
edcda15
Add endpoints and authentication details as parameters
okhasawn 79b0b84
Add separate authentication details for both endpoints + update exist…
okhasawn bd3ab8e
Add more authentication parameters to support more scenarios
okhasawn e16999a
Fix failing workflow
okhasawn 6d59979
Merge branch 'main' into parametersTest
okhasawn c009947
Add default values for parameters + Update documentation
okhasawn 2930a32
Merge branch 'main' into parametersTest
okhasawn f721399
No longer need to specify parameters as there are default values now
okhasawn ae0e482
Merge branch 'parametersTest' of github.com:okhasawn/opensearch-migra…
okhasawn 8e2a3c6
Add SigV4 Support
okhasawn cb13a85
Add unique index parameter + accomodate cloud deployment for OSB test
okhasawn c7c1da3
fix path + update index name
okhasawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# conftest.py | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--proxy_endpoint", action="store", default="https://localhost:9200") | ||
parser.addoption("--source_endpoint", action="store", default="https://localhost:19200") | ||
parser.addoption("--target_endpoint", action="store", default="https://localhost:29200") | ||
parser.addoption("--source_auth_type", action="store", default="basic", choices=["none", "basic", "sigv4"]) | ||
parser.addoption("--source_verify_ssl", action="store", default="False", choices=["True", "False"]) | ||
parser.addoption("--target_auth_type", action="store", default="basic", choices=["none", "basic", "sigv4"]) | ||
parser.addoption("--target_verify_ssl", action="store", default="False", choices=["True", "False"]) | ||
parser.addoption("--source_username", action="store", default="admin") | ||
parser.addoption("--source_password", action="store", default="admin") | ||
parser.addoption("--target_username", action="store", default="admin") | ||
parser.addoption("--target_password", action="store", default="admin") | ||
|
||
|
||
@pytest.fixture | ||
def proxy_endpoint(pytestconfig): | ||
return pytestconfig.getoption("proxy_endpoint") | ||
|
||
|
||
@pytest.fixture | ||
def source_endpoint(pytestconfig): | ||
return pytestconfig.getoption("source_endpoint") | ||
|
||
|
||
@pytest.fixture | ||
def target_endpoint(pytestconfig): | ||
return pytestconfig.getoption("target_endpoint") | ||
|
||
|
||
@pytest.fixture | ||
def source_auth_type(pytestconfig): | ||
return pytestconfig.getoption("source_auth_type") | ||
|
||
|
||
@pytest.fixture | ||
def source_username(pytestconfig): | ||
return pytestconfig.getoption("source_username") | ||
|
||
|
||
@pytest.fixture | ||
def source_password(pytestconfig): | ||
return pytestconfig.getoption("source_password") | ||
|
||
|
||
@pytest.fixture | ||
def target_auth_type(pytestconfig): | ||
return pytestconfig.getoption("target_auth_type") | ||
|
||
|
||
@pytest.fixture | ||
def target_username(pytestconfig): | ||
return pytestconfig.getoption("target_username") | ||
|
||
|
||
@pytest.fixture | ||
def target_password(pytestconfig): | ||
return pytestconfig.getoption("target_password") | ||
|
||
|
||
@pytest.fixture | ||
def target_verify_ssl(pytestconfig): | ||
return pytestconfig.getoption("target_verify_ssl") | ||
|
||
|
||
@pytest.fixture | ||
def source_verify_ssl(pytestconfig): | ||
return pytestconfig.getoption("source_verify_ssl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,47 +3,50 @@ | |
from typing import Optional, Tuple | ||
|
||
|
||
def create_index(endpoint: str, index_name: str, auth: Optional[Tuple[str, str]] = None): | ||
response = requests.put(f'{endpoint}/{index_name}', auth=auth, verify=False) | ||
def create_index(endpoint: str, index_name: str, auth: Optional[Tuple[str, str]] = None, verify_ssl: bool = False): | ||
response = requests.put(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
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. I assume the requests library is smart enough to see if it has basic or sigv4 auth passed to it and parse accordingly 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. That's correct! |
||
|
||
return response | ||
|
||
|
||
def check_index(endpoint: str, index_name: str, auth: Optional[Tuple[str, str]] = None): | ||
response = requests.get(f'{endpoint}/{index_name}', auth=auth, verify=False) | ||
def check_index(endpoint: str, index_name: str, auth: Optional[Tuple[str, str]] = None, verify_ssl: bool = False): | ||
response = requests.get(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
|
||
return response | ||
|
||
|
||
def delete_index(endpoint: str, index_name: str, auth: Optional[Tuple[str, str]] = None): | ||
response = requests.delete(f'{endpoint}/{index_name}', auth=auth, verify=False) | ||
def delete_index(endpoint: str, index_name: str, auth: Optional[Tuple[str, str]] = None, verify_ssl: bool = False): | ||
response = requests.delete(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
|
||
return response | ||
|
||
|
||
def delete_document(endpoint: str, index_name: str, doc_id: str, auth: Optional[Tuple[str, str]] = None): | ||
response = requests.delete(f'{endpoint}/{index_name}/_doc/{doc_id}', auth=auth, verify=False) | ||
def delete_document(endpoint: str, index_name: str, doc_id: str, auth: Optional[Tuple[str, str]] = None, | ||
verify_ssl: bool = False): | ||
response = requests.delete(f'{endpoint}/{index_name}/_doc/{doc_id}', auth=auth, verify=verify_ssl) | ||
|
||
return response | ||
|
||
|
||
def create_document(endpoint: str, index_name: str, doc_id: str, auth: Optional[Tuple[str, str]] = None): | ||
def create_document(endpoint: str, index_name: str, doc_id: str, auth: Optional[Tuple[str, str]] = None, | ||
verify_ssl: bool = False): | ||
document = { | ||
'title': 'Test Document', | ||
'content': 'This is a sample document for testing OpenSearch.' | ||
} | ||
url = f'{endpoint}/{index_name}/_doc/{doc_id}' | ||
headers = {'Content-Type': 'application/json'} | ||
|
||
response = requests.put(url, headers=headers, data=json.dumps(document), auth=auth, verify=False) | ||
response = requests.put(url, headers=headers, data=json.dumps(document), auth=auth, verify=verify_ssl) | ||
|
||
return response | ||
|
||
|
||
def get_document(endpoint: str, index_name: str, doc_id: str, auth: Optional[Tuple[str, str]] = None): | ||
def get_document(endpoint: str, index_name: str, doc_id: str, auth: Optional[Tuple[str, str]] = None, | ||
verify_ssl: bool = False): | ||
url = f'{endpoint}/{index_name}/_doc/{doc_id}' | ||
headers = {'Content-Type': 'application/json'} | ||
|
||
response = requests.get(url, headers=headers, auth=auth, verify=False) | ||
response = requests.get(url, headers=headers, auth=auth, verify=verify_ssl) | ||
|
||
return response |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 these all defaults, do we need to specify?
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.
Could you also add the
--verbose
flag to this command. Some of these tests take a while to run so you start to wonder if things are working with no output. This flag will show each test as it gets started runningThere 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.
You're right, I don't need to specify those in the workflow anymore. I had updated the defaults value after.
I'll update this to remove the values and add the verbose flag. Thank you!