Skip to content

Commit c5473e9

Browse files
committed
Add test for checking if tags exist
1 parent 140d162 commit c5473e9

5 files changed

Lines changed: 73 additions & 3 deletions

File tree

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ jobs:
4646
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae
4747
with:
4848
path: .pytest_cache
49-
key: pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-${{ github.sha }}
49+
key: pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-${{
50+
github.sha }}
5051
restore-keys: |
5152
pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-
5253
- name: Run unit tests
5354
run: make test-unit
5455
- name: Run entire test suite
55-
run: make test-integration
56+
# run: make test-integration
57+
run: uv run pytest ./tests/system/test_ai_agentic_test_app.py::TestAgenticApp

tests/system/__init__.py

Whitespace-only changes.

tests/system/test_ai_agentic_test_app.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,41 @@ def test_agentic_app_with_remote_tools(self) -> None:
107107
app.delete()
108108
self.restart_splunk() # app removal requires a restart
109109

110+
# To execute this test locally, download the Splunk MCP Server App tarball from
111+
# https://splunkbase.splunk.com/app/7931 and place it in a file named
112+
# splunk-mcp-server.tgz at the root of this repo (i.e. ../../splunk-mcp-server.tgz).
113+
#
114+
# Note: that the downloaded file could have a: .spl, .tar, .tar.gz or .tgz extension,
115+
# if it is not .tgz, then you must change it to .tgz.
116+
#
117+
# Our CI does this automatically.
118+
def test_remote_tools_have_tags(self) -> None:
119+
pytest.importorskip("langchain_openai")
120+
self.requires_splunk_10_2()
121+
122+
# Skip test in case the instance does not have a /splunk-mcp-server.tgz file.
123+
try:
124+
resp = self.service.get("agentic_app/has_mcp_app_file")
125+
assert resp.status == 200
126+
except HTTPError as e:
127+
if e.status == 404:
128+
pytest.skip("Splunk MCP Server App file not found on Splunk instance")
129+
raise
130+
131+
app = self.service.apps.create(name="/splunk-mcp-server.tgz", filename=True) # pyright: ignore[reportUnknownVariableType]
132+
133+
resp = self.service.post(
134+
"agentic_app/tool-tags",
135+
body=self.test_llm_settings.model_dump_json(),
136+
)
137+
138+
assert resp.status == 200
139+
body = str(resp.body) # pyright: ignore[reportUnknownArgumentType]
140+
assert "tags" in body
141+
142+
app.delete()
143+
self.restart_splunk() # app removal requires a restart
144+
110145
def requires_splunk_10_2(self) -> None:
111146
if self.service.splunk_version[0] < 10 or self.service.splunk_version[1] < 2:
112147
pytest.skip("Python 3.13 not available on splunk < 10.2")

tests/system/test_apps/ai_agentic_test_app/bin/indexes.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15+
import json
1516
import os
1617
import sys
1718

1819
sys.path.insert(0, "/splunklib-deps")
1920
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "lib"))
2021

21-
from typing import override
22+
from typing import final, override
2223

2324
from pydantic import BaseModel, Field
2425

@@ -72,3 +73,29 @@ class Output(BaseModel):
7273
)
7374

7475
self.response.write(result.structured_output.model_dump_json())
76+
77+
78+
@final
79+
class ToolTagsHandler(CRETestHandler):
80+
@override
81+
async def run(self) -> None:
82+
async with Agent(
83+
model=await self.model(),
84+
system_prompt="You are a helpful Splunk assistant",
85+
tool_settings=ToolSettings(
86+
local=False,
87+
remote=RemoteToolSettings(
88+
allowlist=ToolAllowlist(names=["splunk_get_indexes"])
89+
),
90+
),
91+
service=self.service,
92+
) as agent:
93+
assert len(agent.tools) > 0, "No remote tools loaded"
94+
95+
tools_with_tags = [t for t in agent.tools if len(t.tags) > 0]
96+
assert len(tools_with_tags) > 0, (
97+
f"No tools have tags. Tools: {[t.name for t in agent.tools]}"
98+
)
99+
100+
result = {"tools": [{"name": t.name, "tags": t.tags} for t in agent.tools]}
101+
self.response.write(json.dumps(result))

tests/system/test_apps/ai_agentic_test_app/default/restmap.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ match = /agentic_app/has_mcp_app_file
1515
scripttype = python
1616
handler = mcp_app_file_exists.Handler
1717
python.required = 3.13
18+
19+
[script:tool_tags]
20+
match = /agentic_app/tool-tags
21+
scripttype = python
22+
handler = indexes.ToolTagsHandler
23+
python.required = 3.13

0 commit comments

Comments
 (0)