-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Migrate E2E features #15931
Migrate E2E features #15931
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
f7cde3d
to
79955e6
Compare
92fb9d6
to
c107823
Compare
abc791a
to
eddf6eb
Compare
375aace
to
559add4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to read but I'm not completely done yet, I'll continue reading it tomorrow morning. In the meantime, I left some (probably stupid) comments and questions!
from ddev.cli.env.agent import agent | ||
from ddev.cli.env.check import check | ||
from ddev.cli.env.config import config | ||
from ddev.cli.env.reload import reload_command | ||
from ddev.cli.env.shell import shell | ||
from ddev.cli.env.show import show | ||
from ddev.cli.env.start import start | ||
from ddev.cli.env.stop import stop | ||
from ddev.cli.env.test import test_command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
from ddev.e2e.config import EnvDataStorage | ||
|
||
integration = app.repo.integrations.get(intg_name) | ||
env_data = EnvDataStorage(app.data_dir).get(integration.name, environment) | ||
|
||
if not env_data.exists(): | ||
app.abort(f'Environment `{environment}` for integration `{integration.name}` is not running') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this section is copy/pasted a few times, could we find a way to avoid this repetition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but what that would look like would be a utility function that takes (app, env_data, environment, integration_name)
. I'm not sure that is worth it; what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That or a decorator would work yes. Not sure that's worth it though you're right.
|
||
for command in ( | ||
['docker', 'stop', '-t', '0', self._container_name], | ||
['docker', 'rm', self._container_name], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not docker run --rm
in the start
function for debugging purpose right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes precisely! I just added a comment explaining that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the answers so far! Left some more comments. I probably missed some stuff and will review once more a bit later today or tomorrow morning, sorry.
from ddev.e2e.config import EnvDataStorage | ||
|
||
integration = app.repo.integrations.get(intg_name) | ||
env_data = EnvDataStorage(app.data_dir).get(integration.name, environment) | ||
|
||
if not env_data.exists(): | ||
app.abort(f'Environment `{environment}` for integration `{integration.name}` is not running') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That or a decorator would work yes. Not sure that's worth it though you're right.
agent = get_agent_interface(agent_type)(app.platform, integration, environment, metadata, env_data.config_file) | ||
|
||
app.display_pair('Agent type', agent_type) | ||
app.display_pair('Agent ID', agent.get_id()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have extracted the three different blocks into their own functions but feel free to keep it as it is
ddev/src/ddev/cli/env/show.py
Outdated
metadata = env_data.read_metadata() | ||
|
||
columns['Name'][i] = name | ||
columns['Agent type'][i] = metadata.get('agent_type', DEFAULT_AGENT_TYPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use a constant instead of the hardcoded 'agent_type'
everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done!
ddev/src/ddev/cli/env/test.py
Outdated
env_data = storage.get(integration.name, env_name) | ||
metadata = env_data.read_metadata() | ||
try: | ||
with EnvVars(metadata.get('e2e_env_vars', {})): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use a constant here instead of the hardcoded e2e_env_vars
(similar to my other suggestion for agent_type
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
ddev/src/ddev/e2e/agent/docker.py
Outdated
remaining = ':'.join(parts[2:]) | ||
volumes[i] = f'/{vm_file}:{remaining}' | ||
|
||
process = self._run_command(['docker', 'pull', agent_build]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be related to this PR directly but what if I want to use a docker image built locally? Would the pull
command fail and the command just stops? (asking because it happened to me a few times and I just ended up commenting this line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an environment variable DDEV_E2E_DOCKER_NO_PULL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one last nit comment. It looks good to me, I tried all the commands locally and it worked well. I really like the fact that we also have the docker related info (pulling and co) so we know what's going on exactly! Really good job there 🏅
I might have missed some stuff (sorry, the PR is quite big) but I'll approve once the other comments are resolved. Thanks again for the PR!
agent = get_agent_interface(agent_type)(app.platform, integration, environment, metadata, env_data.config_file) | ||
|
||
try: | ||
agent.restart() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it would be nice to have a log message to confirm that the file XYZ has been successfully reloaded after the restart
call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
* Migrate E2E features * address review * address review ae3fdee
Notes
env test
command no longer requires the--new-env
flag as it is now intelligent enough to spin up or down environments based on the current stateenv agent INTEGRATION ENVIRONMENT [ARGS]
allows for passing arbitrary arguments directly to the agent. Thecheck
command is special in that you can omit its integration argument for ease-of-use.env check
command is now hidden and is a mere wrapper around the newenv agent
command. This will be removed in future.env config
allows for more featureful management of environment config filesenv ls
command has been renamed toenv show
with prettier output and more granularityenv prune
command has been removed as the tooling automatically tears down and removes state upon errorsNext steps
datadog_checks_dev
so consumers can use the updated pytest pluginddev
ddev
Future
ddev
docker_run
and conditions that have to wait should be changed to show outputExample