test: parametrize SIENTIAPDE-1993 e2e regression over max_count=1 and >1
Feedback (Vitor): the intent was a single scenario covering both max_count=1 and max_count>1, checking that in both cases each tag's own latest (properly aggregated) timestamp prevails — not just the max_count>1 case from the previous commit. Renamed the existing fixture to pi_web_api_scouter_distinct_tag_timestamps_multi_point.json and added a sibling _single_point.json (max_count=1, one point per tag, distinct timestamps across tags). test_scenario_2_1_4 is now parametrized over both fixtures with the same assertion: each tag's stored Postgres row keeps its own real timestamp, never another tag's. SIENTIAPDE-1993 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"workflow_input": {
|
"workflow_input": {
|
||||||
"model_id": "13",
|
"model_id": "13",
|
||||||
"model_name": "PI Distinct Tag Timestamps",
|
"model_name": "PI Distinct Tag Timestamps (max_count>1)",
|
||||||
"schedule_name": "pi-distinct-ts",
|
"schedule_name": "pi-distinct-ts-n",
|
||||||
"trigger_laborious": false,
|
"trigger_laborious": false,
|
||||||
"filters": {},
|
"filters": {},
|
||||||
"schema": "sientia_data",
|
"schema": "sientia_data",
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"workflow_input": {
|
||||||
|
"model_id": "14",
|
||||||
|
"model_name": "PI Distinct Tag Timestamps (max_count=1)",
|
||||||
|
"schedule_name": "pi-distinct-ts-1",
|
||||||
|
"trigger_laborious": false,
|
||||||
|
"filters": {},
|
||||||
|
"schema": "sientia_data",
|
||||||
|
"table_name": "laborious_data",
|
||||||
|
"retention_time": 3600,
|
||||||
|
"fill_missing_tags": false,
|
||||||
|
"model_tags": {
|
||||||
|
"tag_early": {"webid": "w1", "aggr_func": "lts", "data_range": [0, 1000], "frequency": 60000},
|
||||||
|
"tag_late": {"webid": "w2", "aggr_func": "lts", "data_range": [0, 1000], "frequency": 60000}
|
||||||
|
},
|
||||||
|
"pi_web_api_query": {
|
||||||
|
"endpoint": "/streamsets/recorded",
|
||||||
|
"period": "*-1d",
|
||||||
|
"max_count": 1,
|
||||||
|
"api_timeout": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pi_web_api_server": {
|
||||||
|
"mode": "success",
|
||||||
|
"rows": [
|
||||||
|
{"name": "tag_early", "timestamp": "2024-06-01T12:00:00Z", "value": 10},
|
||||||
|
{"name": "tag_late", "timestamp": "2024-06-01T15:00:00Z", "value": 100}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"expected_rows": {
|
||||||
|
"tag_early": {"value": 10.0, "timestamp": "2024-06-01T12:00:00Z"},
|
||||||
|
"tag_late": {"value": 100.0, "timestamp": "2024-06-01T15:00:00Z"}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,10 +63,11 @@ Five tags with `avg` / `mdn` / `max` / `min` / `lts`; assert five distinct `vari
|
|||||||
|
|
||||||
### 2.1.4 Distinct tag timestamps preserved
|
### 2.1.4 Distinct tag timestamps preserved
|
||||||
|
|
||||||
Regression test for SIENTIAPDE-1993. Two tags with `max_count=2`, each with two historical
|
Regression test for SIENTIAPDE-1993, parametrized over `max_count=1` and `max_count>1`. Two
|
||||||
points, but at very different times (`tag_early` around 12:00, `tag_late` around 15:00); assert
|
tags (`tag_early` around 12:00, `tag_late` around 15:00) per case; assert each tag's stored
|
||||||
each tag's stored `timestamp` in Postgres equals its own last real point, not the batch-wide
|
`timestamp` in Postgres equals its own latest point after aggregation, not the other tag's
|
||||||
max across tags.
|
(the batch-wide max across tags) — the invariant must hold whether a tag has one point or
|
||||||
|
several historical points.
|
||||||
|
|
||||||
### 2.2.1 Empty response early exit
|
### 2.2.1 Empty response early exit
|
||||||
|
|
||||||
|
|||||||
@@ -106,19 +106,29 @@ async def test_scenario_2_1_3_debug_data_package(
|
|||||||
|
|
||||||
@pytest.mark.e2e
|
@pytest.mark.e2e
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'scenario_name, workflow_id_prefix',
|
||||||
|
[
|
||||||
|
('pi_web_api_scouter_distinct_tag_timestamps_single_point', 'pi-distinct-ts-1'),
|
||||||
|
('pi_web_api_scouter_distinct_tag_timestamps_multi_point', 'pi-distinct-ts-n'),
|
||||||
|
],
|
||||||
|
ids=['max_count_1', 'max_count_gt_1'],
|
||||||
|
)
|
||||||
async def test_scenario_2_1_4_distinct_tag_timestamps_preserved(
|
async def test_scenario_2_1_4_distinct_tag_timestamps_preserved(
|
||||||
temporal_env: WorkflowEnvironment,
|
temporal_env: WorkflowEnvironment,
|
||||||
temporal_worker: Worker,
|
temporal_worker: Worker,
|
||||||
pi_web_api_server: PIWebAPITestServer,
|
pi_web_api_server: PIWebAPITestServer,
|
||||||
postgres_engine,
|
postgres_engine,
|
||||||
|
scenario_name: str,
|
||||||
|
workflow_id_prefix: str,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Regression test for SIENTIAPDE-1993: with max_count > 1 and tags whose real
|
Regression test for SIENTIAPDE-1993: whether a tag has a single point
|
||||||
latest points fall at different times, each tag's stored row must keep its
|
(max_count=1) or several historical points (max_count>1), each tag's
|
||||||
own real timestamp instead of collapsing to the batch-wide maximum across
|
stored row must keep the timestamp of its own latest point after
|
||||||
all tags.
|
aggregation, not another tag's timestamp from the same batch.
|
||||||
"""
|
"""
|
||||||
scenario = load_scenario_input('pi_web_api_scouter_distinct_tag_timestamps')
|
scenario = load_scenario_input(scenario_name)
|
||||||
apply_pi_web_api_server_config(pi_web_api_server, scenario.get('pi_web_api_server'))
|
apply_pi_web_api_server_config(pi_web_api_server, scenario.get('pi_web_api_server'))
|
||||||
workflow_input = scenario['workflow_input']
|
workflow_input = scenario['workflow_input']
|
||||||
|
|
||||||
@@ -126,7 +136,7 @@ async def test_scenario_2_1_4_distinct_tag_timestamps_preserved(
|
|||||||
temporal_env.client,
|
temporal_env.client,
|
||||||
PIWebAPIScouter.run,
|
PIWebAPIScouter.run,
|
||||||
workflow_input,
|
workflow_input,
|
||||||
make_workflow_id('pi-distinct-ts'),
|
make_workflow_id(workflow_id_prefix),
|
||||||
)
|
)
|
||||||
|
|
||||||
rows = {
|
rows = {
|
||||||
|
|||||||
Reference in New Issue
Block a user