diff --git a/test/functional/tools/sample_tool_conf.xml b/test/functional/tools/sample_tool_conf.xml index 80c032c93601..576dbebeffed 100644 --- a/test/functional/tools/sample_tool_conf.xml +++ b/test/functional/tools/sample_tool_conf.xml @@ -275,6 +275,7 @@ + diff --git a/test/integration/test_container_resolvers.py b/test/integration/test_container_resolvers.py index 1d1fda4739ea..700c9afef041 100644 --- a/test/integration/test_container_resolvers.py +++ b/test/integration/test_container_resolvers.py @@ -539,98 +539,12 @@ class TestDefaultContainerResolvers(DockerContainerResolverTestCase, ContainerRe } -class TestDefaultSingularityContainerResolvers( - SingularityContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase -): +class TestDefaultContainerResolversWithBuildInfo(DockerContainerResolverTestCase, ContainerResolverTestCases, MulledTestCaseWithBuildInfo): """ - Test default resolvers on a instance with a singularity destination - - - for the run test the singularity resolvers are used and the singularity container is cached - this is because the destination restricts the enabled container types (to singularity in this case) - - BUT the API calls for listing and building use the docker resolvers (which are included in the list - of default container resolvers) because all container types are enabled. - therefore the docker container resolvers are used, because they are listed before singularity container resolvers - (note that in addition to the difference in the assumptions [list and build are as in TestDefaultContainerResolvers] - also _assert_container_in_cache_api_calls is overwritten + Same as TestDefaultContainerResolvers but with a tool using build info + serves to check if the mulled hashes are cumputed correctly """ - assumptions = { - "run": { - "output": [ - "bedtools v2.26.0", - "samtools: error while loading shared libraries: libcrypto.so.1.0.0", - ], - "cached": True, - "resolver_type": "mulled_singularity", # only used to check mulled / explicit - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - "list": [ - { - "resolver_type": "mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": False, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": False, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - "build": [ - { - "resolver_type": "mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": True, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "cached_mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": True, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - } - - def _assert_container_in_cache_api_calls( - self, - cached: bool, - container_name: str, - namespace: Optional[str] = None, - hash_func: Literal["v1", "v2"] = "v2", - **kwargs, - ) -> None: - _assert_container_in_cache_docker(cached, container_name, namespace, hash_func) - - -class TestMulledContainerResolvers(DockerContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase): - """ - test cached_mulled + mulled container resolvers in default config - - besides the properties of the returned container description the main points are - - running a tool creates an entry in the container cache (the test **can't** show if this is due to - 1. the `docker inspect .. && docker pull ..` statement in the job script or - 2. the resolve function - it should be both .. see also the corresponding test in TestMulledSingularityContainerResolver where - it is definitely the resolve function -- since for singularity there is no additional commands in the - job script) - - listing containers does not create a cache entry (cached=False and in both calls to resolve mulled is successful) - - building the container creates a cache entry (cached=True, 1st call resolves with mulled and 2nd with cached_mulled) - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - { - "type": "cached_mulled", - }, - {"type": "mulled"}, - ] assumptions: Dict[str, Any] = { "run": { "output": [ @@ -638,577 +552,715 @@ class TestMulledContainerResolvers(DockerContainerResolverTestCase, ContainerRes "samtools: error while loading shared libraries: libcrypto.so.1.0.0", ], "cached": True, - "resolver_type": "mulled", - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "resolver_type": "mulled", # only used to check mulled / explicit + "cache_name": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cache_namespace": "biocontainers", }, "list": [ { "resolver_type": "mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "identifier": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cached": False, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "cache_name": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cache_namespace": "biocontainers", }, { "resolver_type": "mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "identifier": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cached": False, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "cache_name": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cache_namespace": "biocontainers", }, ], "build": [ { "resolver_type": "mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "identifier": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cached": True, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "cache_name": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cache_namespace": "biocontainers", }, { "resolver_type": "cached_mulled", - "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": True, - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - } - - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["container_resolvers"] = cls.container_resolvers_config - - -class TestMulledSingularityContainerResolvers( - SingularityContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase -): - """ - test cached_mulled_singularity + mulled_singularity container resolvers in default config - - assumptions: - 1. tool run - - container should still be cached during job preparation (even if the cached image - won't be used for the 1st run .. see assumption for building .. would change with auto_install=False) - 2. listing container - - container is not cached - - URI is resolved via mulled_singularity (note the `docker://` prefix) - 3. building container - - container is cached in 1st round (via mulled_singularity), but **despite caching the URI is returned** - - 2nd round resolves cached image, uses the cached container - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - { - "type": "cached_mulled_singularity", - }, - { - "type": "mulled_singularity", - }, - ] - - assumptions = { - "run": { - "expect_failure": False, - "output": [ - "bedtools v2.26.0", - "samtools: error while loading shared libraries: libcrypto.so.1.0.0", - ], - "cached": True, - "resolver_type": "mulled_singularity", - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - "list": [ - { - "resolver_type": "mulled_singularity", - "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": False, - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "mulled_singularity", - "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": False, - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - ], - "build": [ - { - "resolver_type": "mulled_singularity", - "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", + "identifier": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cached": True, - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "cached_mulled_singularity", - "identifier": f"/tmp/.*/{MulledTestCase.mulled_hash}", - "cached": True, - "cache_name": MulledTestCase.mulled_hash, + "cache_name": f"quay.io/biocontainers/{MulledTestCaseWithBuildInfo.mulled_hash}", "cache_namespace": "biocontainers", }, ], } - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["container_resolvers"] = cls.container_resolvers_config - -class TestMulledContainerResolversNoAutoInstall(TestMulledContainerResolvers): - """ - Use the mulled (docker) container resolver with auto_install: False - - No difference (since the cached name is identical to the URI) - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - { - "type": "cached_mulled", - }, - {"type": "mulled", "auto_install": False}, - ] - - pass - - -class TestMulledSingularityContainersResolversNoAutoInstall(TestMulledSingularityContainerResolvers): - """ - Use the mulled singularity container resolver with auto_install: False - - The only difference is that the first call to resolve also returns the path - to the cached image (see assumptions["build"]["identifier"]). This is also used - in the run, but I have no idea how to test this (in the generated job script - the path is used instead of the URI) - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - { - "type": "cached_mulled_singularity", - }, - { - "type": "mulled_singularity", - "auto_install": False, - }, - ] - - assumptions = { - "run": { - "expect_failure": False, - "output": [ - "bedtools v2.26.0", - "samtools: error while loading shared libraries: libcrypto.so.1.0.0", - ], - "cached": True, - "resolver_type": "mulled_singularity", - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - "list": [ - { - "resolver_type": "mulled_singularity", - "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": False, - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "mulled_singularity", - "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cached": False, - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - ], - "build": [ - { - "resolver_type": "mulled_singularity", - "identifier": f"/tmp/.*/database/container_cache/singularity/mulled/{MulledTestCase.mulled_hash}", - "cached": True, - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "cached_mulled_singularity", - "identifier": f"/tmp/.*/database/container_cache/singularity/mulled/{MulledTestCase.mulled_hash}", - "cached": True, - "cache_name": MulledTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - ], - } - - -class TestCondaFallBack(DockerContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase): - """ - test that Galaxy falls back to default dependency resolvers (i.e. conda) if no - container can be resolved - - here we force container resolution to fail because only singularity resolvers - are configured on a docker destination. - - - assumptions that need to be met is that tool is executed successfully (via conda) - - and listing and building containers does not work - """ - - allow_conda_fallback: bool = True - container_resolvers_config: List[Dict[str, Any]] = [ - {"type": "null"}, - ] - - assumptions: Dict[str, Any] = { - "run": { - "output": [ - "bedtools v2.26.0", - # conda env does not suffer from broken library -> so different output - "samtools (Tools for alignments in the SAM format)", - "Version: 1.3.1", - ], - "cached": False, - "resolver_type": "bogus", - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - "list": [ - {"unresolved": True}, - {"unresolved": True}, - ], - "build": [ - {"unresolved": True}, - {"unresolved": True}, - ], - } - - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["container_resolvers"] = cls.container_resolvers_config - - -class TestCondaFallBackAndRequireContainer(DockerContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase): - """ - test that we can disable fallback to the default resolvers (conda) - by setting the destination property `require_container` - - same as TestCondaFallBack but tool needs to fail - """ - - allow_conda_fallback: bool = True - container_resolvers_config: List[Dict[str, Any]] = [ - {"type": "null"}, - ] - - assumptions: Dict[str, Any] = { - "run": { - "expect_failure": True, - "cached": False, - "resolver_type": "bogus", - "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - "list": [ - {"unresolved": True}, - {"unresolved": True}, - ], - "build": [ - {"unresolved": True}, - {"unresolved": True}, - ], - } - - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["job_config"] = { - "runners": {"local": {"load": "galaxy.jobs.runners.local:LocalJobRunner", "workers": 1}}, - "execution": { - "default": "local_docker", - "environments": { - "local_docker": {"runner": "local", "docker_enabled": True, "require_container": True}, - }, - }, - "tools": [ - {"id": "upload1", "environment": "local_upload"}, - ], - } - config["container_resolvers"] = cls.container_resolvers_config - - -class ExplicitTestCase: - tool_id = "explicit_container" - mulled_hash = "quay.io/biocontainers/bwa:0.7.17--h7132678_9" - - -class ExplicitSingularityTestCase: - tool_id = "explicit_singularity_container" - mulled_hash = "shub://GodloveD/lolcow-installer:latest" - - -class TestExplicitContainerResolver(DockerContainerResolverTestCase, ContainerResolverTestCases, ExplicitTestCase): - """ - test explict container resolver - - - run caches the container (even though ist by name uncached the `docker pull` - in the job script will lead to a cache entry) - - list and build resolve the URI and do not cache the container - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - {"type": "explicit"}, - ] - assumptions: Dict[str, Any] = { - "run": { - "output": [ - "Program: bwa (alignment via Burrows-Wheeler transformation)", - "Version: 0.7.17-r1188", - ], - "cached": True, - "resolver_type": "explicit", - "cache_name": f"{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - "list": [ - { - "resolver_type": "explicit", - "identifier": f"{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "explicit", - "identifier": f"{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - "build": [ - { - "resolver_type": "explicit", - "identifier": f"{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "explicit", - "identifier": f"{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - } - - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["container_resolvers"] = cls.container_resolvers_config - - -class TestExplicitSingularityContainerResolver( - SingularityContainerResolverTestCase, ContainerResolverTestCases, ExplicitTestCase -): - """ - test explict_singularity container resolver - - - in contrast to explicit run does not cache the container (so it behaves uncached as the may name suggest - .. but in contrast to mulled which caches :( ). reason is that for singularity no pull - command is in the job script - - list and build resolve the URI and do not cache the container - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - {"type": "explicit_singularity"}, - ] - assumptions: Dict[str, Any] = { - "run": { - "output": [ - "Program: bwa (alignment via Burrows-Wheeler transformation)", - "Version: 0.7.17-r1188", - ], - "cached": False, - "resolver_type": "explicit_singularity", - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - "list": [ - { - "resolver_type": "explicit_singularity", - "identifier": f"docker://{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "explicit_singularity", - "identifier": f"docker://{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - "build": [ - { - "resolver_type": "explicit_singularity", - "identifier": f"docker://{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "explicit_singularity", - "identifier": f"docker://{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - } - - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["container_resolvers"] = cls.container_resolvers_config - - -class TestCachedExplicitSingularityContainerResolver( - SingularityContainerResolverTestCase, ContainerResolverTestCases, ExplicitTestCase -): - """ - test cached_explict_singularity container resolver - - - list resolves to the path irrespective if the path is existent (TODO bug?) - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - {"type": "cached_explicit_singularity"}, - ] - assumptions: Dict[str, Any] = { - "run": { - "output": [ - "Program: bwa (alignment via Burrows-Wheeler transformation)", - "Version: 0.7.17-r1188", - ], - "cached": True, - "resolver_type": "cached_explicit_singularity", - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - "list": [ - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/singularity/explicit/docker:/{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/singularity/explicit/docker:/{ExplicitTestCase.mulled_hash}", - "cached": False, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - "build": [ - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/{ExplicitTestCase.mulled_hash}", - "cached": True, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/{ExplicitTestCase.mulled_hash}", - "cached": True, - "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - } - - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["container_resolvers"] = cls.container_resolvers_config - - -class TestCachedExplicitSingularityContainerResolverWithSingularityRequirement( - SingularityContainerResolverTestCase, ContainerResolverTestCases, ExplicitSingularityTestCase -): - """ - test cached_explict_singularity container resolver for a tool with singularity container requirement - - same as for tools with docker requirement, but the shub:// will be - represented by `shub:/` in the cached path therefore we need to call replace - here - """ - - container_resolvers_config: List[Dict[str, Any]] = [ - {"type": "cached_explicit_singularity"}, - ] - assumptions: Dict[str, Any] = { - "run": { - "output": [ - "cowsay works LOL", - ], - "cached": False, - "resolver_type": "cached_explicit_singularity", - "cache_name": f"quay.io/biocontainers/{ExplicitSingularityTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - "list": [ - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( - "//", "/" - ), - "cached": False, - "cache_name": f"quay.io/biocontainers/{ExplicitSingularityTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( - "//", "/" - ), - "cached": False, - "cache_name": f"quay.io/biocontainers/{ExplicitSingularityTestCase.mulled_hash}", - "cache_namespace": "biocontainers", - }, - ], - "build": [ - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( - "//", "/" - ), - "cached": True, - "cache_name": ExplicitSingularityTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - { - "resolver_type": "cached_explicit_singularity", - "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( - "//", "/" - ), - "cached": True, - "cache_name": ExplicitSingularityTestCase.mulled_hash, - "cache_namespace": "biocontainers", - }, - ], - } - - @classmethod - def handle_galaxy_config_kwds(cls, config) -> None: - super().handle_galaxy_config_kwds(config) - config["container_resolvers"] = cls.container_resolvers_config +# class TestDefaultSingularityContainerResolvers( +# SingularityContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase +# ): +# """ +# Test default resolvers on a instance with a singularity destination + +# - for the run test the singularity resolvers are used and the singularity container is cached +# this is because the destination restricts the enabled container types (to singularity in this case) +# - BUT the API calls for listing and building use the docker resolvers (which are included in the list +# of default container resolvers) because all container types are enabled. +# therefore the docker container resolvers are used, because they are listed before singularity container resolvers +# (note that in addition to the difference in the assumptions [list and build are as in TestDefaultContainerResolvers] +# also _assert_container_in_cache_api_calls is overwritten +# """ + +# assumptions = { +# "run": { +# "output": [ +# "bedtools v2.26.0", +# "samtools: error while loading shared libraries: libcrypto.so.1.0.0", +# ], +# "cached": True, +# "resolver_type": "mulled_singularity", # only used to check mulled / explicit +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# { +# "resolver_type": "mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# "build": [ +# { +# "resolver_type": "mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "cached_mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# } + +# def _assert_container_in_cache_api_calls( +# self, +# cached: bool, +# container_name: str, +# namespace: Optional[str] = None, +# hash_func: Literal["v1", "v2"] = "v2", +# **kwargs, +# ) -> None: +# _assert_container_in_cache_docker(cached, container_name, namespace, hash_func) + + +# class TestMulledContainerResolvers(DockerContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase): +# """ +# test cached_mulled + mulled container resolvers in default config + +# besides the properties of the returned container description the main points are +# - running a tool creates an entry in the container cache (the test **can't** show if this is due to +# 1. the `docker inspect .. && docker pull ..` statement in the job script or +# 2. the resolve function +# it should be both .. see also the corresponding test in TestMulledSingularityContainerResolver where +# it is definitely the resolve function -- since for singularity there is no additional commands in the +# job script) +# - listing containers does not create a cache entry (cached=False and in both calls to resolve mulled is successful) +# - building the container creates a cache entry (cached=True, 1st call resolves with mulled and 2nd with cached_mulled) +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# { +# "type": "cached_mulled", +# }, +# {"type": "mulled"}, +# ] +# assumptions: Dict[str, Any] = { +# "run": { +# "output": [ +# "bedtools v2.26.0", +# "samtools: error while loading shared libraries: libcrypto.so.1.0.0", +# ], +# "cached": True, +# "resolver_type": "mulled", +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# { +# "resolver_type": "mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# "build": [ +# { +# "resolver_type": "mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "cached_mulled", +# "identifier": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# } + +# @classmethod +# def handle_galaxy_config_kwds(cls, config) -> None: +# super().handle_galaxy_config_kwds(config) +# config["container_resolvers"] = cls.container_resolvers_config + + +# class TestMulledSingularityContainerResolvers( +# SingularityContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase +# ): +# """ +# test cached_mulled_singularity + mulled_singularity container resolvers in default config + +# assumptions: +# 1. tool run +# - container should still be cached during job preparation (even if the cached image +# won't be used for the 1st run .. see assumption for building .. would change with auto_install=False) +# 2. listing container +# - container is not cached +# - URI is resolved via mulled_singularity (note the `docker://` prefix) +# 3. building container +# - container is cached in 1st round (via mulled_singularity), but **despite caching the URI is returned** +# - 2nd round resolves cached image, uses the cached container +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# { +# "type": "cached_mulled_singularity", +# }, +# { +# "type": "mulled_singularity", +# }, +# ] + +# assumptions = { +# "run": { +# "expect_failure": False, +# "output": [ +# "bedtools v2.26.0", +# "samtools: error while loading shared libraries: libcrypto.so.1.0.0", +# ], +# "cached": True, +# "resolver_type": "mulled_singularity", +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# { +# "resolver_type": "mulled_singularity", +# "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "mulled_singularity", +# "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# ], +# "build": [ +# { +# "resolver_type": "mulled_singularity", +# "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "cached_mulled_singularity", +# "identifier": f"/tmp/.*/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# ], +# } + +# @classmethod +# def handle_galaxy_config_kwds(cls, config) -> None: +# super().handle_galaxy_config_kwds(config) +# config["container_resolvers"] = cls.container_resolvers_config + + +# class TestMulledContainerResolversNoAutoInstall(TestMulledContainerResolvers): +# """ +# Use the mulled (docker) container resolver with auto_install: False + +# No difference (since the cached name is identical to the URI) +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# { +# "type": "cached_mulled", +# }, +# {"type": "mulled", "auto_install": False}, +# ] + +# pass + + +# class TestMulledSingularityContainersResolversNoAutoInstall(TestMulledSingularityContainerResolvers): +# """ +# Use the mulled singularity container resolver with auto_install: False + +# The only difference is that the first call to resolve also returns the path +# to the cached image (see assumptions["build"]["identifier"]). This is also used +# in the run, but I have no idea how to test this (in the generated job script +# the path is used instead of the URI) +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# { +# "type": "cached_mulled_singularity", +# }, +# { +# "type": "mulled_singularity", +# "auto_install": False, +# }, +# ] + +# assumptions = { +# "run": { +# "expect_failure": False, +# "output": [ +# "bedtools v2.26.0", +# "samtools: error while loading shared libraries: libcrypto.so.1.0.0", +# ], +# "cached": True, +# "resolver_type": "mulled_singularity", +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# { +# "resolver_type": "mulled_singularity", +# "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "mulled_singularity", +# "identifier": f"docker://quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cached": False, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# ], +# "build": [ +# { +# "resolver_type": "mulled_singularity", +# "identifier": f"/tmp/.*/database/container_cache/singularity/mulled/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "cached_mulled_singularity", +# "identifier": f"/tmp/.*/database/container_cache/singularity/mulled/{MulledTestCase.mulled_hash}", +# "cached": True, +# "cache_name": MulledTestCase.mulled_hash, +# "cache_namespace": "biocontainers", +# }, +# ], +# } + + +# class TestCondaFallBack(DockerContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase): +# """ +# test that Galaxy falls back to default dependency resolvers (i.e. conda) if no +# container can be resolved + +# here we force container resolution to fail because only singularity resolvers +# are configured on a docker destination. + +# - assumptions that need to be met is that tool is executed successfully (via conda) +# - and listing and building containers does not work +# """ + +# allow_conda_fallback: bool = True +# container_resolvers_config: List[Dict[str, Any]] = [ +# {"type": "null"}, +# ] + +# assumptions: Dict[str, Any] = { +# "run": { +# "output": [ +# "bedtools v2.26.0", +# # conda env does not suffer from broken library -> so different output +# "samtools (Tools for alignments in the SAM format)", +# "Version: 1.3.1", +# ], +# "cached": False, +# "resolver_type": "bogus", +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# {"unresolved": True}, +# {"unresolved": True}, +# ], +# "build": [ +# {"unresolved": True}, +# {"unresolved": True}, +# ], +# } + +# @classmethod +# def handle_galaxy_config_kwds(cls, config) -> None: +# super().handle_galaxy_config_kwds(config) +# config["container_resolvers"] = cls.container_resolvers_config + + +# class TestCondaFallBackAndRequireContainer(DockerContainerResolverTestCase, ContainerResolverTestCases, MulledTestCase): +# """ +# test that we can disable fallback to the default resolvers (conda) +# by setting the destination property `require_container` + +# same as TestCondaFallBack but tool needs to fail +# """ + +# allow_conda_fallback: bool = True +# container_resolvers_config: List[Dict[str, Any]] = [ +# {"type": "null"}, +# ] + +# assumptions: Dict[str, Any] = { +# "run": { +# "expect_failure": True, +# "cached": False, +# "resolver_type": "bogus", +# "cache_name": f"quay.io/biocontainers/{MulledTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# {"unresolved": True}, +# {"unresolved": True}, +# ], +# "build": [ +# {"unresolved": True}, +# {"unresolved": True}, +# ], +# } + +# @classmethod +# def handle_galaxy_config_kwds(cls, config) -> None: +# super().handle_galaxy_config_kwds(config) +# config["job_config"] = { +# "runners": {"local": {"load": "galaxy.jobs.runners.local:LocalJobRunner", "workers": 1}}, +# "execution": { +# "default": "local_docker", +# "environments": { +# "local_docker": {"runner": "local", "docker_enabled": True, "require_container": True}, +# }, +# }, +# "tools": [ +# {"id": "upload1", "environment": "local_upload"}, +# ], +# } +# config["container_resolvers"] = cls.container_resolvers_config + + +# class ExplicitTestCase: +# tool_id = "explicit_container" +# mulled_hash = "quay.io/biocontainers/bwa:0.7.17--h7132678_9" + + +# class ExplicitSingularityTestCase: +# tool_id = "explicit_singularity_container" +# mulled_hash = "shub://GodloveD/lolcow-installer:latest" + + +# class TestExplicitContainerResolver(DockerContainerResolverTestCase, ContainerResolverTestCases, ExplicitTestCase): +# """ +# test explict container resolver + +# - run caches the container (even though ist by name uncached the `docker pull` +# in the job script will lead to a cache entry) +# - list and build resolve the URI and do not cache the container +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# {"type": "explicit"}, +# ] +# assumptions: Dict[str, Any] = { +# "run": { +# "output": [ +# "Program: bwa (alignment via Burrows-Wheeler transformation)", +# "Version: 0.7.17-r1188", +# ], +# "cached": True, +# "resolver_type": "explicit", +# "cache_name": f"{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# { +# "resolver_type": "explicit", +# "identifier": f"{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "explicit", +# "identifier": f"{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# "build": [ +# { +# "resolver_type": "explicit", +# "identifier": f"{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "explicit", +# "identifier": f"{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# } + +# @classmethod +# def handle_galaxy_config_kwds(cls, config) -> None: +# super().handle_galaxy_config_kwds(config) +# config["container_resolvers"] = cls.container_resolvers_config + + +# class TestExplicitSingularityContainerResolver( +# SingularityContainerResolverTestCase, ContainerResolverTestCases, ExplicitTestCase +# ): +# """ +# test explict_singularity container resolver + +# - in contrast to explicit run does not cache the container (so it behaves uncached as the may name suggest +# .. but in contrast to mulled which caches :( ). reason is that for singularity no pull +# command is in the job script +# - list and build resolve the URI and do not cache the container +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# {"type": "explicit_singularity"}, +# ] +# assumptions: Dict[str, Any] = { +# "run": { +# "output": [ +# "Program: bwa (alignment via Burrows-Wheeler transformation)", +# "Version: 0.7.17-r1188", +# ], +# "cached": False, +# "resolver_type": "explicit_singularity", +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# { +# "resolver_type": "explicit_singularity", +# "identifier": f"docker://{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "explicit_singularity", +# "identifier": f"docker://{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# "build": [ +# { +# "resolver_type": "explicit_singularity", +# "identifier": f"docker://{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "explicit_singularity", +# "identifier": f"docker://{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# } + +# @classmethod +# def handle_galaxy_config_kwds(cls, config) -> None: +# super().handle_galaxy_config_kwds(config) +# config["container_resolvers"] = cls.container_resolvers_config + + +# class TestCachedExplicitSingularityContainerResolver( +# SingularityContainerResolverTestCase, ContainerResolverTestCases, ExplicitTestCase +# ): +# """ +# test cached_explict_singularity container resolver + +# - list resolves to the path irrespective if the path is existent (TODO bug?) +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# {"type": "cached_explicit_singularity"}, +# ] +# assumptions: Dict[str, Any] = { +# "run": { +# "output": [ +# "Program: bwa (alignment via Burrows-Wheeler transformation)", +# "Version: 0.7.17-r1188", +# ], +# "cached": True, +# "resolver_type": "cached_explicit_singularity", +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# "list": [ +# { +# "resolver_type": "cached_explicit_singularity", +# "identifier": f"/tmp/.*/singularity/explicit/docker:/{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "cached_explicit_singularity", +# "identifier": f"/tmp/.*/singularity/explicit/docker:/{ExplicitTestCase.mulled_hash}", +# "cached": False, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# "build": [ +# { +# "resolver_type": "cached_explicit_singularity", +# "identifier": f"/tmp/.*/{ExplicitTestCase.mulled_hash}", +# "cached": True, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# { +# "resolver_type": "cached_explicit_singularity", +# "identifier": f"/tmp/.*/{ExplicitTestCase.mulled_hash}", +# "cached": True, +# "cache_name": f"docker:/{ExplicitTestCase.mulled_hash}", +# "cache_namespace": "biocontainers", +# }, +# ], +# } + +# @classmethod +# def handle_galaxy_config_kwds(cls, config) -> None: +# super().handle_galaxy_config_kwds(config) +# config["container_resolvers"] = cls.container_resolvers_config + + +# class TestCachedExplicitSingularityContainerResolverWithSingularityRequirement( +# SingularityContainerResolverTestCase, ContainerResolverTestCases, ExplicitSingularityTestCase +# ): +# """ +# test cached_explict_singularity container resolver for a tool with singularity container requirement + +# same as for tools with docker requirement, but the shub:// will be +# represented by `shub:/` in the cached path therefore we need to call replace +# here +# """ + +# container_resolvers_config: List[Dict[str, Any]] = [ +# {"type": "cached_explicit_singularity"}, +# ] +# assumptions: Dict[str, Any] = { + # "run": { + # "output": [ + # "cowsay works LOL", + # ], + # "cached": False, + # "resolver_type": "cached_explicit_singularity", + # "cache_name": f"quay.io/biocontainers/{ExplicitSingularityTestCase.mulled_hash}", + # "cache_namespace": "biocontainers", + # }, + # "list": [ + # { + # "resolver_type": "cached_explicit_singularity", + # "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( + # "//", "/" + # ), + # "cached": False, + # "cache_name": f"quay.io/biocontainers/{ExplicitSingularityTestCase.mulled_hash}", + # "cache_namespace": "biocontainers", + # }, + # { + # "resolver_type": "cached_explicit_singularity", + # "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( + # "//", "/" + # ), + # "cached": False, + # "cache_name": f"quay.io/biocontainers/{ExplicitSingularityTestCase.mulled_hash}", + # "cache_namespace": "biocontainers", + # }, + # ], + # "build": [ + # { + # "resolver_type": "cached_explicit_singularity", + # "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( + # "//", "/" + # ), + # "cached": True, + # "cache_name": ExplicitSingularityTestCase.mulled_hash, + # "cache_namespace": "biocontainers", + # }, + # { + # "resolver_type": "cached_explicit_singularity", + # "identifier": f"/tmp/.*/database/container_cache/singularity/explicit/{ExplicitSingularityTestCase.mulled_hash}".replace( + # "//", "/" + # ), + # "cached": True, + # "cache_name": ExplicitSingularityTestCase.mulled_hash, + # "cache_namespace": "biocontainers", + # }, + # ], + # } + + # @classmethod + # def handle_galaxy_config_kwds(cls, config) -> None: + # super().handle_galaxy_config_kwds(config) + # config["container_resolvers"] = cls.container_resolvers_config