tox.ini 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Tox (http://tox.testrun.org/) is a tool for running tests
  2. # in multiple virtualenvs. This configuration file will run the
  3. # test suite on all supported python versions and providers.
  4. # To use it, "pip install tox" and then run "tox" from this directory.
  5. # You will have to set all required environment variables (below) before
  6. # running the tests.
  7. [tox]
  8. envlist = py3{.10,.13}-{aws,azure,gcp,openstack,mock},lint,mypy
  9. [testenv]
  10. commands = # see pyproject.toml for coverage options; setup.cfg for flake8
  11. # --durations reports the slowest tests with their setup/teardown.
  12. # The cloud suites' wall time is set by one or two long tests, and
  13. # this is the authoritative record of which - the alternative is
  14. # inferring it from gaps between result lines in the CI log, which
  15. # cannot separate a slow test from a worker waiting for work.
  16. coverage run --source=cloudbridge -m pytest -v --durations=25 {posargs:-n 5 tests/}
  17. # Combine parallel-mode data files and emit Cobertura XML for upload
  18. # by coverallsapp/github-action in CI. Locally this produces
  19. # coverage.xml in the project root, which IDEs can also consume.
  20. coverage combine
  21. coverage xml
  22. # Emit any CB_TEST_TRACE output (see tests/conftest.py). A no-op when tracing
  23. # is off, which is the default. This lives in commands_post rather than after
  24. # pytest in commands because tox stops at the first failing command, and a
  25. # failing run is the one whose trace is worth reading.
  26. commands_post = python -c "import glob,sys;[sys.stdout.write(open(f).read()) for f in sorted(glob.glob('cb-trace-*.log'))]"
  27. setenv =
  28. # Fix for moto import issue: https://github.com/travis-ci/travis-ci/issues/7940
  29. BOTO_CONFIG=/dev/null
  30. aws: CB_TEST_PROVIDER=aws
  31. azure: CB_TEST_PROVIDER=azure
  32. gcp: CB_TEST_PROVIDER=gcp
  33. openstack: CB_TEST_PROVIDER=openstack
  34. mock: CB_TEST_PROVIDER=mock
  35. # https://github.com/nedbat/coveragepy/issues/883#issuecomment-650562896
  36. COVERAGE_FILE=.coverage.{envname}
  37. passenv =
  38. PYTHONUNBUFFERED
  39. # Set to 1 to log every wait_for poll and every botocore retry, for
  40. # working out where a slow cloud suite is actually spending its time.
  41. # See tests/conftest.py; verbose by design, so opt-in.
  42. CB_TEST_TRACE
  43. aws: CB_IMAGE_AWS
  44. aws: CB_VM_TYPE_AWS
  45. aws: CB_PLACEMENT_AWS
  46. # Standard boto3 credential env vars — set by aws-actions/configure-aws-credentials
  47. # in CI (OIDC) and by `aws configure` locally. Required because tox does not
  48. # forward arbitrary env vars to the test process.
  49. aws: AWS_ACCESS_KEY_ID
  50. aws: AWS_SECRET_ACCESS_KEY
  51. aws: AWS_SESSION_TOKEN
  52. aws: AWS_REGION
  53. aws: AWS_DEFAULT_REGION
  54. # Cloudbridge-specific names, kept for backward compatibility with local dev
  55. # configs that set these.
  56. aws: AWS_ACCESS_KEY
  57. aws: AWS_SECRET_KEY
  58. azure: CB_IMAGE_AZURE
  59. azure: CB_VM_TYPE_AZURE
  60. azure: AZURE_SUBSCRIPTION_ID
  61. azure: AZURE_CLIENT_ID
  62. azure: AZURE_SECRET
  63. azure: AZURE_TENANT
  64. azure: AZURE_REGION_NAME
  65. azure: AZURE_RESOURCE_GROUP
  66. azure: AZURE_STORAGE_ACCOUNT
  67. azure: AZURE_VM_DEFAULT_USER_NAME
  68. azure: AZURE_PUBLIC_KEY_STORAGE_TABLE_NAME
  69. gcp: CB_IMAGE_GCP
  70. gcp: CB_VM_TYPE_GCP
  71. gcp: CB_PLACEMENT_GCP
  72. gcp: GCP_DEFAULT_REGION
  73. gcp: GCP_DEFAULT_ZONE
  74. gcp: GCP_PROJECT_NAME
  75. gcp: GCP_SERVICE_CREDS_FILE
  76. gcp: GCP_SERVICE_CREDS_DICT
  77. openstack: CB_IMAGE_OS
  78. openstack: CB_VM_TYPE_OS
  79. openstack: CB_PLACEMENT_OS
  80. openstack: OS_AUTH_URL
  81. openstack: OS_PASSWORD
  82. openstack: OS_PROJECT_NAME
  83. openstack: OS_TENANT_NAME
  84. openstack: OS_USERNAME
  85. openstack: OS_REGION_NAME
  86. openstack: OS_USER_DOMAIN_NAME
  87. openstack: OS_PROJECT_DOMAIN_NAME
  88. openstack: NOVA_SERVICE_NAME
  89. openstack: OS_APPLICATION_CREDENTIAL_ID
  90. openstack: OS_APPLICATION_CREDENTIAL_SECRET
  91. mock: CB_IMAGE_AWS
  92. mock: CB_VM_TYPE_AWS
  93. mock: CB_PLACEMENT_AWS
  94. mock: AWS_ACCESS_KEY
  95. mock: AWS_SECRET_KEY
  96. deps =
  97. -rrequirements.txt
  98. coverage
  99. pytest-xdist
  100. [testenv:lint]
  101. commands = flake8 cloudbridge tests
  102. deps =
  103. flake8
  104. flake8-import-order
  105. [testenv:mypy]
  106. # Type-check the codebase (see [tool.mypy] in pyproject.toml). The provider
  107. # layer is typed against the cloud SDKs, so the env installs the full deps
  108. # (via requirements.txt -> .[dev], which includes mypy) rather than running
  109. # bare: without the SDKs installed, mypy infers SDK values as Any and reports
  110. # spurious redundant-cast / unused-ignore errors that don't occur in a real
  111. # dev environment.
  112. deps = -rrequirements.txt
  113. commands = mypy