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

pants ci: add integration tests job #6273

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

pants ci: add integration tests job #6273

wants to merge 44 commits into from

Commits on Nov 9, 2024

  1. Configuration menu
    Copy the full SHA
    6db7446 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    845a388 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1845fe4 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f0bee02 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9256f36 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d103fbf View commit details
    Browse the repository at this point in the history
  7. Add st2tests.config.db_opts_as_env_vars for itests

    Integration tests need to start subprocesses that use the
    same database as the test. This matters when running under
    pantsbuild, because pants runs several instances of pytest
    in parallel. We configured pants to pass an env var to
    disambiguate parallel test runs: ST2TESTS_PARALLEL_SLOT.
    Then, the db name gets suffixed with this slot number at
    runtime. But, when an integration test runs production
    code in a subprocess, the production code does not use--
    and should not use--any ST2TESTS_* vars, meaning the
    subprocess ends up using what is configured in the conf
    file instead of the parallel-safe test db.
    
    Thanks to a new-ish oslo_config feature, we can now
    update config via env variables. So, make use of that
    in integration tests to override the conf-file provided
    values with test-provided values.
    cognifloyd committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    8a8db1b View commit details
    Browse the repository at this point in the history
  8. Add st2tests.config.coord_opts_as_env_vars for itests

    Integration tests need to start subprocesses that use the
    same redis as the test. This matters when running under
    pantsbuild, because pants runs several instances of pytest
    in parallel. This PR prepares to add support, to disambiguate
    test runs--similar to the database logic--using the env var:
    ST2TESTS_PARALLEL_SLOT.
    In any case, when an integration test runs production
    code in a subprocess, the production code does not use--
    and should not use--any ST2TESTS_* vars, meaning the
    subprocess ends up using what is configured in the conf
    file instead of the (planned) parallel-safe coordinator.
    
    Thanks to a new-ish oslo_config feature, we can now
    update config via env variables. So, make use of that
    in integration tests to override the conf-file provided
    values with test-provided values.
    cognifloyd committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    fd8e270 View commit details
    Browse the repository at this point in the history
  9. Run parse_args() in IntegrationTestCase.setUpClass()

    This is needed so that vars are initialized before
    using them to configure the itest subprocesses
    via env vars.
    cognifloyd committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    291539f View commit details
    Browse the repository at this point in the history
  10. Add st2tests.config.mq_opts_as_env_vars for itests

    Integration tests need to start subprocesses that use the
    same exchanges as the test. This matters when running under
    pantsbuild, because pants runs several instances of pytest
    in parallel. This PR prepares to add support, to disambiguate
    test runs--similar to the database logic--using the env var:
    ST2TESTS_PARALLEL_SLOT.
    In any case, when an integration test runs production
    code in a subprocess, the production code does not use--
    and should not use--any ST2TESTS_* vars, meaning the
    subprocess ends up using what is configured in the conf
    file instead of the (planned) parallel-safe coordinator.
    
    Thanks to a new-ish oslo_config feature, we can now
    update config via env variables. So, make use of that
    in integration tests to override the conf-file provided
    values with test-provided values.
    cognifloyd committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    3c99f88 View commit details
    Browse the repository at this point in the history

Commits on Nov 12, 2024

  1. Configuration menu
    Copy the full SHA
    d9bad68 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9c5c8c8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6f1e6be View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cdfd288 View commit details
    Browse the repository at this point in the history
  5. scripts/github/prepare-integration.sh: Drop conf modification

    conf/st2.dev.conf already sets [coordination].url, so we do not
    need to use sed to enable it again.
    
    It looks like the st2.dev.conf change happened shortly after the
    sed logic was added to prepare-integration.sh.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    5660b64 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    df276f2 View commit details
    Browse the repository at this point in the history
  7. test: Add ?namespace=... to redis:// uri for parallel testing

    This will make it safer to run tests in parallel as the
    tests will have separate service registration and coordination locks.
    To do that, this adds a namespace= query param to the redis url
    that includes the slot number that pants creates to allow tests to run in parallel more safely.
    The namespace is used by the tooz library's redis driver as a prefix
    for all the redis keys. Thus, multiple tests can use the same
    redis database without clobbering each other's keys.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    54e861f View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    6a1e9c6 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    0dfcc7c View commit details
    Browse the repository at this point in the history
  10. messaging: Make exchange/queue name prefix configurable

    This, adds a new messaging.prefix option that gets modified
    to include the test slot as needed.
    
    Exchanges are defined as module level vars initialized on import.
    But, oslo_config is not setup yet at import time, so delay applying the
    new prefix setting until just before they get created in RabbitMQ.
    
    Luckily, Exchange() objects are lightweight objects that just
    hold the exchange name and type. They could do more, but we
    don't bind them to a channel. Because the exchange objects
    merely hold strings, and because they are basically singletons
    (module-level vars), we can safely update the exchange name
    just before declaring it in RabbitMQ. From that point on,
    everything that uses a singleton exchange object will get
    the updated name.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    25cf165 View commit details
    Browse the repository at this point in the history
  11. stream: use well known st2. prefix in event names

    Now that the exchange name prefix is configurable, we have
    to undo the prefix to maintain a backwards compatible API.
    Also, having the event names vary based on config would be
    a very bad UX, so we don't want to go there anyway.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    3614c4b View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    71b5022 View commit details
    Browse the repository at this point in the history
  13. Use Producer.auto_declare to declare exchanges as needed

    Connection has a cache of which entities (exchange/queue)
    have been declared, so this shouldn't have too much of a
    performance impact. This does, however, make tests much more
    reliable.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    e7e3fa4 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    bc6ecdf View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    63f9b84 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    53966b6 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    4b02962 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    837ea29 View commit details
    Browse the repository at this point in the history
  19. skip tests that require passwordless sudo for local development

    Only run them when ST2_CI==true to minimize requirements for local development.
    Also fix a typo in a comment.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    6792160 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    6e1054f View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    9085f7d View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    dc9c440 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    730bf72 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    a4fbef0 View commit details
    Browse the repository at this point in the history
  25. pants-plugins/uses_services: follow new conventions in redis rules too

    These changes were already made for MongoDB and RabbitMQ rules.
    This removes a TODO comment and slightly refactors to follow the same convention.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    d4697cf View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    d8af496 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    d83675a View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    7bbc4ef View commit details
    Browse the repository at this point in the history
  29. pants ci: add integration tests job

    pants `--tag=...` notes:
    `--tags=abc,def` (a csv list):
        is an OR condition (either `abc` tag, or `def` tag, or both).
    `--tags=abc --tag=def` (multiple entries):
        is an AND condition (Both `abc` tag AND `def` tag).
    
    So, we use `--tag=integration --tag=-st2cluster` to select targets
    that have the `integration` tag AND do NOT have the `st2cluster` tag.
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    dec8fd5 View commit details
    Browse the repository at this point in the history
  30. pants ci: orquesta (uses=st2cluster) itests

    pants `--tag=...` notes:
    `--tags=abc,def` (a csv list):
        is an OR condition (either `abc` tag, or `def` tag, or both).
    `--tags=abc --tag=def` (multiple entries):
        is an AND condition (Both `abc` tag AND `def` tag).
    
    So, we use `--tag=integration --tag=st2cluster` to select targets
    that have the `integration tag AND the `st2cluster` tag.
    (The other integration test job excludes the st2cluster tagged targets).
    cognifloyd committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    4a3a5a3 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    8baae8a View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    40825ca View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    ca2d42f View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    b98e5ae View commit details
    Browse the repository at this point in the history