Merge "Fix a flaky test." into rvc-dev

This commit is contained in:
JW Wang
2020-04-01 16:37:09 +00:00
committed by Android (Google) Code Review
3 changed files with 6 additions and 14 deletions

View File

@@ -39,7 +39,7 @@ java_test_host {
name: "NetworkStagedRollbackTest",
srcs: ["NetworkStagedRollbackTest/src/**/*.java"],
libs: ["tradefed"],
static_libs: ["testng", "RollbackTestLib"],
static_libs: ["RollbackTestLib"],
test_suites: ["general-tests"],
test_config: "NetworkStagedRollbackTest.xml",
}

View File

@@ -20,7 +20,6 @@ import static com.android.tests.rollback.host.WatchdogEventLogger.watchdogEventO
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.testng.Assert.assertThrows;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
@@ -31,6 +30,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* Runs the network rollback tests.
@@ -83,11 +83,12 @@ public class NetworkStagedRollbackTest extends BaseHostJUnit4Test {
// Verify rollback was enabled
runPhase("testNetworkFailedRollback_Phase2");
assertThrows(AssertionError.class, () -> runPhase("testNetworkFailedRollback_Phase3"));
// Wait for reboot to happen
assertTrue(getDevice().waitForDeviceNotAvailable(TimeUnit.MINUTES.toMillis(5)));
// Wait for reboot to complete and device to become available
getDevice().waitForDeviceAvailable();
// Verify rollback was executed after health check deadline
runPhase("testNetworkFailedRollback_Phase4");
runPhase("testNetworkFailedRollback_Phase3");
List<String> watchdogEvents = mLogger.getWatchdogLoggingEvents();
assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_INITIATE, null,

View File

@@ -119,15 +119,6 @@ public class NetworkStagedRollbackTest {
@Test
public void testNetworkFailedRollback_Phase3() throws Exception {
// Sleep for > health check deadline (120s to trigger rollback + 120s to reboot)
// The device is expected to reboot during sleeping. This device method will fail and
// the host will catch the assertion. If reboot doesn't happen, the host will fail the
// assertion.
Thread.sleep(TimeUnit.SECONDS.toMillis(240));
}
@Test
public void testNetworkFailedRollback_Phase4() throws Exception {
RollbackManager rm = RollbackUtils.getRollbackManager();
assertThat(getUniqueRollbackInfoForPackage(rm.getRecentlyCommittedRollbacks(),
getNetworkStackPackageName())).isNotNull();