Tests: Verify Athena QueryResults work in ProxyMode (#7395)
This commit is contained in:
parent
b331628603
commit
3064a28202
2
.github/workflows/tests_proxymode.yml
vendored
2
.github/workflows/tests_proxymode.yml
vendored
@ -41,7 +41,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TEST_PROXY_MODE: ${{ true }}
|
TEST_PROXY_MODE: ${{ true }}
|
||||||
run: |
|
run: |
|
||||||
pytest -sv tests/test_acmpca tests/test_awslambda tests/test_apigateway tests/test_core/test_proxy.py tests/test_s3
|
pytest -sv tests/test_acmpca tests/test_athena tests/test_awslambda tests/test_apigateway tests/test_core/test_proxy.py tests/test_s3
|
||||||
- name: "Stop MotoProxy"
|
- name: "Stop MotoProxy"
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
@ -287,7 +287,7 @@ def test_get_query_results():
|
|||||||
assert result["ResultSet"]["Rows"] == []
|
assert result["ResultSet"]["Rows"] == []
|
||||||
assert result["ResultSet"]["ResultSetMetadata"]["ColumnInfo"] == []
|
assert result["ResultSet"]["ResultSetMetadata"]["ColumnInfo"] == []
|
||||||
|
|
||||||
if not settings.TEST_SERVER_MODE:
|
if settings.TEST_DECORATOR_MODE:
|
||||||
backend = athena_backends[DEFAULT_ACCOUNT_ID]["us-east-1"]
|
backend = athena_backends[DEFAULT_ACCOUNT_ID]["us-east-1"]
|
||||||
rows = [{"Data": [{"VarCharValue": ".."}]}]
|
rows = [{"Data": [{"VarCharValue": ".."}]}]
|
||||||
column_info = [
|
column_info = [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import boto3
|
import boto3
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from moto import mock_aws, settings
|
from moto import mock_aws, moto_proxy, settings
|
||||||
|
|
||||||
DEFAULT_COLUMN_INFO = [
|
DEFAULT_COLUMN_INFO = [
|
||||||
{
|
{
|
||||||
@ -35,9 +35,13 @@ def test_set_athena_result():
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
kwargs = {}
|
||||||
|
if settings.is_test_proxy_mode():
|
||||||
|
add_proxy_details(kwargs)
|
||||||
resp = requests.post(
|
resp = requests.post(
|
||||||
f"http://{base_url}/moto-api/static/athena/query-results",
|
f"http://{base_url}/moto-api/static/athena/query-results",
|
||||||
json=athena_result,
|
json=athena_result,
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
assert resp.status_code == 201
|
assert resp.status_code == 201
|
||||||
|
|
||||||
@ -60,6 +64,9 @@ def test_set_multiple_athena_result():
|
|||||||
base_url = (
|
base_url = (
|
||||||
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
|
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
|
||||||
)
|
)
|
||||||
|
kwargs = {}
|
||||||
|
if settings.is_test_proxy_mode():
|
||||||
|
add_proxy_details(kwargs)
|
||||||
|
|
||||||
athena_result = {
|
athena_result = {
|
||||||
"results": [
|
"results": [
|
||||||
@ -71,6 +78,7 @@ def test_set_multiple_athena_result():
|
|||||||
resp = requests.post(
|
resp = requests.post(
|
||||||
f"http://{base_url}/moto-api/static/athena/query-results",
|
f"http://{base_url}/moto-api/static/athena/query-results",
|
||||||
json=athena_result,
|
json=athena_result,
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
assert resp.status_code == 201
|
assert resp.status_code == 201
|
||||||
|
|
||||||
@ -100,6 +108,9 @@ def test_set_athena_result_with_custom_region_account():
|
|||||||
base_url = (
|
base_url = (
|
||||||
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
|
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
|
||||||
)
|
)
|
||||||
|
kwargs = {}
|
||||||
|
if settings.is_test_proxy_mode():
|
||||||
|
add_proxy_details(kwargs)
|
||||||
|
|
||||||
athena_result = {
|
athena_result = {
|
||||||
"account_id": "222233334444",
|
"account_id": "222233334444",
|
||||||
@ -116,6 +127,7 @@ def test_set_athena_result_with_custom_region_account():
|
|||||||
resp = requests.post(
|
resp = requests.post(
|
||||||
f"http://{base_url}/moto-api/static/athena/query-results",
|
f"http://{base_url}/moto-api/static/athena/query-results",
|
||||||
json=athena_result,
|
json=athena_result,
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
assert resp.status_code == 201
|
assert resp.status_code == 201
|
||||||
|
|
||||||
@ -157,3 +169,11 @@ def test_set_athena_result_with_custom_region_account():
|
|||||||
client = boto3.client("athena", region_name="eu-west-1")
|
client = boto3.client("athena", region_name="eu-west-1")
|
||||||
details = client.get_query_results(QueryExecutionId="anyid")["ResultSet"]
|
details = client.get_query_results(QueryExecutionId="anyid")["ResultSet"]
|
||||||
assert details["Rows"] == []
|
assert details["Rows"] == []
|
||||||
|
|
||||||
|
|
||||||
|
def add_proxy_details(kwargs):
|
||||||
|
kwargs["proxies"] = {
|
||||||
|
"http": "http://localhost:5005",
|
||||||
|
"https": "http://localhost:5005",
|
||||||
|
}
|
||||||
|
kwargs["verify"] = moto_proxy.__file__.replace("__init__.py", "ca.crt")
|
||||||
|
Loading…
Reference in New Issue
Block a user