Commit 151076c0 authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Fix NQE Cronet tests

The tests broke due to changes on the Chromium side. Specifically,
those changes optimized when the prefs are written. With the changes,
the prefs may not be written in certain cases.

This CL forces the value of effective connection type
as Slow2G in the tests. This causes the prefs to be always written.

Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Bug: 793154
Change-Id: Ie09261da07ed44a78b37d02527e105a1dc72ca6c
Reviewed-on: https://chromium-review.googlesource.com/815949
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarHelen Li <xunjieli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523126}
parent 7426194d
......@@ -23,7 +23,6 @@ import org.junit.runner.RunWith;
import org.chromium.base.Log;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MetricsUtils.HistogramDelta;
import org.chromium.net.CronetTestRule.OnlyRunNativeCronet;
......@@ -164,7 +163,6 @@ public class NQETest {
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
@DisabledTest(message = "crbug.com/793154")
public void testQuicDisabled() throws Exception {
ExperimentalCronetEngine.Builder cronetEngineBuilder =
new ExperimentalCronetEngine.Builder(getContext());
......@@ -175,6 +173,16 @@ public class NQETest {
TestNetworkQualityThroughputListener throughputListener =
new TestNetworkQualityThroughputListener(listenersExecutor);
cronetEngineBuilder.enableNetworkQualityEstimator(true).enableHttp2(true).enableQuic(false);
// The pref may not be written if the computed Effective Connection Type (ECT) matches the
// default ECT for the current connection type. Force the ECT to "Slow-2G". Since "Slow-2G"
// is not the default ECT for any connection type, this ensures that the pref is written to.
JSONObject nqeOptions = new JSONObject().put("force_effective_connection_type", "Slow-2G");
JSONObject experimentalOptions =
new JSONObject().put("NetworkQualityEstimator", nqeOptions);
cronetEngineBuilder.setExperimentalOptions(experimentalOptions.toString());
cronetEngineBuilder.setStoragePath(getTestStorage(getContext()));
final ExperimentalCronetEngine cronetEngine = cronetEngineBuilder.build();
cronetEngine.configureNetworkQualityEstimatorForTesting(true, true, true);
......@@ -259,7 +267,6 @@ public class NQETest {
@SmallTest
@OnlyRunNativeCronet
@Feature({"Cronet"})
@DisabledTest(message = "crbug.com/793154")
public void testPrefsWriteRead() throws Exception {
// When the loop is run for the first time, network quality is written to the disk. The
// test verifies that in the next loop, the network quality is read back.
......@@ -273,6 +280,18 @@ public class NQETest {
new TestNetworkQualityRttListener(listenersExecutor);
cronetEngineBuilder.enableNetworkQualityEstimator(true).enableHttp2(true).enableQuic(
false);
// The pref may not be written if the computed Effective Connection Type (ECT) matches
// the default ECT for the current connection type. Force the ECT to "Slow-2G". Since
// "Slow-2G" is not the default ECT for any connection type, this ensures that the pref
// is written to.
JSONObject nqeOptions =
new JSONObject().put("force_effective_connection_type", "Slow-2G");
JSONObject experimentalOptions =
new JSONObject().put("NetworkQualityEstimator", nqeOptions);
cronetEngineBuilder.setExperimentalOptions(experimentalOptions.toString());
cronetEngineBuilder.setStoragePath(getTestStorage(getContext()));
final ExperimentalCronetEngine cronetEngine = cronetEngineBuilder.build();
......@@ -324,7 +343,9 @@ public class NQETest {
// Stored network quality in the pref should be read in the second iteration.
assertEquals(readPrefsSizeHistogram.getDelta() > 0, i > 0);
assertEquals(cachedRttHistogram.getDelta() > 0, i > 0);
if (i > 0) {
assertTrue(cachedRttHistogram.getDelta() > 0);
}
}
}
......
......@@ -22,7 +22,6 @@ import org.junit.runner.RunWith;
import org.chromium.base.Log;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.net.CronetTestRule.OnlyRunNativeCronet;
import org.chromium.net.MetricsTestUtil.TestRequestFinishedListener;
......@@ -57,6 +56,11 @@ public class QuicTest {
mBuilder.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getServerPort(),
QuicTestServer.getServerPort());
// The pref may not be written if the computed Effective Connection Type (ECT) matches the
// default ECT for the current connection type. Force the ECT to "Slow-2G". Since "Slow-2G"
// is not the default ECT for any connection type, this ensures that the pref is written to.
JSONObject nqeParams = new JSONObject().put("force_effective_connection_type", "Slow-2G");
// TODO(mgersh): Enable connection migration once it works, see http://crbug.com/634910
JSONObject quicParams = new JSONObject()
.put("connection_options", "PACE,IW10,FOO,DEADBEEF")
......@@ -68,7 +72,8 @@ public class QuicTest {
JSONObject hostResolverParams = CronetTestUtil.generateHostResolverRules();
JSONObject experimentalOptions = new JSONObject()
.put("QUIC", quicParams)
.put("HostResolverRules", hostResolverParams);
.put("HostResolverRules", hostResolverParams)
.put("NetworkQualityEstimator", nqeParams);
mBuilder.setExperimentalOptions(experimentalOptions.toString());
mBuilder.setStoragePath(getTestStorage(getContext()));
mBuilder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 1000 * 1024);
......@@ -168,7 +173,6 @@ public class QuicTest {
@Feature({"Cronet"})
@OnlyRunNativeCronet
@SuppressWarnings("deprecation")
@DisabledTest(message = "crbug.com/793154")
public void testNQEWithQuic() throws Exception {
ExperimentalCronetEngine cronetEngine = mBuilder.build();
String quicURL = QuicTestServer.getServerURL() + "/simple.txt";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment