{
"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",
{
- "name" : "~NAME~",
"lxcTemplate" : "tizen-common-wayland.sh",
"initWithArgs" : [],
"ipv4Gateway" : "10.0.~IP~.1",
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"privilege" : 10,
- "vt" : ~VT~,
+ "vt" : 0,
"switchToDefaultAfterTimeout" : true,
"enableDbusIntegration" : true,
"runMountPoint" : "~NAME~/run",
}
}
- // 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) {
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)
{
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());
}
/**
* 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();
/**
struct ZoneConfig {
/**
- * Zone name
- */
- std::string name;
-
- /**
* Lxc template name (relative to lxcTemplatePrefix)
*/
std::string lxcTemplate;
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.
*/
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.
*/
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
} // 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));
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()
int Zone::getVT() const
{
- return mConfig.vt;
+ return mDynamicConfig.vt;
}
std::string Zone::getRootPath() const
{
Lock lock(mReconnectMutex);
- if (mConfig.vt >= 0) {
- return utils::activateVT(mConfig.vt);
+ if (mDynamicConfig.vt >= 0) {
+ return utils::activateVT(mDynamicConfig.vt);
}
return true;
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);
std::string zoneTemplateDir;
/**
- * Prefix added to a path for new zone configuration files
- */
- std::string zoneNewConfigPrefix;
-
- /**
* Path prefix for lxc templates
*/
std::string lxcTemplatePrefix;
zonesPath,
zoneImagePath,
zoneTemplateDir,
- zoneNewConfigPrefix,
lxcTemplatePrefix,
availableVTs,
inputConfig,
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.
CONFIG_REGISTER
(
- zoneConfigs,
+ zoneIds,
defaultId
)
};
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)
{
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();
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));
}
// update dynamic config
- remove(mDynamicConfig.zoneConfigs, getConfigName(zoneId));
+ remove(mDynamicConfig.zoneIds, zoneId);
saveDynamicConfig();
updateDefaultId();
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()
}
}
- // 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");
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));
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();
}
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,
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)
{
- "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" : "",
{
"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" : [],
+++ /dev/null
-{
- "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" : "*"}]
-}
+++ /dev/null
-{
- "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" : []
-}
+++ /dev/null
-{
- "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" : []
-}
+++ /dev/null
-{
- "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" : []
-}
#include "utils/scoped-dir.hpp"
#include "zones-manager.hpp"
#include "zone-dbus-definitions.hpp"
+#include "logger/logger.hpp"
#include <map>
#include <string>
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()
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"
}
};
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());
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);
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);
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();
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)
## 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 #####################################################################
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)
+++ /dev/null
-{
- "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" : []
-}
{
- "name" : "ut-server-zone1",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
"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,
+++ /dev/null
-{
- "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" : []
-}
{
- "name" : "ut-zone-admin-test",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/foo"],
"ipv4Gateway" : "",
{
- "name" : "ut-zone-admin-test",
"lxcTemplate" : "missing.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-zone-admin-test",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh"],
"ipv4Gateway" : "",
{
- "name" : "ut-server-zone2",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
+++ /dev/null
-{
- "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" : []
-}
{
- "name" : "ut-zone-test",
"lxcTemplate" : "/buggy/path",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "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" : "",
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-zone-test-dbus",
+ "runMountPoint" : "/tmp/ut-run/zoneId",
"provisions" : [],
"permittedToSend" : [],
"permittedToRecv" : [],
{
- "name" : "ut-zone-test",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
+++ /dev/null
-{
- "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" : []
-}
{
- "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" : "",
"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/.*" ],
{
- "name" : "ut-zones-manager-console1",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
"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" : "*"}]
}
+++ /dev/null
-{
- "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" : "*"}]
-}
+++ /dev/null
-{
- "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" : []
-}
+++ /dev/null
-{
- "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" : []
-}
+++ /dev/null
-{
- "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" : []
-}
+++ /dev/null
-{
- "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" : []
-}
#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>
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;
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
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)
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;
utils::ScopedDir mZonesPathGuard;
ZoneConfig mConfig;
+ ZoneDynamicConfig mDynamicConfig;
Fixture()
: mZonesPathGuard(ZONES_PATH)
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()
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)
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)
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";
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,
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)
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"
"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
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";
}
};
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;
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;
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,
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;
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;
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),
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;
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,
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,
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;
// 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
// 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
}
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)
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());
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
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);
}
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);
}
DbusException);
cm.stopAll();
- BOOST_REQUIRE_THROW(dbus.callMethodSetActiveZone("ut-zones-manager-console1-dbus"),
+ BOOST_REQUIRE_THROW(dbus.callMethodSetActiveZone("zone1"),
DbusException);
}
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(), "");
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();
};
auto getZoneIds = []() -> std::vector<std::string> {
- ZonesManager cm(EMPTY_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
cm.startAll();
DbusAccessory dbus(DbusAccessory::HOST_ID);
// 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));
}
// 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));
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 = [&]() {
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);
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);
}