-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add Amazon OpenSearch Serverless Support (#29)
* Fix failing tests expected formatting Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Add serverless support for OS connections Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Add serverless tests Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Remove unused import Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Capitalize Serverless Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Add vcrpy dep Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Revert adding vcrpy dep Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Add vcrpy again Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Revert "Fix failing tests expected formatting" This reverts commit d8b24df. Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Add vcr to tox config Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Fix usage of credentials fixture Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Correct limit in `TestMain.test_explain` Signed-off-by: Simeon Widdis <sawiddis@amazon.com> * Fix lychee Signed-off-by: Simeon Widdis <sawiddis@amazon.com> --------- Signed-off-by: Simeon Widdis <sawiddis@amazon.com>
Showing
11 changed files
with
167 additions
and
17 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
http://localhost:9200/ |
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
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,5 +1,6 @@ | ||
pytest==7.4.2 | ||
pytest==8.3.3 | ||
mock==3.0.5 | ||
pexpect==3.3 | ||
twine==1.13.0 | ||
tox>=1.9.2 | ||
tox>=1.9.2 | ||
pytest-vcr>=1.0.2 |
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,102 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Authorization: | ||
- AWS4-HMAC-SHA256 Credential=testing/20240924/us-east-1/aoss/aws4_request, | ||
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-security-token, | ||
Signature=6835b7bf753ce295f7bcfe9eceb26c6150e3ac95b3f8b829d8ab280b851b5c6e | ||
content-type: | ||
- application/json | ||
user-agent: | ||
- opensearch-py/1.0.0 (Python 3.12.5) | ||
x-amz-content-sha256: | ||
- e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||
x-amz-date: | ||
- 20240924T221825Z | ||
x-amz-security-token: | ||
- redacted | ||
method: GET | ||
uri: https://example_endpoint.beta-us-east-1.aoss.amazonaws.com:443/_alias | ||
response: | ||
body: | ||
string: '{"target_index":{"aliases":{}},".opensearch_dashboards_1":{"aliases":{".opensearch_dashboards":{}}},"sample-index1":{"aliases":{}}}' | ||
headers: | ||
content-length: | ||
- '131' | ||
content-type: | ||
- application/json; charset=UTF-8 | ||
date: | ||
- Tue, 24 Sep 2024 22:18:26 GMT | ||
server: | ||
- aoss-amazon-m | ||
x-envoy-upstream-service-time: | ||
- '49' | ||
x-request-id: | ||
- d77aa3ab-e474-98fc-b33d-1841f27e8b29 | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: '{"query":"SHOW TABLES LIKE %"}' | ||
headers: | ||
Accept-Charset: | ||
- UTF-8 | ||
Authorization: | ||
- AWS4-HMAC-SHA256 Credential=testing/20240924/us-east-1/aoss/aws4_request, | ||
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-security-token, | ||
Signature=272ec9c51f0be839579f97311adce6f2c757e77498f3552ac9c794e8e951cf68 | ||
Content-Length: | ||
- '30' | ||
Content-Type: | ||
- application/json | ||
user-agent: | ||
- opensearch-py/1.0.0 (Python 3.12.5) | ||
x-amz-content-sha256: | ||
- e53aaf06a94a0ef15a30e8ccb84866025b8ec4fec42338a4683a735b0fae6e9d | ||
x-amz-date: | ||
- 20240924T221826Z | ||
x-amz-security-token: | ||
- redacted | ||
method: POST | ||
uri: https://example_endpoint.beta-us-east-1.aoss.amazonaws.com:443/_plugins/_sql | ||
response: | ||
body: | ||
string: "{\n \"schema\": [\n {\n \"name\": \"TABLE_CAT\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"TABLE_SCHEM\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"TABLE_NAME\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"TABLE_TYPE\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"REMARKS\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"TYPE_CAT\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"TYPE_SCHEM\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"TYPE_NAME\",\n \"type\": | ||
\"keyword\"\n },\n {\n \"name\": \"SELF_REFERENCING_COL_NAME\",\n | ||
\ \"type\": \"keyword\"\n },\n {\n \"name\": \"REF_GENERATION\",\n | ||
\ \"type\": \"keyword\"\n }\n ],\n \"datarows\": [\n [\n \"opensearch\",\n | ||
\ null,\n \".opensearch_dashboards_1\",\n \"BASE TABLE\",\n | ||
\ null,\n null,\n null,\n null,\n null,\n null\n | ||
\ ],\n [\n \"opensearch\",\n null,\n \"sample-index1\",\n | ||
\ \"BASE TABLE\",\n null,\n null,\n null,\n null,\n | ||
\ null,\n null\n ],\n [\n \"opensearch\",\n null,\n | ||
\ \"target_index\",\n \"BASE TABLE\",\n null,\n null,\n | ||
\ null,\n null,\n null,\n null\n ],\n [\n \"opensearch\",\n | ||
\ null,\n \".opensearch_dashboards\",\n \"BASE TABLE\",\n null,\n | ||
\ null,\n null,\n null,\n null,\n null\n ]\n ],\n | ||
\ \"total\": 4,\n \"size\": 4,\n \"status\": 200\n}" | ||
headers: | ||
content-length: | ||
- '1402' | ||
content-type: | ||
- application/json; charset=UTF-8 | ||
date: | ||
- Tue, 24 Sep 2024 22:18:26 GMT | ||
server: | ||
- aoss-amazon-s | ||
x-envoy-upstream-service-time: | ||
- '27' | ||
x-request-id: | ||
- 644a3560-53d4-49d0-a46c-959353a62724 | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
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,36 @@ | ||
import os | ||
import pytest | ||
from opensearch_sql_cli.opensearch_connection import OpenSearchConnection | ||
import vcr | ||
|
||
|
||
sql_cli_vcr = vcr.VCR( | ||
cassette_library_dir="tests/cassettes", | ||
record_mode="once", | ||
match_on=["method", "path", "query", "body"], | ||
) | ||
|
||
class TestServerless: | ||
@pytest.fixture(scope="function") | ||
def aws_serverless_credentials(self): | ||
os.environ["TEST_ENDPOINT_URL"] = "https://example_endpoint.beta-us-east-1.aoss.amazonaws.com:443" | ||
os.environ["AWS_ACCESS_KEY_ID"] = "testing" | ||
os.environ["AWS_SECRET_ACCESS_KEY"] = "testing" | ||
os.environ["AWS_SESSION_TOKEN"] = "testing" | ||
|
||
|
||
def test_show_tables(self, aws_serverless_credentials): | ||
with sql_cli_vcr.use_cassette("serverless_show_tables.yaml"): | ||
aes_test_executor = OpenSearchConnection(endpoint=os.environ["TEST_ENDPOINT_URL"], use_aws_authentication=True) | ||
aes_test_executor.set_connection() | ||
|
||
response = aes_test_executor.client.transport.perform_request( | ||
method="POST", | ||
url="/_plugins/_sql", | ||
body={"query": "SHOW TABLES LIKE %"}, | ||
headers={"Content-Type": "application/json", "Accept-Charset": "UTF-8"}, | ||
) | ||
|
||
assert response["status"] == 200 | ||
assert response["total"] == 4 | ||
assert response["datarows"][0][2] == ".opensearch_dashboards_1" |
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ envlist = py38 | |
deps = pytest==4.6.3 | ||
mock==3.0.5 | ||
pexpect==3.3 | ||
pytest-vcr==1.0.2 | ||
commands = pytest |