From 1aa2095fa1cb213ffec2be7a361fb922f0eebcef Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Tue, 31 Oct 2023 12:34:52 -0700 Subject: [PATCH 1/3] Updated love_stress_test.py and love_stress_test_configs.py to define the LOVE 'location' URL based on the test environment. --- .../configs/love_stress_test_configs.py | 2 +- .../ts/IntegrationTests/love_stress_test.py | 37 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/python/lsst/ts/IntegrationTests/configs/love_stress_test_configs.py b/python/lsst/ts/IntegrationTests/configs/love_stress_test_configs.py index 1a593432..0d333c6b 100644 --- a/python/lsst/ts/IntegrationTests/configs/love_stress_test_configs.py +++ b/python/lsst/ts/IntegrationTests/configs/love_stress_test_configs.py @@ -30,7 +30,7 @@ registry["love_stress"] = yaml.safe_dump( { - "location": "love1.tu.lsst.org", + "location": "replace_me", "number_of_clients": 50, "number_of_messages": 5000, "data": [ diff --git a/python/lsst/ts/IntegrationTests/love_stress_test.py b/python/lsst/ts/IntegrationTests/love_stress_test.py index bab417d9..5d5fd9d5 100644 --- a/python/lsst/ts/IntegrationTests/love_stress_test.py +++ b/python/lsst/ts/IntegrationTests/love_stress_test.py @@ -24,9 +24,11 @@ import asyncio +import yaml from lsst.ts.IntegrationTests import BaseScript from .configs.config_registry import registry +from .utils import get_test_env_arg class LoveStressTest(BaseScript): @@ -42,12 +44,37 @@ class LoveStressTest(BaseScript): ("make_love_stress_tests.py", BaseScript.is_external), ] - def __init__(self) -> None: + def __init__(self, test_env: str) -> None: super().__init__() + # Set the LOVE location based on test environment + self.test_env = test_env + self.env_configs = yaml.safe_load(registry["love_stress"]) + if test_env.lower() == "bts": + # Running on BTS + self.location = "love01.ls.lsst.org" + elif test_env.lower() == "tts": + # Running on TTS + self.location = "love1.tu.lsst.org" + self.env_configs["location"] = self.location + self.configs = (yaml.safe_dump(self.env_configs),) def run_love_stress_test() -> None: - script_class = LoveStressTest() - num_scripts = len(script_class.scripts) - print(f"\nLOVE Stress Test; running {num_scripts} scripts") - asyncio.run(script_class.run()) + # Ensure the invocation is correct. + # If not, raise KeyError. + # If it is correct, execute the Stress Test. + args = get_test_env_arg() + try: + script_class = LoveStressTest( + test_env=args.test_env, + ) + except KeyError as ke: + print(repr(ke)) + else: + num_scripts = len(script_class.scripts) + print( + f"\nLOVE Stress Test; running {num_scripts} scripts" + f" with this configuration:\n" + f"{script_class.configs}" + ) + asyncio.run(script_class.run()) From 2d169d3bb6c6b33b69d751a696dd3e2d22e730b3 Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Tue, 31 Oct 2023 12:35:28 -0700 Subject: [PATCH 2/3] Updated test_love_stress.py unit test with new 'location' defintion. --- .../lsst/ts/IntegrationTests/love_stress_test.py | 13 ++++++++++--- tests/test_love_stress.py | 14 +++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/python/lsst/ts/IntegrationTests/love_stress_test.py b/python/lsst/ts/IntegrationTests/love_stress_test.py index 5d5fd9d5..2276b5d7 100644 --- a/python/lsst/ts/IntegrationTests/love_stress_test.py +++ b/python/lsst/ts/IntegrationTests/love_stress_test.py @@ -49,12 +49,19 @@ def __init__(self, test_env: str) -> None: # Set the LOVE location based on test environment self.test_env = test_env self.env_configs = yaml.safe_load(registry["love_stress"]) - if test_env.lower() == "bts": - # Running on BTS - self.location = "love01.ls.lsst.org" + if test_env.lower() == "summit": + # Running on Summit + self.location = "love01.cp.lsst.org" elif test_env.lower() == "tts": # Running on TTS self.location = "love1.tu.lsst.org" + elif test_env.lower() == "bts": + # Running on BTS + self.location = "love01.ls.lsst.org" + else: + raise Exception( + "Please choose one of the proper locations: ['bts', 'tts', 'summit']" + ) self.env_configs["location"] = self.location self.configs = (yaml.safe_dump(self.env_configs),) diff --git a/tests/test_love_stress.py b/tests/test_love_stress.py index b489c09f..dab521b9 100644 --- a/tests/test_love_stress.py +++ b/tests/test_love_stress.py @@ -23,6 +23,7 @@ import unittest +import yaml from lsst.ts import salobj from lsst.ts.IntegrationTests import LoveStressTest, ScriptQueueController @@ -47,16 +48,23 @@ async def test_love_stress(self) -> None: """ # Instantiate the LoveStress integration tests. - script_class = LoveStressTest() - # Get number of scripts + script_class = LoveStressTest(test_env="bts") + # Get number of scripts and the configuration. num_scripts = len(script_class.scripts) - print(f"LOVE Stress Test; running {num_scripts} scripts") + script_config = yaml.safe_load(script_class.configs[0]) + print( + f"LOVE Stress Test; running {num_scripts} scripts" + f" on the BTS environment, with this configuration: \n" + f"{script_config}" + ) # Execute the scripts. await script_class.run() # Assert script was added to ScriptQueue. self.assertEqual(len(self.controller.queue_list), num_scripts) # Assert scripts passed. self.assertEqual(script_class.script_states, [8]) + # Assert location is correct. + self.assertEqual(script_config["location"], "love01.ls.lsst.org") async def asyncTearDown(self) -> None: await self.controller.close() From 32daa3aba63ffa1dd7cb27948b4dbd3002e4d8f5 Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Tue, 31 Oct 2023 12:52:33 -0700 Subject: [PATCH 3/3] Updated version-history. --- doc/version-history.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/version-history.rst b/doc/version-history.rst index 74a75238..6d0e412b 100644 --- a/doc/version-history.rst +++ b/doc/version-history.rst @@ -13,6 +13,7 @@ Version History v0.17.0 ------- * Parameterized the OCSP 2||3 index, determined by test environment. +* Updated love_stress_test to define the LOVE 'location' URL based on the test environment. v0.16.0 -------