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

Tickets/dm41284: Updated love_stress_test to define 'location' URL based on the test environment #86

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/version-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
44 changes: 39 additions & 5 deletions python/lsst/ts/IntegrationTests/love_stress_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -42,12 +44,44 @@ 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() == "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),)


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())
14 changes: 11 additions & 3 deletions tests/test_love_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import unittest

import yaml
from lsst.ts import salobj
from lsst.ts.IntegrationTests import LoveStressTest, ScriptQueueController

Expand All @@ -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()
Expand Down