forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opensearch-project#637 from AndreKurait/E2EWaitBet…
…weenRequestsOnConnection Add test that verifies replayer function when waiting a minute between requests
- Loading branch information
Showing
2 changed files
with
74 additions
and
40 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
import requests | ||
import json | ||
from requests import Session | ||
|
||
|
||
def create_index(endpoint: str, index_name: str, auth, verify_ssl: bool = False): | ||
response = requests.put(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
def create_index(endpoint: str, index_name: str, auth, verify_ssl: bool = False, session: Session = Session()): | ||
response = session.put(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
|
||
return response | ||
|
||
|
||
def check_index(endpoint: str, index_name: str, auth, verify_ssl: bool = False): | ||
response = requests.get(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
def check_index(endpoint: str, index_name: str, auth, verify_ssl: bool = False, session: Session = Session()): | ||
response = session.get(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
|
||
return response | ||
|
||
|
||
def delete_index(endpoint: str, index_name: str, auth, verify_ssl: bool = False): | ||
response = requests.delete(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
def delete_index(endpoint: str, index_name: str, auth, verify_ssl: bool = False, session: Session = Session()): | ||
response = session.delete(f'{endpoint}/{index_name}', auth=auth, verify=verify_ssl) | ||
|
||
return response | ||
|
||
|
||
def delete_document(endpoint: str, index_name: str, doc_id: str, auth, | ||
verify_ssl: bool = False): | ||
response = requests.delete(f'{endpoint}/{index_name}/_doc/{doc_id}', auth=auth, verify=verify_ssl) | ||
verify_ssl: bool = False, session: Session = Session()): | ||
response = session.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, | ||
verify_ssl: bool = False): | ||
verify_ssl: bool = False, session: Session = Session()): | ||
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=verify_ssl) | ||
response = session.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, | ||
verify_ssl: bool = False): | ||
verify_ssl: bool = False, session: Session = Session()): | ||
url = f'{endpoint}/{index_name}/_doc/{doc_id}' | ||
headers = {'Content-Type': 'application/json'} | ||
response = requests.get(url, headers=headers, auth=auth, verify=verify_ssl) | ||
response = session.get(url, headers=headers, auth=auth, verify=verify_ssl) | ||
|
||
return response |
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