tox.ini 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. # Emit any CB_TEST_TRACE output (see tests/conftest.py). A no-op
  18. # when tracing is off, which is the default.
  19. python -c "import glob,sys;[sys.stdout.write(open(f).read()) for f in sorted(glob.glob('cb-trace-*.log'))]"
  20. # Combine parallel-mode data files and emit Cobertura XML for upload
  21. # by coverallsapp/github-action in CI. Locally this produces
  22. # coverage.xml in the project root, which IDEs can also consume.
  23. coverage combine
  24. coverage xml
  25. setenv =
  26. # Fix for moto import issue: https://github.com/travis-ci/travis-ci/issues/7940
  27. BOTO_CONFIG=/dev/null
  28. aws: CB_TEST_PROVIDER=aws
  29. azure: CB_TEST_PROVIDER=azure
  30. gcp: CB_TEST_PROVIDER=gcp
  31. openstack: CB_TEST_PROVIDER=openstack
  32. mock: CB_TEST_PROVIDER=mock
  33. # https://github.com/nedbat/coveragepy/issues/883#issuecomment-650562896
  34. COVERAGE_FILE=.coverage.{envname}
  35. passenv =
  36. PYTHONUNBUFFERED
  37. # Set to 1 to log every wait_for poll and every botocore retry, for
  38. # working out where a slow cloud suite is actually spending its time.
  39. # See tests/conftest.py; verbose by design, so opt-in.
  40. CB_TEST_TRACE
  41. aws: CB_IMAGE_AWS
  42. aws: CB_VM_TYPE_AWS
  43. aws: CB_PLACEMENT_AWS
  44. # Standard boto3 credential env vars — set by aws-actions/configure-aws-credentials
  45. # in CI (OIDC) and by `aws configure` locally. Required because tox does not
  46. # forward arbitrary env vars to the test process.
  47. aws: AWS_ACCESS_KEY_ID
  48. aws: AWS_SECRET_ACCESS_KEY
  49. aws: AWS_SESSION_TOKEN
  50. aws: AWS_REGION
  51. aws: AWS_DEFAULT_REGION
  52. # Cloudbridge-specific names, kept for backward compatibility with local dev
  53. # configs that set these.
  54. aws: AWS_ACCESS_KEY
  55. aws: AWS_SECRET_KEY
  56. azure: CB_IMAGE_AZURE
  57. azure: CB_VM_TYPE_AZURE
  58. azure: AZURE_SUBSCRIPTION_ID
  59. azure: AZURE_CLIENT_ID
  60. azure: AZURE_SECRET
  61. azure: AZURE_TENANT
  62. azure: AZURE_REGION_NAME
  63. azure: AZURE_RESOURCE_GROUP
  64. azure: AZURE_STORAGE_ACCOUNT
  65. azure: AZURE_VM_DEFAULT_USER_NAME
  66. azure: AZURE_PUBLIC_KEY_STORAGE_TABLE_NAME
  67. gcp: CB_IMAGE_GCP
  68. gcp: CB_VM_TYPE_GCP
  69. gcp: CB_PLACEMENT_GCP
  70. gcp: GCP_DEFAULT_REGION
  71. gcp: GCP_DEFAULT_ZONE
  72. gcp: GCP_PROJECT_NAME
  73. gcp: GCP_SERVICE_CREDS_FILE
  74. gcp: GCP_SERVICE_CREDS_DICT
  75. openstack: CB_IMAGE_OS
  76. openstack: CB_VM_TYPE_OS
  77. openstack: CB_PLACEMENT_OS
  78. openstack: OS_AUTH_URL
  79. openstack: OS_PASSWORD
  80. openstack: OS_PROJECT_NAME
  81. openstack: OS_TENANT_NAME
  82. openstack: OS_USERNAME
  83. openstack: OS_REGION_NAME
  84. openstack: OS_USER_DOMAIN_NAME
  85. openstack: OS_PROJECT_DOMAIN_NAME
  86. openstack: NOVA_SERVICE_NAME
  87. openstack: OS_APPLICATION_CREDENTIAL_ID
  88. openstack: OS_APPLICATION_CREDENTIAL_SECRET
  89. mock: CB_IMAGE_AWS
  90. mock: CB_VM_TYPE_AWS
  91. mock: CB_PLACEMENT_AWS
  92. mock: AWS_ACCESS_KEY
  93. mock: AWS_SECRET_KEY
  94. deps =
  95. -rrequirements.txt
  96. coverage
  97. pytest-xdist
  98. [testenv:lint]
  99. commands = flake8 cloudbridge tests
  100. deps =
  101. flake8
  102. flake8-import-order
  103. [testenv:mypy]
  104. # Type-check the codebase (see [tool.mypy] in pyproject.toml). The provider
  105. # layer is typed against the cloud SDKs, so the env installs the full deps
  106. # (via requirements.txt -> .[dev], which includes mypy) rather than running
  107. # bare: without the SDKs installed, mypy infers SDK values as Any and reports
  108. # spurious redundant-cast / unused-ignore errors that don't occur in a real
  109. # dev environment.
  110. deps = -rrequirements.txt
  111. commands = mypy