tox.ini 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. # DIAGNOSTIC - REMOVE BEFORE MERGING. Turns on the wait/retry tracing
  30. # described in tests/conftest.py for the AWS suite. It lives here rather
  31. # than in the workflow env because the cloud workflow triggers on
  32. # pull_request_target, so its definition comes from the base branch and a
  33. # PR cannot change it; tox.ini is checked out from the PR head and can.
  34. aws: CB_TEST_TRACE=1
  35. azure: CB_TEST_PROVIDER=azure
  36. gcp: CB_TEST_PROVIDER=gcp
  37. openstack: CB_TEST_PROVIDER=openstack
  38. mock: CB_TEST_PROVIDER=mock
  39. # https://github.com/nedbat/coveragepy/issues/883#issuecomment-650562896
  40. COVERAGE_FILE=.coverage.{envname}
  41. passenv =
  42. PYTHONUNBUFFERED
  43. # Set to 1 to log every wait_for poll and every botocore retry, for
  44. # working out where a slow cloud suite is actually spending its time.
  45. # See tests/conftest.py; verbose by design, so opt-in.
  46. CB_TEST_TRACE
  47. aws: CB_IMAGE_AWS
  48. aws: CB_VM_TYPE_AWS
  49. aws: CB_PLACEMENT_AWS
  50. # Standard boto3 credential env vars — set by aws-actions/configure-aws-credentials
  51. # in CI (OIDC) and by `aws configure` locally. Required because tox does not
  52. # forward arbitrary env vars to the test process.
  53. aws: AWS_ACCESS_KEY_ID
  54. aws: AWS_SECRET_ACCESS_KEY
  55. aws: AWS_SESSION_TOKEN
  56. aws: AWS_REGION
  57. aws: AWS_DEFAULT_REGION
  58. # Cloudbridge-specific names, kept for backward compatibility with local dev
  59. # configs that set these.
  60. aws: AWS_ACCESS_KEY
  61. aws: AWS_SECRET_KEY
  62. azure: CB_IMAGE_AZURE
  63. azure: CB_VM_TYPE_AZURE
  64. azure: AZURE_SUBSCRIPTION_ID
  65. azure: AZURE_CLIENT_ID
  66. azure: AZURE_SECRET
  67. azure: AZURE_TENANT
  68. azure: AZURE_REGION_NAME
  69. azure: AZURE_RESOURCE_GROUP
  70. azure: AZURE_STORAGE_ACCOUNT
  71. azure: AZURE_VM_DEFAULT_USER_NAME
  72. azure: AZURE_PUBLIC_KEY_STORAGE_TABLE_NAME
  73. gcp: CB_IMAGE_GCP
  74. gcp: CB_VM_TYPE_GCP
  75. gcp: CB_PLACEMENT_GCP
  76. gcp: GCP_DEFAULT_REGION
  77. gcp: GCP_DEFAULT_ZONE
  78. gcp: GCP_PROJECT_NAME
  79. gcp: GCP_SERVICE_CREDS_FILE
  80. gcp: GCP_SERVICE_CREDS_DICT
  81. openstack: CB_IMAGE_OS
  82. openstack: CB_VM_TYPE_OS
  83. openstack: CB_PLACEMENT_OS
  84. openstack: OS_AUTH_URL
  85. openstack: OS_PASSWORD
  86. openstack: OS_PROJECT_NAME
  87. openstack: OS_TENANT_NAME
  88. openstack: OS_USERNAME
  89. openstack: OS_REGION_NAME
  90. openstack: OS_USER_DOMAIN_NAME
  91. openstack: OS_PROJECT_DOMAIN_NAME
  92. openstack: NOVA_SERVICE_NAME
  93. openstack: OS_APPLICATION_CREDENTIAL_ID
  94. openstack: OS_APPLICATION_CREDENTIAL_SECRET
  95. mock: CB_IMAGE_AWS
  96. mock: CB_VM_TYPE_AWS
  97. mock: CB_PLACEMENT_AWS
  98. mock: AWS_ACCESS_KEY
  99. mock: AWS_SECRET_KEY
  100. deps =
  101. -rrequirements.txt
  102. coverage
  103. pytest-xdist
  104. [testenv:lint]
  105. commands = flake8 cloudbridge tests
  106. deps =
  107. flake8
  108. flake8-import-order
  109. [testenv:mypy]
  110. # Type-check the codebase (see [tool.mypy] in pyproject.toml). The provider
  111. # layer is typed against the cloud SDKs, so the env installs the full deps
  112. # (via requirements.txt -> .[dev], which includes mypy) rather than running
  113. # bare: without the SDKs installed, mypy infers SDK values as Any and reports
  114. # spurious redundant-cast / unused-ignore errors that don't occur in a real
  115. # dev environment.
  116. deps = -rrequirements.txt
  117. commands = mypy