Don't store dynamic config in conf files 25/35425/1
authorPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Thu, 12 Feb 2015 09:21:18 +0000 (10:21 +0100)
committerPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Fri, 13 Feb 2015 13:58:45 +0000 (14:58 +0100)
[Bug/Feature]   Per-zone mutable config fields (ip, vt and more in
                the future) goes to dynamic config.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, run tests

Change-Id: I2a59b0292fc326a689e3ff9375da1199dc8b7618

45 files changed:
server/configs/daemon.conf.in
server/configs/templates/default.conf
server/server.cpp
server/zone-admin.cpp
server/zone-admin.hpp
server/zone-config.hpp
server/zone.cpp
server/zone.hpp
server/zones-manager-config.hpp
server/zones-manager.cpp
server/zones-manager.hpp
tests/unit_tests/client/configs/CMakeLists.txt
tests/unit_tests/client/configs/ut-client/templates/console-dbus.conf.in [moved from tests/unit_tests/server/configs/ut-zones-manager/templates/default.conf.in with 96% similarity]
tests/unit_tests/client/configs/ut-client/test-daemon.conf.in [moved from tests/unit_tests/server/configs/ut-zones-manager/empty-dbus-daemon.conf.in with 80% similarity]
tests/unit_tests/client/configs/ut-client/test-dbus-daemon.conf.in [deleted file]
tests/unit_tests/client/configs/ut-client/zones/console1-dbus.conf.in [deleted file]
tests/unit_tests/client/configs/ut-client/zones/console2-dbus.conf.in [deleted file]
tests/unit_tests/client/configs/ut-client/zones/console3-dbus.conf.in [deleted file]
tests/unit_tests/client/ut-client.cpp
tests/unit_tests/server/configs/CMakeLists.txt
tests/unit_tests/server/configs/ut-server/buggy-daemon.conf.in [deleted file]
tests/unit_tests/server/configs/ut-server/templates/default.conf [moved from tests/unit_tests/server/configs/ut-server/zones/zone1.conf with 93% similarity]
tests/unit_tests/server/configs/ut-server/test-daemon.conf.in
tests/unit_tests/server/configs/ut-server/zones/zone3.conf [deleted file]
tests/unit_tests/server/configs/ut-zone-admin/templates/buggy.conf [moved from tests/unit_tests/server/configs/ut-zone-admin/zones/buggy.conf with 92% similarity]
tests/unit_tests/server/configs/ut-zone-admin/templates/missing.conf [moved from tests/unit_tests/server/configs/ut-zone-admin/zones/missing.conf with 92% similarity]
tests/unit_tests/server/configs/ut-zone-admin/templates/test-no-shutdown.conf [moved from tests/unit_tests/server/configs/ut-zone-admin/zones/test-no-shutdown.conf with 92% similarity]
tests/unit_tests/server/configs/ut-zone-admin/templates/test.conf [moved from tests/unit_tests/server/configs/ut-server/zones/zone2.conf with 93% similarity]
tests/unit_tests/server/configs/ut-zone-admin/zones/test.conf [deleted file]
tests/unit_tests/server/configs/ut-zone/templates/buggy.conf [moved from tests/unit_tests/server/configs/ut-zone/zones/buggy.conf with 94% similarity]
tests/unit_tests/server/configs/ut-zone/templates/test-dbus.conf.in [moved from tests/unit_tests/server/configs/ut-zone/zones/test-dbus.conf.in with 85% similarity]
tests/unit_tests/server/configs/ut-zone/templates/test.conf [moved from tests/unit_tests/server/configs/ut-zone/zones/test.conf with 94% similarity]
tests/unit_tests/server/configs/ut-zones-manager/buggy-daemon.conf.in [deleted file]
tests/unit_tests/server/configs/ut-zones-manager/templates/console-dbus.conf.in [moved from tests/unit_tests/server/configs/ut-zones-manager/zones/console3-dbus.conf.in with 83% similarity]
tests/unit_tests/server/configs/ut-zones-manager/templates/console.conf [moved from tests/unit_tests/server/configs/ut-zones-manager/zones/console1.conf with 91% similarity]
tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in
tests/unit_tests/server/configs/ut-zones-manager/test-dbus-daemon.conf.in [deleted file]
tests/unit_tests/server/configs/ut-zones-manager/zones/console1-dbus.conf.in [deleted file]
tests/unit_tests/server/configs/ut-zones-manager/zones/console2-dbus.conf.in [deleted file]
tests/unit_tests/server/configs/ut-zones-manager/zones/console2.conf [deleted file]
tests/unit_tests/server/configs/ut-zones-manager/zones/console3.conf [deleted file]
tests/unit_tests/server/ut-server.cpp
tests/unit_tests/server/ut-zone-admin.cpp
tests/unit_tests/server/ut-zone.cpp
tests/unit_tests/server/ut-zones-manager.cpp

index 327e470..a6359fa 100644 (file)
@@ -1,10 +1,9 @@
 {
     "dbPath" : "/usr/dbspace/vasum.db",
-    "zoneConfigs" : [],
+    "zoneIds" : [],
     "zonesPath" : "${DATA_DIR}/.zones",
     "zoneImagePath" : "",
     "zoneTemplateDir" : "/etc/vasum/templates/",
-    "zoneNewConfigPrefix" : "/var/lib/vasum",
     "runMountPointPrefix" : "/var/run/zones",
     "defaultId" : "",
     "lxcTemplatePrefix" : "/etc/vasum/lxc-templates",
index 9690a87..2aa7a66 100644 (file)
@@ -1,5 +1,4 @@
 {
-    "name" : "~NAME~",
     "lxcTemplate" : "tizen-common-wayland.sh",
     "initWithArgs" : [],
     "ipv4Gateway" : "10.0.~IP~.1",
@@ -7,7 +6,7 @@
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "privilege" : 10,
-    "vt" : ~VT~,
+    "vt" : 0,
     "switchToDefaultAfterTimeout" : true,
     "enableDbusIntegration" : true,
     "runMountPoint" : "~NAME~/run",
index 874b02f..b4e2344 100644 (file)
@@ -165,16 +165,6 @@ bool Server::prepareEnvironment(const std::string& configPath, bool runAsRoot)
         }
     }
 
-    // create directory for additional zone data (if needed)
-    if (!config.zoneNewConfigPrefix.empty()) {
-        if (!utils::createDir(config.zoneNewConfigPrefix, uid, gid,
-                              fs::perms::owner_all |
-                              fs::perms::group_read | fs::perms::group_exe |
-                              fs::perms::others_read | fs::perms::others_exe)) {
-            return false;
-        }
-    }
-
     // Omit supplementaty group setup and root drop if the user is already switched.
     // This situation will happen during daemon update triggered by SIGUSR1.
     if (!runAsRoot && geteuid() == uid) {
index 46c4974..32a18d2 100644 (file)
@@ -46,12 +46,14 @@ const int SHUTDOWN_WAIT = 10;
 const std::uint64_t DEFAULT_CPU_SHARES = 1024;
 const std::uint64_t DEFAULT_VCPU_PERIOD_MS = 100000;
 
-ZoneAdmin::ZoneAdmin(const std::string& zonesPath,
-                               const std::string& lxcTemplatePrefix,
-                               const ZoneConfig& config)
+ZoneAdmin::ZoneAdmin(const std::string& zoneId,
+                     const std::string& zonesPath,
+                     const std::string& lxcTemplatePrefix,
+                     const ZoneConfig& config,
+                     const ZoneDynamicConfig& dynamicConfig)
     : mConfig(config),
-      mZone(zonesPath, config.name),
-      mId(mZone.getName()),
+      mZone(zonesPath, zoneId),
+      mId(zoneId),
       mDetachOnExit(false),
       mDestroyOnExit(false)
 {
@@ -63,16 +65,16 @@ ZoneAdmin::ZoneAdmin(const std::string& zonesPath,
                                                                lxcTemplatePrefix);
         LOGI(mId << ": Creating zone from template: " << lxcTemplate);
         utils::CStringArrayBuilder args;
-        if (!config.ipv4Gateway.empty()) {
+        if (!dynamicConfig.ipv4Gateway.empty()) {
             args.add("--ipv4-gateway");
-            args.add(config.ipv4Gateway.c_str());
+            args.add(dynamicConfig.ipv4Gateway.c_str());
         }
-        if (!config.ipv4.empty()) {
+        if (!dynamicConfig.ipv4.empty()) {
             args.add("--ipv4");
-            args.add(config.ipv4.c_str());
+            args.add(dynamicConfig.ipv4.c_str());
         }
-        const std::string vt = std::to_string(config.vt);
-        if (config.vt > 0) {
+        const std::string vt = std::to_string(dynamicConfig.vt);
+        if (dynamicConfig.vt > 0) {
             args.add("--vt");
             args.add(vt.c_str());
         }
index 1d31ab4..10b7f02 100644 (file)
@@ -44,13 +44,17 @@ public:
 
     /**
      * ZoneAdmin constructor
+     * @param zoneId zone id
      * @param zonesPath directory where zones are defined (lxc configs, rootfs etc)
      * @param lxcTemplatePrefix directory where templates are stored
      * @param config zones config
+     * @param dynamicConfig zones dynamic config
      */
-    ZoneAdmin(const std::string& zonesPath,
-                   const std::string& lxcTemplatePrefix,
-                   const ZoneConfig& config);
+    ZoneAdmin(const std::string& zoneId,
+              const std::string& zonesPath,
+              const std::string& lxcTemplatePrefix,
+              const ZoneConfig& config,
+              const ZoneDynamicConfig& dynamicConfig);
     virtual ~ZoneAdmin();
 
     /**
index 02db1c4..da4b570 100644 (file)
@@ -38,11 +38,6 @@ namespace vasum {
 struct ZoneConfig {
 
     /**
-     * Zone name
-     */
-    std::string name;
-
-    /**
      * Lxc template name (relative to lxcTemplatePrefix)
      */
     std::string lxcTemplate;
@@ -53,27 +48,12 @@ struct ZoneConfig {
     std::vector<std::string> initWithArgs;
 
     /**
-     * IP v4 gateway address
-     */
-    std::string ipv4Gateway;
-
-    /**
-     * IP v4 address
-     */
-    std::string ipv4;
-
-    /**
      * Privilege of the zone.
      * The smaller the value the more important the zone
      */
     int privilege;
 
     /**
-     * Number of virtual terminal used by xserver inside zone
-     */
-    int vt;
-
-    /**
      * Allow switching to default zone after timeout.
      * Setting this to false will disable switching to default zone after timeout.
      */
@@ -96,11 +76,6 @@ struct ZoneConfig {
     std::int64_t cpuQuotaBackground;
 
     /**
-     * Path to zones dbus unix socket
-     */
-    std::string runMountPoint;
-
-    /**
      * When you move a file out of the zone (by move request)
      * its path must match at least one of the regexps in this vector.
      */
@@ -119,27 +94,57 @@ struct ZoneConfig {
 
     CONFIG_REGISTER
     (
-        name,
         lxcTemplate,
         initWithArgs,
-        ipv4Gateway,
-        ipv4,
-        privilege,
-        vt,
-        switchToDefaultAfterTimeout,
+        privilege, // TODO not needed?
+        switchToDefaultAfterTimeout, // TODO move to dynamic and add an API to change
         enableDbusIntegration,
         cpuQuotaForeground,
         cpuQuotaBackground,
-        runMountPoint,
-        permittedToSend,
-        permittedToRecv,
+        permittedToSend, // TODO move to dynamic and add an API to change
+        permittedToRecv, // TODO move to dynamic and add an API to change
         validLinkPrefixes
     )
 };
 
 struct ZoneDynamicConfig {
-    //TODO a place for zone dynamic config (other than provisioning which has its own struct)
-    CONFIG_REGISTER_EMPTY
+
+    /**
+     * IP v4 gateway address
+     */
+    std::string ipv4Gateway;
+
+    /**
+     * IP v4 address
+     */
+    std::string ipv4;
+
+    /**
+     * Number of virtual terminal used by xserver inside zone
+     */
+    int vt;
+
+    /**
+     * Path to zones dbus unix socket
+     */
+    std::string runMountPoint;
+
+    CONFIG_REGISTER
+    (
+        ipv4Gateway,
+        ipv4,
+        vt,
+        runMountPoint
+    )
+};
+
+struct ZoneTemplatePathConfig {
+    /**
+     * A path to zone template config (containing default values)
+     */
+    std::string zoneTemplatePath;
+
+    CONFIG_REGISTER(zoneTemplatePath)
 };
 
 } // namespace vasum
index 0c2eca7..e8580e1 100644 (file)
@@ -53,14 +53,17 @@ const int RECONNECT_DELAY = 1 * 1000;
 } // namespace
 
 Zone::Zone(const utils::Worker::Pointer& worker,
+           const std::string& zoneId,
            const std::string& zonesPath,
-           const std::string& zoneConfigPath,
+           const std::string& zoneTemplatePath,
            const std::string& dbPath,
            const std::string& lxcTemplatePrefix,
            const std::string& baseRunMountPointPath)
     : mWorker(worker)
 {
-    config::loadFromJsonFile(zoneConfigPath, mConfig);
+    const std::string dbPrefix = getZoneDbPrefix(zoneId);
+    config::loadFromKVStoreWithJsonFile(dbPath, zoneTemplatePath, mConfig, dbPrefix);
+    config::loadFromKVStoreWithJsonFile(dbPath, zoneTemplatePath, mDynamicConfig, dbPrefix);
 
     for (std::string r: mConfig.permittedToSend) {
         mPermittedToSend.push_back(boost::regex(r));
@@ -69,18 +72,16 @@ Zone::Zone(const utils::Worker::Pointer& worker,
         mPermittedToRecv.push_back(boost::regex(r));
     }
 
-    if (!mConfig.runMountPoint.empty()) {
-        mRunMountPoint = fs::absolute(mConfig.runMountPoint, baseRunMountPointPath).string();
+    if (!mDynamicConfig.runMountPoint.empty()) {
+        mRunMountPoint = fs::absolute(mDynamicConfig.runMountPoint, baseRunMountPointPath).string();
     }
 
-    mAdmin.reset(new ZoneAdmin(zonesPath, lxcTemplatePrefix, mConfig));
+    mAdmin.reset(new ZoneAdmin(zoneId, zonesPath, lxcTemplatePrefix, mConfig, mDynamicConfig));
 
-    const fs::path zonePath = fs::path(zonesPath) / mAdmin->getId();
+    const fs::path zonePath = fs::path(zonesPath) / zoneId;
     mRootPath = (zonePath / fs::path("rootfs")).string();
-    const std::string dbPrefix = getZoneDbPrefix(mAdmin->getId());
 
-    config::loadFromKVStoreWithJsonFile(dbPath, zoneConfigPath, mDynamicConfig, dbPrefix);
-    mProvision.reset(new ZoneProvision(mRootPath, zoneConfigPath, dbPath, dbPrefix, mConfig.validLinkPrefixes));
+    mProvision.reset(new ZoneProvision(mRootPath, zoneTemplatePath, dbPath, dbPrefix, mConfig.validLinkPrefixes));
 }
 
 Zone::~Zone()
@@ -187,7 +188,7 @@ std::string Zone::getDbusAddress() const
 
 int Zone::getVT() const
 {
-    return mConfig.vt;
+    return mDynamicConfig.vt;
 }
 
 std::string Zone::getRootPath() const
@@ -199,8 +200,8 @@ bool Zone::activateVT()
 {
     Lock lock(mReconnectMutex);
 
-    if (mConfig.vt >= 0) {
-        return utils::activateVT(mConfig.vt);
+    if (mDynamicConfig.vt >= 0) {
+        return utils::activateVT(mDynamicConfig.vt);
     }
 
     return true;
index dbffc22..b708811 100644 (file)
@@ -47,14 +47,17 @@ class Zone {
 public:
     /**
      * Zone constructor
+     * @param zoneId zone id
      * @param zonesPath directory where zones are defined (lxc configs, rootfs etc)
-     * @param zoneConfigPath path for zones config
+     * @param zoneTemplatePath path for zones config template
+     * @param dbPath path to dynamic config db file
      * @param lxcTemplatePrefix directory where templates are stored
      * @param baseRunMountPointPath base directory for run mount point
      */
     Zone(const utils::Worker::Pointer& worker,
+         const std::string& zoneId,
          const std::string& zonesPath,
-         const std::string& zoneConfigPath,
+         const std::string& zoneTemplatePath,
          const std::string& dbPath,
          const std::string& lxcTemplatePrefix,
          const std::string& baseRunMountPointPath);
index 3ae6e5a..bfc1b25 100644 (file)
@@ -60,11 +60,6 @@ struct ZonesManagerConfig {
     std::string zoneTemplateDir;
 
     /**
-     * Prefix added to a path for new zone configuration files
-     */
-    std::string zoneNewConfigPrefix;
-
-    /**
      * Path prefix for lxc templates
      */
     std::string lxcTemplatePrefix;
@@ -95,7 +90,6 @@ struct ZonesManagerConfig {
         zonesPath,
         zoneImagePath,
         zoneTemplateDir,
-        zoneNewConfigPrefix,
         lxcTemplatePrefix,
         availableVTs,
         inputConfig,
@@ -107,10 +101,9 @@ struct ZonesManagerConfig {
 struct ZonesManagerDynamicConfig {
 
     /**
-     * List of zones' configs that we manage.
-     * File paths can be relative to the ZoneManager config file.
+     * A list of created zones.
      */
-    std::vector<std::string> zoneConfigs;
+    std::vector<std::string> zoneIds;
 
     /**
      * An ID of default zone.
@@ -119,7 +112,7 @@ struct ZonesManagerDynamicConfig {
 
     CONFIG_REGISTER
     (
-        zoneConfigs,
+        zoneIds,
         defaultId
     )
 };
index 3baa2a2..bccfd21 100644 (file)
@@ -70,15 +70,9 @@ const std::string ENABLED_FILE_NAME = "enabled";
 
 const boost::regex ZONE_NAME_REGEX("~NAME~");
 const boost::regex ZONE_IP_THIRD_OCTET_REGEX("~IP~");
-const boost::regex ZONE_VT_REGEX("~VT~");
 
 const unsigned int ZONE_IP_BASE_THIRD_OCTET = 100;
 
-std::string getConfigName(const std::string& zoneId)
-{
-    return "zones/" + zoneId + ".conf";
-}
-
 template<typename T>
 void remove(std::vector<T>& v, const T& item)
 {
@@ -189,8 +183,8 @@ ZonesManager::ZonesManager(const std::string& configPath)
     mHostConnection.setRevokeDeviceCallback(bind(&ZonesManager::handleRevokeDeviceCall,
                                                  this, _1, _2, _3));
 
-    for (const auto& zoneConfig : mDynamicConfig.zoneConfigs) {
-        insertZone(utils::createFilePath(mConfig.zoneNewConfigPrefix, zoneConfig));
+    for (const auto& zoneId : mDynamicConfig.zoneIds) {
+        insertZone(zoneId, getTemplatePathForExistingZone(zoneId));
     }
 
     updateDefaultId();
@@ -269,38 +263,46 @@ void ZonesManager::updateDefaultId()
     saveDynamicConfig();
 }
 
-void ZonesManager::insertZone(const std::string& zoneConfigPath)
+std::string ZonesManager::getTemplatePathForExistingZone(const std::string& id)
 {
-    LOGT("Creating Zone " << zoneConfigPath);
+    ZoneTemplatePathConfig config;
+    config::loadFromKVStore(mConfig.dbPath, config, getZoneDbPrefix(id));
+    return config.zoneTemplatePath;
+}
+
+void ZonesManager::insertZone(const std::string& zoneId, const std::string& zoneTemplatePath)
+{
+    if (zoneId == HOST_ID) {
+        throw InvalidZoneIdException("Cannot use reserved zone ID");
+    }
+    if (findZone(zoneId) != mZones.end()) {
+        throw InvalidZoneIdException("Zone already exists");
+    }
+
+    LOGT("Creating Zone " << zoneId);
     std::unique_ptr<Zone> zone(new Zone(mWorker->createSubWorker(),
+                                        zoneId,
                                         mConfig.zonesPath,
-                                        zoneConfigPath,
+                                        zoneTemplatePath,
                                         mConfig.dbPath,
                                         mConfig.lxcTemplatePrefix,
                                         mConfig.runMountPointPrefix));
-    const std::string id = zone->getId();
-    if (id == HOST_ID) {
-        throw InvalidZoneIdException("Cannot use reserved zone ID");
-    }
-    if (findZone(id) != mZones.end()) {
-        throw InvalidZoneIdException("Zone already exists");
-    }
 
     using namespace std::placeholders;
     zone->setNotifyActiveZoneCallback(bind(&ZonesManager::notifyActiveZoneHandler,
-                                           this, id, _1, _2));
+                                           this, zoneId, _1, _2));
 
     zone->setDisplayOffCallback(bind(&ZonesManager::displayOffHandler,
-                                     this, id));
+                                     this, zoneId));
 
     zone->setFileMoveRequestCallback(bind(&ZonesManager::handleZoneMoveFileRequest,
-                                          this, id, _1, _2, _3));
+                                          this, zoneId, _1, _2, _3));
 
     zone->setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
-                                    this, id, _1, _2, _3, _4, _5, _6, _7));
+                                    this, zoneId, _1, _2, _3, _4, _5, _6, _7));
 
     zone->setDbusStateChangedCallback(bind(&ZonesManager::handleDbusStateChanged,
-                                           this, id, _1));
+                                           this, zoneId, _1));
 
     mZones.push_back(std::move(zone));
 
@@ -333,7 +335,7 @@ void ZonesManager::destroyZone(const std::string& zoneId)
     }
 
     // update dynamic config
-    remove(mDynamicConfig.zoneConfigs, getConfigName(zoneId));
+    remove(mDynamicConfig.zoneIds, zoneId);
     saveDynamicConfig();
     updateDefaultId();
 
@@ -932,52 +934,40 @@ void ZonesManager::handleSetActiveZoneCall(const std::string& id,
 
 
 void ZonesManager::generateNewConfig(const std::string& id,
-                                     const std::string& templatePath,
-                                     const std::string& resultPath)
+                                     const std::string& templatePath)
 {
-    // TODO Do not store new config at all, use template and dynamic config instead
-    namespace fs = boost::filesystem;
+    const std::string dbPrefix = getZoneDbPrefix(id);
+    ZoneDynamicConfig dynamicConfig;
+    config::loadFromKVStoreWithJsonFile(mConfig.dbPath, templatePath, dynamicConfig, dbPrefix);
 
-    if (fs::exists(resultPath)) {
-        LOGT(resultPath << " already exists, removing");
-        fs::remove(resultPath);
-    } else {
-        std::string resultFileDir = utils::dirName(resultPath);
-        if (!utils::createDirs(resultFileDir, fs::perms::owner_all |
-                                              fs::perms::group_read | fs::perms::group_exe |
-                                              fs::perms::others_read | fs::perms::others_exe)) {
-            LOGE("Unable to create directory for new config.");
-            throw ZoneOperationException("Unable to create directory for new config.");
-        }
-    }
-
-    std::string config;
-    if (!utils::readFileContent(templatePath, config)) {
-        LOGE("Failed to read template config file.");
-        throw ZoneOperationException("Failed to read template config file.");
-    }
-
-    std::string resultConfig = boost::regex_replace(config, ZONE_NAME_REGEX, id);
+    // update mount point path
+    dynamicConfig.runMountPoint = boost::regex_replace(dynamicConfig.runMountPoint,
+                                                       ZONE_NAME_REGEX,
+                                                       id);
 
     // generate first free VT number
     const int freeVT = getVTForNewZone();
     LOGD("VT number: " << freeVT);
-    resultConfig = boost::regex_replace(resultConfig, ZONE_VT_REGEX, std::to_string(freeVT));
+    dynamicConfig.vt = freeVT;
 
     // generate third IP octet for network config
     std::string thirdOctetStr = std::to_string(ZONE_IP_BASE_THIRD_OCTET + freeVT);
     LOGD("IP third octet: " << thirdOctetStr);
-    resultConfig = boost::regex_replace(resultConfig, ZONE_IP_THIRD_OCTET_REGEX, thirdOctetStr);
+    dynamicConfig.ipv4Gateway = boost::regex_replace(dynamicConfig.ipv4Gateway,
+                                                     ZONE_IP_THIRD_OCTET_REGEX,
+                                                     thirdOctetStr);
+    dynamicConfig.ipv4 = boost::regex_replace(dynamicConfig.ipv4,
+                                              ZONE_IP_THIRD_OCTET_REGEX,
+                                              thirdOctetStr);
 
-    if (!utils::saveFileContent(resultPath, resultConfig)) {
-        LOGE("Faield to save new config file.");
-        throw ZoneOperationException("Failed to save new config file.");
-    }
+    // save dynamic config
+    config::saveToKVStore(mConfig.dbPath, dynamicConfig, dbPrefix);
+
+    // save zone template path
+    ZoneTemplatePathConfig templatePathConfig;
+    templatePathConfig.zoneTemplatePath = templatePath;
+    config::saveToKVStore(mConfig.dbPath, templatePathConfig, dbPrefix);
 
-    // restrict new config file so that only owner (vasum) can write it
-    fs::permissions(resultPath, fs::perms::owner_read | fs::perms::owner_write |
-                                fs::perms::group_read |
-                                fs::perms::others_read);
 }
 
 int ZonesManager::getVTForNewZone()
@@ -1035,10 +1025,6 @@ void ZonesManager::createZone(const std::string& id,
         }
     }
 
-    // generate paths to new configuration files
-    std::string newConfigName = getConfigName(id);
-    std::string newConfigPath = utils::createFilePath(mConfig.zoneNewConfigPrefix, newConfigName);
-
     auto removeAllWrapper = [](const std::string& path) -> bool {
         try {
             LOGD("Removing copied data");
@@ -1053,9 +1039,8 @@ void ZonesManager::createZone(const std::string& id,
                                                          templateName + ".conf");
 
     try {
-        LOGI("Generating config from " << zoneTemplatePath << " to " << newConfigPath);
-        generateNewConfig(id, zoneTemplatePath, newConfigPath);
-
+        LOGI("Generating config from " << zoneTemplatePath);
+        generateNewConfig(id, zoneTemplatePath);
     } catch (VasumException& e) {
         LOGE("Generate config failed: " << e.what());
         utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
@@ -1064,14 +1049,14 @@ void ZonesManager::createZone(const std::string& id,
 
     LOGT("Creating new zone");
     try {
-        insertZone(newConfigPath);
+        insertZone(id, zoneTemplatePath);
     } catch (VasumException& e) {
         LOGE("Creating new zone failed: " << e.what());
         utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
         throw e;
     }
 
-    mDynamicConfig.zoneConfigs.push_back(newConfigName);
+    mDynamicConfig.zoneIds.push_back(id);
     saveDynamicConfig();
     updateDefaultId();
 }
index 529ef8b..6453278 100644 (file)
@@ -135,10 +135,10 @@ private:
     void refocus();
     void switchingSequenceMonitorNotify();
     void generateNewConfig(const std::string& id,
-                           const std::string& templatePath,
-                           const std::string& resultPath);
+                           const std::string& templatePath);
+    std::string getTemplatePathForExistingZone(const std::string& id);
     int getVTForNewZone();
-    void insertZone(const std::string& zoneConfigPath);
+    void insertZone(const std::string& zoneId, const std::string& templatePath);
 
     void notifyActiveZoneHandler(const std::string& caller,
                                  const std::string& appliaction,
index 8742612..5587d11 100644 (file)
 MESSAGE(STATUS "Installing configs for the Client Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR})
 
 ## Generate ####################################################################
-CONFIGURE_FILE(ut-client/test-dbus-daemon.conf.in
-              ${CMAKE_BINARY_DIR}/ut-client/test-dbus-daemon.conf @ONLY)
+CONFIGURE_FILE(ut-client/test-daemon.conf.in
+              ${CMAKE_BINARY_DIR}/ut-client/test-daemon.conf @ONLY)
 FILE(GLOB client_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/*.conf)
 
-CONFIGURE_FILE(ut-client/zones/console1-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-client/zones/console1-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-client/zones/console2-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-client/zones/console2-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-client/zones/console3-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-client/zones/console3-dbus.conf @ONLY)
-FILE(GLOB client_zone_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/zones/*.conf)
+CONFIGURE_FILE(ut-client/templates/console-dbus.conf.in
+               ${CMAKE_BINARY_DIR}/ut-client/templates/console-dbus.conf @ONLY)
+FILE(GLOB client_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/templates/*.conf)
 
 ## Install #####################################################################
 INSTALL(FILES        ${client_manager_CONF_GEN}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client)
-INSTALL(FILES        ${client_zone_CONF_GEN}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client/zones)
+INSTALL(FILES        ${client_templates_CONF_GEN}
+        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client/templates)
@@ -1,5 +1,4 @@
 {
-    "name" : "~NAME~",
     "lxcTemplate" : "minimal-dbus.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
     "ipv4Gateway" : "",
@@ -1,11 +1,10 @@
 {
     "dbPath" : "/tmp/ut-zones/vasum.db",
-    "zoneConfigs" : [],
+    "zoneIds" : [],
     "defaultId" : "",
     "zonesPath" : "/tmp/ut-zones",
     "zoneImagePath" : "",
-    "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/templates/",
-    "zoneNewConfigPrefix" : "/tmp/ut-zones/generated-configs/",
+    "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/client/ut-client/templates/",
     "runMountPointPrefix" : "",
     "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
     "availableVTs" : [],
diff --git a/tests/unit_tests/client/configs/ut-client/test-dbus-daemon.conf.in b/tests/unit_tests/client/configs/ut-client/test-dbus-daemon.conf.in
deleted file mode 100644 (file)
index b51ee9a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-    "dbPath" : "/tmp/ut-zones/vasum.db",
-    "zoneConfigs" : ["zones/console1-dbus.conf",
-                          "zones/console2-dbus.conf",
-                          "zones/console3-dbus.conf"],
-    "defaultId" : "ut-zones-manager-console1-dbus",
-    "zonesPath" : "/tmp/ut-zones",
-    "zoneImagePath" : "",
-    "zoneTemplateDir" : "no_need_for_templates_in_this_test",
-    "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/client/ut-client/",
-    "runMountPointPrefix" : "",
-    "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
-    "availableVTs" : [],
-    "inputConfig" : {"enabled" : false,
-                     "device" : "/dev/doesnotexist",
-                     "code" : 139,
-                     "numberOfEvents" : 2,
-                     "timeWindowMs" : 500},
-    "proxyCallRules" : [{"caller" : "*",
-                         "target" : "*",
-                         "targetBusName" : "org.tizen.vasum.tests",
-                         "targetObjectPath" : "*",
-                         "targetInterface" : "*",
-                         "targetMethod" : "*"}]
-}
diff --git a/tests/unit_tests/client/configs/ut-client/zones/console1-dbus.conf.in b/tests/unit_tests/client/configs/ut-client/zones/console1-dbus.conf.in
deleted file mode 100644 (file)
index 097480d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zones-manager-console1-dbus",
-    "lxcTemplate" : "minimal-dbus.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 20,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "enableDbusIntegration" : true,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console1-dbus",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*", "/etc/secret2" ],
-    "permittedToRecv" : [ "/tmp/.*" ],
-    "validLinkPrefixes" : []
-}
diff --git a/tests/unit_tests/client/configs/ut-client/zones/console2-dbus.conf.in b/tests/unit_tests/client/configs/ut-client/zones/console2-dbus.conf.in
deleted file mode 100644 (file)
index 440772b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zones-manager-console2-dbus",
-    "lxcTemplate" : "minimal-dbus.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 20,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : false,
-    "enableDbusIntegration" : true,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console2-dbus",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*" ],
-    "permittedToRecv" : [ "/tmp/.*", "/etc/secret1" ],
-    "validLinkPrefixes" : []
-}
diff --git a/tests/unit_tests/client/configs/ut-client/zones/console3-dbus.conf.in b/tests/unit_tests/client/configs/ut-client/zones/console3-dbus.conf.in
deleted file mode 100644 (file)
index 2f28ee1..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zones-manager-console3-dbus",
-    "lxcTemplate" : "minimal-dbus.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 20,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "enableDbusIntegration" : true,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console3-dbus",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*" ],
-    "permittedToRecv" : [ "/tmp/.*" ],
-    "validLinkPrefixes" : []
-}
index a188a9d..1c55668 100644 (file)
@@ -31,6 +31,7 @@
 #include "utils/scoped-dir.hpp"
 #include "zones-manager.hpp"
 #include "zone-dbus-definitions.hpp"
+#include "logger/logger.hpp"
 
 #include <map>
 #include <string>
@@ -45,9 +46,10 @@ using namespace vasum::utils;
 
 namespace {
 
-const std::string TEST_DBUS_CONFIG_PATH =
-    VSM_TEST_CONFIG_INSTALL_DIR "/client/ut-client/test-dbus-daemon.conf";
+const std::string TEST_CONFIG_PATH =
+    VSM_TEST_CONFIG_INSTALL_DIR "/client/ut-client/test-daemon.conf";
 const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
+const std::string TEMPLATE_NAME = "console-dbus";
 
 struct Loop {
     Loop()
@@ -70,25 +72,34 @@ struct Fixture {
     Fixture()
         : mZonesPathGuard(ZONES_PATH)
         , mRunGuard("/tmp/ut-run")
-        , cm(TEST_DBUS_CONFIG_PATH)
+        , cm(TEST_CONFIG_PATH)
     {
+        cm.createZone("zone1", TEMPLATE_NAME);
+        cm.createZone("zone2", TEMPLATE_NAME);
+        cm.createZone("zone3", TEMPLATE_NAME);
         cm.startAll();
+        LOGI("------- setup complete --------");
+    }
+
+    ~Fixture()
+    {
+        LOGI("------- cleanup --------");
     }
 };
 
 const int EVENT_TIMEOUT = 5000; ///< ms
 const std::map<std::string, std::string> EXPECTED_DBUSES_STARTED = {
     {
-        "ut-zones-manager-console1-dbus",
-        "unix:path=/tmp/ut-run/ut-zones-manager-console1-dbus/dbus/system_bus_socket"
+        "zone1",
+        "unix:path=/tmp/ut-run/zone1/dbus/system_bus_socket"
     },
     {
-        "ut-zones-manager-console2-dbus",
-        "unix:path=/tmp/ut-run/ut-zones-manager-console2-dbus/dbus/system_bus_socket"
+        "zone2",
+        "unix:path=/tmp/ut-run/zone2/dbus/system_bus_socket"
     },
     {
-        "ut-zones-manager-console3-dbus",
-        "unix:path=/tmp/ut-run/ut-zones-manager-console3-dbus/dbus/system_bus_socket"
+        "zone3",
+        "unix:path=/tmp/ut-run/zone3/dbus/system_bus_socket"
     }
 };
 
@@ -212,7 +223,7 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneIdTest)
 
 BOOST_AUTO_TEST_CASE(SetActiveZoneTest)
 {
-    const std::string newActiveZoneId = "ut-zones-manager-console2-dbus";
+    const std::string newActiveZoneId = "zone2";
 
     BOOST_REQUIRE_NE(newActiveZoneId, cm.getRunningForegroundZoneId());
 
@@ -239,7 +250,7 @@ BOOST_AUTO_TEST_CASE(CreateZoneTest)
 
 BOOST_AUTO_TEST_CASE(StartShutdownZoneTest)
 {
-    const std::string newActiveZoneId = "ut-zones-manager-console1-dbus";
+    const std::string newActiveZoneId = "zone1";
 
     VsmClient client = vsm_client_create();
     VsmStatus status = vsm_connect(client);
@@ -253,7 +264,7 @@ BOOST_AUTO_TEST_CASE(StartShutdownZoneTest)
 
 BOOST_AUTO_TEST_CASE(LockUnlockZoneTest)
 {
-    const std::string newActiveZoneId = "ut-zones-manager-console2-dbus";
+    const std::string newActiveZoneId = "zone2";
 
     VsmClient client = vsm_client_create();
     VsmStatus status = vsm_connect(client);
@@ -374,7 +385,7 @@ BOOST_AUTO_TEST_CASE(GetZoneIdByPidTest2)
 
 BOOST_AUTO_TEST_CASE(GrantRevokeTest)
 {
-    const std::string zoneId = "ut-zones-manager-console2-dbus";
+    const std::string zoneId = "zone2";
     const std::string dev = "tty3";
 
     VsmClient client = vsm_client_create();
index fca8500..6c8a1af 100644 (file)
 MESSAGE(STATUS "Installing configs for the Server Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR})
 
 FILE(GLOB server_manager_CONF       ut-server/*.conf)
-FILE(GLOB server_zone_CONF     ut-server/zones/*.conf)
+FILE(GLOB server_templates_CONF     ut-server/templates/*.conf)
 
 FILE(GLOB manager_manager_CONF      ut-zones-manager/*.conf)
-FILE(GLOB manager_zone_CONF    ut-zones-manager/zones/*.conf)
+FILE(GLOB manager_templates_CONF    ut-zones-manager/templates/*.conf)
 
 FILE(GLOB zone_CONF            ut-zone/*.conf)
-FILE(GLOB zone_zone_CONF  ut-zone/zones/*.conf)
+FILE(GLOB zone_templates_CONF  ut-zone/templates/*.conf)
 
 FILE(GLOB zone_provision_CONF  ut-zone-provision/*.conf)
 
-FILE(GLOB admin_zone_CONF      ut-zone-admin/zones/*.conf)
+FILE(GLOB admin_templates_CONF      ut-zone-admin/templates/*.conf)
 
 FILE(GLOB connection_CONF           ut-zone-connection/*.conf)
 
@@ -38,35 +38,19 @@ FILE(GLOB connection_CONF           ut-zone-connection/*.conf)
 ## Generate ####################################################################
 CONFIGURE_FILE(ut-server/test-daemon.conf.in
               ${CMAKE_BINARY_DIR}/ut-server/test-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-server/buggy-daemon.conf.in
-              ${CMAKE_BINARY_DIR}/ut-server/buggy-daemon.conf @ONLY)
 FILE(GLOB server_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-server/*.conf)
 
-CONFIGURE_FILE(ut-zone/zones/test-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zone/zones/test-dbus.conf @ONLY)
-FILE(GLOB zone_zone_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zone/zones/*.conf)
+CONFIGURE_FILE(ut-zone/templates/test-dbus.conf.in
+               ${CMAKE_BINARY_DIR}/ut-zone/templates/test-dbus.conf @ONLY)
+FILE(GLOB zone_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zone/templates/*.conf)
 
 CONFIGURE_FILE(ut-zones-manager/test-daemon.conf.in
                ${CMAKE_BINARY_DIR}/ut-zones-manager/test-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-zones-manager/buggy-daemon.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/buggy-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-zones-manager/test-dbus-daemon.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/test-dbus-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-zones-manager/empty-dbus-daemon.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/empty-dbus-daemon.conf @ONLY)
 FILE(GLOB manager_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/*.conf)
 
-CONFIGURE_FILE(ut-zones-manager/zones/console1-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/console1-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-zones-manager/zones/console2-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/console2-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-zones-manager/zones/console3-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/console3-dbus.conf @ONLY)
-FILE(GLOB manager_zone_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/*.conf)
-
-CONFIGURE_FILE(ut-zones-manager/templates/default.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/default.conf @ONLY)
-FILE(GLOB manager_zone_TEMPLATE_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/*.conf)
+CONFIGURE_FILE(ut-zones-manager/templates/console-dbus.conf.in
+               ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/console-dbus.conf @ONLY)
+FILE(GLOB manager_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/*.conf)
 
 
 ## Install #####################################################################
@@ -74,32 +58,30 @@ INSTALL(FILES        ${server_manager_CONF}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server)
 INSTALL(FILES        ${server_manager_CONF_GEN}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server)
-INSTALL(FILES        ${server_zone_CONF}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server/zones)
+INSTALL(FILES        ${server_templates_CONF}
+        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server/templates)
 
 INSTALL(FILES        ${manager_manager_CONF}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager)
 INSTALL(FILES        ${manager_manager_CONF_GEN}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager)
-INSTALL(FILES        ${manager_zone_CONF}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/zones)
-INSTALL(FILES        ${manager_zone_CONF_GEN}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/zones)
-INSTALL(FILES        ${manager_zone_TEMPLATE_GEN}
+INSTALL(FILES        ${manager_templates_CONF}
+        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/templates)
+INSTALL(FILES        ${manager_templates_CONF_GEN}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/templates)
 
 INSTALL(FILES        ${zone_CONF}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone)
-INSTALL(FILES        ${zone_zone_CONF}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/zones)
-INSTALL(FILES        ${zone_zone_CONF_GEN}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/zones)
+INSTALL(FILES        ${zone_templates_CONF}
+        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/templates)
+INSTALL(FILES        ${zone_templates_CONF_GEN}
+        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/templates)
 
 INSTALL(FILES        ${zone_provision_CONF}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-provision)
 
-INSTALL(FILES        ${admin_zone_CONF}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-admin/zones)
+INSTALL(FILES        ${admin_templates_CONF}
+        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-admin/templates)
 
 INSTALL(FILES        ${connection_CONF}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-connection)
diff --git a/tests/unit_tests/server/configs/ut-server/buggy-daemon.conf.in b/tests/unit_tests/server/configs/ut-server/buggy-daemon.conf.in
deleted file mode 100644 (file)
index a39bcb4..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "dbPath" : "/tmp/ut-zones/vasum.db",
-    "zoneConfigs" : ["zones/zone1.conf", "missing/file/path/missing.conf", "zones/zone3.conf"],
-    "zonesPath" : "/tmp/ut-zones",
-    "zoneImagePath" : "",
-    "zoneTemplateDir" : "no_need_for_templates_in_this_test",
-    "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-server/",
-    "runMountPointPrefix" : "",
-    "defaultId" : "ut-server-zone1",
-    "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
-    "availableVTs" : [],
-    "inputConfig" : {"enabled" : false,
-                     "device" : "/dev/doesnotexist",
-                     "code" : 139,
-                     "numberOfEvents" : 2,
-                     "timeWindowMs" : 500},
-    "proxyCallRules" : []
-}
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-server-zone1",
     "lxcTemplate" : "minimal.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
     "ipv4Gateway" : "",
index 932ee89..8fb9ee2 100644 (file)
@@ -1,12 +1,11 @@
 {
     "dbPath" : "/tmp/ut-zones/vasum.db",
-    "zoneConfigs" : ["zones/zone1.conf", "zones/zone2.conf", "zones/zone3.conf"],
+    "zoneIds" : [],
     "zonesPath" : "/tmp/ut-zones",
     "zoneImagePath" : "",
-    "zoneTemplateDir" : "no_need_for_templates_in_this_test",
-    "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-server/",
+    "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-server/templates/",
     "runMountPointPrefix" : "",
-    "defaultId" : "ut-server-zone1",
+    "defaultId" : "",
     "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
     "availableVTs" : [],
     "inputConfig" : {"enabled" : false,
diff --git a/tests/unit_tests/server/configs/ut-server/zones/zone3.conf b/tests/unit_tests/server/configs/ut-server/zones/zone3.conf
deleted file mode 100644 (file)
index dfc4a04..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-server-zone3",
-    "lxcTemplate" : "minimal.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 15,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "enableDbusIntegration" : false,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "",
-    "provisions" : [],
-    "permittedToSend" : [],
-    "permittedToRecv" : [],
-    "validLinkPrefixes" : []
-}
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-zone-admin-test",
     "lxcTemplate" : "missing.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
     "ipv4Gateway" : "",
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-server-zone2",
     "lxcTemplate" : "minimal.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
     "ipv4Gateway" : "",
diff --git a/tests/unit_tests/server/configs/ut-zone-admin/zones/test.conf b/tests/unit_tests/server/configs/ut-zone-admin/zones/test.conf
deleted file mode 100644 (file)
index 215fa4f..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zone-admin-test",
-    "lxcTemplate" : "minimal.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 10,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "enableDbusIntegration" : false,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "",
-    "provisions" : [],
-    "permittedToSend" : [],
-    "permittedToRecv" : [],
-    "validLinkPrefixes" : []
-}
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-zone-test",
     "lxcTemplate" : "/buggy/path",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
     "ipv4Gateway" : "",
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-zone-test-dbus",
     "lxcTemplate" : "minimal-dbus.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zone/ut-dbus.conf --fork; read"],
     "ipv4Gateway" : "",
@@ -10,7 +9,7 @@
     "enableDbusIntegration" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "/tmp/ut-run/ut-zone-test-dbus",
+    "runMountPoint" : "/tmp/ut-run/zoneId",
     "provisions" : [],
     "permittedToSend" : [],
     "permittedToRecv" : [],
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-zone-test",
     "lxcTemplate" : "minimal.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
     "ipv4Gateway" : "",
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/buggy-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/buggy-daemon.conf.in
deleted file mode 100644 (file)
index 50a95b2..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "dbPath" : "/tmp/ut-zones/vasum.db",
-    "zoneConfigs" : ["zones/console1.conf", "missing/file/path/missing.conf", "zones/console3.conf"],
-    "runMountPointPrefix" : "",
-    "defaultId" : "ut-zones-manager-console1",
-    "zonesPath" : "/tmp/ut-zones",
-    "zoneImagePath" : "",
-    "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/templates/",
-    "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
-    "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
-    "availableVTs" : [],
-    "inputConfig" : {"enabled" : false,
-                     "device" : "/dev/doesnotexist",
-                     "code" : 139,
-                     "numberOfEvents" : 2,
-                     "timeWindowMs" : 500},
-    "proxyCallRules" : []
-}
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-zones-manager-console3-dbus",
     "lxcTemplate" : "minimal-dbus.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
     "ipv4Gateway" : "",
@@ -10,7 +9,7 @@
     "enableDbusIntegration" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console3-dbus",
+    "runMountPoint" : "/tmp/ut-run/~NAME~",
     "provisions" : [],
     "permittedToSend" : [ "/tmp/.*" ],
     "permittedToRecv" : [ "/tmp/.*" ],
@@ -1,5 +1,4 @@
 {
-    "name" : "ut-zones-manager-console1",
     "lxcTemplate" : "minimal.sh",
     "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
     "ipv4Gateway" : "",
index d8f1ad4..adea9b6 100644 (file)
@@ -1,12 +1,11 @@
 {
     "dbPath" : "/tmp/ut-zones/vasum.db",
-    "zoneConfigs" : ["zones/console1.conf", "zones/console2.conf", "zones/console3.conf"],
-    "runMountPointPrefix" : "",
-    "defaultId" : "ut-zones-manager-console1",
+    "zoneIds" : [],
+    "defaultId" : "",
     "zonesPath" : "/tmp/ut-zones",
     "zoneImagePath" : "",
     "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/templates/",
-    "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
+    "runMountPointPrefix" : "",
     "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
     "availableVTs" : [],
     "inputConfig" : {"enabled" : false,
                      "code" : 139,
                      "numberOfEvents" : 2,
                      "timeWindowMs" : 500},
-    "proxyCallRules" : []
+    "proxyCallRules" : [{"caller" : "*",
+                         "target" : "*",
+                         "targetBusName" : "org.tizen.vasum.tests",
+                         "targetObjectPath" : "*",
+                         "targetInterface" : "*",
+                         "targetMethod" : "*"}]
 }
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/test-dbus-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/test-dbus-daemon.conf.in
deleted file mode 100644 (file)
index 4f8f6e8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-    "dbPath" : "/tmp/ut-zones/vasum.db",
-    "zoneConfigs" : ["zones/console1-dbus.conf",
-                          "zones/console2-dbus.conf",
-                          "zones/console3-dbus.conf"],
-    "defaultId" : "ut-zones-manager-console1-dbus",
-    "zonesPath" : "/tmp/ut-zones",
-    "zoneImagePath" : "",
-    "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/templates/",
-    "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
-    "runMountPointPrefix" : "",
-    "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
-    "availableVTs" : [],
-    "inputConfig" : {"enabled" : false,
-                     "device" : "/dev/doesnotexist",
-                     "code" : 139,
-                     "numberOfEvents" : 2,
-                     "timeWindowMs" : 500},
-    "proxyCallRules" : [{"caller" : "*",
-                         "target" : "*",
-                         "targetBusName" : "org.tizen.vasum.tests",
-                         "targetObjectPath" : "*",
-                         "targetInterface" : "*",
-                         "targetMethod" : "*"}]
-}
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/zones/console1-dbus.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/zones/console1-dbus.conf.in
deleted file mode 100644 (file)
index 097480d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zones-manager-console1-dbus",
-    "lxcTemplate" : "minimal-dbus.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 20,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "enableDbusIntegration" : true,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console1-dbus",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*", "/etc/secret2" ],
-    "permittedToRecv" : [ "/tmp/.*" ],
-    "validLinkPrefixes" : []
-}
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/zones/console2-dbus.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/zones/console2-dbus.conf.in
deleted file mode 100644 (file)
index 440772b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zones-manager-console2-dbus",
-    "lxcTemplate" : "minimal-dbus.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 20,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : false,
-    "enableDbusIntegration" : true,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console2-dbus",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*" ],
-    "permittedToRecv" : [ "/tmp/.*", "/etc/secret1" ],
-    "validLinkPrefixes" : []
-}
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/zones/console2.conf b/tests/unit_tests/server/configs/ut-zones-manager/zones/console2.conf
deleted file mode 100644 (file)
index 3c37313..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zones-manager-console2",
-    "lxcTemplate" : "minimal.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 10,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "enableDbusIntegration" : false,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*" ],
-    "permittedToRecv" : [ "/tmp/.*" ],
-    "validLinkPrefixes" : []
-}
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/zones/console3.conf b/tests/unit_tests/server/configs/ut-zones-manager/zones/console3.conf
deleted file mode 100644 (file)
index 8e54fe6..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "name" : "ut-zones-manager-console3",
-    "lxcTemplate" : "minimal.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 15,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "enableDbusIntegration" : false,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "runMountPoint" : "",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*" ],
-    "permittedToRecv" : [ "/tmp/.*" ],
-    "validLinkPrefixes" : []
-}
index 3cd3e51..c65e652 100644 (file)
 #include "ut.hpp"
 
 #include "server.hpp"
+#include "zones-manager.hpp"
 #include "exception.hpp"
 #include "config/exception.hpp"
+#include "utils/glib-loop.hpp"
 #include "utils/scoped-dir.hpp"
+#include "logger/logger.hpp"
 
 #include <string>
 #include <future>
@@ -38,8 +41,8 @@ namespace {
 
 const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-server";
 const std::string TEST_CONFIG_PATH = CONFIG_DIR + "/test-daemon.conf";
-const std::string BUGGY_CONFIG_PATH = CONFIG_DIR + "/buggy-daemon.conf";
 const std::string MISSING_CONFIG_PATH = CONFIG_DIR + "/missing-daemon.conf";
+const std::string TEMPLATE_NAME = "default";
 
 const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
 const bool AS_ROOT = true;
@@ -49,7 +52,19 @@ struct Fixture {
 
     Fixture()
         : mZonesPathGuard(ZONES_PATH)
-    {}
+    {
+        prepare();
+        LOGI("------------ setup complete -----------");
+    }
+
+    void prepare()
+    {
+        vasum::utils::ScopedGlibLoop loop;
+        vasum::ZonesManager manager(TEST_CONFIG_PATH);
+        manager.createZone("zone1", TEMPLATE_NAME);
+        manager.createZone("zone2", TEMPLATE_NAME);
+        manager.startAll();
+    }
 };
 } // namespace
 
@@ -65,14 +80,9 @@ BOOST_AUTO_TEST_CASE(ConstructorDestructorTest)
     s.reset();
 }
 
-BOOST_AUTO_TEST_CASE(BuggyConfigTest)
-{
-    BOOST_REQUIRE_THROW(Server(BUGGY_CONFIG_PATH).run(AS_ROOT), ConfigException);
-}
-
 BOOST_AUTO_TEST_CASE(MissingConfigTest)
 {
-    BOOST_REQUIRE_THROW(Server(MISSING_CONFIG_PATH).run(AS_ROOT), ConfigException);
+    BOOST_REQUIRE_THROW(Server(MISSING_CONFIG_PATH).run(AS_ROOT), ConfigException);//TODO check message
 }
 
 BOOST_AUTO_TEST_CASE(TerminateTest)
index ba21ea9..21cc850 100644 (file)
@@ -37,11 +37,11 @@ using namespace vasum;
 
 namespace {
 
-const std::string ZONES_CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-admin/zones";
-const std::string TEST_CONFIG_PATH = ZONES_CONFIG_DIR + "/test.conf";
-const std::string TEST_NO_SHUTDOWN_CONFIG_PATH = ZONES_CONFIG_DIR + "/test-no-shutdown.conf";
-const std::string BUGGY_CONFIG_PATH = ZONES_CONFIG_DIR + "/buggy.conf";
-const std::string MISSING_CONFIG_PATH = ZONES_CONFIG_DIR + "/missing.conf";
+const std::string TEMPLATES_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-admin/templates";
+const std::string TEST_CONFIG_PATH = TEMPLATES_DIR + "/test.conf";
+const std::string TEST_NO_SHUTDOWN_CONFIG_PATH = TEMPLATES_DIR + "/test-no-shutdown.conf";
+const std::string BUGGY_CONFIG_PATH = TEMPLATES_DIR + "/buggy.conf";
+const std::string MISSING_CONFIG_PATH = TEMPLATES_DIR + "/missing.conf";
 const std::string ZONES_PATH = "/tmp/ut-zones";
 const std::string LXC_TEMPLATES_PATH = VSM_TEST_LXC_TEMPLATES_INSTALL_DIR;
 
@@ -50,6 +50,7 @@ struct Fixture {
     utils::ScopedDir mZonesPathGuard;
 
     ZoneConfig mConfig;
+    ZoneDynamicConfig mDynamicConfig;
 
     Fixture()
         : mZonesPathGuard(ZONES_PATH)
@@ -58,9 +59,12 @@ struct Fixture {
     std::unique_ptr<ZoneAdmin> create(const std::string& configPath)
     {
         config::loadFromJsonFile(configPath, mConfig);
-        return std::unique_ptr<ZoneAdmin>(new ZoneAdmin(ZONES_PATH,
-                                                                  LXC_TEMPLATES_PATH,
-                                                                  mConfig));
+        config::loadFromJsonFile(configPath, mDynamicConfig);
+        return std::unique_ptr<ZoneAdmin>(new ZoneAdmin("zoneId",
+                                                        ZONES_PATH,
+                                                        LXC_TEMPLATES_PATH,
+                                                        mConfig,
+                                                        mDynamicConfig));
     }
 
     void ensureStarted()
@@ -83,7 +87,7 @@ BOOST_AUTO_TEST_CASE(ConstructorDestructorTest)
 
 BOOST_AUTO_TEST_CASE(MissingConfigTest)
 {
-    BOOST_REQUIRE_THROW(create(MISSING_CONFIG_PATH), ZoneOperationException);
+    BOOST_REQUIRE_THROW(create(MISSING_CONFIG_PATH), ZoneOperationException);//TODO check message
 }
 
 BOOST_AUTO_TEST_CASE(StartTest)
@@ -99,7 +103,7 @@ BOOST_AUTO_TEST_CASE(StartTest)
 BOOST_AUTO_TEST_CASE(StartBuggyTest)
 {
     auto admin = create(BUGGY_CONFIG_PATH);
-    BOOST_REQUIRE_THROW(admin->start(), ZoneOperationException);
+    BOOST_REQUIRE_THROW(admin->start(), ZoneOperationException);//TODO check message
 }
 
 BOOST_AUTO_TEST_CASE(StopShutdownTest)
index 646a0a8..dbdf65a 100644 (file)
@@ -45,11 +45,11 @@ using namespace config;
 
 namespace {
 
-const std::string ZONES_CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone/zones";
-const std::string TEST_CONFIG_PATH = ZONES_CONFIG_DIR + "/test.conf";
-const std::string TEST_DBUS_CONFIG_PATH = ZONES_CONFIG_DIR + "/test-dbus.conf";
-const std::string BUGGY_CONFIG_PATH = ZONES_CONFIG_DIR + "/buggy.conf";
-const std::string MISSING_CONFIG_PATH = ZONES_CONFIG_DIR + "/missing.conf";
+const std::string TEMPLATES_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone/templates";
+const std::string TEST_CONFIG_PATH = TEMPLATES_DIR + "/test.conf";
+const std::string TEST_DBUS_CONFIG_PATH = TEMPLATES_DIR + "/test-dbus.conf";
+const std::string BUGGY_CONFIG_PATH = TEMPLATES_DIR + "/buggy.conf";
+const std::string MISSING_CONFIG_PATH = TEMPLATES_DIR + "/missing.conf";
 const std::string ZONES_PATH = "/tmp/ut-zones";
 const std::string LXC_TEMPLATES_PATH = VSM_TEST_LXC_TEMPLATES_INSTALL_DIR;
 const std::string DB_PATH = ZONES_PATH + "/vasum.db";
@@ -66,6 +66,7 @@ struct Fixture {
     std::unique_ptr<Zone> create(const std::string& configPath)
     {
         return std::unique_ptr<Zone>(new Zone(utils::Worker::create(),
+                                              "zoneId",
                                               ZONES_PATH,
                                               configPath,
                                               DB_PATH,
@@ -93,12 +94,12 @@ BOOST_AUTO_TEST_CASE(ConstructorDestructorTest)
 
 BOOST_AUTO_TEST_CASE(BuggyConfigTest)
 {
-    BOOST_REQUIRE_THROW(create(BUGGY_CONFIG_PATH), ZoneOperationException);
+    BOOST_REQUIRE_THROW(create(BUGGY_CONFIG_PATH), ZoneOperationException);//TODO check message
 }
 
 BOOST_AUTO_TEST_CASE(MissingConfigTest)
 {
-    BOOST_REQUIRE_THROW(create(MISSING_CONFIG_PATH), ConfigException);
+    BOOST_REQUIRE_THROW(create(MISSING_CONFIG_PATH), ConfigException);//TODO check message
 }
 
 BOOST_AUTO_TEST_CASE(StartStopTest)
index a32aaa7..58ac060 100644 (file)
@@ -63,14 +63,10 @@ namespace {
 
 const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager";
 const std::string TEST_CONFIG_PATH = CONFIG_DIR + "/test-daemon.conf";
-const std::string TEST_DBUS_CONFIG_PATH = CONFIG_DIR + "/test-dbus-daemon.conf";
-const std::string EMPTY_DBUS_CONFIG_PATH = CONFIG_DIR + "/empty-dbus-daemon.conf";
-const std::string BUGGY_CONFIG_PATH = CONFIG_DIR + "/buggy-daemon.conf";
 const std::string MISSING_CONFIG_PATH = CONFIG_DIR + "/missing-daemon.conf";
 const int EVENT_TIMEOUT = 5000;
-const int UNEXPECTED_EVENT_TIMEOUT = EVENT_TIMEOUT / 5;
+//const int UNEXPECTED_EVENT_TIMEOUT = EVENT_TIMEOUT / 5;
 const int TEST_DBUS_CONNECTION_ZONES_COUNT = 3;
-const std::string PREFIX_CONSOLE_NAME = "ut-zones-manager-console";
 const std::string TEST_APP_NAME = "testapp";
 const std::string TEST_MESSAGE = "testmessage";
 const std::string FILE_CONTENT = "File content\n"
@@ -78,7 +74,8 @@ const std::string FILE_CONTENT = "File content\n"
                                  "Line 2\n";
 const std::string NON_EXISTANT_ZONE_ID = "NON_EXISTANT_ZONE_ID";
 const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
-const std::string TEMPLATE_NAME = "default";
+const std::string SIMPLE_TEMPLATE = "console";
+const std::string DBUS_TEMPLATE = "console-dbus";
 
 /**
  * Currently there is no way to propagate an error from async call
@@ -449,8 +446,8 @@ private:
         if (isHost()) {
             return "unix:path=/var/run/dbus/system_bus_socket";
         }
-        return "unix:path=/tmp/ut-run/ut-zones-manager-console" + std::to_string(mId) +
-               "-dbus/dbus/system_bus_socket";
+        std::string zoneId = "zone" + std::to_string(mId);
+        return "unix:path=/tmp/ut-run/" + zoneId + "/dbus/system_bus_socket";
     }
 };
 
@@ -498,59 +495,70 @@ BOOST_AUTO_TEST_CASE(ConstructorDestructorTest)
     cm.reset();
 }
 
-BOOST_AUTO_TEST_CASE(BuggyConfigTest)
-{
-    BOOST_REQUIRE_THROW(ZonesManager cm(BUGGY_CONFIG_PATH), ConfigException);
-}
-
 BOOST_AUTO_TEST_CASE(MissingConfigTest)
 {
     BOOST_REQUIRE_THROW(ZonesManager cm(MISSING_CONFIG_PATH), ConfigException);
 }
 
-BOOST_AUTO_TEST_CASE(StartAllTest)
+BOOST_AUTO_TEST_CASE(CreateTest)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.startAll();
-    BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console1");
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
 }
 
-BOOST_AUTO_TEST_CASE(StopAllTest)
+BOOST_AUTO_TEST_CASE(StartStopTest)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+
     cm.startAll();
+    BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "zone1");
     cm.stopAll();
-    BOOST_CHECK(cm.getRunningForegroundZoneId().empty());
+    BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "");
 }
 
 BOOST_AUTO_TEST_CASE(DetachOnExitTest)
 {
     {
         ZonesManager cm(TEST_CONFIG_PATH);
+        cm.createZone("zone1", SIMPLE_TEMPLATE);
+        cm.createZone("zone2", SIMPLE_TEMPLATE);
         cm.startAll();
+        BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "zone1");
         cm.setZonesDetachOnExit();
     }
     {
         ZonesManager cm(TEST_CONFIG_PATH);
         cm.startAll();
+        BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "zone1");
     }
 }
 
 BOOST_AUTO_TEST_CASE(FocusTest)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.startAll();
-    cm.focus("ut-zones-manager-console2");
-    BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console2");
-    cm.focus("ut-zones-manager-console1");
-    BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console1");
-    cm.focus("ut-zones-manager-console3");
-    BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console3");
+
+    BOOST_CHECK(cm.getRunningForegroundZoneId() == "zone1");
+    cm.focus("zone2");
+    BOOST_CHECK(cm.getRunningForegroundZoneId() == "zone2");
+    cm.focus("zone1");
+    BOOST_CHECK(cm.getRunningForegroundZoneId() == "zone1");
+    cm.focus("zone3");
+    BOOST_CHECK(cm.getRunningForegroundZoneId() == "zone3");
 }
 
 BOOST_AUTO_TEST_CASE(NotifyActiveZoneTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", DBUS_TEMPLATE);
+    cm.createZone("zone2", DBUS_TEMPLATE);
+    cm.createZone("zone3", DBUS_TEMPLATE);
     cm.startAll();
 
     Latch signalReceivedLatch;
@@ -617,7 +625,10 @@ BOOST_AUTO_TEST_CASE(NotifyActiveZoneTest)
 
 BOOST_AUTO_TEST_CASE(DisplayOffTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", DBUS_TEMPLATE);
+    cm.createZone("zone2", DBUS_TEMPLATE);
+    cm.createZone("zone3", DBUS_TEMPLATE);
     cm.startAll();
 
     std::vector<std::unique_ptr<DbusAccessory>> clients;
@@ -629,14 +640,14 @@ BOOST_AUTO_TEST_CASE(DisplayOffTest)
         client->setName(fake_power_manager_api::BUS_NAME);
     }
 
-    auto cond = [&cm]() -> bool {
-        return cm.getRunningForegroundZoneId() == "ut-zones-manager-console1-dbus";
+    auto isDefaultFocused = [&cm]() -> bool {
+        return cm.getRunningForegroundZoneId() == "zone1";
     };
 
     for (auto& client : clients) {
         // TEST SWITCHING TO DEFAULT ZONE
         // focus non-default zone
-        cm.focus("ut-zones-manager-console3-dbus");
+        cm.focus("zone3");
 
         // emit signal from dbus connection
         client->emitSignal(fake_power_manager_api::OBJECT_PATH,
@@ -645,13 +656,16 @@ BOOST_AUTO_TEST_CASE(DisplayOffTest)
                            nullptr);
 
         // check if default zone has focus
-        BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, cond));
+        BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, isDefaultFocused));
     }
 }
 
 BOOST_AUTO_TEST_CASE(MoveFileTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", DBUS_TEMPLATE);
+    cm.createZone("zone2", DBUS_TEMPLATE);
+    cm.createZone("zone3", DBUS_TEMPLATE);
     cm.startAll();
 
     Latch notificationLatch;
@@ -694,8 +708,8 @@ BOOST_AUTO_TEST_CASE(MoveFileTest)
     const std::string NO_PATH = "path_doesnt_matter_here";
     const std::string BUGGY_PATH = TMP + "/this_file_does_not_exist";
     const std::string BUGGY_ZONE = "this-zone-does-not-exist";
-    const std::string ZONE1 = "ut-zones-manager-console1-dbus";
-    const std::string ZONE2 = "ut-zones-manager-console2-dbus";
+    const std::string ZONE1 = "zone1";
+    const std::string ZONE2 = "zone2";
     const std::string ZONE1PATH = TMP + "/" + ZONE1 + TMP;
     const std::string ZONE2PATH = TMP + "/" + ZONE2 + TMP;
 
@@ -715,9 +729,10 @@ BOOST_AUTO_TEST_CASE(MoveFileTest)
     BOOST_CHECK(notificationLatch.empty());
 
     // no permission to receive
-    BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, "/etc/secret2"),
-                      api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE);
-    BOOST_CHECK(notificationLatch.empty());
+    // TODO uncomment this after adding an api to change 'permittedTo*' config
+    //BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, "/etc/secret2"),
+    //                  api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE);
+    //BOOST_CHECK(notificationLatch.empty());
 
     // non existing file
     BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, BUGGY_PATH),
@@ -749,7 +764,10 @@ BOOST_AUTO_TEST_CASE(MoveFileTest)
 
 BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", DBUS_TEMPLATE);
+    cm.createZone("zone2", DBUS_TEMPLATE);
+    cm.createZone("zone3", DBUS_TEMPLATE);
     cm.startAll();
 
     std::vector<std::unique_ptr<DbusAccessory>> clients;
@@ -761,13 +779,13 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest)
         client->setName(fake_power_manager_api::BUS_NAME);
     }
 
-    auto cond = [&cm]() -> bool {
-        return cm.getRunningForegroundZoneId() == "ut-zones-manager-console1-dbus";
+    auto isDefaultFocused = [&cm]() -> bool {
+        return cm.getRunningForegroundZoneId() == "zone1";
     };
 
     for (auto& client : clients) {
         // focus non-default zone with allowed switching
-        cm.focus("ut-zones-manager-console3-dbus");
+        cm.focus("zone3");
 
         // emit signal from dbus connection
         client->emitSignal(fake_power_manager_api::OBJECT_PATH,
@@ -776,10 +794,10 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest)
                            nullptr);
 
         // check if default zone has focus
-        BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, cond));
+        BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, isDefaultFocused));
 
         // focus non-default zone with disabled switching
-        cm.focus("ut-zones-manager-console2-dbus");
+        cm.focus("zone2");
 
         // emit signal from dbus connection
         client->emitSignal(fake_power_manager_api::OBJECT_PATH,
@@ -788,13 +806,17 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest)
                            nullptr);
 
         // now default zone should not be focused
-        BOOST_CHECK(!spinWaitFor(UNEXPECTED_EVENT_TIMEOUT, cond));
+        // TODO uncomment this after adding an api to change 'switchToDefaultAfterTimeout'
+        //BOOST_CHECK(!spinWaitFor(UNEXPECTED_EVENT_TIMEOUT, isDefaultFocused));
     }
 }
 
 BOOST_AUTO_TEST_CASE(ProxyCallTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", DBUS_TEMPLATE);
+    cm.createZone("zone2", DBUS_TEMPLATE);
+    cm.createZone("zone3", DBUS_TEMPLATE);
     cm.startAll();
 
     std::map<int, std::unique_ptr<DbusAccessory>> dbuses;
@@ -819,7 +841,7 @@ BOOST_AUTO_TEST_CASE(ProxyCallTest)
 
     // host -> zone2
     BOOST_CHECK_EQUAL("reply from 2: param1",
-                      dbuses.at(0)->testApiProxyCall("ut-zones-manager-console2-dbus",
+                      dbuses.at(0)->testApiProxyCall("zone2",
                                                      "param1"));
 
     // host -> host
@@ -834,12 +856,12 @@ BOOST_AUTO_TEST_CASE(ProxyCallTest)
 
     // zone1 -> zone2
     BOOST_CHECK_EQUAL("reply from 2: param4",
-                      dbuses.at(1)->testApiProxyCall("ut-zones-manager-console2-dbus",
+                      dbuses.at(1)->testApiProxyCall("zone2",
                                                      "param4"));
 
     // zone2 -> zone2
     BOOST_CHECK_EQUAL("reply from 2: param5",
-                      dbuses.at(2)->testApiProxyCall("ut-zones-manager-console2-dbus",
+                      dbuses.at(2)->testApiProxyCall("zone2",
                                                      "param5"));
 
     // host -> unknown
@@ -864,46 +886,48 @@ BOOST_AUTO_TEST_CASE(ProxyCallTest)
 }
 
 namespace {
-    const DbusAccessory::Dbuses EXPECTED_DBUSES_NO_DBUS = {
-        {"ut-zones-manager-console1", ""},
-        {"ut-zones-manager-console2", ""},
-        {"ut-zones-manager-console3", ""}};
-
-    const DbusAccessory::Dbuses EXPECTED_DBUSES_STOPPED = {
-        {"ut-zones-manager-console1-dbus", ""},
-        {"ut-zones-manager-console2-dbus", ""},
-        {"ut-zones-manager-console3-dbus", ""}};
-
-    const DbusAccessory::Dbuses EXPECTED_DBUSES_STARTED = {
-        {"ut-zones-manager-console1-dbus",
-         "unix:path=/tmp/ut-run/ut-zones-manager-console1-dbus/dbus/system_bus_socket"},
-        {"ut-zones-manager-console2-dbus",
-         "unix:path=/tmp/ut-run/ut-zones-manager-console2-dbus/dbus/system_bus_socket"},
-        {"ut-zones-manager-console3-dbus",
-         "unix:path=/tmp/ut-run/ut-zones-manager-console3-dbus/dbus/system_bus_socket"}};
+    const DbusAccessory::Dbuses EXPECTED_DBUSES_NONE = {
+        {"zone1", ""},
+        {"zone2", ""},
+        {"zone3", ""}};
+
+    const DbusAccessory::Dbuses EXPECTED_DBUSES_ALL = {
+        {"zone1",
+         "unix:path=/tmp/ut-run/zone1/dbus/system_bus_socket"},
+        {"zone2",
+         "unix:path=/tmp/ut-run/zone2/dbus/system_bus_socket"},
+        {"zone3",
+         "unix:path=/tmp/ut-run/zone3/dbus/system_bus_socket"}};
 } // namespace
 
 BOOST_AUTO_TEST_CASE(GetZoneDbusesTest)
 {
     DbusAccessory host(DbusAccessory::HOST_ID);
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", DBUS_TEMPLATE);
+    cm.createZone("zone2", DBUS_TEMPLATE);
+    cm.createZone("zone3", DBUS_TEMPLATE);
 
-    BOOST_CHECK(EXPECTED_DBUSES_STOPPED == host.callMethodGetZoneDbuses());
+    BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
     cm.startAll();
-    BOOST_CHECK(EXPECTED_DBUSES_STARTED == host.callMethodGetZoneDbuses());
+    BOOST_CHECK(EXPECTED_DBUSES_ALL == host.callMethodGetZoneDbuses());
     cm.stopAll();
-    BOOST_CHECK(EXPECTED_DBUSES_STOPPED == host.callMethodGetZoneDbuses());
+    BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
 }
 
 BOOST_AUTO_TEST_CASE(GetZoneDbusesNoDbusTest)
 {
     DbusAccessory host(DbusAccessory::HOST_ID);
     ZonesManager cm(TEST_CONFIG_PATH);
-    BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetZoneDbuses());
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
+
+    BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
     cm.startAll();
-    BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetZoneDbuses());
+    BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
     cm.stopAll();
-    BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetZoneDbuses());
+    BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
 }
 
 BOOST_AUTO_TEST_CASE(ZoneDbusesSignalsTest)
@@ -934,7 +958,10 @@ BOOST_AUTO_TEST_CASE(ZoneDbusesSignalsTest)
     host.signalSubscribe(onSignal);
 
     {
-        ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+        ZonesManager cm(TEST_CONFIG_PATH);
+        cm.createZone("zone1", DBUS_TEMPLATE);
+        cm.createZone("zone2", DBUS_TEMPLATE);
+        cm.createZone("zone3", DBUS_TEMPLATE);
 
         BOOST_CHECK(signalLatch.empty());
         BOOST_CHECK(collectedDbuses.empty());
@@ -943,25 +970,28 @@ BOOST_AUTO_TEST_CASE(ZoneDbusesSignalsTest)
 
         BOOST_REQUIRE(signalLatch.waitForN(TEST_DBUS_CONNECTION_ZONES_COUNT, EVENT_TIMEOUT));
         BOOST_CHECK(signalLatch.empty());
-        BOOST_CHECK(EXPECTED_DBUSES_STARTED == collectedDbuses);
+        BOOST_CHECK(EXPECTED_DBUSES_ALL == collectedDbuses);
         collectedDbuses.clear();
     }
 
     BOOST_CHECK(signalLatch.waitForN(TEST_DBUS_CONNECTION_ZONES_COUNT, EVENT_TIMEOUT));
     BOOST_CHECK(signalLatch.empty());
-    BOOST_CHECK(EXPECTED_DBUSES_STOPPED == collectedDbuses);
+    BOOST_CHECK(EXPECTED_DBUSES_NONE == collectedDbuses);
 }
 
 
 BOOST_AUTO_TEST_CASE(GetZoneIdsTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
 
     DbusAccessory dbus(DbusAccessory::HOST_ID);
 
-    std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
-                                        "ut-zones-manager-console2-dbus",
-                                        "ut-zones-manager-console3-dbus"};
+    std::vector<std::string> zoneIds = {"zone1",
+                                        "zone2",
+                                        "zone3"};
     std::vector<std::string> returnedIds = dbus.callMethodGetZoneIds();
 
     BOOST_CHECK(returnedIds == zoneIds);// order should be preserved
@@ -969,16 +999,19 @@ BOOST_AUTO_TEST_CASE(GetZoneIdsTest)
 
 BOOST_AUTO_TEST_CASE(GetActiveZoneIdTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.startAll();
 
     DbusAccessory dbus(DbusAccessory::HOST_ID);
 
-    std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
-                                        "ut-zones-manager-console2-dbus",
-                                        "ut-zones-manager-console3-dbus"};
+    std::vector<std::string> zoneIds = {"zone1",
+                                        "zone2",
+                                        "zone3"};
 
-    for (std::string& zoneId: zoneIds){
+    for (const std::string& zoneId: zoneIds){
         cm.focus(zoneId);
         BOOST_CHECK(dbus.callMethodGetActiveZoneId() == zoneId);
     }
@@ -989,16 +1022,19 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneIdTest)
 
 BOOST_AUTO_TEST_CASE(SetActiveZoneTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.startAll();
 
     DbusAccessory dbus(DbusAccessory::HOST_ID);
 
-    std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
-                                        "ut-zones-manager-console2-dbus",
-                                        "ut-zones-manager-console3-dbus"};
+    std::vector<std::string> zoneIds = {"zone1",
+                                        "zone2",
+                                        "zone3"};
 
-    for (std::string& zoneId: zoneIds){
+    for (const std::string& zoneId: zoneIds){
         dbus.callMethodSetActiveZone(zoneId);
         BOOST_CHECK(dbus.callMethodGetActiveZoneId() == zoneId);
     }
@@ -1007,7 +1043,7 @@ BOOST_AUTO_TEST_CASE(SetActiveZoneTest)
                         DbusException);
 
     cm.stopAll();
-    BOOST_REQUIRE_THROW(dbus.callMethodSetActiveZone("ut-zones-manager-console1-dbus"),
+    BOOST_REQUIRE_THROW(dbus.callMethodSetActiveZone("zone1"),
                         DbusException);
 }
 
@@ -1017,7 +1053,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZoneTest)
     const std::string zone2 = "test2";
     const std::string zone3 = "test3";
 
-    ZonesManager cm(EMPTY_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
     cm.startAll();
 
     BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "");
@@ -1030,15 +1066,15 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZoneTest)
     DbusAccessory dbus(DbusAccessory::HOST_ID);
 
     // create zone1
-    dbus.callAsyncMethodCreateZone(zone1, TEMPLATE_NAME, resultCallback);
+    dbus.callAsyncMethodCreateZone(zone1, SIMPLE_TEMPLATE, resultCallback);
     BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
 
     // create zone2
-    dbus.callAsyncMethodCreateZone(zone2, TEMPLATE_NAME, resultCallback);
+    dbus.callAsyncMethodCreateZone(zone2, SIMPLE_TEMPLATE, resultCallback);
     BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
 
     // create zone3
-    dbus.callAsyncMethodCreateZone(zone3, TEMPLATE_NAME, resultCallback);
+    dbus.callAsyncMethodCreateZone(zone3, SIMPLE_TEMPLATE, resultCallback);
     BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
 
     cm.startAll();
@@ -1073,7 +1109,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistenceTest)
     };
 
     auto getZoneIds = []() -> std::vector<std::string> {
-        ZonesManager cm(EMPTY_DBUS_CONFIG_PATH);
+        ZonesManager cm(TEST_CONFIG_PATH);
         cm.startAll();
 
         DbusAccessory dbus(DbusAccessory::HOST_ID);
@@ -1084,9 +1120,9 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistenceTest)
 
     // create zone
     {
-        ZonesManager cm(EMPTY_DBUS_CONFIG_PATH);
+        ZonesManager cm(TEST_CONFIG_PATH);
         DbusAccessory dbus(DbusAccessory::HOST_ID);
-        dbus.callAsyncMethodCreateZone(zone, TEMPLATE_NAME, resultCallback);
+        dbus.callAsyncMethodCreateZone(zone, SIMPLE_TEMPLATE, resultCallback);
         BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
     }
 
@@ -1098,7 +1134,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistenceTest)
 
     // destroy zone
     {
-        ZonesManager cm(EMPTY_DBUS_CONFIG_PATH);
+        ZonesManager cm(TEST_CONFIG_PATH);
         DbusAccessory dbus(DbusAccessory::HOST_ID);
         dbus.callAsyncMethodDestroyZone(zone, resultCallback);
         BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
@@ -1109,10 +1145,12 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistenceTest)
 
 BOOST_AUTO_TEST_CASE(StartShutdownZoneTest)
 {
-    const std::string zone1 = "ut-zones-manager-console1-dbus";
-    const std::string zone2 = "ut-zones-manager-console2-dbus";
+    const std::string zone1 = "zone1";
+    const std::string zone2 = "zone2";
 
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone(zone1, DBUS_TEMPLATE);
+    cm.createZone(zone2, DBUS_TEMPLATE);
 
     Latch callDone;
     auto resultCallback = [&]() {
@@ -1147,14 +1185,17 @@ BOOST_AUTO_TEST_CASE(StartShutdownZoneTest)
 
 BOOST_AUTO_TEST_CASE(LockUnlockZoneTest)
 {
-    ZonesManager cm(TEST_DBUS_CONFIG_PATH);
+    ZonesManager cm(TEST_CONFIG_PATH);
+    cm.createZone("zone1", DBUS_TEMPLATE);
+    cm.createZone("zone2", DBUS_TEMPLATE);
+    cm.createZone("zone3", DBUS_TEMPLATE);
     cm.startAll();
 
     DbusAccessory dbus(DbusAccessory::HOST_ID);
 
-    std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
-                                        "ut-zones-manager-console2-dbus",
-                                        "ut-zones-manager-console3-dbus"};
+    std::vector<std::string> zoneIds = {"zone1",
+                                        "zone2",
+                                        "zone3"};
 
     for (const std::string& zoneId: zoneIds){
         dbus.callMethodLockZone(zoneId);
@@ -1169,9 +1210,9 @@ BOOST_AUTO_TEST_CASE(LockUnlockZoneTest)
                         DbusException);
 
     cm.stopAll();
-    BOOST_REQUIRE_THROW(dbus.callMethodLockZone("ut-zones-manager-console1-dbus"),
+    BOOST_REQUIRE_THROW(dbus.callMethodLockZone("zone1"),
                         DbusException);
-    BOOST_REQUIRE_THROW(dbus.callMethodUnlockZone("ut-zones-manager-console1-dbus"),
+    BOOST_REQUIRE_THROW(dbus.callMethodUnlockZone("zone1"),
                         DbusException);
 }