mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-25 23:21:29 +03:00
Bug #1086: Core tests for cache bug
This commit is contained in:
parent
f05942f6e4
commit
7a5b42b184
@ -67,6 +67,8 @@ class GroupPoolTest : public PoolTest
|
|||||||
CPPUNIT_TEST (duplicates);
|
CPPUNIT_TEST (duplicates);
|
||||||
CPPUNIT_TEST (dump);
|
CPPUNIT_TEST (dump);
|
||||||
|
|
||||||
|
CPPUNIT_TEST (name_index);
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END ();
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -222,6 +224,69 @@ public:
|
|||||||
CPPUNIT_ASSERT( oss.str() == group_xml_dump );
|
CPPUNIT_ASSERT( oss.str() == group_xml_dump );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ********************************************************************* */
|
||||||
|
|
||||||
|
void name_index()
|
||||||
|
{
|
||||||
|
Group *group_oid, *group_name;
|
||||||
|
int oid_0;
|
||||||
|
int uid_0;
|
||||||
|
string name_0;
|
||||||
|
|
||||||
|
oid_0 = allocate(0);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(oid_0 != -1);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Get by oid
|
||||||
|
group_oid = gpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(group_oid != 0);
|
||||||
|
|
||||||
|
name_0 = group_oid->get_name();
|
||||||
|
uid_0 = group_oid->get_uid();
|
||||||
|
|
||||||
|
group_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
group_name = gpool->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(group_name != 0);
|
||||||
|
group_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(group_oid == group_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
gpool->clean();
|
||||||
|
|
||||||
|
// Get by oid
|
||||||
|
group_oid = gpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(group_oid != 0);
|
||||||
|
group_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
group_name = gpool->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(group_name != 0);
|
||||||
|
group_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(group_oid == group_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
gpool->clean();
|
||||||
|
|
||||||
|
// Get by name
|
||||||
|
group_name = gpool->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(group_name != 0);
|
||||||
|
group_name->unlock();
|
||||||
|
|
||||||
|
// Get by oid and check it is the same object
|
||||||
|
group_oid = gpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(group_oid != 0);
|
||||||
|
group_oid->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(group_oid == group_name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -139,6 +139,7 @@ class HostPoolTest : public PoolTest
|
|||||||
CPPUNIT_TEST (discover);
|
CPPUNIT_TEST (discover);
|
||||||
CPPUNIT_TEST (duplicates);
|
CPPUNIT_TEST (duplicates);
|
||||||
CPPUNIT_TEST (update_info);
|
CPPUNIT_TEST (update_info);
|
||||||
|
CPPUNIT_TEST (name_index);
|
||||||
|
|
||||||
// CPPUNIT_TEST (scale_test);
|
// CPPUNIT_TEST (scale_test);
|
||||||
|
|
||||||
@ -492,6 +493,70 @@ public:
|
|||||||
CPPUNIT_ASSERT( host != 0 );
|
CPPUNIT_ASSERT( host != 0 );
|
||||||
CPPUNIT_ASSERT( host->to_xml(str) == host0_updated );
|
CPPUNIT_ASSERT( host->to_xml(str) == host0_updated );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ********************************************************************* */
|
||||||
|
|
||||||
|
void name_index()
|
||||||
|
{
|
||||||
|
HostPool * hp = static_cast<HostPool *>(pool);
|
||||||
|
Host *host_oid, *host_name;
|
||||||
|
int oid_0;
|
||||||
|
int uid_0;
|
||||||
|
string name_0;
|
||||||
|
|
||||||
|
oid_0 = allocate(0);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(oid_0 != -1);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Get by oid
|
||||||
|
host_oid = hp->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(host_oid != 0);
|
||||||
|
|
||||||
|
name_0 = host_oid->get_name();
|
||||||
|
uid_0 = host_oid->get_uid();
|
||||||
|
|
||||||
|
host_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
host_name = hp->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(host_name != 0);
|
||||||
|
host_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(host_oid == host_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
hp->clean();
|
||||||
|
|
||||||
|
// Get by oid
|
||||||
|
host_oid = hp->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(host_oid != 0);
|
||||||
|
host_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
host_name = hp->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(host_name != 0);
|
||||||
|
host_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(host_oid == host_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
hp->clean();
|
||||||
|
|
||||||
|
// Get by name
|
||||||
|
host_name = hp->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(host_name != 0);
|
||||||
|
host_name->unlock();
|
||||||
|
|
||||||
|
// Get by oid and check it is the same object
|
||||||
|
host_oid = hp->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(host_oid != 0);
|
||||||
|
host_oid->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(host_oid == host_name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,6 +150,8 @@ class ImagePoolTest : public PoolTest
|
|||||||
CPPUNIT_TEST ( dump_where );
|
CPPUNIT_TEST ( dump_where );
|
||||||
CPPUNIT_TEST ( get_using_name );
|
CPPUNIT_TEST ( get_using_name );
|
||||||
CPPUNIT_TEST ( wrong_get_name );
|
CPPUNIT_TEST ( wrong_get_name );
|
||||||
|
CPPUNIT_TEST ( name_index );
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END ();
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -962,6 +964,68 @@ public:
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void name_index()
|
||||||
|
{
|
||||||
|
Image *img_oid, *img_name;
|
||||||
|
int oid_0;
|
||||||
|
int uid_0;
|
||||||
|
string name_0;
|
||||||
|
|
||||||
|
oid_0 = allocate(0);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(oid_0 != -1);
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Get by oid
|
||||||
|
img_oid = ipool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(img_oid != 0);
|
||||||
|
|
||||||
|
name_0 = img_oid->get_name();
|
||||||
|
uid_0 = img_oid->get_uid();
|
||||||
|
|
||||||
|
img_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
img_name = ipool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(img_name != 0);
|
||||||
|
img_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(img_oid == img_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
ipool->clean();
|
||||||
|
|
||||||
|
// Get by oid
|
||||||
|
img_oid = ipool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(img_oid != 0);
|
||||||
|
img_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
img_name = ipool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(img_name != 0);
|
||||||
|
img_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(img_oid == img_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
ipool->clean();
|
||||||
|
|
||||||
|
// Get by name
|
||||||
|
img_name = ipool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(img_name != 0);
|
||||||
|
img_name->unlock();
|
||||||
|
|
||||||
|
// Get by oid and check it is the same object
|
||||||
|
img_oid = ipool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(img_oid != 0);
|
||||||
|
img_oid->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(img_oid == img_name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -77,6 +77,7 @@ class UserPoolTest : public PoolTest
|
|||||||
CPPUNIT_TEST (duplicates);
|
CPPUNIT_TEST (duplicates);
|
||||||
//CPPUNIT_TEST (dump);
|
//CPPUNIT_TEST (dump);
|
||||||
CPPUNIT_TEST (dump_where);
|
CPPUNIT_TEST (dump_where);
|
||||||
|
CPPUNIT_TEST (name_index);
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END ();
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
@ -374,6 +375,67 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( oss.str() == dump_where_result );
|
CPPUNIT_ASSERT( oss.str() == dump_where_result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void name_index()
|
||||||
|
{
|
||||||
|
User *user_oid, *user_name;
|
||||||
|
int oid_0;
|
||||||
|
int uid_0;
|
||||||
|
string name_0;
|
||||||
|
|
||||||
|
oid_0 = allocate(0);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(oid_0 != -1);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Get by oid
|
||||||
|
user_oid = upool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(user_oid != 0);
|
||||||
|
|
||||||
|
name_0 = user_oid->get_name();
|
||||||
|
uid_0 = user_oid->get_uid();
|
||||||
|
|
||||||
|
user_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
user_name = upool->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(user_name != 0);
|
||||||
|
user_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(user_oid == user_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
upool->clean();
|
||||||
|
|
||||||
|
// Get by oid
|
||||||
|
user_oid = upool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(user_oid != 0);
|
||||||
|
user_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
user_name = upool->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(user_name != 0);
|
||||||
|
user_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(user_oid == user_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
upool->clean();
|
||||||
|
|
||||||
|
// Get by name
|
||||||
|
user_name = upool->get(name_0, true);
|
||||||
|
CPPUNIT_ASSERT(user_name != 0);
|
||||||
|
user_name->unlock();
|
||||||
|
|
||||||
|
// Get by oid and check it is the same object
|
||||||
|
user_oid = upool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(user_oid != 0);
|
||||||
|
user_oid->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(user_oid == user_name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -110,6 +110,7 @@ class VMTemplatePoolTest : public PoolTest
|
|||||||
CPPUNIT_TEST ( duplicates );
|
CPPUNIT_TEST ( duplicates );
|
||||||
CPPUNIT_TEST ( dump );
|
CPPUNIT_TEST ( dump );
|
||||||
CPPUNIT_TEST ( dump_where );
|
CPPUNIT_TEST ( dump_where );
|
||||||
|
CPPUNIT_TEST ( name_index );
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END ();
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
@ -447,6 +448,71 @@ public:
|
|||||||
CPPUNIT_ASSERT( result == xml_dump_where );
|
CPPUNIT_ASSERT( result == xml_dump_where );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void name_index()
|
||||||
|
{
|
||||||
|
VMTemplatePool *tpool = static_cast<VMTemplatePool*>(pool);
|
||||||
|
VMTemplate *vnet_oid, *vnet_name;
|
||||||
|
int oid_0;
|
||||||
|
int uid_0;
|
||||||
|
string name_0;
|
||||||
|
|
||||||
|
oid_0 = allocate(0);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(oid_0 != -1);
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Get by oid
|
||||||
|
vnet_oid = tpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_oid != 0);
|
||||||
|
|
||||||
|
name_0 = vnet_oid->get_name();
|
||||||
|
uid_0 = vnet_oid->get_uid();
|
||||||
|
|
||||||
|
vnet_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
vnet_name = tpool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_name != 0);
|
||||||
|
vnet_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(vnet_oid == vnet_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
tpool->clean();
|
||||||
|
|
||||||
|
// Get by oid
|
||||||
|
vnet_oid = tpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_oid != 0);
|
||||||
|
vnet_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
vnet_name = tpool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_name != 0);
|
||||||
|
vnet_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(vnet_oid == vnet_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
tpool->clean();
|
||||||
|
|
||||||
|
// Get by name
|
||||||
|
vnet_name = tpool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_name != 0);
|
||||||
|
vnet_name->unlock();
|
||||||
|
|
||||||
|
// Get by oid and check it is the same object
|
||||||
|
vnet_oid = tpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_oid != 0);
|
||||||
|
vnet_oid->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(vnet_oid == vnet_name);
|
||||||
|
}
|
||||||
/* ********************************************************************* */
|
/* ********************************************************************* */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -180,6 +180,8 @@ class VirtualNetworkPoolTest : public PoolTest
|
|||||||
|
|
||||||
CPPUNIT_TEST (range_definition);
|
CPPUNIT_TEST (range_definition);
|
||||||
|
|
||||||
|
CPPUNIT_TEST (name_index);
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END ();
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -1690,6 +1692,71 @@ public:
|
|||||||
vnpool->drop(vnet, err);
|
vnpool->drop(vnet, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void name_index()
|
||||||
|
{
|
||||||
|
VirtualNetwork *vnet_oid, *vnet_name;
|
||||||
|
int oid_0;
|
||||||
|
int uid_0;
|
||||||
|
string name_0;
|
||||||
|
|
||||||
|
oid_0 = allocate(0);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(oid_0 != -1);
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Get by oid
|
||||||
|
vnet_oid = vnpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_oid != 0);
|
||||||
|
|
||||||
|
name_0 = vnet_oid->get_name();
|
||||||
|
uid_0 = vnet_oid->get_uid();
|
||||||
|
|
||||||
|
vnet_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
vnet_name = vnpool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_name != 0);
|
||||||
|
vnet_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(vnet_oid == vnet_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
vnpool->clean();
|
||||||
|
|
||||||
|
// Get by oid
|
||||||
|
vnet_oid = vnpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_oid != 0);
|
||||||
|
vnet_oid->unlock();
|
||||||
|
|
||||||
|
// Get by name and check it is the same object
|
||||||
|
vnet_name = vnpool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_name != 0);
|
||||||
|
vnet_name->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(vnet_oid == vnet_name);
|
||||||
|
|
||||||
|
// ---------------------------------
|
||||||
|
// Clean the cache, forcing the pool to read the objects from the DB
|
||||||
|
vnpool->clean();
|
||||||
|
|
||||||
|
// Get by name
|
||||||
|
vnet_name = vnpool->get(name_0, uid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_name != 0);
|
||||||
|
vnet_name->unlock();
|
||||||
|
|
||||||
|
// Get by oid and check it is the same object
|
||||||
|
vnet_oid = vnpool->get(oid_0, true);
|
||||||
|
CPPUNIT_ASSERT(vnet_oid != 0);
|
||||||
|
vnet_oid->unlock();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(vnet_oid == vnet_name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
Loading…
Reference in New Issue
Block a user