Skip to content
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
7 changes: 7 additions & 0 deletions github_ops_manager/synchronize/test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ async def create_tracking_issue_for_catalog_test_case(
"parameters_to_parsed_data_mapping": test_case.get("jobfile_parameters_mapping", ""),
}

# Extract test_plan metadata if present for inclusion in tracking issue
test_plan = test_case.get("metadata", {}).get("test_plan", {})
if test_plan:
test_requirement["test_case_group_name"] = test_plan.get("test_case_group_name", "")
test_requirement["test_case_identifier"] = test_plan.get("test_case_identifier", "")
test_requirement["test_case_title"] = test_plan.get("test_case_title", "")

# Load and render the tracking issue template
template = load_tracking_issue_template()
issue_body = template.render(
Expand Down
14 changes: 9 additions & 5 deletions github_ops_manager/synchronize/tracking_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ async def create_tracking_issue_for_catalog_pr(
test_case = test_cases[0]
test_case_title = test_case.get("title", "Untitled Test Case")

# Strip OS tag from title for CLI commands (e.g., "[IOS-XE] Do Thing" -> "Do Thing")
# This matches the test case group name that will appear in cxtm.yaml
clean_title = strip_os_tag_from_title(test_case_title)

# Compute suggested project branch name from catalog branch
suggested_branch = compute_project_branch_name(catalog_pr.head.ref)

Expand All @@ -132,12 +128,21 @@ async def create_tracking_issue_for_catalog_pr(
else:
commands_list.append(str(cmd))

# Extract test_plan metadata injected by tac-tools synchronizer expand
test_plan_metadata = test_case.get("metadata", {}).get("test_plan", {})
test_case_group_name = test_plan_metadata.get("test_case_group_name", "")
test_case_identifier = test_plan_metadata.get("test_case_identifier", "")
test_case_title_from_metadata = test_plan_metadata.get("test_case_title", "")

test_requirement = {
"purpose": test_case.get("purpose", ""),
"commands": commands_list,
"pass_criteria": test_case.get("pass_criteria", ""),
"sample_parameters": test_case.get("jobfile_parameters", ""),
"parameters_to_parsed_data_mapping": test_case.get("jobfile_parameters_mapping", ""),
"test_case_group_name": test_case_group_name,
"test_case_identifier": test_case_identifier,
"test_case_title": test_case_title_from_metadata,
}

# Load and render the tracking issue template
Expand All @@ -149,7 +154,6 @@ async def create_tracking_issue_for_catalog_pr(
catalog_branch=catalog_pr.head.ref,
suggested_project_branch=suggested_branch,
test_case_title=test_case_title, # Original title with OS tag for display
test_case_title_clean=clean_title, # Clean title for CLI commands
os_name=os_name.upper(),
test_requirement=test_requirement,
)
Expand Down
11 changes: 9 additions & 2 deletions github_ops_manager/templates/tracking_issue.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ sample_parameters: |
{{ test_requirement.sample_parameters | indent(2, first=True) }}
parameters_to_parsed_data_mapping: |
{{ test_requirement.parameters_to_parsed_data_mapping | indent(2, first=True) }}
{% if test_requirement.test_case_group_name or test_requirement.test_case_identifier or test_requirement.test_case_title -%}
metadata:
test_plan:
{% if test_requirement.test_case_group_name %} test_case_group_name: "{{ test_requirement.test_case_group_name }}"
{% endif %}{% if test_requirement.test_case_identifier %} test_case_identifier: "{{ test_requirement.test_case_identifier }}"
{% endif %}{% if test_requirement.test_case_title %} test_case_title: "{{ test_requirement.test_case_title }}"
{% endif %}{% endif -%}
```

### Tasks
Expand All @@ -33,12 +40,12 @@ parameters_to_parsed_data_mapping: |

- [ ] Execute the following command to learn parameters and validate whether test case parameters are successfully inserted into the cxtm.yaml file. If any errors occur, troubleshoot and resolve them by editing the test automation script in the branch associated with the Catalog PR in the Catalog repository:
```bash
tac-tools scripts learn "{{ test_case_title_clean }}"
tac-tools scripts learn "{{ test_requirement.test_case_group_name }}"
```

- [ ] Execute the following command to run tests and validate whether test case parameters are successfully validated against the testbed. If any errors occur, troubleshoot and verify that they are not due to a legitimate issue with the testbed. If the testbed is healthy, edit the test automation script in the branch associated with the Catalog PR in the Catalog repository:
```bash
tac-tools scripts run "{{ test_case_title_clean }}"
tac-tools scripts run "{{ test_requirement.test_case_group_name }}"
```

- [ ] When the test automation script in the Catalog repository is in a known working condition, assign a Catalog reviewer to review the PR
Expand Down
42 changes: 42 additions & 0 deletions tests/unit/test_synchronize_test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,48 @@ async def test_renders_suggested_branch_name(self) -> None:
body = mock_adapter.create_issue.call_args[1]["body"]
assert "learn/nxos/add-verify-nxos-interfaces" in body

@pytest.mark.asyncio
async def test_includes_test_plan_metadata_in_body(self) -> None:
"""Should include test_plan metadata in tracking issue body when present."""
mock_adapter = AsyncMock()
mock_issue = MagicMock()
mock_issue.number = 1
mock_issue.html_url = "https://url"
mock_adapter.create_issue.return_value = mock_issue

test_case: dict[str, Any] = {
"title": "[NX-OS] Verify Interface Status",
"purpose": "Check all interfaces are up",
"commands": [{"command": "show interface status"}],
"metadata": {
"catalog": {"destined": True},
"catalog_tracking": {
"pr_number": 101,
"pr_url": "https://github.com/catalog/repo/pull/101",
"pr_branch": "feat/nxos/add-verify-nxos-interface-status",
},
"test_plan": {
"test_case_group_name": "Verify Interface Status on all NX-OS devices",
"test_case_identifier": "1.0.42.",
"test_case_title": "Verify Interface Status on all NX-OS devices",
},
},
}

await create_tracking_issue_for_catalog_test_case(
test_case,
mock_adapter,
"https://github.com/catalog/repo",
)

body = mock_adapter.create_issue.call_args[1]["body"]
# Verify test_plan metadata is included in the YAML block
assert "test_case_group_name" in body
assert "Verify Interface Status on all NX-OS devices" in body
assert "test_case_identifier" in body
assert "1.0.42." in body
assert "test_case_title" in body


class TestProcessTestRequirements:
"""Tests for process_test_requirements function."""
Expand Down