Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run more tests via Pants + pytest #6202

Draft
wants to merge 98 commits into
base: master
Choose a base branch
from
Draft

Run more tests via Pants + pytest #6202

wants to merge 98 commits into from

Commits on Sep 12, 2024

  1. Upgrade to pants 2.23.0a0

    Lockfile diff: lockfiles/pants-plugins.lock [pants-plugins]
    
    ==                    Upgraded dependencies                     ==
    
      pantsbuild-pants               2.22.0       -->   2.23.0a0
      pantsbuild-pants-testutil      2.22.0       -->   2.23.0a0
      pex                            2.3.1        -->   2.16.2
      typing-extensions              4.3.0        -->   4.12.2
    
    ==                      Added dependencies                      ==
    
      libcst                         1.4.0
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    bce1194 View commit details
    Browse the repository at this point in the history
  2. pants: rename [export].py_hermetic_scripts option

    It is now a per-resolve option:
    [export].py_non_hermetic_scripts_in_resolve = ["st2"]
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    0046645 View commit details
    Browse the repository at this point in the history
  3. update changelog entry

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    1e91b62 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    dc9f98b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d85903a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    60b5814 View commit details
    Browse the repository at this point in the history
  7. use fixtures imports for test_content_loader

    First, add metadata so pants can load the packs base path fixtures
    from st2common/resources for the content laoder tests.
    Second, add a fixture.py file in each base path, similar to the
    fixtures we have in st2tests, so that pants dependency inferrence
    can see where these fixtures are used.
    Third, the fixture file ended up creating a __pycache__ directory
    in the packs base paths which made tests fail due to an unexpected
    extra "pack" named "__pycache__". So, I excluded that as a valid
    pack name.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    7228e10 View commit details
    Browse the repository at this point in the history
  8. use fixtures imports for test_logger

    First, add metadata so pants can load the conf fixture from
    st2common/tests/resources for the logger test.
    
    Second, add a fixture.py file, similar to the fixtures we have in
    st2tests, so that pants dependency inferrence can see where these
    fixtures are used.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    4aefa9d View commit details
    Browse the repository at this point in the history
  9. use fixture import for test_plugin_loader

    First, add metadata so pants can load the loadableplugin fixture
    from st2common/tests/resources for the plugin loader test.
    
    Second, add a fixture.py file, similar to the fixtures we have in
    st2tests, so that pants dependency inferrence can see where these
    fixtures are used.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    9fddea6 View commit details
    Browse the repository at this point in the history
  10. pants: ignore test_dist_utils.py since we already ignore dist_utils.py

    Once pants can build our packages, all of the dist_utils bits should be deleted.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    717e2d0 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    1707923 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    c90fd8b View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    81bf32e View commit details
    Browse the repository at this point in the history
  14. tests: Ensure tests can run in isolation

    Various tests were relying on the side effects of tests that nosetest
    runs before they ran. These include:
    - 3 in test_action_alias_utils.py::TestInjectImmutableParameters
    - 2 in test_jinja_render_data_filters.py
    - 1 in test_logging_middleware.py
    - 9 in test_operators.py::SearchOperatorTest
    - 3 in test_util_payload.py
    
    In particular, the oslo config initialization from the tests in
    st2common/tests/unit/services/ happens before these test ran, obscuring
    their dependence on this initialization.
    
    Pants runs each test file separately for fine-grained caching.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    49f7253 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    a7d435c View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    c54dafc View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    1f1ae2e View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    8a2f489 View commit details
    Browse the repository at this point in the history
  19. tests: drop unnecessary calls to tests_config.parse_args()

    This looks like copy pasta as some of these files have a comment
    saying that running this before importing something else is required.
    However, by importing st2tests, that already implicitly happens
    in st2tests/st2tests/base.py. Then tests_config.parse_args() gets called
    again in the class init.
    
    Plus, I reviewed all the other imports, and none of them have import time
    side effects that matter for oslo config bits. So, these calls are not
    necessary, and the comments about them are wrong.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    785add8 View commit details
    Browse the repository at this point in the history
  20. tests: add missing monkey_patch for isolated test support

    pants runs each test file separately. test_workflow_rerun only worked
    under nosetest because earlier files already did the monkey_patch.
    Without this, running this file in isolation, with either nosetest
    or pytest, hangs.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    88a5d88 View commit details
    Browse the repository at this point in the history
  21. tests: allow overriding system_user.user via env vars in tests

    This way we do not need to patch the conf files in so many places.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    cf93d96 View commit details
    Browse the repository at this point in the history
  22. pants ci: run st2common unit tests

    all are passing locally now
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    8869245 View commit details
    Browse the repository at this point in the history
  23. fmt with black

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    6a0e971 View commit details
    Browse the repository at this point in the history
  24. satisfy pylint

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    69ef3db View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    d4a943f View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    65cae40 View commit details
    Browse the repository at this point in the history
  27. Remove duplicate test fixture files

    These are not test files:
    - st2actions/tests/unit/test_async_runner.py
    - st2actions/tests/unit/test_polling_async_runner.py
    
    It looks like they were copied to st2tests/st2tests/mocks/runners/
    at some point. Nothing imports from or uses the copies in st2actions,
    so just delete them.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    8a17a7b View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    6361089 View commit details
    Browse the repository at this point in the history
  29. tests: reorder st2tests imports in st2actions tests for import side-e…

    …ffects
    
    importing anything form st2tests already handles running
    st2tests.config.parse_args() on import before loading
    the files from st2common that need those side effects.
    So, rely on that, and on the db test case base classes
    for running parse_args() where appropriate.
    
    The import side-effects are unfortunate, but this reduces
    how many places are making those changes.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    656ae8e View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    c6346c2 View commit details
    Browse the repository at this point in the history
  31. tests: reorder st2tests imports in st2common tests for import side-ef…

    …fects
    
    importing anything form st2tests already handles running
    st2tests.config.parse_args() on import before loading
    the files from st2common that need those side effects.
    So, rely on that, and on the db test case base classes
    for running parse_args() where appropriate.
    
    The import side-effects are unfortunate, but this reduces
    how many places are making those changes.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    ddca590 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    c25eba5 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    fc65de2 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    2b54d84 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    b2db72d View commit details
    Browse the repository at this point in the history
  36. pants: run unit tests for st2tests/ st2actions/ st2reactor/

    Actually there are no unit tests in st2tests/, so this just
    ensures no one will add one without pants running it.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    f465455 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    d26da96 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    ae3c06d View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    1bb600f View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    6b8c84d View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    5302211 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    6bba55b View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    b4c7155 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    5bf1332 View commit details
    Browse the repository at this point in the history
  45. fmt

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    5bc97c0 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    4a48fad View commit details
    Browse the repository at this point in the history
  47. pants-plugins/pack_metadata: add pack_content_resource target type

    Now pack_metadata targets will generate pack_content_resource instead of just resource.
    pack_content_resource is still a resource, but this setup allows us to find
    the generated resource targets more simply.
    
    This also harmonizes the implementation of pack_metadata to follow the fields
    definition of resources (esp moving dependencies into moved_fields instead of core_fields).
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    68d817c View commit details
    Browse the repository at this point in the history
  48. pants-plugins/pack_metadata: classify metadata type of pack_content_r…

    …esource targets
    
    This will allow rules to look up just action and sensor metadata (for example).
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    f6d028e View commit details
    Browse the repository at this point in the history
  49. pants-plugins/pack_metadata: register actions/sensors in pants python…

    … module mapping
    
    Only handles the actual action/sensor python files. It does not yet handle:
    - <pack>/lib
    - <pack>/actions/lib
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    371db6c View commit details
    Browse the repository at this point in the history
  50. pants-plugins/pack_metadata: register lib and actions/lib in pants py…

    …thon module mapping
    
    This makes dependency inference aware of these which may be on the PYTHONPATH.
    - <pack>/lib
    - <pack>/actions/lib
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    b655e84 View commit details
    Browse the repository at this point in the history
  51. pants: Remove <pack>/lib and <pack>/actions/lib from source roots

    The pack_metadata plugin now handles identifying these imports for dep inference.
    Next step, modify the PYTHONPATH as well.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    b3ca250 View commit details
    Browse the repository at this point in the history
  52. pants: Resolve ambiguous imports

    The pack_metadata plugin now handles identifying these imports for dep inference,
    so there are more opportunities for the core pack to be imported ambiguously
    thanks to its symlink in st2tests/st2tests/fixtures/packs
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    433e901 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    b6ca68f View commit details
    Browse the repository at this point in the history
  54. Rename file

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    0577b2b View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    76e249a View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    13c1500 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    ca2237c View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    3bd815a View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    31b7e64 View commit details
    Browse the repository at this point in the history
  60. pants-plugins/pack_metadata: Add implementation notes for python_pack…

    …_content and related rules
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    ffa1f5e View commit details
    Browse the repository at this point in the history
  61. pants-plugins/pack_metadata: Add python_path_rules to generate PEX_EX…

    …TRA_SYS_PATH for tests
    
    This won't work until pants gets support for injecting path entries.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    3a82a29 View commit details
    Browse the repository at this point in the history
  62. Configuration menu
    Copy the full SHA
    df71152 View commit details
    Browse the repository at this point in the history
  63. Configuration menu
    Copy the full SHA
    bf34e01 View commit details
    Browse the repository at this point in the history
  64. Configuration menu
    Copy the full SHA
    4a4dcbc View commit details
    Browse the repository at this point in the history
  65. Configuration menu
    Copy the full SHA
    8354129 View commit details
    Browse the repository at this point in the history
  66. Configuration menu
    Copy the full SHA
    fb48612 View commit details
    Browse the repository at this point in the history
  67. Configuration menu
    Copy the full SHA
    09af97d View commit details
    Browse the repository at this point in the history
  68. Configuration menu
    Copy the full SHA
    1de71ae View commit details
    Browse the repository at this point in the history
  69. pants-plugins/pack_metadata: add python_rules.conftest.rule_runner fi…

    …xture
    
    Writes various test scenarios in the test sandbox.
    This should avoid repeating the setup in every test.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    5494a2a View commit details
    Browse the repository at this point in the history
  70. Configuration menu
    Copy the full SHA
    97f7226 View commit details
    Browse the repository at this point in the history
  71. pants-plugins/pack_metadata: add test for pack content type detection

    And fix the identified issues.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    b069a83 View commit details
    Browse the repository at this point in the history
  72. pants-plugins/pack_metadata: add tests for entry_point and pack_lib r…

    …ules
    
    And fix the identified mistake in conftest.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    8ff5e93 View commit details
    Browse the repository at this point in the history
  73. Configuration menu
    Copy the full SHA
    d3b06a9 View commit details
    Browse the repository at this point in the history
  74. Configuration menu
    Copy the full SHA
    1c37c68 View commit details
    Browse the repository at this point in the history
  75. Configuration menu
    Copy the full SHA
    8b99025 View commit details
    Browse the repository at this point in the history
  76. Configuration menu
    Copy the full SHA
    d81ff6b View commit details
    Browse the repository at this point in the history
  77. Configuration menu
    Copy the full SHA
    33d5085 View commit details
    Browse the repository at this point in the history
  78. fix shell syntax in action chain test

    I do not know why this worked before. Perhaps it relied on quirks from old versions of /bin/sh.
    Without this fix the action chain test test_chain_pause_resume_with_error fails.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    7b39bff View commit details
    Browse the repository at this point in the history
  79. Configuration menu
    Copy the full SHA
    f841444 View commit details
    Browse the repository at this point in the history
  80. do not rely on the runner.yaml symlink in the test

    The symlink is not registered in pants. So far, this is the first
    time something has tried to access that file. So, just use the actual
    file instead of the symlink
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    9dacdf3 View commit details
    Browse the repository at this point in the history
  81. Configuration menu
    Copy the full SHA
    1079b9c View commit details
    Browse the repository at this point in the history
  82. Configuration menu
    Copy the full SHA
    4b3f8cb View commit details
    Browse the repository at this point in the history
  83. Configuration menu
    Copy the full SHA
    6471f25 View commit details
    Browse the repository at this point in the history
  84. Configuration menu
    Copy the full SHA
    45f6cee View commit details
    Browse the repository at this point in the history
  85. Configuration menu
    Copy the full SHA
    cb1c612 View commit details
    Browse the repository at this point in the history
  86. Configuration menu
    Copy the full SHA
    63e5c21 View commit details
    Browse the repository at this point in the history
  87. add/update TODOs

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    542e120 View commit details
    Browse the repository at this point in the history
  88. Configuration menu
    Copy the full SHA
    4ea9245 View commit details
    Browse the repository at this point in the history
  89. fmt w/ black

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    a80e091 View commit details
    Browse the repository at this point in the history
  90. Configuration menu
    Copy the full SHA
    a14721f View commit details
    Browse the repository at this point in the history
  91. Configuration menu
    Copy the full SHA
    e90c2c0 View commit details
    Browse the repository at this point in the history
  92. Configuration menu
    Copy the full SHA
    de25a79 View commit details
    Browse the repository at this point in the history
  93. Configuration menu
    Copy the full SHA
    b5545a8 View commit details
    Browse the repository at this point in the history
  94. pants: workaround GHA using fetch-depth=1 for submodules

    I could change fetch-depth, but that would change it for
    both submodules and for the st2.git checkout.
    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    1a8a911 View commit details
    Browse the repository at this point in the history
  95. Configuration menu
    Copy the full SHA
    1e13d28 View commit details
    Browse the repository at this point in the history
  96. Configuration menu
    Copy the full SHA
    d9a115d View commit details
    Browse the repository at this point in the history
  97. Configuration menu
    Copy the full SHA
    3ff52e8 View commit details
    Browse the repository at this point in the history
  98. pants: ignore pylint error

    cognifloyd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    a026915 View commit details
    Browse the repository at this point in the history