144 Commits

Author SHA1 Message Date
Erik Kline
60d14c429b Merge "Add test coverage for cleanup bug to be fixed." am: 89e6bf0532 am: 0cca15ff88
am: 3de5971b40

Change-Id: I470c481a0eebc9cadf134c73ece08803927f4ca2
2017-02-13 12:08:11 +00:00
Erik Kline
0cca15ff88 Merge "Add test coverage for cleanup bug to be fixed."
am: 89e6bf0532

Change-Id: I33347c8fc2bec5660b8e9c14a316f6d14a6cf8b1
2017-02-13 11:57:37 +00:00
Erik Kline
a954be9563 Add test coverage for cleanup bug to be fixed.
The test calls that need to pass but do not currently are commented out.

Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest -x .../tethering/TetherInterfaceStateMachineTest.java passes
Bug: 32031803
Bug: 32163131

Change-Id: I68ed476920bef882f353d8e8a54c72120bc27002
2017-02-13 17:38:34 +09:00
Erik Kline
c700509ade Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe am: 6f32aa0259
am: 7196e935a8

Change-Id: I2ab05143299f13012dc2a88efca52160e08c6d97
2017-02-02 07:32:09 +00:00
Erik Kline
6f32aa0259 Merge "Add ConnectivityManager.networkCapabilitiesForType()"
am: c313123afe

Change-Id: I0ad50fbf38f11b383fd889dc598cfddd47051477
2017-02-02 07:22:05 +00:00
Treehugger Robot
c313123afe Merge "Add ConnectivityManager.networkCapabilitiesForType()" 2017-02-02 07:15:05 +00:00
Erik Kline
2ebea21074 Merge "Add test for repeated calls to registerMobileUpstreamRequest()" am: 603eefd5d5 am: 180a3d07a8
am: d85f448274

Change-Id: Ia629aa5dbdf10566c28525d9a05b096482db3f2d
2017-02-02 05:25:05 +00:00
Erik Kline
180a3d07a8 Merge "Add test for repeated calls to registerMobileUpstreamRequest()"
am: 603eefd5d5

Change-Id: I6b2a0d6df70df028ef9b8ff5d689c5a627d8daf8
2017-02-02 05:15:23 +00:00
Erik Kline
35bf06c968 Add ConnectivityManager.networkCapabilitiesForType()
This static method returns a NetworkCapabilities instance with
transports and capabilities set according to the given legacy type.

Also:
    - add NetworkRequest.Builder.setCapabilities(), to be able to use
      the NetworkCapabilities instances returned from the above
    - update UpstreamNetworkMonitor to make immediate use of this

Test: as follows
    - build (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - WiFi to DUN upstream tethering works
Bug: 32163131

Change-Id: Idfe1ddd2815c355cbf27cf29eb0e3de177de84e9
2017-02-02 11:07:59 +09:00
Erik Kline
7462f467c1 Add test for repeated calls to registerMobileUpstreamRequest()
Test: as follows
    - built
    - flashed
    - booted
    - runtest framework-net passes
Bug: 32163131

Change-Id: I6d2519601b7a9dcfda2917118214a7ceb9dbbb7f
2017-02-01 21:30:15 +09:00
Lorenzo Colitti
6e7f7dc643 ConnectivityServiceTest: remove remaining poll loops. am: d2706127d0 am: 54e9050710
am: 67d6d41954

Change-Id: I31681e1248721704a9b792962a2ef5955e375e93
2017-02-01 03:01:52 +00:00
Lorenzo Colitti
4fc1296cef Remove assertEventuallyTrue as it's unnecessary. am: 30145d755c am: 90a70cac26
am: 90babed246

Change-Id: Ib16f54aeaa783a6e26a9d80e61388cbd9ecd9bd3
2017-02-01 03:00:41 +00:00
Lorenzo Colitti
d526434f05 Rename AvoidBadWifiTracker to MultinetworkPolicyTracker am: 58ebe1c6f1 am: 0bc8070fce
am: 338241de94

Change-Id: I91f1338f3488cfc60eef0c2147aa7b1d61107cdd
2017-02-01 02:59:42 +00:00
Lorenzo Colitti
8e3718459b Attempt to make waitForIdleHandler reliable. am: ae3ce81cc3 am: 8780a8afeb
am: 943808385a

Change-Id: I2369fbd693b467283232f47703fd471c8ff60c1f
2017-02-01 02:58:24 +00:00
Lorenzo Colitti
54e9050710 ConnectivityServiceTest: remove remaining poll loops.
am: d2706127d0

Change-Id: I675096683c8ed4bc0e540491c0ff6aa828114313
2017-02-01 02:39:30 +00:00
Lorenzo Colitti
90a70cac26 Remove assertEventuallyTrue as it's unnecessary.
am: 30145d755c

Change-Id: Id574b27b40e35fbccac49910867e9735c03118d4
2017-02-01 02:38:30 +00:00
Lorenzo Colitti
0bc8070fce Rename AvoidBadWifiTracker to MultinetworkPolicyTracker
am: 58ebe1c6f1

Change-Id: I7615c9128deed7011eb9ab6f2efdcfe2e237a1a5
2017-02-01 02:37:31 +00:00
Lorenzo Colitti
8780a8afeb Attempt to make waitForIdleHandler reliable.
am: ae3ce81cc3

Change-Id: Id7e23c3a2c885ff239efa577a8d366d3df6ca9a2
2017-02-01 02:36:22 +00:00
Lorenzo Colitti
d2706127d0 ConnectivityServiceTest: remove remaining poll loops.
All the tests are now asynchronous. The only remaining uses of
Thread.sleep() are in the tests that check for NetworkRequest
timeouts.

Test: ConnectivityServiceTest passes 100 times in a row
Bug: 32561414
Change-Id: If420bd66c692a90d5031ee06a888a8cc3b4398a8
2017-01-31 15:44:23 +09:00
Lorenzo Colitti
30145d755c Remove assertEventuallyTrue as it's unnecessary.
The calls in testAvoidBadWifi are no longer necessary now that
waitForIdle is reliable, and the calls in testPacketKeepalives
are replaced with a wait for the NetworkAgent to disconnect.

Test: ConnectivityServiceTest passes 100 times in a row.
Bug: 32561414
Change-Id: Icbb161ca6e343bd14764a1c9ccfdd14b6cd6803f
2017-01-31 15:42:58 +09:00
Lorenzo Colitti
58ebe1c6f1 Rename AvoidBadWifiTracker to MultinetworkPolicyTracker
Rename the class and ensure that all code related to bad wifi
avoidance has names that reflect its purpose.  This will allow us
to reuse most of the the code for other purposes in future CLs.

Test: runtest frameworks-net passes
Bug: 34630278
Change-Id: Ida190e5a79e7a12f4eec07e1a3e4d9d138e83bcd
2017-01-31 15:42:57 +09:00
Lorenzo Colitti
ae3ce81cc3 Attempt to make waitForIdleHandler reliable.
The current implementation of IdleableHandlerThread is based on
the assumption that MessageQueue#isIdle will return true iff the
message loop has finished processing its messages.

Unfortunately, this is incorrect: isIdle returns true iff are no
more messages waiting in the queue; thus, it will also return
true while it is processing the last message before going idle.

Instead of using idle handlers, take the simpler approach of
posting a runnable to the message loop and waiting for it to
be processed.

Test: see other CLs in this patch series
Bug: 31479480
Change-Id: Iae75781f067b762c8653a488a5e4d5ee0c789e01
2017-01-31 15:42:17 +09:00
Hugo Benichi
488ffdc784 Merge "ApfTest: fix flaky testApfFilterRa." am: c2e8588396 am: 60e1375f79
am: 811f6c86da

Change-Id: Idd738e1a4c9f0a865f5b84270535a94c492341ce
2017-01-31 06:11:35 +00:00
Hugo Benichi
60e1375f79 Merge "ApfTest: fix flaky testApfFilterRa."
am: c2e8588396

Change-Id: I79c3ec0ba35973cc0dd32709447b2cc30e790d08
2017-01-31 06:01:58 +00:00
Hugo Benichi
4456f33a95 ApfTest: fix flaky testApfFilterRa.
testApfFilterRa is failing with probabiliy 1/10 ~ 1/15 on the following
assert: assertDrop(program, packet, lifetime/6), for lifetime values
that are multiple of 6, where 6 is the hardcoded fraction of RA lifetime
to filter in ApfFilter.java.

When the lifetime is not a multiple of 6, the remainder of 1 to 5
seconds gives enough margin so that when the APF program is simulated
the faked lifetime of the program is less than lifetime/6 away and the
packet is dropped.

However for lifetimes which are exact multiples of 6, this margin is
always 0s and that result in nondeterminism in the result. This is
consistent with the obervation that the only failed assert was for a
lifetime of 300s, the only multiple of 6.

This can be observed by detecting the age limit at which the filter
stops dropping packet oscillating between lifetime/6 and lifetime/6 + 1
for lifetimes which are multiple of 6.

This patch fixes the flakyness by freezing the flow of time in tests so
that the expected filter age threshold is consistent and stable.

Test: no failure observed in 1000 runs.
Bug: 32561414
Change-Id: I5251d047039f34b82ce8a5d20ae46563e1e0cce8
2017-01-31 11:13:44 +09:00
Erik Kline
8aba32468a Merge "Switch to listening for all network changes." am: 085ffa76fa am: 46f8abd229
am: 118c0c9e7d

Change-Id: I82ac34a2f846f4ebe164e4190716559186204934
2017-01-27 19:33:16 +00:00
Erik Kline
46f8abd229 Merge "Switch to listening for all network changes."
am: 085ffa76fa

Change-Id: I87157788c5c2dc1015f9518c1c443256cfd30bae
2017-01-27 19:14:39 +00:00
Treehugger Robot
085ffa76fa Merge "Switch to listening for all network changes." 2017-01-27 19:07:08 +00:00
Lorenzo Colitti
5bad599e2e Merge "ConnectivityServiceTest: fix flaky tests" am: b8bbd30203 am: 8fea8e5bbd
am: c620e64f61

Change-Id: Iaa1ab50a323133cadfa4f39440fce982cde8d1fe
2017-01-27 10:00:06 +00:00
Lorenzo Colitti
420ad9748a Merge "ConnectivityServiceTest: remove flaky waitForIdle test." am: be80577f5b am: 0c659d2065
am: f8cff961c8

Change-Id: I1d3707b4bc2ae00ca0fad1c3ec7e6ca859fcdd16
2017-01-27 09:55:36 +00:00
Lorenzo Colitti
8fea8e5bbd Merge "ConnectivityServiceTest: fix flaky tests"
am: b8bbd30203

Change-Id: I0577f6b48de8a95e7d12e58a672fb0374ced9403
2017-01-27 09:51:32 +00:00
Lorenzo Colitti
0c659d2065 Merge "ConnectivityServiceTest: remove flaky waitForIdle test."
am: be80577f5b

Change-Id: I444746af6adc7be4a3f69243379f65aadf29ea19
2017-01-27 09:47:05 +00:00
Lorenzo Colitti
b8bbd30203 Merge "ConnectivityServiceTest: fix flaky tests" 2017-01-27 09:40:47 +00:00
Erik Kline
d2ec3919cb Switch to listening for all network changes.
This is for use while preferred upstreams are expressed as legacy types.

Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - USB tethering to WiFi and DUN works
Bug: 32163131
Change-Id: I76e7b6c95eb1b54e926096b2791163617bb0a818
2017-01-26 20:50:51 +09:00
Hugo Benichi
352147a308 frameworks-test: adding missing @SmallTest
This activates all frameworks-test tests in runs of the continuous
platform tests.

Test: $ runtest frameworks-net passes (expect Tether
Bug: 32561414
(cherry picked from commit fa8a6f6220d1a0027ba7969c2d3f72690ddc6495)

Change-Id: I7b0706a7e3368f971d508388e8ad4afc5de9d646
2017-01-26 18:52:45 +09:00
Hugo Benichi
222ebe48ba Netd events: record connect() success/errno
Test: $ runtest frameworks-net pass
Bug: 32198976

(cherry picked from commit 8b06bcdfd24100302818ae0e11ee751dd813d5cf)

Change-Id: Ib3be06d2678c3fcfe4fa9d7b77f50c6e8812db3d
2017-01-26 18:52:41 +09:00
Tony Mak
094fbe6719 Show notification for always-on app VPN
This is the same notification as the one shown during legacy lockdown
mode, sans the 'reset' button.

The notification is only shown during times when VPN has not yet
established or has failed, for example during boot or after a crash.

Bug: 29123115

(cherry picked from commit 1a405fe300950d6ceae2166fd074b596d8110dbe)

Change-Id: I929a05c24df01e21415535a333bb14ac4b790a9d
2017-01-26 18:52:35 +09:00
Hugo Benichi
5c2111bc3a APF: also drop any ICMPv6 RSs
Test: new unit test + $ runtest franeworks-net
Bug: 32833400

(cherry picked from commit f98182ef5e80ede5de7f2c2a5f40fc92a46c9704)

Change-Id: Ifaf6e778c811c7d865c790a293b1fce3f43cad1c
2017-01-26 18:52:21 +09:00
Hugo Benichi
d49596f479 ConnectivityServiceTest: fix testAvoidBadWifiSettings
This patch introduces an assertEventuallyThat helper function in
ConnectivityServiceTest which given a boolean function retries until the
function returns true or until a maximum retry time is reached.

This function is used to fix flakyness of testAvoidBadWifiSetting where
the Message posted by reevaluate() could reach the Handler's
MessageQueue after waitForIdle takes effect, resulting in the test to
fail.

Instead of fixing the flakyness by introdcing hard sleep times,
assertEventuallyThat is used to reduce the overall test time.

With this change the test has been observed to pass with 100% success
rate over 50000 invocations.

Test: $ runtest frameworks-net
Bug: 32561414

(cherry picked from commit 99c8294ef0c7a720364abb5884063e0a9d1bb5fe)

Change-Id: If41a24989d5f65aeb439f68741f511b5eb53b18d
2017-01-26 18:52:18 +09:00
Hugo Benichi
b038044758 Fix ConnectivityServiceTest testRequestBenchmark
This patch fixes flakyness of testRequestBenchmark by adjusting time
limit for callback registration from 100ms to 180ms, and time limits for
onAvailable and onLost triggers from 30ms to 40ms.

With these timeouts the test succeeds 100% over 5000 iterations.

When using 150ms for registration timeout, running the test 5000 times
fails 2 times.

When using 30ms for onLost timeout, running the test 5000 times fails
1 times.

In addition, this patch also cleans testRequestBenchmark and uses the
more stable SystemClock.elapsedRealtime() for duration measurements.

Test: $ runtest frameworks-net
Bug: 32561414

(cherry picked from commit 38be57b438a0c1754091f045317db2049304e16f)

Change-Id: I196ab9ef7f5abe456a783eed65db09279d2ecb8c
2017-01-26 18:52:14 +09:00
Hugo Benichi
728842ad47 IpConnectivityMetrics reads buffer size in settings
Test: IpConnectivityMetricsTest passes. Also manually changed the new
setting and verified the buffer size is as expected after flushing the
buffer.
Bug: 32198637

(cherry picked from commit 05686dbb6b965eb1a54591d2ed2334337886c6ee)

Change-Id: Iefbeac3a688b260fb3f92dfe0bfd9db28e26749d
2017-01-26 18:51:30 +09:00
Hugo Benichi
d19752c3d0 IpConnectivity metrics: add version number
This patch adds a version field to ipconnectivity.proto and populates it
to 2, which is the logical version number for NYC-MR2.

Test: IpConnectivity{EventBuilder,Metrics}Test pass
Bug: 32127906

(cherry picked from commit d680d4c856f54bea0c60dea74ba4204822391e49)

Change-Id: If8f167c0dc4c1abe0e235e2adfd131168a4ddc52
2017-01-26 18:51:18 +09:00
Etan Cohen
1256590348 [CS] Remove timeout event after first available
Guarantees that timeouts are only delivered if a network never
becomes available. Once a network is available the timeout is
canceled.

Bug: 31402633
Test: all timeout related unit tests pass (new one added)

(cherry picked from commit 681fcda5896fd6c94f8a543ef9983c0a0644e87e)

Change-Id: I7cd3086544c881915fc6dbf14b87a24ab0cd8748
2017-01-26 18:51:15 +09:00
Hugo Benichi
f488ffd3be ApfTest: tag tests with @SmallTest or @MediumTest
Test methods not tagged with @{Small,Medium,Large}Test will not appear
in the Android Platform Continuous Testing dashboard.

Test methods tagged with @LargeTest will not be run in the Android
Platform Continuous Testing dashboard.

Test: ApfTest passes ($runtest frameworks-net)
Bug: 31479480

(cherry picked from commit 4195c28347cc100954f83c3c92b4dde4673f8608)

Change-Id: Ia215fc8e2ccc61f6223c24fdf390e1e759de302f
2017-01-26 18:51:12 +09:00
Lorenzo Colitti
f537c5eb74 Unbreak TetherInterfaceStateMachineTest.
This was broken by the implementation of IPv6 tethering, which
relies on various private classes which end up calling unmockable
final classes like NetworkInterface.

Making everything public like this is almost certainly not the
best way of fixing this test, but on the other hand there is
value to the test continuing to pass.

Test: runtest frameworks-net  # Everything passes.
Test: IPv6 tethering continues to work.

(cherry picked from commit 7e0eeca8ba4063d0d35dda9a8dfcc612e45efb87)

Change-Id: I8a3cf466871c026f4ae0f5cfa73071338cdf5b7e
2017-01-26 18:51:09 +09:00
Lorenzo Colitti
47a44ba2b1 Move the connectivity tests to frameworks/base/tests/net.
This will give us a good place to put all the networking tests.

Fix: 31479480
Test: adb  shell am instrument -w -e notClass com.android.server.connectivity.tethering.TetherInterfaceStateMachineTest 'com.android.frameworks.tests.net/android.support.test.runner.AndroidJUnitRunner'  # PASS

(cherry picked from commit ecc986d430f4b8158f177ed97d2edb741f11ff71)

Change-Id: I993eeaa5dec001c39389023f355f506129b356e7
2017-01-26 18:50:59 +09:00
Hugo Benichi
141923e5b6 DO NOT MERGE frameworks-test: adding missing @SmallTest
This activates all frameworks-test tests in runs of the continuous
platform tests.

Test: $ runtest frameworks-net passes (expect Tether
Bug: 32561414

(cherry picked from commit fa8a6f6220d1a0027ba7969c2d3f72690ddc6495)

Change-Id: I84f9aecfbf9ebe07c6fcfec26acb2c2cfaae2d60
2017-01-24 15:42:45 +09:00
Hugo Benichi
ad4db4ed58 ConnectivityServiceTest: remove flaky waitForIdle test.
This patch removes testNotWaitingForIdleCausesRaceConditions() from
ConnectivityServiceTest because it is in nature flaky and prevents using
ConnectivityServiceTest as a patch presubmit check. Estimated failure
rate is 1/15 on Nexus 6p.

This patch also simplifies how ConnectivityServiceTest waits for
handlers to become idle by removing IdleableHandlerThread and turning it
into a signle static method.

Test: $ runtest frameworks-net
Bug: 31479480
Change-Id: I2d78709cbb61d5d01cd59cff326469417f73f1ab
2017-01-24 15:22:48 +09:00
Hugo Benichi
dfb559a363 ConnectivityServiceTest: fix flaky tests
This patch adjusts timeouts in ConnectivityServiceTest to fix tests
known to fail spruriously.

Test: ran the following tests 500 times without observing any failure
 - testBackgroundNetworks()
 - testMultipleLingering()
 - testPacketKeepalives()
 - testSatisfiedNetworkRequestDoesNotTriggerOnUnavailable()
 - testSatisfiedThenLostNetworkRequestDoesNotTriggerOnUnavailable()
Bug: 32561414
Change-Id: I184fe7189aac768a65b927cc42eefaf8b1b3f930
2017-01-24 15:21:18 +09:00
Erik Kline
552f5620d1 Merge "Add test for updateMobileRequiresDun()" am: 7f018500dc am: 2a3338084a
am: 503374c0ae

Change-Id: I25751833ed6623ab156156fc76aa23b158a60fb4
2017-01-23 11:06:06 +00:00