Skip to content

Commit

Permalink
Merge pull request #5929: Pants: add dependencies to the st2tests `py…
Browse files Browse the repository at this point in the history
…thon_distributions`
  • Loading branch information
cognifloyd authored Mar 10, 2023
2 parents 1c36c97 + 1fd08cd commit c5ec5b0
Show file tree
Hide file tree
Showing 23 changed files with 97 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Added
to pants' use of PEX lockfiles. This is not a user-facing addition.
#5778 #5789 #5817 #5795 #5830 #5833 #5834 #5841 #5840 #5838 #5842 #5837 #5849 #5850
#5846 #5853 #5848 #5847 #5858 #5857 #5860 #5868 #5871 #5864 #5874 #5884 #5893 #5891
#5890 #5898 #5901 #5906 #5899 #5907 #5909 #5922 #5926 #5927 #5925 #5928
#5890 #5898 #5901 #5906 #5899 #5907 #5909 #5922 #5926 #5927 #5925 #5928 #5929
Contributed by @cognifloyd

* Added a joint index to solve the problem of slow mongo queries for scheduled executions. #5805
Expand Down
4 changes: 2 additions & 2 deletions st2actions/tests/unit/test_actions_registrar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from st2tests.fixtures.generic.fixture import (
PACK_NAME as GENERIC_PACK,
PACK_PATH as GENERIC_PACK_PATH,
PACK_BASE_PATH as PACKS_BASE_PATH,
)
import st2tests.fixturesloader as fixtures_loader

Expand All @@ -52,9 +53,8 @@ class ActionsRegistrarTest(tests_base.DbTestCase):
)
def test_register_all_actions(self):
try:
packs_base_path = fixtures_loader.get_fixtures_base_path()
all_actions_in_db = Action.get_all()
actions_registrar.register_actions(packs_base_paths=[packs_base_path])
actions_registrar.register_actions(packs_base_paths=[PACKS_BASE_PATH])
except Exception as e:
print(six.text_type(e))
self.fail("All actions must be registered without exceptions.")
Expand Down
8 changes: 8 additions & 0 deletions st2common/tests/unit/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ python_tests(
"st2common/tests/unit/base.py",
],
uses=["mongo", "rabbitmq"],
overrides={
"test_util_file_system.py": dict(
dependencies=[
"st2tests/st2tests/policies",
"st2tests/st2tests/policies/meta",
],
),
},
)

python_test_utils(
Expand Down
30 changes: 30 additions & 0 deletions st2tests/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
st2_component_python_distribution(
component_name="st2tests",
dependencies=[
"./st2tests/policies",
"./st2tests/policies/meta",
"./st2tests/mocks",
"./st2tests/mocks/runners",
# fixture packs
"./st2tests/fixtures/generic",
"./st2tests/fixtures/localrunner_pack",
"./st2tests/fixtures/packs:all_packs",
"./st2tests/fixtures/packs_1:all_packs",
"./st2tests/fixtures/packs_invalid:all_packs",
# fixtures in packs that are not (directly) packs
"./st2tests/fixtures/packs/executions",
"./st2tests/fixtures/packs/runners",
"./st2tests/fixtures/packs/test_content_version_fixture", # provides fixture const
# fixture db resources (eg yaml dump of db resources)
"./st2tests/fixtures/aliases",
"./st2tests/fixtures/backstop",
"./st2tests/fixtures/descendants",
"./st2tests/fixtures:rbac_fixtures",
"./st2tests/fixtures/rule_enforcements",
"./st2tests/fixtures/timers",
"./st2tests/fixtures/traces",
# fixture etc
"./st2tests/fixtures/conf",
"./st2tests/fixtures/history_views",
"./st2tests/fixtures/keyczar_keys",
"./st2tests/fixtures/specs",
"./st2tests/fixtures/ssl_certs",
],
)
1 change: 1 addition & 0 deletions st2tests/st2tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ python_sources(
"st2tests/conf:st2.conf",
"st2tests/conf:st2_kvstore_tests.crypto.key.json",
"st2tests/conf:logging.conf",
# These are for base.py, but do not use overrides because __init__ import base.
"./resources:ssh",
"./resources:packs",
],
Expand Down
1 change: 1 addition & 0 deletions st2tests/st2tests/fixtures/generic/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
from st2tests import fixturesloader

PACK_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__)
PACK_BASE_PATH = fixturesloader.get_fixtures_base_path()
5 changes: 4 additions & 1 deletion st2tests/st2tests/fixtures/localrunner_pack/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ pack_metadata(
)

python_sources(
dependencies=[":metadata"],
dependencies=[
":metadata",
"./actions",
],
)
3 changes: 3 additions & 0 deletions st2tests/st2tests/fixtures/packs/dummy_pack_1/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pack_metadata(
python_sources(
dependencies=[
":metadata",
"./actions",
"./sensors",
"./etc", # extra binary files for st2api/tests/unit/controllers/v1/test_packs_views.py
"st2tests/st2tests/fixtures/packs/configs/dummy_pack_1.yaml",
],
)
3 changes: 3 additions & 0 deletions st2tests/st2tests/fixtures/packs/dummy_pack_1/etc/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources(
sources=["*.png"],
)
7 changes: 6 additions & 1 deletion st2tests/st2tests/fixtures/packs/dummy_pack_2/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pack_metadata(
name="metadata",
dependencies=[":pack_requirements"],
)

resource(
Expand All @@ -8,5 +9,9 @@ resource(
)

python_sources(
dependencies=[":metadata"],
dependencies=[
":metadata",
"./actions",
"./sensors",
],
)
6 changes: 5 additions & 1 deletion st2tests/st2tests/fixtures/packs/dummy_pack_3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ pack_metadata(
)

python_sources(
dependencies=[":metadata"],
dependencies=[
":metadata",
"./actions",
"./sensors",
],
)
1 change: 1 addition & 0 deletions st2tests/st2tests/fixtures/packs/dummy_pack_7/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pack_metadata(
python_sources(
dependencies=[
":metadata",
"./actions",
"st2tests/st2tests/fixtures/packs/configs/dummy_pack_7.yaml",
],
)
5 changes: 4 additions & 1 deletion st2tests/st2tests/fixtures/packs/dummy_pack_9/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ pack_metadata(
)

python_sources(
dependencies=[":metadata"],
dependencies=[
":metadata",
"./actions",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

from __future__ import absolute_import
from invalid import Invalid # noqa
from invalid import Invalid # noqa # pants: no-infer-dep


class Foo:
Expand Down
5 changes: 4 additions & 1 deletion st2tests/st2tests/fixtures/packs/orquesta_tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ pack_metadata(
)

python_sources(
dependencies=[":metadata"],
dependencies=[
":metadata",
"./actions",
],
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pack_metadata(
name="metadata",
dependencies=[":pack_requirements"],
)

resource(
Expand Down
7 changes: 6 additions & 1 deletion st2tests/st2tests/fixtures/packs/runners/BUILD
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
python_sources()
python_sources(
dependencies=[
"./test_async_runner",
"./test_polling_async_runner",
],
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python_tests(
name="tests",
python_sources(
sources=["*.py"],
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python_tests(
name="tests",
python_sources(
sources=["*.py"],
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pack_metadata(
name="metadata",
dependencies=[":pack_requirements"],
)

resource(
Expand All @@ -8,5 +9,8 @@ resource(
)

python_sources(
dependencies=[":metadata"],
dependencies=[
":metadata",
"./actions",
],
)
6 changes: 6 additions & 0 deletions st2tests/st2tests/fixtures/specs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ resource(
name="openapi_specs",
source="openapi.yaml.j2",
)

# This is for an empty __init__.py file.
# Tests will import __package__ from it to tell dep inference it is needed.
python_sources(
dependencies=[":openapi_specs"],
)
1 change: 1 addition & 0 deletions st2tests/st2tests/fixtures/ssl_certs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resources(
"**/*.pem",
"ca/index.txt*",
"ca/serial*",
"README.md",
],
)

Expand Down
1 change: 0 additions & 1 deletion st2tests/st2tests/policies/meta/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
resources(
name="policies_meta",
sources=["*.yaml"],
)

0 comments on commit c5ec5b0

Please sign in to comment.