Skip to content

Commit c17ed5e

Browse files
Follow up PR to the previous testing fixes (#1847)
* Follow up PR to the previous testing fixes * Force tox v4 * Try adding an echo for debugging * Debug extras,sso * Escape commas? * Bash brace expansion doesn't work the way you thought it does * Install tox4 in docker files * Use --installpkg for tox4; does it work with wildcards? * Expand --installpkg wheels * Remove unnecessary factoring
1 parent ca8a580 commit c17ed5e

File tree

9 files changed

+50
-41
lines changed

9 files changed

+50
-41
lines changed

.github/workflows/build_test.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ jobs:
3636
- name: Upgrade setuptools, pip and wheel
3737
run: python -m pip install -U setuptools pip wheel
3838
- name: Install tox
39-
run: python -m pip install tox
39+
run: python -m pip install tox>=4
4040
- name: Set PY
4141
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
4242
- uses: actions/cache@v3
4343
with:
4444
path: ~/.cache/pre-commit
4545
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
4646
- name: Run fix_lint
47-
run: python -m tox -e fix_lint
47+
run: python -m tox run -e fix_lint
4848

4949
dependency:
5050
name: Check dependency
@@ -61,9 +61,9 @@ jobs:
6161
- name: Display Python version
6262
run: python -c "import sys; print(sys.version)"
6363
- name: Install tox
64-
run: python -m pip install tox tox-external-wheels
64+
run: python -m pip install tox>=4
6565
- name: Run tests
66-
run: python -m tox -e dependency
66+
run: python -m tox run -e dependency
6767

6868
build:
6969
needs: lint
@@ -152,17 +152,17 @@ jobs:
152152
- name: Upgrade setuptools, pip and wheel
153153
run: python -m pip install -U setuptools pip wheel
154154
- name: Install tox
155-
run: python -m pip install tox tox-external-wheels
155+
run: python -m pip install tox>=4
156156
- name: Run tests
157-
run: python -m tox -e "py${PYTHON_VERSION/\./}-{extras,unit,integ,pandas,sso}-ci"
157+
run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-{extras,unit,integ,pandas,sso}-ci | sed 's/ /,/g'`
158158
env:
159159
PYTHON_VERSION: ${{ matrix.python-version }}
160160
cloud_provider: ${{ matrix.cloud-provider }}
161161
PYTEST_ADDOPTS: --color=yes --tb=short
162162
TOX_PARALLEL_NO_SPINNER: 1
163163
shell: bash
164164
- name: Combine coverages
165-
run: python -m tox -e coverage --skip-missing-interpreters false
165+
run: python -m tox run -e coverage --skip-missing-interpreters false
166166
shell: bash
167167
- uses: actions/upload-artifact@v3
168168
with:
@@ -201,9 +201,9 @@ jobs:
201201
- name: Upgrade setuptools, pip and wheel
202202
run: python -m pip install -U setuptools pip wheel
203203
- name: Install tox
204-
run: python -m pip install tox
204+
run: python -m pip install tox>=4
205205
- name: Run tests
206-
run: python -m tox -e olddriver
206+
run: python -m tox run -e olddriver
207207
env:
208208
PYTHON_VERSION: ${{ matrix.python-version }}
209209
cloud_provider: ${{ matrix.cloud-provider }}
@@ -233,9 +233,9 @@ jobs:
233233
- name: Upgrade setuptools, pip and wheel
234234
run: python -m pip install -U setuptools pip wheel
235235
- name: Install tox
236-
run: python -m pip install tox
236+
run: python -m pip install tox>=4
237237
- name: Run tests
238-
run: python -m tox -e noarrowextension
238+
run: python -m tox run -e noarrowextension
239239
env:
240240
PYTHON_VERSION: ${{ matrix.python-version }}
241241
cloud_provider: ${{ matrix.cloud-provider }}
@@ -347,7 +347,7 @@ jobs:
347347
- name: Upgrade setuptools and pip
348348
run: python -m pip install -U setuptools pip wheel
349349
- name: Install tox
350-
run: python -m pip install tox
350+
run: python -m pip install tox>=4
351351
- name: Collect all coverages to one dir
352352
run: |
353353
python -c '
@@ -362,7 +362,7 @@ jobs:
362362
print("{} copy to {}".format(src_file, dst_file))
363363
shutil.copy(str(src_file), str(dst_file))'
364364
- name: Combine coverages
365-
run: python -m tox -e coverage
365+
run: python -m tox run -e coverage
366366
- name: Publish html coverage
367367
uses: actions/upload-artifact@v3
368368
with:

ci/docker/connector_test_lambda/Dockerfile310

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ RUN chmod 777 /home/user/snowflake-connector-python
77
ENV PATH="${PATH}:/opt/python/cp310-cp310/bin/"
88
ENV PYTHONPATH="${PYTHONPATH}:/home/user/snowflake-connector-python/ci/docker/connector_test_lambda/"
99

10-
RUN pip3 install -U pip setuptools wheel tox tox-external_wheels
10+
RUN pip3 install -U pip setuptools wheel tox>=4
1111

1212
CMD [ "app.handler" ]

ci/docker/connector_test_lambda/Dockerfile311

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ RUN chmod 777 /home/user/snowflake-connector-python
77
ENV PATH="${PATH}:/opt/python/cp311-cp311/bin/"
88
ENV PYTHONPATH="${PYTHONPATH}:/home/user/snowflake-connector-python/ci/docker/connector_test_lambda/"
99

10-
RUN pip3 install -U pip setuptools wheel tox tox-external_wheels
10+
RUN pip3 install -U pip setuptools wheel tox>=4
1111

1212
CMD [ "app.handler" ]

ci/docker/connector_test_lambda/Dockerfile312

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ RUN chmod 777 /home/user/snowflake-connector-python
55
ENV PATH="${PATH}:/opt/python/cp312-cp312/bin/"
66
ENV PYTHONPATH="${PYTHONPATH}:/home/user/snowflake-connector-python/ci/docker/connector_test_lambda/"
77

8-
RUN pip3 install -U pip setuptools wheel tox tox-external_wheels
8+
RUN pip3 install -U pip setuptools wheel tox>=4
99

1010
CMD [ "app.handler" ]

ci/docker/connector_test_lambda/Dockerfile38

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ RUN chmod 777 /home/user/snowflake-connector-python
77
ENV PATH="${PATH}:/opt/python/cp38-cp38/bin/"
88
ENV PYTHONPATH="${PYTHONPATH}:/home/user/snowflake-connector-python/ci/docker/connector_test_lambda/"
99

10-
RUN pip3 install -U pip setuptools wheel tox tox-external_wheels
10+
RUN pip3 install -U pip setuptools wheel tox>=4
1111

1212
CMD [ "app.handler" ]

ci/docker/connector_test_lambda/Dockerfile39

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ RUN chmod 777 /home/user/snowflake-connector-python
77
ENV PATH="${PATH}:/opt/python/cp39-cp39/bin/"
88
ENV PYTHONPATH="${PYTHONPATH}:/home/user/snowflake-connector-python/ci/docker/connector_test_lambda/"
99

10-
RUN pip3 install -U pip setuptools wheel tox tox-external_wheels
10+
RUN pip3 install -U pip setuptools wheel tox>=4
1111

1212
CMD [ "app.handler" ]

ci/docker/connector_test_lambda/app.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import sys
33
import xml.etree.ElementTree as ET
4+
from glob import glob
45
from pathlib import Path
56
from subprocess import PIPE, Popen
67

@@ -13,23 +14,30 @@
1314
def run_tests():
1415
"""Run tests using tox"""
1516
LOGGER.info("Running tests..")
17+
# Get the list of wheels; pass them to tox, one per --installpkg option.
18+
args = [
19+
"python",
20+
"-m",
21+
"tox",
22+
"run",
23+
"-e",
24+
f"py{PY_SHORT_VER}-lambda-ci",
25+
"-c",
26+
f"{REPO_PATH}/tox.ini",
27+
"--workdir",
28+
REPO_PATH,
29+
]
30+
for wheel in glob(f"{REPO_PATH}/dist/*.whl"):
31+
args.extend(["--installpkg", wheel])
32+
33+
LOGGER.info(f"Popen args: {args}")
34+
1635
test_log, err = Popen(
17-
[
18-
"python",
19-
"-m",
20-
"tox",
21-
"-e",
22-
f"py{PY_SHORT_VER}{{-lambda}}-ci",
23-
"-c",
24-
f"{REPO_PATH}/tox.ini",
25-
"--workdir",
26-
REPO_PATH,
27-
"--external_wheels",
28-
f"{REPO_PATH}/dist/*.whl",
29-
],
36+
args,
3037
stdout=PIPE,
3138
stderr=PIPE,
3239
).communicate()
40+
3341
LOGGER.info(test_log)
3442
LOGGER.info(err)
3543
return test_log.decode("utf-8")

test/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,22 @@ tox -e "fix_lint,py37{,-pandas,-sso}"
2525
```
2626

2727
**NOTE** Some integration tests may be sensitive to the cloud provider of the
28-
account that the test suite connects to. By default, when testing locally,
29-
the "provider" is called `dev`, but you may see some test failures with this
30-
provider (which isn't really a provider). To eliminate this false failure,
31-
set the environment variable `cloud_provider` to one of `aws`, `gcp`, or
32-
`azure` as appropriate for the account you're running integration tests
33-
against. This is handled correctly in CI so should only affect local
34-
developers. In the future, we'll try to make this automatic by querying the
35-
account after the connection is made.
28+
account that the test suite connects to. The default `dev` provider acts like
29+
all cloud providers, but you may see some test failures during integration
30+
tests, depending on the actual cloud of the account you are connecting to. To
31+
eliminate any such false failure, set the environment variable
32+
`cloud_provider` to one of `aws`, `gcp`, or `azure` as appropriate for the
33+
account you're running the integration tests against. This is handled
34+
correctly in CI so should only affect your local testing. In the future,
35+
we'll try to make this automatic by querying the account after the connection
36+
is made.
3637

3738
### Running a single test
3839

3940
Enter the tox environment you want (e.g. `py38`) and run `pytest` from there:
4041

4142
```shell
42-
source .tox/py38/bin/activate
43+
. .tox/py38/bin/activate
4344
pytest -v test/integ/test_connection.py::test_basic
4445
```
4546

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ source = src/snowflake/connector
1616
*/fips_env/lib/python*/site-packages/snowflake/connector
1717

1818
[tox]
19-
minversion = 3.7
19+
minversion = 4
2020
envlist = fix_lint,
2121
py{37,38,39,310,311,312}-{extras,unit-parallel,integ,pandas,sso},
2222
coverage

0 commit comments

Comments
 (0)