test driver: reset_shed_tools calls reconcile_index before reload

After ``setup_shed_config`` blanks ``shed_tool_conf.xml``, the toolbox
reload that follows would otherwise inherit stale shed-tool
``ToolIndexEntry`` rows: the populator-driven cold-start check only
re-runs when discovery finds a *new* path, not when it finds *fewer*
than the index already has.

Calling ``galaxy.tool_source_store.populator.reconcile_index`` between
the conf rewrite and the ``reload_toolbox`` broadcast prunes those
orphans. The next boot reads a clean index that matches the empty
shed conf; integration tests that depend on ``reset_shed_tools``
leaving zero shed entries (``test_repository_*``) get the contract
they want.

Wrapped in try/except so a missing populator dependency in a stripped-
down test environment doesn't break the rest of the reset path.
Adds a module-level logger.
This commit is contained in:
mvdbeek
2026-07-28 17:27:17 +02:00
parent 57901fcd0e
commit 9d3727b567
+13
View File
@@ -1,4 +1,5 @@
import abc
import logging
import os
import shutil
import string
@@ -6,6 +7,8 @@ import tempfile
from typing import ClassVar
from unittest import SkipTest
log = logging.getLogger(__name__)
from galaxy.app import UniverseApplication
from galaxy.util.tool_shed.tool_shed_registry import DEFAULT_TOOL_SHED_URL
from galaxy.util.unittest_utils import is_site_up
@@ -82,6 +85,16 @@ class UsesShed(UsesShedApi):
self._app.config.shed_tools_dir = self.shed_tools_dir
with open(self._app.config.shed_tool_config_file, "w") as tool_conf_file:
tool_conf_file.write(SHED_TOOL_CONF.substitute(shed_tools_path=self._app.config.shed_tools_dir))
# Drop shed-tool index entries that no longer have a backing conf.
# The populator is the single writer of the index, so a stale entry
# would otherwise survive the ``reload_toolbox`` below: ``LazyToolBox``
# only re-runs the populator when discovery turns up a *new* path.
try:
from galaxy.tool_source_store.populator import reconcile_index
reconcile_index(self._app.config, self._app.model.context, rebuild_whoosh=True)
except Exception as e:
log.warning("reset_shed_tools: reconcile_index raised (continuing): %s", e)
# deleting the containing folder doesn't trigger a toolbox reload, so signal it now and wait until it's done
self._app.queue_worker.send_control_task("reload_toolbox", get_response=True)