Run installer with subprocess in smoke test 13/286413/3
authorilho kim <ilho159.kim@samsung.com>
Thu, 5 Jan 2023 10:55:14 +0000 (19:55 +0900)
committerilho kim <ilho159.kim@samsung.com>
Thu, 5 Jan 2023 12:47:10 +0000 (21:47 +0900)
The main process becomes heavy because the extensive smoke test
generates and executes a large amount of installer instance. To lighten
the main process, execute it as subprocess

Change-Id: Ie53606a3ce61bc2fe097e7a3d8e5badb02a2509e
Signed-off-by: ilho kim <ilho159.kim@samsung.com>
test/smoke_tests/extensive_smoke_test.cc
test/smoke_tests/wgt_smoke_utils.cc
test/smoke_tests/wgt_smoke_utils.h

index a2a8114..e51a0f7 100644 (file)
@@ -112,12 +112,12 @@ TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
           GetRecoverFileInfo(recovery_file);
-      EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
-          ci::AppInstaller::Result::OK);
+      EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file),
+          BackendInterface::SubProcessResult::SUCCESS);
       if (recovery_info->cleanup()) {
         EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
-        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
-            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid),
+            BackendInterface::SubProcessResult::SUCCESS);
       } else {
         EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
       }
@@ -130,7 +130,8 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
   bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt";
   bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
   RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
-  ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.InstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
   std::string pkgid = "smokewgt10";
   std::string appid = "smokewgt10.RecoveryModeForUpdate";
   AddDataFiles(pkgid, params.test_user.uid);
@@ -145,8 +146,8 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
           GetRecoverFileInfo(recovery_file);
-      EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
-          ci::AppInstaller::Result::OK);
+      EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file),
+          BackendInterface::SubProcessResult::SUCCESS);
       EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
 
       std::string version = recovery_info->cleanup() ? "2\n" :"1\n";
@@ -155,10 +156,10 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
       EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
 
       if (recovery_info->cleanup()) {
-        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
-            ci::AppInstaller::Result::OK);
-        EXTENDED_ASSERT_EQ(backend.Install(path_old),
-            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid),
+            BackendInterface::SubProcessResult::SUCCESS);
+        EXTENDED_ASSERT_EQ(backend.InstallWithSubprocess(path_old),
+            BackendInterface::SubProcessResult::SUCCESS);
         AddDataFiles(pkgid, params.test_user.uid);
       }
     }
@@ -172,7 +173,8 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
   std::string pkgid = "smokewgt30";
   std::string appid = "smokewgt30.RecoveryModeForDelta";
   RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
-  ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(BackendInterface::SubProcessResult::SUCCESS,
+      backend.InstallWithSubprocess(path_old));
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   std::vector<std::string> args =
@@ -184,8 +186,8 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
           GetRecoverFileInfo(recovery_file);
-      EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
-          ci::AppInstaller::Result::OK);
+      EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file),
+          BackendInterface::SubProcessResult::SUCCESS);
       EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
       std::string contents = recovery_info->cleanup() ? "2\n" : "1\n";
 
@@ -194,10 +196,10 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
       EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
 
       if (recovery_info->cleanup()) {
-        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
-            ci::AppInstaller::Result::OK);
-        EXTENDED_ASSERT_EQ(backend.Install(path_old),
-            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid),
+            BackendInterface::SubProcessResult::SUCCESS);
+        EXTENDED_ASSERT_EQ(backend.InstallWithSubprocess(path_old),
+            BackendInterface::SubProcessResult::SUCCESS);
         AddDataFiles(pkgid, params.test_user.uid);
       }
     }
@@ -220,13 +222,13 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
           GetRecoverFileInfo(recovery_file);
-      EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
-          ci::AppInstaller::Result::OK);
+      EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file),
+          BackendInterface::SubProcessResult::SUCCESS);
       ScopedTzipInterface interface(pkgid, params.test_user.uid);
       if (recovery_info->cleanup()) {
         EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
-        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
-            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid),
+            BackendInterface::SubProcessResult::SUCCESS);
       } else {
         EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
       }
@@ -243,7 +245,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
   std::string pkgid = "smokewgt32";
   std::string appid = "smokewgt32.RecoveryModeForMountUpdate";
   RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
-  ASSERT_EQ(backend.MountInstall(path_old), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.MountInstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   std::vector<std::string> args =
@@ -260,8 +263,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
           GetRecoverFileInfo(recovery_file);
-      EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
-          ci::AppInstaller::Result::OK);
+      EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file),
+          BackendInterface::SubProcessResult::SUCCESS);
 
       ScopedTzipInterface interface(pkgid, params.test_user.uid);
       EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
@@ -271,10 +274,10 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
       EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
       if (recovery_info->cleanup()) {
         interface.Release();
-        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
-            ci::AppInstaller::Result::OK);
-        EXTENDED_ASSERT_EQ(backend.MountInstall(path_old),
-            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid),
+            BackendInterface::SubProcessResult::SUCCESS);
+        EXTENDED_ASSERT_EQ(backend.MountInstallWithSubprocess(path_old),
+            BackendInterface::SubProcessResult::SUCCESS);
         AddDataFiles(pkgid, params.test_user.uid);
       }
     }
@@ -301,7 +304,8 @@ TEST_F(SmokeTest, UpdateMode_Rollback) {
   bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt";
   std::string pkgid = "smokewgt07";
   std::string appid = "smokewgt07.UpdateModeRollback";
-  ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.InstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   const char* argv[] =
@@ -321,7 +325,8 @@ TEST_F(SmokeTest, DeltaMode_Rollback) {
   bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Rollback.delta";
   std::string pkgid = "smokewgt01";
   std::string appid = "smokewgt01.DeltaMode";
-  ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.InstallWithSubprocess(path),
+      BackendInterface::SubProcessResult::SUCCESS);
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   const char* argv[] =
@@ -359,7 +364,8 @@ TEST_F(HybridSmokeTest, UpdateMode_Rollback) {
       "UpdateMode_Rollback_Hybrid_2.wgt";
   std::string pkgid = "smokehyb08";
   std::string appid1 = "smokehyb08.web";
-  ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.InstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   const char* argv[] =
@@ -382,7 +388,8 @@ TEST_F(HybridSmokeTest, DeltaMode_Rollback_Hybrid) {
       "DeltaMode_Rollback_Hybrid.delta";
   std::string pkgid = "smokehyb11";
   std::string appid1 = "smokehyb11.web";
-  ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.InstallWithSubprocess(path),
+      BackendInterface::SubProcessResult::SUCCESS);
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   const char* argv[] = {"", "-i", path.c_str(), "-u", test_user_str.c_str()};
@@ -424,7 +431,8 @@ TEST_F(HybridSmokeTest, MountUpdateMode_Rollback) {
       "MountUpdateMode_Rollback_Hybrid_2.wgt";
   std::string pkgid = "smokehyb10";
   std::string appid1 = "smokehyb10.web";
-  ASSERT_EQ(backend.MountInstall(path_old), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.MountInstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   const char* argv[] =
@@ -462,8 +470,8 @@ TEST_F(SmokeTest, MountUpdateMode_Rollback) {
       kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
   std::string pkgid = "smokewgt34";
   std::string appid = "smokewgt34.web";
-  ASSERT_EQ(backend.MountInstall(path_old),
-            ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.MountInstallWithSubprocess(path_old),
+            BackendInterface::SubProcessResult::SUCCESS);
   AddDataFiles(pkgid, params.test_user.uid);
   std::string test_user_str = std::to_string(params.test_user.uid);
   const char* argv[] =
@@ -486,7 +494,8 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) {
   bf::path path_new = kSmokePackagesDirectory /
       "RecoveryMode_ForReadonlyUpdateInstall_2.wgt";
   RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
-  ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
+  ASSERT_EQ(backend.InstallPreloadWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
   std::string pkgid = "smokewgt51";
   std::string appid = "smokewgt51.RecoveryModeForReadonlyUpdateInstall";
   AddDataFiles(pkgid, params.test_user.uid);
@@ -500,8 +509,8 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) {
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
           GetRecoverFileInfo(recovery_file);
-      EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
-          ci::AppInstaller::Result::OK);
+      EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file),
+          BackendInterface::SubProcessResult::SUCCESS);
       if (recovery_info->cleanup())
         params.is_readonly = false;
       EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
@@ -512,8 +521,8 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) {
       EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
 
       if (recovery_info->cleanup()) {
-        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
-            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid),
+            BackendInterface::SubProcessResult::SUCCESS);
         AddDataFiles(pkgid, params.test_user.uid);
       }
     }
index dec1e73..3b11756 100644 (file)
@@ -67,6 +67,11 @@ WgtBackendInterface::CreateFailExpectedInstaller(
   return AppInstallerPtr(new FailExpectedWgtInstaller(pkgmgr, fail_at));
 }
 
+common_installer::Subprocess WgtBackendInterface::CreateSubprocess() const {
+  return common_installer::Subprocess(
+      "/usr/bin/wgt-installer-ut/smoke-test-helper");
+}
+
 HybridBackendInterface::AppQueryInterfacePtr
 HybridBackendInterface::CreateQueryInterface() const {
   return AppQueryInterfacePtr(new wgt::WgtAppQueryInterface());
index 6b223e2..4467971 100644 (file)
@@ -44,6 +44,7 @@ class WgtBackendInterface: public BackendInterface {
       common_installer::PkgMgrPtr pkgmgr) const override;
   AppInstallerPtr CreateFailExpectedInstaller(
       common_installer::PkgMgrPtr pkgmgr, int fail_at) const override;
+  common_installer::Subprocess CreateSubprocess() const override;
 };
 
 class HybridBackendInterface: public BackendInterface {