Commit Graph

302 Commits

Author SHA1 Message Date
Hugo Benichi
ae3dac0601 Merge "Networking unit tests: fix some flaky tests"
am: 501bae6492

Change-Id: I6815e732f334d11208ff12af4023912593d96499
2017-07-03 09:35:06 +00:00
Hugo Benichi
44ceaa602e Networking unit tests: fix some flaky tests
- less strict regex for SharedLogTest: the subsecond part of the
   timestamp can have 0, 1, 2 or 3 digits.
 - refactor NetworkStatsServiceTest and NetworkStatsObserversTest to use
   waitForIdleHandler facility of ConnectivityServiceTest.
   NetworkStatsServiceTest was using a flaky custom version of
   waitForIdleHandler.

Bug: 62918393
Bug: 32561414
Test: runtest frameworks-net
Change-Id: I634acfb5f4fe1bd5267e3f14b9f645edc32d5d12
2017-07-03 16:29:01 +09:00
Hugo Benichi
ac7ad05464 Merge "Fix race condition in NsdManagerTest" am: f2383db747 am: 2dfb494827
am: ba82d646a6

Change-Id: I7efa4f92838428f69a6a7a9fa767fefa47246f69
2017-05-31 13:25:53 +00:00
Hugo Benichi
986eaa7b76 Fix race condition in NsdManagerTest
NsdManagerTest relies on the lastMessage variable to assert the
connection of a client to the service. The asserts in test are done on a
different thread, although the variable was not qualified volatile,
which creates the chance to read a stale value. This patch fixes this
race by marking the variable volatile.

Bug: 32561414
Bug: 62044295
Test: NsdManagerTest works
Change-Id: I0bc2cd8059c6ff8b78a2dda0ba8d6bc7e13ef951
2017-05-31 15:35:54 +09:00
Hugo Benichi
bbdcd7c4a4 Merge "ConnectivityServiceTest: more tweaks to testRequestBenchmark" am: 76efbb30f5 am: 5f046cb614
am: 7bbdfcd8eb

Change-Id: I96c39ca1899768d039a108426fb04655aaf8d55f
2017-05-31 04:10:03 +00:00
Hugo Benichi
4d7887a2fa ConnectivityServiceTest: more tweaks to testRequestBenchmark
Recent continuous testing runs indicates that commit 79614aee did not
completely fixed the issue with testRequestBenchmark.

This patch changes the name of the test to not include "test" and
removes @SmallTest annotation, which should do the job of @Ignore while
ConnectivityServiceTest still extends AndroidTestCase.

In addition timeouts are adjusted to take into account recent failures
observed.

This is the last pending action before turning on FrameworksNetTests on
presubmits.

Bug: 32561414
Test: no functional change
Change-Id: I56ef334e19e99e5a3483418330e5f0ccd6eb31bb
2017-05-31 10:23:42 +09:00
Hugo Benichi
7cabb60411 Merge changes If4deb106,Ib25d7658 am: 0388f0e47b am: 41a57af66a
am: ae278410f5

Change-Id: I4fa34b647e7b2408d4493cfb148ae7d8c24bd6e8
2017-05-26 00:58:27 +00:00
Hugo Benichi
79614aee12 @Ignore ConnectivityServiceTest#testRequestBenchmark
Ignore the last remaining test in ConnectivityServiceTest with spurious
failures. testRequestBenchmark has some intrinsic chances of failure due
to the fact it attempts to assert elapsed time durations against a
reference target.

Bug: 32561414
Test: no functional change
Change-Id: Ib25d76581b47997b2ef84df3e6a9fd9224b85d92
2017-05-26 07:18:15 +09:00
Hugo Benichi
6cd853a362 Merge "NsdServiceInfo: move test to tests/net" am: 48859e01d5 am: 1b0f4bf606
am: e8c2700519

Change-Id: I44cae417fcddad72c13938b6fb751de6ed784046
2017-05-25 01:12:51 +00:00
Hugo Benichi
f0fdd9a831 Merge "Move NsdServiceTest to correct directory" am: 6a5c978605 am: ca9fcb79f6
am: ecf4267889

Change-Id: Ib4e100fc8219b58ab7850407735a444dad3ec153
2017-05-24 07:15:09 +00:00
Hugo Benichi
f56aa32b2b NsdServiceInfo: move test to tests/net
This patch also
  - adds a license plate to NsdServiceInfoTest
  - fixes some formatting and style issues
      package name
      uses of canonical junit asserts
  - update NsdServiceInfoTest to not use the deprecated AndroidTestCase

Bug: 62044295
Bug: 32561414
Test: $ runtest frameworks-net passes
Change-Id: Ie5ebb00172aef4eec19e6ecd2b41c4467901b93d
2017-05-24 16:03:43 +09:00
Treehugger Robot
6a5c978605 Merge "Move NsdServiceTest to correct directory" 2017-05-24 06:47:30 +00:00
Hugo Benichi
168489b45d Move NsdServiceTest to correct directory
Test: no functional change
Bug: 62044295
Change-Id: Iad3af646e8d252f84978d1a367878a78c2869982
2017-05-24 14:18:48 +09:00
Hugo Benichi
15dcccb4a1 Merge "Fix NetworkStatsObserversTest" am: bec71d8f9b am: 25282c3e38
am: 814351c843

Change-Id: Ice4bb8de4267cba7a15a60838e165fab5ebade72
2017-05-23 14:18:30 +00:00
Hugo Benichi
ce5380e12c Merge "Fix NetworkStatsAccessTest" am: d8d4bcd3bc am: cdb75d321b
am: 85afabc4ec

Change-Id: I60f9d8867655a6aa24ee192c772d4c26a96c9bcd
2017-05-23 07:02:54 +00:00
Hugo Benichi
2d2b500068 Merge "ConnectivityServiceTest: fix flakyness" am: 8222ec90c6 am: 004f36d5bc
am: eb9d0f16aa

Change-Id: Ic792060aafb5aa8b485054be18c3dba82bb15a3b
2017-05-23 04:56:41 +00:00
Hugo Benichi
a2a3380def Fix NetworkStatsObserversTest
This patch fixes several spurious unit tests in
NetworkStatsObserversTest by using the updated waitForIdleHandler of
ConnectivityServiceTest. More specifically this fixes the following
tests:
  - testUnregister_knownRequest_releasesCaller
  - testUpdateStats_deviceAccess_notifies
  - testUpdateStats_userAccess_usageSameUser_notifies
  - testUpdateStats_defaultAccess_notifiesSameUid

This patch also removes the dummy message with type -1 sent at the end
of tests in NetworkStatsObserversTest and the associated assert, because
nothing is exercised or asserted immediately after.

This patch also updates NetworkStatsObserversTest to not depend on the
deprecated junit.framework.TestCase.

Bug: 32561414
Test: runtest -x frameworks/base/tests/../NetworkStatsObserversTest.java
Change-Id: I4fc909ee9bacc964c859fa7a3db34f9dc86b89cf
2017-05-23 10:18:41 +09:00
Hugo Benichi
de08c23dc9 Fix NetworkStatsAccessTest
This patch fixes NetworkStatsAccessTest by taking into account
DEVICESUMMARY which was added in commit
3a8b343ce5220086c4f71e63f5d42f2d28434c4b.

Doing $ git revert 3a8b343ce5220086c4f71e63f5d42f2d28434c4b shows that
the existing assertions of NetworkStatsAccessTest passed before that
commit.

This patch also changes NetworkStatsAccessTest to use up-to-date testing
style and not depend on the deprecated junit.framework.TestCase.

Bug: 32561414
Test: runtest -x frameworks/base/../NetworkStatsAccessTest.java
Change-Id: Ib78f137578cf35e1c766b377b7f812a09173c49e
2017-05-23 10:18:41 +09:00
Hugo Benichi
ea4148caa3 ConnectivityServiceTest: fix flakyness
This patch attempts to fix the remaining spurious failures in
ConnectivityServiceTest, which have two causes:
 - waitForIdle() does not take into account the NetworkAgents handlers.
 - the deadlines in testRequestBenchmark are sometimes exceeded.

To fix the first issue, waitForIdle() is moved to a test level instance
method and also calls waitForIdleHandler on any non null
MockNetworkAgent. This is expected to fix spurious errors for the
following tests:
  - testMobildeDataAlwaysOn
  - testLingering
  - testPacketKeepAlive
  - testMMSonWiFi

To fix the second issue, the deadlines for testRequestBenchmark are
extended by 10ms. Also, the failure message is made more actionable by
providing the total time it took for the operation, instead of printing
the number of dispatches that were achieved before the deadline.

Bug: 32561414
Test: tests pass many times in a row (~500).
Change-Id: Id33c6ac1edfb0b89634fa7789dccb2da237e2709
2017-05-23 10:18:41 +09:00
Lorenzo Colitti
4f58f0cde4 Merge "Add test coverage for explicitlySelected networks." am: f6db1c5889 am: 3d55c5539c
am: b7535c86a0

Change-Id: I4caf9f55edeb51365293558db9d7d028b61c501c
2017-05-19 02:34:58 +00:00
Hugo Benichi
a4876e64b8 Merge "Add a method to start the captive portal login app." 2017-05-19 02:29:21 +00:00
Lorenzo Colitti
f6db1c5889 Merge "Add test coverage for explicitlySelected networks." 2017-05-19 02:05:55 +00:00
Lorenzo Colitti
de1e515306 Add a method to start the captive portal login app.
Bug: 36203355
Bug: 36656914
Test: ConnectivityServiceTest (including new test) passes
Change-Id: Ide82858af67024623560ab79beea27c201b63447
Merged-In: I82a9a9a8da47870ba3f1bbef5941b37e970c844f

(cherry picked from commit 500dbae1b5)
2017-05-19 00:58:41 +00:00
Hugo Benichi
343091956d Fix NetworkNotificationManagerTest
The testNotificationsShownAndCleared test was not doing anything
because the list of notification to show was always empty.

This patch fixes this issue and actually makes the test loop on
non-empty collections, and also fixes another ordering issue in
assertions themselves, hidden until now by the first issue.

Bug: 32561414
Test: runtest -x frameworks/base/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java
Merged-In: I4837b1175d7c9133e9156e33acaa1e7e3341cc62
Change-Id: Ia30587bd68a87b83b62f57eeeb28fef7d95dbf81

(cherry picked from commit 9eec272054)
2017-05-18 11:08:31 +09:00
Hugo Benichi
67615a5906 Merge "Finish moving NetworkStats tests to tests/net" am: e1a0562a3f am: cd821b231a
am: 544bcbe78e

Change-Id: I5d9a01a5804a7cc6289253db09078ede00fc0dc5
2017-05-18 00:48:14 +00:00
Lorenzo Colitti
0bd6e3b946 Add test coverage for explicitlySelected networks.
Also, make all tests start with mobile data always on disabled.

This is because some tests only pass when mobile data always on
is disabled. This doesn't cause any problems when running all
the tests in the file, because these tests are always run after
one or more calls to tearDown, which disables mobile data always
on. However, it does cause issues when those tests are run alone.

Test: new test passes 50 times in a row
Test: ConnectivityServiceTest passes
Change-Id: I1eef5d7f5ec5464e0f9a1d7f1130d9ba6dea4557
2017-05-18 00:46:14 +09:00
Hugo Benichi
e9a6b0e100 Move NetworkNotificationManagerTest to tests/net
Bug: 32561414
Test: no functional change
Change-Id: Iad17e3336a4a589da5cf88fd6359323e34b747e1
2017-05-17 22:24:05 +09:00
Hugo Benichi
b9693f313b Finish moving NetworkStats tests to tests/net
Follow-up of commit 4ff3a778ab.

Also add @SmallTest annotation to classes moved to tests/net.

Test: no functional change
Bug: 32561414
Change-Id: I0a0e8865d37ba7bae06ce352d3fc385989adc300
2017-05-17 22:24:05 +09:00
Hugo Benichi
39294ce0cd Merge changes Ie762ce75,I611fd791 am: 21a57f263f am: cc9f695ba0
am: 164854bde2

Change-Id: I1495249f1ced84438dbd5dd0ad6678e2ee4062cb
2017-05-11 14:28:23 +00:00
Hugo Benichi
7abd43f6fb ConnectivityManager: unit test for argument validation
Bug: 36701874, 37107940
Test: new test passes
Change-Id: Ie762ce758b3d94052b7438a67fc55bef4690cbbb
2017-05-11 14:15:20 +09:00
Hugo Benichi
a590ab8373 ConnectivityManager: uses service error codes and exceptions
This patch introduces between ConnectivityManager and
ConnectivityService a mechanism for propagating back to clients
informative errors in the form of error codes and associated custom
runtime exceptions.

Without error code, the service can only throw a limited number of
different exceptions over Binder. Furthermore the throw site stack
traces are always loss. Although for individual instances of a throw,
the error message can be inspected, aggregations of stack traces from
app crashes sanitize error messages and only leaves the stack traces.

This makes debugging dificult for some service calls such as
requestNetwork that can have a variety of failure modes.

In this patch only one failure mode is codified. More can be added later
at a light cost by: 1) defining an error code, 2) defining an
associated exception, 3) mapping the code to the exception. This patch
can serves as a template for doing so.

Test: $ runtest frameworks-net,
      #testNetworkRequestMaximum() detects the new exception type.
Bug:  36556809, 36701874
Change-Id: I611fd7915575c9e418f7149fcdc8a879d2a3716d
2017-05-11 14:15:15 +09:00
Hugo Benichi
d66a25ab97 Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: 60c8870d97 am: 76dc14ec88
am: 1697d48faf

Change-Id: I7dbfe3c96678e2325eb533f31523ad10d861ad02
2017-05-10 00:40:28 +00:00
Hugo Benichi
60c8870d97 Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" 2017-05-10 00:07:29 +00:00
Hugo Benichi
a884d4fc21 NetworkStatsFactory: fix double accounting on IPv6 only networks
For 464xlat scenarios on IPv6 networks, the clatd interface setup
introduces double counting of apps ipv4 traffic. NetworkStatsFactory was
accounting for this on the tx path, but not on the rx path. Also it did
not accounted for the 20 bytes added by the IPv6 header.

This patch subtract correctly the rx and tx traffic from the root uid on
the underlying interface, and also adds correctly the 20 bytes cost per
packet on the stacked interface for 464xlat traffic.

Test: added several new unit tests, based on synthetic data and real
      data also.
Bug: 33681750
Change-Id: I2675643b220acbc6110179fa937d4c313b6f5e32
2017-05-09 22:46:14 +09:00
Hugo Benichi
ce04f07399 Merge changes I4872f8ba,I92039f29,Iaad13e13 am: 767ac317e2 am: 717238a614
am: 44e9b81c54

Change-Id: I9c38d1254f82b50f4d1e953e72bf15a46562d3b8
2017-05-09 06:30:48 +00:00
Hugo Benichi
0a118cefb8 NsdService: test coverage for client requests.
Adding coverage for:
  - NsdManager client disconnection
  - in-flight request GC

Test: new test passes
Bug: 37013369, 33298084
Change-Id: I92039f297cf99352bbf4196797933d89c0b819ff
2017-05-09 10:49:33 +09:00
Hugo Benichi
f828e46f2d Merge "NsdManager: add test coverage for discoverServices()" am: 3e21b1745c am: 60182dbe4e
am: 27b0eebb4d

Change-Id: I46acfd104ac3457126c3ccef5041788e4146321c
2017-05-02 09:04:59 +00:00
Hugo Benichi
31b86a0a68 Merge "NsdManager: unit test coverage for servive registration" am: b0e408450c am: bc57faa1ac
am: 9a3e69d9b6

Change-Id: Ideabb1c929ddd4307e66831cddb20e2feac2c6d9
2017-05-02 06:49:52 +00:00
Hugo Benichi
3382f9fe27 NsdManager: add test coverage for discoverServices()
Test: added new tests
Bug: 37013369, 33298084
Change-Id: If6c1113ee1bd4690db90abd5a61c3e229c827aec
2017-05-02 15:26:33 +09:00
Lorenzo Colitti
d388cbb9e4 Merge "Add a method to start the captive portal login app." into oc-dev
am: 5555b1e3d1

Change-Id: Ic7c14bd3dfd07f97c04901f043ed1cd3b1eee6e4
2017-05-02 04:44:31 +00:00
Hugo Benichi
f04537fd28 NsdManager: unit test coverage for servive registration
This patch adds test coverage for NsdManager#registerService() and
NsdManager#unregisterService(). This test shows a potential defect in
the api: if unregisterService() fails, the associated listener is always
unregistered from NsdManager. If the service initially registered is
still registered, this potentially make it impossible to unregister.

Test: added new unit test
Bug: 37013369, 33298084
Change-Id: Ia089b6d2f2a349907a8b29d9a3acd7f59e177887
2017-05-02 13:31:24 +09:00
Lorenzo Colitti
500dbae1b5 Add a method to start the captive portal login app.
Bug: 36203355
Bug: 36656914
Test: ConnectivityServiceTest (including new test) passes
Change-Id: I82a9a9a8da47870ba3f1bbef5941b37e970c844f
2017-05-01 16:01:15 +09:00
Hugo Benichi
eebf240d12 Merge "NsdManager: unit tests for argument validation" am: 3cff7deecb am: d97e358f7a
am: 48947de481

Change-Id: I8a51ff51071adc60fe9f4d99ec629edabbed353d
2017-04-27 13:09:02 +00:00
Hugo Benichi
2018a29a88 Merge "NsdService: disentangle NativeDaemonConnector from ctor" am: fa97f11b20 am: 47748b754c
am: 5d0bd13538

Change-Id: Ic8ddf92c7c64d4214a75bea6d6e5083f4612a76a
2017-04-27 13:06:59 +00:00
Hugo Benichi
bad1bfedcd NsdManager: unit tests for argument validation
Test: new tests pass.
Bug: 37013369, 33298084
Change-Id: Ia514d2bbd967d46fed54e379f319b572ade22c62
2017-04-27 16:35:48 +09:00
Hugo Benichi
59ade871f8 NsdService: disentangle NativeDaemonConnector from ctor
This patch disentangles the creation of NativeDaemonConnector from the
creation of NsdService by introducing a wrapper type DaemonConnection.

This allows to mock this dependency in unit tests.

Test: enhanced previously introduced new tests.
Bug: 37013369, 33298084
Change-Id: I894b7cddfc509f86d0134d214c88c063b81b5e0a
2017-04-27 16:35:30 +09:00
Hugo Benichi
a5cd2bc5eb Merge "NsdService: bootstrap unit tests" am: 0f0ab71fb1 am: dd53c962b2
am: d29ce6ae8c

Change-Id: Iaf0679790e934baaaf48bcb04098aa18deca4d60
2017-04-27 05:49:47 +00:00
Hugo Benichi
0f0ab71fb1 Merge "NsdService: bootstrap unit tests" 2017-04-27 05:22:54 +00:00
Etan Cohen
e6d346bc06 Merge "[AWARE] Add UID checking to WifiAwareNetworkSpecifier" am: 7b6ba2b3ea am: 3c6305cc55
am: 887fd90742

Change-Id: I8480ac43d89dc85b541e6255c3cdc597393896cf
2017-04-25 13:40:42 +00:00
Etan Cohen
7b6ba2b3ea Merge "[AWARE] Add UID checking to WifiAwareNetworkSpecifier" 2017-04-25 13:21:36 +00:00