1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Fix core tests in master

This commit is contained in:
Carlos Martín 2012-01-26 17:26:57 +01:00
parent 01e0248929
commit 498f6aa2ba
3 changed files with 22 additions and 103 deletions

View File

@ -87,13 +87,15 @@ public:
class ImagePoolFriend : public ImagePool
{
public:
ImagePoolFriend(SqlDB * db,
const string& _default_type,
const string& _default_dev_prefix):
ImagePoolFriend(SqlDB * db,
const string& _default_type,
const string& _default_dev_prefix,
vector<const Attribute *> _restricted_attrs):
ImagePool( db,
_default_type,
_default_dev_prefix){};
_default_dev_prefix,
_restricted_attrs){};
int allocate(const int& uid, const std::string& stemplate, int* oid)
@ -251,7 +253,8 @@ public:
// Create a new pool, using the same DB. This new pool should read the
// allocated images.
imp = new ImagePool(db,"OS", "hd");
vector<const Attribute *> restricted_attrs;
imp = new ImagePool(db,"OS", "hd", restricted_attrs);
img = imp->get(0, false);
CPPUNIT_ASSERT( img != 0 );
@ -654,99 +657,6 @@ public:
delete disk;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*
void public_attribute()
{
int oid;
ImagePoolFriend * imp = static_cast<ImagePoolFriend *>(pool);
Image * img;
string templates[] =
{
// false
"NAME = \"name A\"\n"
"PATH = \"/tmp/nothing\"\n",
// true
"NAME = \"name B\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = YES",
// false
"NAME = \"name C\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = NO",
// false
"NAME = \"name D\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = 1",
// true
"NAME = \"name E\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = Yes",
// false
"NAME = \"name F\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = TRUE",
// true
"NAME = \"name G\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = yes",
// false
"NAME = \"name H\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = 'YES'",
// true
"NAME = \"name I\"\n"
"PATH = \"/tmp/nothing\"\n"
"PUBLIC = \"YES\"",
"END"
};
bool results[] = { false, true, false, false,
true, false, true, false, true };
int i = 0;
while( templates[i] != "END" )
{
imp->allocate(0, templates[i], &oid);
CPPUNIT_ASSERT( oid >= 0 );
img = imp->get( oid, false );
CPPUNIT_ASSERT( img != 0 );
//cout << endl << i << " : exp. " << results[i] << " got " << img->is_public();
CPPUNIT_ASSERT( img->isPublic() == results[i] );
i++;
}
int success;
// img 0 is not public.
img = imp->get( 0, false );
CPPUNIT_ASSERT( img != 0 );
success = img->publish(false);
CPPUNIT_ASSERT( success == 0 );
CPPUNIT_ASSERT( img->isPublic() == false );
success = img->publish(true);
CPPUNIT_ASSERT( success == 0 );
CPPUNIT_ASSERT( img->isPublic() == true );
}
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*

View File

@ -22,7 +22,9 @@ VirtualMachinePool* NebulaTest::create_vmpool(SqlDB* db, string hook_location,
string vloc)
{
vector<const Attribute *> hooks;
return new VirtualMachinePool(db, hooks, hook_location, vloc);
vector<const Attribute *> restricted_attrs;
return new VirtualMachinePool(db, hooks, hook_location, vloc, restricted_attrs);
}
HostPool* NebulaTest::create_hpool(SqlDB* db, string hook_location, string vloc)
@ -45,7 +47,9 @@ ImagePool* NebulaTest::create_ipool( SqlDB* db,
string default_image_type,
string default_device_prefix)
{
return new ImagePool(db,default_image_type,default_device_prefix);
vector<const Attribute *> restricted_attrs;
return new ImagePool(db, default_image_type, default_device_prefix, restricted_attrs);
}
VMTemplatePool* NebulaTest::create_tpool(SqlDB* db)

View File

@ -74,8 +74,11 @@ const string xml_history_dump =
class VirtualMachinePoolFriend : public VirtualMachinePool
{
public:
VirtualMachinePoolFriend(SqlDB * db, vector<const Attribute *> hook_mads):
VirtualMachinePool(db, hook_mads, "./", "./")
VirtualMachinePoolFriend(
SqlDB * db,
vector<const Attribute *> hook_mads,
vector<const Attribute *> restricted_attrs):
VirtualMachinePool(db, hook_mads, "./", "./", restricted_attrs)
{};
@ -138,7 +141,9 @@ protected:
{
// The VM pool needs a vector containing the vm hooks
vector<const Attribute *> vm_hooks;
return new VirtualMachinePoolFriend(db, vm_hooks);
vector<const Attribute *> restricted_attrs;
return new VirtualMachinePoolFriend(db, vm_hooks, restricted_attrs);
};
int allocate(int index)