Skip to content
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

Support multiple Python versions for E2E #4075

Merged
merged 3 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
address review
  • Loading branch information
ofek committed Jul 9, 2019
commit 93e054c7e912d198fbb7c78ea48cfd3e6b774ad1
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
'--python',
'-py',
type=click.INT,
default=DEFAULT_PYTHON_VERSION,
help='The version of Python to use (default {})'.format(DEFAULT_PYTHON_VERSION),
help='The version of Python to use. Defaults to {} if no tox Python is specified.'.format(DEFAULT_PYTHON_VERSION),
)
@click.option('--dev/--prod', help='Whether to use the latest version of a check or what is shipped')
@click.option('--base', is_flag=True, help='Whether to use the latest version of the base check or what is shipped')
Expand Down Expand Up @@ -73,7 +72,10 @@ def start(ctx, check, env, agent, python, dev, base, env_vars):
abort()

env_python_version = get_tox_env_python_version(env)
if env_python_version and env_python_version != str(python):
if not python:
# Make the tox environment Python specifier influence the Agent
python = env_python_version or DEFAULT_PYTHON_VERSION
elif env_python_version and env_python_version != str(python):
ofek marked this conversation as resolved.
Show resolved Hide resolved
echo_warning(
'The local environment `{}` does not match the expected Python. The Agent will use Python {}. '
'To influence the Agent Python version, use the `-py/--python` option.'.format(env, python)
Expand Down Expand Up @@ -128,7 +130,7 @@ def start(ctx, check, env, agent, python, dev, base, env_vars):
stop_environment(check, env, metadata=metadata)
abort()

env_vars = dict(ev.split('=') for ev in env_vars)
env_vars = dict(ev.split('=', 1) for ev in env_vars)
for key, value in metadata.get('env_vars', {}):
env_vars.setdefault(key, value)
AlexandreYang marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click

from ...e2e.agent import DEFAULT_PYTHON_VERSION
from ...testing import get_tox_env_python_version, get_tox_envs
from ...testing import get_tox_envs
from ..console import CONTEXT_SETTINGS, echo_info, echo_warning
from ..test import test as test_command
from .start import start
Expand Down Expand Up @@ -68,14 +68,6 @@ def test(ctx, checks, agent, python, dev, base, env_vars, new_env):

for env in envs:
if new_env:
if not python:
# Make the tox environment Python specifier influence the Agent
env_python_version = get_tox_env_python_version(env)
if env_python_version:
python = env_python_version
else:
python = DEFAULT_PYTHON_VERSION

ctx.invoke(
start, check=check, env=env, agent=agent, python=python, dev=dev, base=base, env_vars=env_vars
)
Expand Down
2 changes: 1 addition & 1 deletion datadog_checks_dev/datadog_checks/dev/tooling/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,4 @@ def get_changed_checks():
def get_tox_env_python_version(env):
match = re.match(PYTHON_MAJOR_PATTERN, env)
if match:
return match.group(1)
return int(match.group(1))