Adding auto-investigation of one more flake
Reshuffling the tests to make the investigator the outmost rule and run the code that throws the original exception inside the investigator. Change-Id: I714717a9b616862db5ce59116138ba7ea6ceb971
This commit is contained in:
@@ -56,6 +56,7 @@ import com.android.launcher3.tapl.OverviewTask;
|
||||
import com.android.launcher3.tapl.TestHelpers;
|
||||
import com.android.launcher3.testcomponent.TestCommandReceiver;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.launcher3.util.rule.FailureRewriterRule;
|
||||
import com.android.launcher3.util.rule.FailureWatcher;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -99,7 +100,9 @@ public class FallbackRecentsTest {
|
||||
Utilities.enableRunningInTestHarnessForTests();
|
||||
}
|
||||
|
||||
mOrderSensitiveRules = RuleChain.outerRule(new NavigationModeSwitchRule(mLauncher))
|
||||
mOrderSensitiveRules = RuleChain
|
||||
.outerRule(new FailureRewriterRule())
|
||||
.around(new NavigationModeSwitchRule(mLauncher))
|
||||
.around(new FailureWatcher(mDevice));
|
||||
|
||||
mOtherLauncherActivity = context.getPackageManager().queryIntentActivities(
|
||||
|
||||
@@ -18,9 +18,6 @@ package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.util.RaceConditionReproducer.enterEvt;
|
||||
import static com.android.launcher3.util.RaceConditionReproducer.exitEvt;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_PRESUBMIT;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.RUN_FLAFOR;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.UNBUNDLED_PRESUBMIT;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ import com.android.launcher3.util.ContentWriter;
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.launcher3.util.rule.FailureRewriterRule;
|
||||
import com.android.launcher3.util.rule.FailureWatcher;
|
||||
import com.android.launcher3.util.rule.LauncherActivityRule;
|
||||
import com.android.launcher3.util.rule.ShellCommandRule;
|
||||
@@ -161,9 +162,10 @@ public abstract class AbstractLauncherUiTest {
|
||||
|
||||
@Rule
|
||||
public TestRule mOrderSensitiveRules = RuleChain.
|
||||
outerRule(new TestStabilityRule()).
|
||||
around(mActivityMonitor).
|
||||
around(getRulesInsideActivityMonitor());
|
||||
outerRule(new FailureRewriterRule())
|
||||
.around(new TestStabilityRule())
|
||||
.around(mActivityMonitor)
|
||||
.around(getRulesInsideActivityMonitor());
|
||||
|
||||
public UiDevice getDevice() {
|
||||
return mDevice;
|
||||
|
||||
@@ -47,6 +47,12 @@ class FailureInvestigator {
|
||||
logSinceTestsStart)) {
|
||||
return 147845913;
|
||||
}
|
||||
} else if (matches("java.lang.AssertionError: Launcher build match not found", exception)) {
|
||||
if (matches(
|
||||
"TestStabilityRule: Launcher package: com.google.android.setupwizard",
|
||||
logSinceTestsStart)) {
|
||||
return 145935261;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.launcher3.util.rule;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class FailureRewriterRule implements TestRule {
|
||||
private static final String TAG = "FailureRewriter";
|
||||
|
||||
private static final String testsStartTime =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
try {
|
||||
base.evaluate();
|
||||
} catch (Throwable e) {
|
||||
final int bug =
|
||||
FailureInvestigator.getBugForFailure(e.toString(), testsStartTime);
|
||||
if (bug == 0) throw e;
|
||||
|
||||
Log.e(TAG, "Known bug found for the original failure "
|
||||
+ android.util.Log.getStackTraceString(e));
|
||||
throw new AssertionError(
|
||||
"Detected a failure that matches a known bug b/" + bug);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,10 @@ import androidx.test.uiautomator.UiDevice;
|
||||
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class FailureWatcher extends TestWatcher {
|
||||
private static final String TAG = "FailureWatcher";
|
||||
@@ -38,30 +35,6 @@ public class FailureWatcher extends TestWatcher {
|
||||
}
|
||||
}
|
||||
|
||||
private static final String testsStartTime =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
try {
|
||||
base.evaluate();
|
||||
} catch (Throwable e) {
|
||||
final int bug =
|
||||
FailureInvestigator.getBugForFailure(e.toString(), testsStartTime);
|
||||
if (bug == 0) throw e;
|
||||
|
||||
Log.e(TAG, "Known bug found for the original failure "
|
||||
+ android.util.Log.getStackTraceString(e));
|
||||
throw new AssertionError(
|
||||
"Detected a failure that matches a known bug b/" + bug);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void failed(Throwable e, Description description) {
|
||||
onError(mDevice, description, e);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class TestStabilityRule implements TestRule {
|
||||
public static final int PLATFORM_PRESUBMIT = 0x8;
|
||||
public static final int PLATFORM_POSTSUBMIT = 0x10;
|
||||
|
||||
public static final int RUN_FLAFOR = getRunFlavor();
|
||||
private static int sRunFlavor;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@@ -73,7 +73,8 @@ public class TestStabilityRule implements TestRule {
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
if ((stability.flavors() & RUN_FLAFOR) != 0) {
|
||||
if (sRunFlavor == 0) sRunFlavor = getRunFlavor();
|
||||
if ((stability.flavors() & sRunFlavor) != 0) {
|
||||
Log.d(TAG, "Running " + description.getDisplayName());
|
||||
base.evaluate();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user