diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-12-14 02:09:54 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-12-14 02:09:54 +0000 |
commit | 64966bb9ed2f46f732f0e9560eb64145865b2f5b (patch) | |
tree | 0b543d9b1afe494ea0f40f9f0e9888b45d66d652 | |
parent | 69d26bdb7a2b702eb49551d84fb603aa067e0db9 (diff) | |
parent | 106a9d2d788be37e9245e083a9d4f30fee6a9f7e (diff) | |
download | OnDevicePersonalization-64966bb9ed2f46f732f0e9560eb64145865b2f5b.tar.gz |
Merge "Add FCP CUJ: training for a non existent population" into udc-mainline-prod am: 106a9d2d78
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/OnDevicePersonalization/+/25642549
Change-Id: I942f5de52a89b981beb6e2dc2687272a36a16bda
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
4 files changed, 138 insertions, 1 deletions
diff --git a/federatedcompute/src/com/android/federatedcompute/services/training/FederatedComputeWorker.java b/federatedcompute/src/com/android/federatedcompute/services/training/FederatedComputeWorker.java index 4244aff4..a6583bab 100644 --- a/federatedcompute/src/com/android/federatedcompute/services/training/FederatedComputeWorker.java +++ b/federatedcompute/src/com/android/federatedcompute/services/training/FederatedComputeWorker.java @@ -244,6 +244,8 @@ public class FederatedComputeWorker { TrainingRun run, CheckinResult checkinResult) { // Stop processing if have rejection Info if (checkinResult.getRejectionInfo() != null) { + LogUtil.d(TAG, "job %d was rejected during check in, reason %s", + run.mTask.jobId(), checkinResult.getRejectionInfo().getReason()); mJobManager.onTrainingCompleted( run.mTask.jobId(), run.mTask.populationName(), diff --git a/tests/perftests/scenarios/src/android/federatedcompute/test/scenario/federatedcompute/ScheduleNonExistentPopulationForTraining.java b/tests/perftests/scenarios/src/android/federatedcompute/test/scenario/federatedcompute/ScheduleNonExistentPopulationForTraining.java new file mode 100644 index 00000000..27ee61c7 --- /dev/null +++ b/tests/perftests/scenarios/src/android/federatedcompute/test/scenario/federatedcompute/ScheduleNonExistentPopulationForTraining.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.federatedcompute.test.scenario.federatedcompute; + +import android.platform.test.scenario.annotation.Scenario; + +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.io.IOException; + +@Scenario +@RunWith(JUnit4.class) +/** + * Schedule a non-existent population training task from Odp Test app UI + * Force the task execution through ADB commands and verify error handling and exit behavior + */ +public class ScheduleNonExistentPopulationForTraining { + private TestHelper mTestHelper = new TestHelper(); + + /** Prepare the device before entering the test class */ + @BeforeClass + public static void prepareDevice() throws IOException { + TestHelper.initialize(); + TestHelper.killRunningProcess(); + } + + @Before + public void setup() throws IOException { + mTestHelper.pressHome(); + mTestHelper.openTestApp(); + mTestHelper.inputNonExistentPopulationForScheduleTraining(); + } + + @Test + public void testScheduleNonExistentPopulationForTraining() throws IOException { + mTestHelper.clickScheduleTraining(); + mTestHelper.forceExecuteTrainingForNonExistentPopulation(); + } + + /** Return device to original state after test exeuction */ + @AfterClass + public static void tearDown() throws IOException { + TestHelper.pressHome(); + TestHelper.wrapUp(); + } +} diff --git a/tests/perftests/scenarios/src/android/federatedcompute/test/scenario/federatedcompute/TestHelper.java b/tests/perftests/scenarios/src/android/federatedcompute/test/scenario/federatedcompute/TestHelper.java index 07ec1f87..4c135533 100644 --- a/tests/perftests/scenarios/src/android/federatedcompute/test/scenario/federatedcompute/TestHelper.java +++ b/tests/perftests/scenarios/src/android/federatedcompute/test/scenario/federatedcompute/TestHelper.java @@ -34,6 +34,7 @@ public class TestHelper { private static UiDevice sUiDevice; private static final long UI_FIND_RESOURCE_TIMEOUT = 5000; private static final long TRAINING_TASK_COMPLETION_TIMEOUT = 120_000; + private static final long CHECKIN_REJECTION_COMPLETION_TIMEOUT = 20_000; private static final String ODP_CLIENT_TEST_APP_PACKAGE_NAME = "com.example.odpclient"; private static final String SCHEDULE_TRAINING_BUTTON_RESOURCE_ID = "schedule_training_button"; private static final String SCHEDULE_TRAINING_TEXT_BOX_RESOURCE_ID = @@ -42,6 +43,10 @@ public class TestHelper { private static final String ODP_TEST_APP_TRAINING_TASK_JOB_ID = "-630817781"; private static final String FEDERATED_TRAINING_JOB_SUCCESS_LOG = "FederatedJobService - Federated computation job -630817781 is done"; + private static final String NON_EXISTENT_POPULATION_NAME = "test_non_existent_population"; + private static final String NON_EXISTENT_POPULATION_TASK_JOB_ID = "1892833995"; + private static final String NON_EXISTENT_POPULATION_JOB_FAILURE_LOG = + "job 1892833995 was rejected during check in, reason NO_TASK_AVAILABLE"; public static void pressHome() { getUiDevice().pressHome(); @@ -119,6 +124,13 @@ public class TestHelper { scheduleTrainingTextBox.setText(ODP_TEST_APP_POPULATION_NAME); } + /** Put a test non existent population name down for training */ + public void inputNonExistentPopulationForScheduleTraining() { + UiObject2 scheduleTrainingTextBox = getScheduleTrainingTextBox(); + assertNotNull("Schedule Training text box not found", scheduleTrainingTextBox); + scheduleTrainingTextBox.setText(NON_EXISTENT_POPULATION_NAME); + } + /** Click Schedule Training button. */ public void clickScheduleTraining() { UiObject2 scheduleTrainingButton = getScheduleTrainingButton(); @@ -143,11 +155,34 @@ public class TestHelper { if (!foundTrainingJobSuccessLog) { Assert.fail(String.format( - "Failed to find federated training job success log within test window %d ms", + "Failed to find federated training job success log %s within test window %d ms", + FEDERATED_TRAINING_JOB_SUCCESS_LOG, TRAINING_TASK_COMPLETION_TIMEOUT)); } } + /** Force the JobScheduler to execute the training task for non existent population */ + public void forceExecuteTrainingForNonExistentPopulation() throws IOException { + executeShellCommand("logcat -c"); // Cleans the log buffer + executeShellCommand("logcat -G 32M"); // Set log buffer to 32MB + executeShellCommand( + "cmd jobscheduler run -f com.google.android.federatedcompute " + + NON_EXISTENT_POPULATION_TASK_JOB_ID); + SystemClock.sleep(10000); + + boolean foundTrainingFailureLog = findLog( + NON_EXISTENT_POPULATION_JOB_FAILURE_LOG, + CHECKIN_REJECTION_COMPLETION_TIMEOUT, + 5000); + + if (!foundTrainingFailureLog) { + Assert.fail(String.format( + "Failed to find federated training failure log: %s within test window %d ms", + NON_EXISTENT_POPULATION_JOB_FAILURE_LOG, + CHECKIN_REJECTION_COMPLETION_TIMEOUT)); + } + } + /** Attempt to find a specific log entry within the timeout window */ private boolean findLog(final String targetLog, long timeoutMillis, long queryIntervalMillis) throws IOException { diff --git a/tests/perftests/scenarios/tests/src/android/federatedcompute/test/scenario/federatedcompute/ScheduleNonExistentPopulationForTrainingMicrobenchmark.java b/tests/perftests/scenarios/tests/src/android/federatedcompute/test/scenario/federatedcompute/ScheduleNonExistentPopulationForTrainingMicrobenchmark.java new file mode 100644 index 00000000..8150bf3d --- /dev/null +++ b/tests/perftests/scenarios/tests/src/android/federatedcompute/test/scenario/federatedcompute/ScheduleNonExistentPopulationForTrainingMicrobenchmark.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.federatedcompute.test.scenario.federatedcompute; + +import android.platform.test.microbenchmark.Microbenchmark; +import android.platform.test.rule.DropCachesRule; +import android.platform.test.rule.KillAppsRule; +import android.platform.test.rule.PressHomeRule; + +import org.junit.Rule; +import org.junit.rules.RuleChain; +import org.junit.runner.RunWith; + +@RunWith(Microbenchmark.class) +public class ScheduleNonExistentPopulationForTrainingMicrobenchmark + extends ScheduleNonExistentPopulationForTraining { + + @Rule + public RuleChain rules = RuleChain.outerRule(new DropCachesRule()) + .around(new KillAppsRule("com.example.odpclient")) + .around(new PressHomeRule()); +} |