Commit c4a7ccd6 authored by Ryo Hashimoto's avatar Ryo Hashimoto Committed by Commit Bot

arc: Use arcvm-pre-login-services upstart job to control jobs

BUG=b:171408795
TEST=Launch Play Store

Change-Id: I9bff72a850d74bfb226f14ca3a90afca325ad29e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2540047
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829174}
parent 07899db4
...@@ -60,16 +60,12 @@ namespace { ...@@ -60,16 +60,12 @@ namespace {
// The "_2d" in job names below corresponds to "-". Upstart escapes characters // The "_2d" in job names below corresponds to "-". Upstart escapes characters
// that aren't valid in D-Bus object paths with underscore followed by its // that aren't valid in D-Bus object paths with underscore followed by its
// ascii code in hex. So "arc_2dcreate_2ddata" becomes "arc-create-data". // ascii code in hex. So "arc_2dcreate_2ddata" becomes "arc-create-data".
constexpr const char kArcHostClockServiceJobName[] =
"arc_2dhost_2dclock_2dservice";
constexpr const char kArcKeymasterJobName[] = "arc_2dkeymasterd";
constexpr const char kArcSensorServiceJobName[] = "arc_2dsensor_2dservice";
constexpr const char kArcVmAdbdJobName[] = "arcvm_2dadbd"; constexpr const char kArcVmAdbdJobName[] = "arcvm_2dadbd";
constexpr const char kArcVmPerBoardFeaturesJobName[] = constexpr const char kArcVmPerBoardFeaturesJobName[] =
"arcvm_2dper_2dboard_2dfeatures"; "arcvm_2dper_2dboard_2dfeatures";
constexpr const char kArcVmBootNotificationServerJobName[] = // TODO(hashimoto): Introduce another job for post-vm-start services.
"arcvm_2dboot_2dnotification_2dserver"; constexpr char kArcVmPreLoginServicesJobName[] =
// TODO(hashimoto): Introduce another job for pre-login services. "arcvm_2dpre_2dlogin_2dservices";
constexpr char kArcVmPostLoginServicesJobName[] = constexpr char kArcVmPostLoginServicesJobName[] =
"arcvm_2dpost_2dlogin_2dservices"; "arcvm_2dpost_2dlogin_2dservices";
...@@ -642,13 +638,7 @@ class ArcVmClientAdapter : public ArcClientAdapter, ...@@ -642,13 +638,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
JobDesc{kArcVmPerBoardFeaturesJobName, UpstartOperation::JOB_START, {}}, JobDesc{kArcVmPerBoardFeaturesJobName, UpstartOperation::JOB_START, {}},
JobDesc{kArcVmPostLoginServicesJobName, UpstartOperation::JOB_STOP, {}}, JobDesc{kArcVmPostLoginServicesJobName, UpstartOperation::JOB_STOP, {}},
JobDesc{kArcKeymasterJobName, UpstartOperation::JOB_STOP_AND_START, {}}, JobDesc{kArcVmPreLoginServicesJobName,
JobDesc{
kArcSensorServiceJobName, UpstartOperation::JOB_STOP_AND_START, {}},
JobDesc{kArcHostClockServiceJobName,
UpstartOperation::JOB_STOP_AND_START,
{}},
JobDesc{kArcVmBootNotificationServerJobName,
UpstartOperation::JOB_STOP_AND_START, UpstartOperation::JOB_STOP_AND_START,
{}}, {}},
}; };
......
...@@ -43,18 +43,14 @@ ...@@ -43,18 +43,14 @@
namespace arc { namespace arc {
namespace { namespace {
constexpr const char kArcHostClockServiceJobName[] =
"arc_2dhost_2dclock_2dservice";
constexpr const char kArcKeymasterJobName[] = "arc_2dkeymasterd";
constexpr const char kArcSensorServiceJobName[] = "arc_2dsensor_2dservice";
constexpr const char kArcVmAdbdJobName[] = "arcvm_2dadbd"; constexpr const char kArcVmAdbdJobName[] = "arcvm_2dadbd";
constexpr const char kArcVmPerBoardFeaturesJobName[] = constexpr const char kArcVmPerBoardFeaturesJobName[] =
"arcvm_2dper_2dboard_2dfeatures"; "arcvm_2dper_2dboard_2dfeatures";
constexpr const char kArcVmBootNotificationServerJobName[] =
"arcvm_2dboot_2dnotification_2dserver";
constexpr const size_t kUnixMaxPathLen = sizeof(sockaddr_un::sun_path); constexpr const size_t kUnixMaxPathLen = sizeof(sockaddr_un::sun_path);
constexpr const char kArcVmBootNotificationServerAddress[kUnixMaxPathLen] = constexpr const char kArcVmBootNotificationServerAddress[kUnixMaxPathLen] =
"\0test_arcvm_boot_notification_server"; "\0test_arcvm_boot_notification_server";
constexpr char kArcVmPreLoginServicesJobName[] =
"arcvm_2dpre_2dlogin_2dservices";
constexpr char kArcVmPostLoginServicesJobName[] = constexpr char kArcVmPostLoginServicesJobName[] =
"arcvm_2dpost_2dlogin_2dservices"; "arcvm_2dpost_2dlogin_2dservices";
...@@ -511,52 +507,21 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcVmPostLoginServicesJobFail) { ...@@ -511,52 +507,21 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcVmPostLoginServicesJobFail) {
// for other StartMiniArc_...Fail tests. // for other StartMiniArc_...Fail tests.
} }
// Tests that StartMiniArc() fails if Upstart fails to start // Tests that StartMiniArc() fails when Upstart fails to start the job.
// arc-host-clock-service. TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcVmPerBoardFeaturesJobFail) {
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcHostClockServiceJobFail) {
// Inject failure to FakeUpstartClient.
InjectUpstartStartJobFailure(kArcHostClockServiceJobName);
StartMiniArcWithParams(false, {});
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc() succeeds if Upstart fails to stop
// arc-host-clock-service.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcHostClockServiceJobFail) {
// Inject failure to FakeUpstartClient.
InjectUpstartStopJobFailure(kArcHostClockServiceJobName);
StartMiniArc();
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc() fails if Upstart fails to start arc-keymasterd.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcKeymasterJobFail) {
// Inject failure to FakeUpstartClient. // Inject failure to FakeUpstartClient.
InjectUpstartStartJobFailure(kArcKeymasterJobName); InjectUpstartStartJobFailure(kArcVmPerBoardFeaturesJobName);
StartMiniArcWithParams(false, {}); StartMiniArcWithParams(false, {});
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet. // Confirm that no VM is started.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc() succeeds if Upstart fails to stop arc-keymasterd.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcKeymasterJobFail) {
// Inject failure to FakeUpstartClient.
InjectUpstartStopJobFailure(kArcKeymasterJobName);
StartMiniArc();
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called()); EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
} }
// Tests that StartMiniArc() fails if Upstart fails to start arc-sensor-service. // Tests that StartMiniArc() fails if Upstart fails to start
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcSensorServiceJobFail) { // arcvm-pre-login-services.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcVmPreLoginServicesJobFail) {
// Inject failure to FakeUpstartClient. // Inject failure to FakeUpstartClient.
InjectUpstartStartJobFailure(kArcSensorServiceJobName); InjectUpstartStartJobFailure(kArcVmPreLoginServicesJobName);
StartMiniArcWithParams(false, {}); StartMiniArcWithParams(false, {});
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet. // Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
...@@ -564,42 +529,32 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcSensorServiceJobFail) { ...@@ -564,42 +529,32 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcSensorServiceJobFail) {
} }
// Tests that StartMiniArc() succeeds if Upstart fails to stop // Tests that StartMiniArc() succeeds if Upstart fails to stop
// arc-sensor-service. // arcvm-pre-login-services.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcSensorServiceJobFail) { TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcVmPreLoginServicesJobFail) {
// Inject failure to FakeUpstartClient. // Inject failure to FakeUpstartClient.
InjectUpstartStopJobFailure(kArcSensorServiceJobName); InjectUpstartStopJobFailure(kArcVmPreLoginServicesJobName);
StartMiniArc(); StartMiniArc();
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet. // Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called()); EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
} }
// Tests that StartMiniArc() fails when Upstart fails to start the job. // Tests that StartMiniArc()'s JOB_STOP_AND_START for
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcVmPerBoardFeaturesJobFail) { // |kArcVmPreLoginServicesJobName| is properly implemented.
// Inject failure to FakeUpstartClient.
InjectUpstartStartJobFailure(kArcVmPerBoardFeaturesJobName);
StartMiniArcWithParams(false, {});
// Confirm that no VM is started.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc()'s JOB_RESTART for |kArcSensorServiceJobName| is
// properly implemented.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_JobRestart) { TEST_F(ArcVmClientAdapterTest, StartMiniArc_JobRestart) {
StartRecordingUpstartOperations(); StartRecordingUpstartOperations();
StartMiniArc(); StartMiniArc();
const auto& ops = upstart_operations(); const auto& ops = upstart_operations();
// Find the STOP operation for the job. // Find the STOP operation for the job.
auto it = auto it = std::find(
std::find(ops.begin(), ops.end(), ops.begin(), ops.end(),
std::make_pair(std::string(kArcSensorServiceJobName), false)); std::make_pair(std::string(kArcVmPreLoginServicesJobName), false));
ASSERT_NE(ops.end(), it); ASSERT_NE(ops.end(), it);
++it; ++it;
ASSERT_NE(ops.end(), it); ASSERT_NE(ops.end(), it);
// The next operation must be START for the job. // The next operation must be START for the job.
EXPECT_EQ(it->first, kArcSensorServiceJobName); EXPECT_EQ(it->first, kArcVmPreLoginServicesJobName);
EXPECT_TRUE(it->second); // true means START. EXPECT_TRUE(it->second); // true means START.
} }
...@@ -1326,14 +1281,6 @@ TEST_F(ArcVmClientAdapterTest, TestConnectToBootNotificationServer) { ...@@ -1326,14 +1281,6 @@ TEST_F(ArcVmClientAdapterTest, TestConnectToBootNotificationServer) {
EXPECT_EQ(boot_notification_server()->received_data(), expected_props); EXPECT_EQ(boot_notification_server()->received_data(), expected_props);
} }
// Tests that StartMiniArc fails when the boot notification server's Upstart
// job fails.
TEST_F(ArcVmClientAdapterTest, TestBootNotificationServerUpstartJobFails) {
InjectUpstartStartJobFailure(kArcVmBootNotificationServerJobName);
StartMiniArcWithParams(false, {});
}
// Tests that StartMiniArc fails when the boot notification server is not // Tests that StartMiniArc fails when the boot notification server is not
// listening. // listening.
TEST_F(ArcVmClientAdapterTest, TestBootNotificationServerIsNotListening) { TEST_F(ArcVmClientAdapterTest, TestBootNotificationServerIsNotListening) {
......
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