mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-12 04:22:58 +00:00
Add run_command script in tests (#1931)
* Add run_command script in tests * Fix * Add timeout back
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import logging
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.package_helper import run_package_manager
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
from tests.run_command import run_command
|
||||
|
||||
|
||||
def test_npm_package_manager(container: TrackedContainer) -> None:
|
||||
"""Test that npm is installed and runs."""
|
||||
run_package_manager(container, "npm", "--version")
|
||||
run_command(container, "npm --version")
|
||||
|
@@ -1,18 +0,0 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_julia(container: TrackedContainer) -> None:
|
||||
"""Basic julia test"""
|
||||
LOGGER.info("Test that julia is correctly installed ...")
|
||||
logs = container.run_and_wait(
|
||||
timeout=5,
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", "julia --version"],
|
||||
)
|
||||
LOGGER.debug(logs)
|
8
tests/datascience-notebook/test_julia_datascience.py
Normal file
8
tests/datascience-notebook/test_julia_datascience.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.run_command import run_command
|
||||
|
||||
|
||||
def test_julia(container: TrackedContainer) -> None:
|
||||
run_command(container, "julia --version")
|
@@ -1,27 +1,22 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import logging
|
||||
|
||||
import pytest # type: ignore
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.package_helper import run_package_manager
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
from tests.run_command import run_command
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"package_manager, version_arg",
|
||||
"package_manager_command",
|
||||
[
|
||||
("apt", "--version"),
|
||||
("conda", "--version"),
|
||||
("mamba", "--version"),
|
||||
("pip", "--version"),
|
||||
"apt --version",
|
||||
"conda --version",
|
||||
"mamba --version",
|
||||
"pip --version",
|
||||
],
|
||||
)
|
||||
def test_package_manager(
|
||||
container: TrackedContainer, package_manager: str, version_arg: str
|
||||
container: TrackedContainer, package_manager_command: str
|
||||
) -> None:
|
||||
"""Test that package managers are installed and run."""
|
||||
run_package_manager(container, package_manager, version_arg)
|
||||
run_command(container, package_manager_command)
|
||||
|
8
tests/julia-notebook/test_julia.py
Normal file
8
tests/julia-notebook/test_julia.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.run_command import run_command
|
||||
|
||||
|
||||
def test_julia(container: TrackedContainer) -> None:
|
||||
run_command(container, "julia --version")
|
@@ -1,18 +0,0 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_julia(container: TrackedContainer) -> None:
|
||||
"""Basic julia test"""
|
||||
LOGGER.info("Test that julia is correctly installed ...")
|
||||
logs = container.run_and_wait(
|
||||
timeout=5,
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", "julia --version"],
|
||||
)
|
||||
LOGGER.debug(logs)
|
@@ -37,21 +37,6 @@ from tests.conftest import TrackedContainer
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_package_manager(
|
||||
container: TrackedContainer, package_manager: str, version_arg: str
|
||||
) -> None:
|
||||
"""Runs the given package manager with its version argument."""
|
||||
|
||||
LOGGER.info(
|
||||
f"Test that the package manager {package_manager} is working properly ..."
|
||||
)
|
||||
container.run_and_wait(
|
||||
timeout=5,
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", f"{package_manager} {version_arg}"],
|
||||
)
|
||||
|
||||
|
||||
class CondaPackageHelper:
|
||||
"""Conda package helper permitting to get information about packages"""
|
||||
|
||||
|
@@ -3,16 +3,12 @@
|
||||
import logging
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.run_command import run_command
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_spark_shell(container: TrackedContainer) -> None:
|
||||
"""Checking if Spark (spark-shell) is running properly"""
|
||||
logs = container.run_and_wait(
|
||||
timeout=60,
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", 'spark-shell <<< "1+1"'],
|
||||
)
|
||||
|
||||
logs = run_command(container, 'spark-shell <<< "1+1"', timeout=60)
|
||||
assert "res0: Int = 2" in logs, "spark-shell does not work"
|
||||
|
22
tests/run_command.py
Normal file
22
tests/run_command.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_command(
|
||||
container: TrackedContainer,
|
||||
command: str,
|
||||
timeout: int = 5,
|
||||
) -> str:
|
||||
"""Runs the given package manager with its version argument."""
|
||||
|
||||
LOGGER.info(f"Test that the command '{command}' is working properly ...")
|
||||
return container.run_and_wait(
|
||||
timeout=timeout,
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", command],
|
||||
)
|
Reference in New Issue
Block a user