-
Notifications
You must be signed in to change notification settings - Fork 182
Add presubmit test to verify v2 metrics are working when enabled #1980
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
Open
cjreynol
wants to merge
4
commits into
google:main
Choose a base branch
from
cjreynol:test_metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+131
−12
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
573bc8a
Only write metrics event files when enabled
cjreynol 455c901
Add group metrics directory to `cvd fleet` output
cjreynol 65411d7
Install `cuttlefish-metrics` to test containers
cjreynol 7272605
Add presubmit test to verify metrics transmission
cjreynol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e -x | ||
|
|
||
| BRANCH="" | ||
| TARGET="" | ||
| CREDENTIAL_SOURCE="${CREDENTIAL_SOURCE:-}" | ||
|
|
||
| while getopts "b:c:t:" opt; do | ||
| case "${opt}" in | ||
| b) | ||
| BRANCH="${OPTARG}" | ||
| ;; | ||
| c) | ||
| CREDENTIAL_SOURCE="${OPTARG}" | ||
| ;; | ||
| t) | ||
| TARGET="${OPTARG}" | ||
| ;; | ||
| *) | ||
| echo "Unknown flag: -${opt}" >&2 | ||
| echo "Usage: $0 -b BRANCH -t TARGET" | ||
| exit 1 | ||
| esac | ||
| done | ||
| shift $((OPTIND-1)) | ||
|
|
||
| if [[ "${BRANCH}" == "" ]]; then | ||
| echo "Missing required -b argument" | ||
| fi | ||
|
|
||
| if [[ "${TARGET}" == "" ]]; then | ||
| echo "Missing required -t argument" | ||
| fi | ||
|
|
||
| workdir="$(mktemp -d -t cvd_command_test.XXXXXX)" | ||
|
|
||
| function collect_logs_and_cleanup() { | ||
| # Don't immediately exit on failure anymore | ||
| set +e | ||
| if [[ -n "${TEST_UNDECLARED_OUTPUTS_DIR}" ]] && [[ -d "${TEST_UNDECLARED_OUTPUTS_DIR}" ]]; then | ||
| cp "${workdir}"/*.log "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
| cp "${workdir}"/cuttlefish_runtime/*.log "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
| cp "${workdir}"/cuttlefish_runtime/logcat "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
| cp "${workdir}"/cuttlefish_runtime/cuttlefish_config.json "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
| fi | ||
| rm -rf "${workdir}" | ||
| # Be nice, don't leave devices behind. | ||
| cvd reset -y | ||
| } | ||
|
|
||
| # Regardless of whether and when a failure occurs logs must collected | ||
| trap collect_logs_and_cleanup EXIT | ||
|
|
||
| # Make sure to run in a clean environment, without any devices running | ||
| cvd reset -y | ||
|
|
||
| credential_arg="" | ||
| if [[ -n "$CREDENTIAL_SOURCE" ]]; then | ||
| credential_arg="--credential_source=${CREDENTIAL_SOURCE}" | ||
| fi | ||
|
|
||
| cvd fetch \ | ||
| --default_build="${BRANCH}/${TARGET}" \ | ||
| --target_directory="${workdir}" \ | ||
| ${credential_arg} | ||
|
|
||
| ( | ||
| cd "${workdir}" | ||
|
|
||
| # generate instantiation, start, and boot complete events | ||
| cvd create --host_path="${workdir}" --product_path="${workdir}" | ||
|
|
||
| # verify transmission by detecting existence of the metrics directory and the debug event files | ||
| metrics_dir=`cvd fleet 2> /dev/null | jq --raw-output '.groups[0].metrics_dir'` | ||
| if ! [[ -d "${metrics_dir}" ]]; then | ||
| echo "metrics directory not found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # file prefixes sourced from `cuttlefish/host/libs/metrics/event_type.cc::EventTypeString` function | ||
| if ! [[ -f "`ls ${metrics_dir}/device_instantiation*.txtpb`" ]]; then | ||
| echo "metrics not transmitted for the expected instantiation event" | ||
| exit 1 | ||
| fi | ||
| if ! [[ -f "`ls ${metrics_dir}/device_boot_start*.txtpb`" ]]; then | ||
| echo "metrics not transmitted for the expected start event" | ||
| exit 1 | ||
| fi | ||
| if ! [[ -f "`ls ${metrics_dir}/device_boot_complete*.txtpb`" ]]; then | ||
| echo "metrics not transmitted for the expected boot complete event" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # generate stop event and verify transmission | ||
| cvd stop | ||
| if ! [[ -f "`ls ${metrics_dir}/device_stop*.txtpb`" ]]; then | ||
| echo "metrics not transmitted for the expected stop event" | ||
| exit 1 | ||
| fi | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.