tox.ini 5.0 KB

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