crosvm/infra/recipes/health_check.py
Dennis Kempin b597678ad4 dev_container: Fix reuse logic and add testing
Some recent changes introduced a bug that breaks reusage of
containers. Instead of trying to restart a stopped container,
we delete it instead and start a fresh one.

The code was refactored to allow for testing. The tests run
against the real docker service and are run as part of the health
checks in kokoro / luci.

This CL also gets rid of the custon command line parsing since
luci can now run it with argh available.

BUG=b:234402839
TEST=./tools/dev_containes --self-test [--podman]

Change-Id: Id5eaf0ea83ff07433f8f57cb652b5c393dcb9da3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3681399
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-31 21:54:23 +00:00

40 lines
1 KiB
Python

# Copyright 2022 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine.post_process import Filter
PYTHON_VERSION_COMPATIBILITY = "PY3"
DEPS = [
"crosvm",
"recipe_engine/buildbucket",
"recipe_engine/context",
"recipe_engine/properties",
"recipe_engine/step",
]
def RunSteps(api):
with api.crosvm.build_context():
api.step(
"Self-test dev-container",
[
"vpython3",
api.crosvm.source_dir.join("tools/dev_container"),
"--verbose",
"--self-test",
],
)
for check in ("python", "misc", "fmt", "clippy"):
api.crosvm.step_in_container("Checking %s" % check, ["./tools/health-check", check])
def GenTests(api):
yield (
api.test(
"basic",
api.buildbucket.ci_build(project="crosvm/crosvm"),
)
+ api.post_process(Filter().include_re(r"Checking.*"))
)