diff options
author | Julien Desprez <jdesprez@google.com> | 2024-04-22 11:24:33 -0700 |
---|---|---|
committer | Julien Desprez <jdesprez@google.com> | 2024-04-22 11:25:22 -0700 |
commit | 8476ed4d8ed85f0a978507b1d8353c170827ca77 (patch) | |
tree | bd534d2dee46bcae8674ccf935b4029b14040ed9 | |
parent | ca219d56da1bd04443bd1c02aeac8a9a3074e524 (diff) | |
download | tradefederation-8476ed4d8ed85f0a978507b1d8353c170827ca77.tar.gz |
Allow experiment with heuristic levels to continue analysis
Test: presubmit
Bug: 335511290
Change-Id: I5ce39dd77895d32200f6822a61059500b59d5ef3
5 files changed, 57 insertions, 4 deletions
diff --git a/common_util/com/android/tradefed/invoker/logger/InvocationMetricLogger.java b/common_util/com/android/tradefed/invoker/logger/InvocationMetricLogger.java index fed79e6a8..077ac57e1 100644 --- a/common_util/com/android/tradefed/invoker/logger/InvocationMetricLogger.java +++ b/common_util/com/android/tradefed/invoker/logger/InvocationMetricLogger.java @@ -313,6 +313,7 @@ public class InvocationMetricLogger { DEVICE_IMAGE_NOT_CHANGED("device_image_not_changed", false), IMAGE_CHANGES_IN_KEY_FILE("image_changes_in_key_file", true), DEVICE_IMAGE_FILE_CHANGES("device_image_file_changes", true), + DEVICE_IMAGE_USED_HEURISTIC("device_image_used_heuristic", true), TEST_ARTIFACT_NOT_CHANGED("test_artifact_not_changed", true), PURE_DEVICE_IMAGE_UNCHANGED("pure_device_image_unchanged", true), TEST_ARTIFACT_CHANGE_ONLY("test_artifact_change_only", true), diff --git a/src/com/android/tradefed/build/content/ImageContentAnalyzer.java b/src/com/android/tradefed/build/content/ImageContentAnalyzer.java index 198af2c9b..79f74794d 100644 --- a/src/com/android/tradefed/build/content/ImageContentAnalyzer.java +++ b/src/com/android/tradefed/build/content/ImageContentAnalyzer.java @@ -21,6 +21,7 @@ import com.android.tradefed.invoker.logger.InvocationMetricLogger; import com.android.tradefed.invoker.logger.InvocationMetricLogger.InvocationMetricKey; import com.android.tradefed.invoker.tracing.CloseableTraceScope; import com.android.tradefed.log.LogUtil.CLog; +import com.android.tradefed.result.skipped.AnalysisHeuristic; import com.google.api.client.util.Joiner; @@ -33,10 +34,15 @@ public class ImageContentAnalyzer { private final boolean presubmitMode; private final List<ContentAnalysisContext> contexts; + private final AnalysisHeuristic mAnalysisLevel; - public ImageContentAnalyzer(boolean presubmitMode, List<ContentAnalysisContext> contexts) { + public ImageContentAnalyzer( + boolean presubmitMode, + List<ContentAnalysisContext> contexts, + AnalysisHeuristic analysisLevel) { this.presubmitMode = presubmitMode; this.contexts = contexts; + this.mAnalysisLevel = analysisLevel; } public ContentAnalysisResults evaluate() { @@ -143,6 +149,22 @@ public class ImageContentAnalyzer { diffs.removeIf(d -> d.path.startsWith("META/")); diffs.removeIf(d -> d.path.startsWith("PREBUILT_IMAGES/")); diffs.removeIf(d -> d.path.startsWith("RADIO/")); + if (mAnalysisLevel.ordinal() >= AnalysisHeuristic.REMOVE_EXEMPTION.ordinal()) { + boolean removed = false; + // b/335722003 + removed = + removed + || diffs.removeIf( + d -> d.path.equals("SYSTEM/boot_otas/boot_ota_4k.zip")); + removed = + removed + || diffs.removeIf( + d -> d.path.equals("SYSTEM/boot_otas/boot_ota_16k.zip")); + if (removed) { + InvocationMetricLogger.addInvocationMetrics( + InvocationMetricKey.DEVICE_IMAGE_USED_HEURISTIC, mAnalysisLevel.name()); + } + } if (diffs.isEmpty()) { CLog.d("Device image from '%s' is unchanged", context.contentEntry()); } diff --git a/src/com/android/tradefed/result/skipped/AnalysisHeuristic.java b/src/com/android/tradefed/result/skipped/AnalysisHeuristic.java new file mode 100644 index 000000000..5843e9ab2 --- /dev/null +++ b/src/com/android/tradefed/result/skipped/AnalysisHeuristic.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tradefed.result.skipped; + +/** Order is important. */ +public enum AnalysisHeuristic { + CORE, // No assumption + REMOVE_EXEMPTION, // Core + known issues +} diff --git a/src/com/android/tradefed/result/skipped/ArtifactsAnalyzer.java b/src/com/android/tradefed/result/skipped/ArtifactsAnalyzer.java index 618840d15..adc8ff2dd 100644 --- a/src/com/android/tradefed/result/skipped/ArtifactsAnalyzer.java +++ b/src/com/android/tradefed/result/skipped/ArtifactsAnalyzer.java @@ -47,18 +47,21 @@ public class ArtifactsAnalyzer { private final List<ContentAnalysisContext> mTestArtifactsAnalysisContent; private final List<String> mModulesDiscovered; private final List<String> mDependencyFiles; + private final AnalysisHeuristic mAnalysisLevel; public ArtifactsAnalyzer( TestInformation information, MultiMap<ITestDevice, ContentAnalysisContext> imageAnalysis, List<ContentAnalysisContext> testAnalysisContexts, List<String> moduleDiscovered, - List<String> dependencyFiles) { + List<String> dependencyFiles, + AnalysisHeuristic analysisLevel) { this.information = information; this.mImageAnalysis = imageAnalysis; this.mTestArtifactsAnalysisContent = testAnalysisContexts; this.mModulesDiscovered = moduleDiscovered; this.mDependencyFiles = dependencyFiles; + this.mAnalysisLevel = analysisLevel; } public BuildAnalysis analyzeArtifacts() { @@ -134,7 +137,8 @@ public class ArtifactsAnalyzer { c -> c.analysisMethod() .equals(AnalysisMethod.DEVICE_IMAGE)); - ImageContentAnalyzer analyze = new ImageContentAnalyzer(presubmit, context); + ImageContentAnalyzer analyze = + new ImageContentAnalyzer(presubmit, context, mAnalysisLevel); ContentAnalysisResults res = analyze.evaluate(); if (res == null) { deviceImageChanged = true; diff --git a/src/com/android/tradefed/result/skipped/SkipManager.java b/src/com/android/tradefed/result/skipped/SkipManager.java index 359343ef0..4518ff7c2 100644 --- a/src/com/android/tradefed/result/skipped/SkipManager.java +++ b/src/com/android/tradefed/result/skipped/SkipManager.java @@ -77,6 +77,9 @@ public class SkipManager implements IDisableable { description = "Some tests do not directly rely on content for being relevant.") private boolean mConsideredForContent = true; + @Option(name = "analysis-level", description = "Alter assumptions level of the analysis.") + private AnalysisHeuristic mAnalysisLevel = AnalysisHeuristic.REMOVE_EXEMPTION; + // Contains the filter and reason for demotion private final Map<String, SkipReason> mDemotionFilters = new LinkedHashMap<>(); @@ -155,7 +158,8 @@ public class SkipManager implements IDisableable { mImageAnalysis, mTestArtifactsAnalysisContent, mModulesDiscovered, - mDependencyFiles); + mDependencyFiles, + mAnalysisLevel); return buildAnalysisDecision(information, analyzer.analyzeArtifacts()); } |