Skip to content

Commit 9596d0a

Browse files
authoredJan 10, 2023
SNOW-716364: Revert client app id and add connector regression tests (snowflakedb#369)
1 parent a84fa77 commit 9596d0a

File tree

6 files changed

+91
-24
lines changed

6 files changed

+91
-24
lines changed
 

‎.github/workflows/build_test.yml

+42-1
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,51 @@ jobs:
9797
.tox/.coverage
9898
.tox/coverage.xml
9999
100+
test_connector_regression:
101+
name: Connector Regression Test ${{ matrix.os.download_name }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
102+
needs: lint
103+
runs-on: ${{ matrix.os.image_name }}
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
os:
108+
- image_name: ubuntu-latest
109+
download_name: manylinux_x86_64
110+
python-version: ["3.7"]
111+
cloud-provider: [aws]
112+
steps:
113+
- uses: actions/checkout@v2
114+
with:
115+
submodules: true
116+
- name: Set up Python
117+
uses: actions/setup-python@v2
118+
with:
119+
python-version: ${{ matrix.python-version }}
120+
- name: Display Python version
121+
run: python -c "import sys; print(sys.version)"
122+
- name: Setup parameters file
123+
shell: bash
124+
env:
125+
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
126+
run: |
127+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" \
128+
.github/workflows/parameters/parameters_${{ matrix.cloud-provider }}.py.gpg > tests/connector_regression/test/parameters.py
129+
- name: Upgrade setuptools, pip and wheel
130+
run: python -m pip install -U setuptools pip wheel
131+
- name: Install tox
132+
run: python -m pip install tox
133+
- name: List installed packages
134+
run: python -m pip freeze
135+
- name: Run tests
136+
run: python -m tox -e connector_regression --skip-missing-interpreters false
137+
env:
138+
PYTEST_ADDOPTS: -vvv --color=yes --tb=short
139+
TOX_PARALLEL_NO_SPINNER: 1
140+
100141
combine-coverage:
101142
if: ${{ success() || failure() }}
102143
name: Combine coverage
103-
needs: test
144+
needs: [test, test_connector_regression]
104145
runs-on: ubuntu-latest
105146
steps:
106147
- uses: actions/checkout@v2

‎.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tests/connector_regression"]
2+
path = tests/connector_regression
3+
url = git@github.com:snowflakedb/snowflake-connector-python

‎src/snowflake/sqlalchemy/snowdialect.py

-7
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
_CUSTOM_Float,
6262
_CUSTOM_Time,
6363
)
64-
from .util import _update_connection_application_name
6564

6665
colspecs = {
6766
Date: _CUSTOM_Date,
@@ -835,12 +834,6 @@ def get_table_comment(self, connection, table_name, schema=None, **kw):
835834
else None
836835
}
837836

838-
def connect(self, *cargs, **cparams):
839-
snowflake_conn = super().connect(
840-
*cargs, **_update_connection_application_name(**cparams)
841-
)
842-
return snowflake_conn
843-
844837

845838
@sa_vnt.listens_for(Table, "before_create")
846839
def check_table(table, connection, _ddl_runner, **kw):

‎tests/connector_regression

Submodule connector_regression added at a313240

‎tests/test_core.py

+27-14
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,35 @@ def _create_users_addresses_tables_without_sequence(engine_testaccount, metadata
9999
return users, addresses
100100

101101

102-
def verify_engine_connection(engine):
102+
def verify_engine_connection(engine, verify_app_name):
103103
with engine.connect() as conn:
104104
results = conn.execute(text("select current_version()")).fetchone()
105-
assert conn.connection.driver_connection.application == APPLICATION_NAME
106-
assert (
107-
conn.connection.driver_connection._internal_application_name
108-
== APPLICATION_NAME
109-
)
110-
assert (
111-
conn.connection.driver_connection._internal_application_version
112-
== SNOWFLAKE_SQLALCHEMY_VERSION
113-
)
105+
if verify_app_name:
106+
assert conn.connection.driver_connection.application == APPLICATION_NAME
107+
assert (
108+
conn.connection.driver_connection._internal_application_name
109+
== APPLICATION_NAME
110+
)
111+
assert (
112+
conn.connection.driver_connection._internal_application_version
113+
== SNOWFLAKE_SQLALCHEMY_VERSION
114+
)
114115
assert results is not None
115116

116117

117-
def test_connect_args():
118+
@pytest.mark.parametrize(
119+
"verify_app_name",
120+
[
121+
False,
122+
pytest.param(
123+
True,
124+
marks=pytest.mark.xfail(
125+
reason="Pending backend service to recognize SnowflakeSQLAlchemy as a valid client app id"
126+
),
127+
),
128+
],
129+
)
130+
def test_connect_args(verify_app_name):
118131
"""
119132
Tests connect string
120133
@@ -135,7 +148,7 @@ def test_connect_args():
135148
)
136149
)
137150
try:
138-
verify_engine_connection(engine)
151+
verify_engine_connection(engine, verify_app_name)
139152
finally:
140153
engine.dispose()
141154

@@ -150,7 +163,7 @@ def test_connect_args():
150163
)
151164
)
152165
try:
153-
verify_engine_connection(engine)
166+
verify_engine_connection(engine, verify_app_name)
154167
finally:
155168
engine.dispose()
156169

@@ -166,7 +179,7 @@ def test_connect_args():
166179
)
167180
)
168181
try:
169-
verify_engine_connection(engine)
182+
verify_engine_connection(engine, verify_app_name)
170183
finally:
171184
engine.dispose()
172185

‎tox.ini

+18-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
min_version = 4.0.0
33
envlist = fix_lint,
44
py{37,38,39,310}{,-pandas},
5-
coverage
5+
coverage,
6+
connector_regression
67
skip_missing_interpreters = true
78

89
[testenv]
@@ -50,6 +51,13 @@ commands = pytest \
5051
--run_v20_sqlalchemy \
5152
{posargs:tests}
5253

54+
[testenv:connector_regression]
55+
deps = pendulum
56+
commands = pytest \
57+
{env:SNOWFLAKE_PYTEST_OPTS:} \
58+
-m "not gcp and not azure" \
59+
{posargs:tests/connector_regression/test}
60+
5361
[testenv:.pkg_external]
5462
deps = build
5563
package_glob = {toxinidir}{/}dist{/}*.whl
@@ -85,14 +93,22 @@ commands = pre-commit run --all-files
8593
python -c 'import pathlib; print("hint: run \{\} install to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}") / "bin" / "pre-commit"))'
8694

8795
[pytest]
88-
addopts = -ra --strict-markers --ignore=tests/sqlalchemy_test_suite
96+
addopts = -ra --strict-markers --ignore=tests/sqlalchemy_test_suite --ignore=tests/connector_regression
8997
junit_family = legacy
9098
log_level = info
9199
markers =
100+
# Optional dependency groups markers
101+
lambda: AWS lambda tests
102+
pandas: tests for pandas integration
103+
sso: tests for sso optional dependency integration
92104
# Cloud provider markers
93105
aws: tests for Amazon Cloud storage
94106
azure: tests for Azure Cloud storage
95107
gcp: tests for Google Cloud storage
108+
# Test type markers
109+
integ: integration tests
110+
unit: unit tests
111+
skipolddriver: skip for old driver tests
96112
# Other markers
97113
timeout: tests that need a timeout time
98114
internal: tests that could but should only run on our internal CI

0 commit comments

Comments
 (0)
Please sign in to comment.