-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --create-external-resources pytest flag to opt into running end-t…
…o-end tests (#324)
- Loading branch information
1 parent
09c72a2
commit 4d2d9ea
Showing
8 changed files
with
88 additions
and
0 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
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,28 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--create-external-resources", | ||
action="store_true", | ||
default=False, | ||
help="Run tests that create external resources.", | ||
) | ||
|
||
|
||
def pytest_configure(config): | ||
config.addinivalue_line( | ||
"markers", "external: mark test as creates external resources" | ||
) | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
if config.getoption("--create-external-resources"): | ||
# --runslow given in cli: do not skip slow tests | ||
return | ||
skip_slow = pytest.mark.skip( | ||
reason="need --create-external-resources option to run" | ||
) | ||
for item in items: | ||
if "external" in item.keywords: | ||
item.add_marker(skip_slow) |
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 |
---|---|---|
|
@@ -84,4 +84,5 @@ this code. | |
:hidden: | ||
:caption: Developer | ||
|
||
testing.rst | ||
releasing.rst |
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,41 @@ | ||
Testing | ||
======= | ||
|
||
Tests in ``dask-cloudprovider`` and written and run using ``pytest``. | ||
|
||
To set up your testing environment run: | ||
|
||
.. code-block:: bash | ||
pip install -r requirements_test.txt | ||
To run tests run ``pytest`` from the root directory | ||
|
||
.. code-block:: bash | ||
pytest | ||
You may notice that many tests will be skipped. This is because those tests create external resources on cloud providers. You can set those tests to run with the | ||
``--create-external-resources`` flag. | ||
|
||
.. warning:: | ||
|
||
Running tests that create external resources are slow and will cost a small amount of credit on each cloud provider. | ||
|
||
.. code-block:: bash | ||
pytest -rs --create-external-resources | ||
It is also helpful to set the ``-rs`` flag here because tests may also skip if you do not have appropriate credentials to create those external resources. | ||
If this is the case the skip reason will contain instructions on how to set up those credentials. For example | ||
|
||
.. code-block:: | ||
SKIPPED [1] dask_cloudprovider/azure/tests/test_azurevm.py:49: | ||
You must configure your Azure resource group and vnet to run this test. | ||
$ export DASK_CLOUDPROVIDER__AZURE__LOCATION="<LOCATION>" | ||
$ export DASK_CLOUDPROVIDER__AZURE__AZUREVM__RESOURCE_GROUP="<RESOURCE GROUP>" | ||
$ export DASK_CLOUDPROVIDER__AZURE__AZUREVM__VNET="<VNET>" | ||
$ export DASK_CLOUDPROVIDER__AZURE__AZUREVM__SECURITY_GROUP="<SECUROTY GROUP>" | ||