Skip to content

[WIP] Add support for vm_run context manager for testing #20353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: noueman/glusterfs-vendor-gstatus
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions datadog_checks_dev/datadog_checks/dev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .__about__ import __version__
from .conditions import WaitFor
from .docker import docker_run, get_docker_hostname
from .vm import vm_run, vm_is_running
from .env import environment_run
from .errors import RetryError
from .fs import chdir, get_here, temp_chdir, temp_dir
Expand Down
29 changes: 29 additions & 0 deletions datadog_checks_dev/datadog_checks/dev/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,35 @@ def __init__(
)
self.identifier = identifier

class CheckVMLogs(CheckCommandOutput):
def __init__(
self,
identifier, # type: str
patterns, # type: Union[str, List[str]]
matches=1, # type: Union[str, int]
stdout=True, # type: bool
stderr=True, # type: bool
attempts=60, # type: int
wait=1, # type: int
):
"""
Checks if the provided patterns are present in docker logs

:param identifier: The docker image identifier
:param patterns: List of patterns to match
:param matches: How many of the provided patterns need to match, it can be a number or "all"
:param stdout: Whether to search for the provided patterns in stdout
:param stderr: Whether to search for the provided patterns in stderr
:param attempts: How many times to try searching for the patterns
:param wait: How long, in seconds, to wait between attempts
"""
command = ["VBoxManage", "showvminfo", identifier, "--log", "0"]

super(CheckVMLogs, self).__init__(
command, patterns, matches=matches, stdout=stdout, stderr=stderr, attempts=attempts, wait=wait
)
self.identifier = identifier


class WaitForPortListening(WaitFor):
"""Wait until a server is available on `host:port`."""
Expand Down
Loading
Loading