Fix testing with/without connectivity module

Add missing @ConnectivityModuleTest annotations to tests that cover
functionalities that were introduced in a newer connectivity module
update.

Also add CtsNetTestCasesLatestSdk to postsubmit with only APK modules
installed, and with only the connectivity/tethering module installed.
This can then be moved to presubmit to catch such issues before they are
merged.

While doing this cleanup the TEST_MAPPING file in tests/ and merge its
contents into the root TEST_MAPPING file. This does not change anything
for "postsubmit" tests as they are run independently of changes. It only
causes FrameworksNetIntegrationTests to run in presubmit on any change
in modules/Connectivity/ instead of only on modules/Connectivity/tests/
changes, which is how it should be.

Bug: 218611855
Test: TH needs to test TEST_MAPPING
Change-Id: I26629a35d8c2df3db33180ecc22d49d538ad3b8b
This commit is contained in:
Remi NGUYEN VAN
2022-02-16 12:15:14 +09:00
parent 6d80f10bb3
commit 3b81323e4a
7 changed files with 62 additions and 39 deletions

View File

@@ -32,6 +32,9 @@
},
{
"name": "libnetworkstats_test"
},
{
"name": "FrameworksNetIntegrationTests"
}
],
"postsubmit": [
@@ -55,6 +58,9 @@
},
{
"name": "libnetworkstats_test"
},
{
"name": "FrameworksNetDeflakeTest"
}
],
"mainline-presubmit": [
@@ -88,6 +94,35 @@
"name": "CtsNetTestCasesLatestSdk[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]",
"keywords": ["sim"]
},
// TODO: move to mainline-presubmit when known green.
// Test with APK modules only, in cases where APEX is not supported, or the other modules were simply not updated
{
"name": "CtsNetTestCasesLatestSdk[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk]",
"options": [
{
"exclude-annotation": "com.android.testutils.SkipPresubmit"
},
{
"exclude-annotation": "androidx.test.filters.RequiresDevice"
},
{
"exclude-annotation": "com.android.testutils.ConnectivityModuleTest"
}
]
},
// TODO: move to mainline-presubmit when known green.
// Test with connectivity/tethering module only, to catch integration issues with older versions of other modules
{
"name": "CtsNetTestCasesLatestSdk[com.google.android.tethering.apex]",
"options": [
{
"exclude-annotation": "com.android.testutils.SkipPresubmit"
},
{
"exclude-annotation": "androidx.test.filters.RequiresDevice"
}
]
},
{
"name": "TetheringCoverageTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]"
},
@@ -96,6 +131,23 @@
"name": "bpf_existence_test[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]"
}
],
"auto-postsubmit": [
// Test tag for automotive targets. These are only running in postsubmit so as to harden the
// automotive targets to avoid introducing additional test flake and build time. The plan for
// presubmit testing for auto is to augment the existing tests to cover auto use cases as well.
// Additionally, this tag is used in targeted test suites to limit resource usage on the test
// infra during the hardening phase.
// TODO: this tag to be removed once the above is no longer an issue.
{
"name": "FrameworksNetTests"
},
{
"name": "FrameworksNetIntegrationTests"
},
{
"name": "FrameworksNetDeflakeTest"
}
],
"imports": [
{
"path": "frameworks/base/core/java/android/net"
@@ -109,9 +161,6 @@
{
"path": "packages/modules/CaptivePortalLogin"
},
{
"path": "packages/modules/Connectivity"
},
{
"path": "packages/modules/Connectivity/Tethering"
}

View File

@@ -1,34 +0,0 @@
{
"presubmit": [
{
"name": "FrameworksNetIntegrationTests"
}
],
"postsubmit": [
{
"name": "FrameworksNetDeflakeTest"
}
],
"auto-postsubmit": [
// Test tag for automotive targets. These are only running in postsubmit so as to harden the
// automotive targets to avoid introducing additional test flake and build time. The plan for
// presubmit testing for auto is to augment the existing tests to cover auto use cases as well.
// Additionally, this tag is used in targeted test suites to limit resource usage on the test
// infra during the hardening phase.
// TODO: this tag to be removed once the above is no longer an issue.
{
"name": "FrameworksNetTests"
},
{
"name": "FrameworksNetIntegrationTests"
},
{
"name": "FrameworksNetDeflakeTest"
}
],
"imports": [
{
"path": "packages/modules/Connectivity"
}
]
}

View File

@@ -67,6 +67,7 @@ import android.util.Range
import androidx.test.InstrumentationRegistry
import androidx.test.filters.SmallTest
import com.android.net.module.util.ConnectivitySettingsUtils.getPrivateDnsModeAsString
import com.android.testutils.ConnectivityModuleTest
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
import com.android.testutils.DevSdkIgnoreRunner
import junit.framework.Assert.assertEquals
@@ -295,6 +296,7 @@ class ConnectivitySettingsManagerTest {
testIntValues = intArrayOf(0))
}
@ConnectivityModuleTest // get/setIngressRateLimitInBytesPerSecond was added via module update
@Test
fun testInternetNetworkRateLimitInBytesPerSecond() {
val defaultRate = getIngressRateLimitInBytesPerSecond(context)

View File

@@ -21,6 +21,8 @@
<option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
<option name="config-descriptor:metadata" key="mainline-param" value="CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex" />
<option name="config-descriptor:metadata" key="mainline-param" value="CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk" />
<option name="config-descriptor:metadata" key="mainline-param" value="com.google.android.tethering.apex" />
<option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />

View File

@@ -29,6 +29,7 @@ import android.os.Build;
import androidx.test.runner.AndroidJUnit4;
import com.android.testutils.ConnectivityModuleTest;
import com.android.testutils.DevSdkIgnoreRule;
import libcore.net.InetAddressUtils;
@@ -106,7 +107,7 @@ public final class IpConfigurationTest {
assertIpConfigurationEqual(ipConfig, new IpConfiguration(ipConfig));
}
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
@ConnectivityModuleTest @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
@Test
public void testBuilder() {
final IpConfiguration c = new IpConfiguration.Builder()

View File

@@ -77,6 +77,7 @@ import com.android.compatibility.common.util.ThrowingSupplier
import com.android.modules.utils.build.SdkLevel
import com.android.net.module.util.ArrayTrackRecord
import com.android.testutils.CompatUtil
import com.android.testutils.ConnectivityModuleTest
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
import com.android.testutils.DevSdkIgnoreRunner
import com.android.testutils.RecorderCallback.CallbackEntry.Available
@@ -465,6 +466,7 @@ class NetworkAgentTest {
.addTransportType(TRANSPORT_TEST)
.setAccessUids(uids.toSet()).build()
@ConnectivityModuleTest // Functionality was added post-S via connectivity module update
@Test
fun testRejectedUpdates() {
val callback = TestableNetworkCallback()

View File

@@ -35,6 +35,7 @@ import android.os.Parcel;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.testutils.ConnectivityModuleTest;
import com.android.testutils.DevSdkIgnoreRule;
import org.junit.Rule;
@@ -256,7 +257,7 @@ public class StaticIpConfigurationTest {
assertEquals(DNS1, s.getDnsServers().get(0));
}
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
@ConnectivityModuleTest @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
@Test
public void testIllegalBuilders() {
assertThrows("Can't set IP Address to IPv6!", IllegalArgumentException.class, () -> {