diff --git a/src/cluster/test/ClusterPoolTest.cc b/src/cluster/test/ClusterPoolTest.cc
index 22b1724feb..9dda30cae9 100644
--- a/src/cluster/test/ClusterPoolTest.cc
+++ b/src/cluster/test/ClusterPoolTest.cc
@@ -27,15 +27,15 @@ const string names[] = {"cluster_a", "Second cluster"};
const string xmls[] =
{
- "1cluster_a",
- "2Second cluster"
+ "1cluster_a",
+ "2Second cluster"
};
const string cluster_default =
- "0default";
+ "0default";
const string cluster_xml_dump =
- "0default1cluster_a3cluster_c4cluster_d";
+ "0default1cluster_a3cluster_c4cluster_d";
const string host_0_cluster =
"0Host one0im_madvmm_madtm_mad010000000000000";
@@ -83,8 +83,6 @@ class ClusterPoolTest : public PoolTest
CPPUNIT_TEST (name_pool);
CPPUNIT_TEST (duplicates);
- CPPUNIT_TEST (set_cluster);
- CPPUNIT_TEST (remove_cluster);
CPPUNIT_TEST (delete_cluster);
CPPUNIT_TEST (dump);
@@ -260,72 +258,12 @@ public:
/* ********************************************************************* */
- void set_cluster()
- {
- Host* host;
- int rc;
- string xml_str, err;
-
- init_hp();
-
- host = hpool->get(0, false);
- CPPUNIT_ASSERT(host != 0);
-
- rc = host->set_cluster(1);
- CPPUNIT_ASSERT( rc == 0 );
-
- hpool->update(host);
-
- host->to_xml(xml_str);
- CPPUNIT_ASSERT( xml_str == host_0_cluster);
- }
-
- /* ********************************************************************* */
-
- void remove_cluster()
- {
- Host* host;
-
- int rc;
- string xml_str;
-
- init_hp();
-
- host = hpool->get(0, false);
- CPPUNIT_ASSERT(host != 0);
-
- // Set cluster
- rc = host->set_cluster(1);
- CPPUNIT_ASSERT( rc == 0 );
-
- hpool->update(host);
-
- host->to_xml(xml_str);
- CPPUNIT_ASSERT( xml_str == host_0_cluster);
-
- // Remove from the cluster
- rc = cpool->set_default_cluster(host);
- CPPUNIT_ASSERT( rc == 0 );
-
- hpool->update(host);
-
- // The host should have been moved to the default cluster
-
- host = hpool->get(0, false);
- CPPUNIT_ASSERT(host != 0);
-
- host->to_xml(xml_str);
- CPPUNIT_ASSERT( xml_str == host_0_default);
- }
-
- /* ********************************************************************* */
-
void delete_cluster()
{
Host * host;
- Cluster * cluster;
+ Cluster * cluster, * cluster_old;
- int rc, oid;
+ int rc, oid, host_gid;
string xml_str;
init_hp();
@@ -338,11 +276,28 @@ public:
cluster = cpool->get(1, false);
+ // Get current host cluster
+ host_gid = host->get_gid();
+
// Set cluster
- rc = host->set_cluster(cluster->get_oid());
+ rc = host->set_gid(cluster->get_oid());
CPPUNIT_ASSERT( rc == 0 );
+ // Add host ID to cluster
+ rc = static_cast(cluster)->add_collection_id(host);
+ CPPUNIT_ASSERT( rc == 0 );
+
+ // Update the DB
hpool->update(host);
+ cpool->update(cluster);
+
+ // Now get the old cluster, and remove the Host Id from it
+ cluster_old = cpool->get(host_gid, false);
+ CPPUNIT_ASSERT(cluster_old != 0);
+
+ cluster_old->del_collection_id(host);
+ cpool->update(cluster_old);
+
host->to_xml(xml_str);
CPPUNIT_ASSERT( xml_str == host_0_cluster);
diff --git a/src/group/test/GroupPoolTest.cc b/src/group/test/GroupPoolTest.cc
index f76cc71abe..e237f00d0f 100644
--- a/src/group/test/GroupPoolTest.cc
+++ b/src/group/test/GroupPoolTest.cc
@@ -28,12 +28,13 @@ const string names[] = {"First name", "Second name"};
const string xmls[] =
{
- "1000First name",
- "1011Second name"
+ "1000First name",
+ "1011Second name"
};
const string group_xml_dump =
- "00oneadmin10users1005group_a1025group_c1035group_d";
+ "00oneadmin10users1005group_a1025group_c1035group_d";
+
/* ************************************************************************* */
/* ************************************************************************* */
diff --git a/src/host/test/NebulaTestHost.h b/src/host/test/NebulaTestHost.h
index 6d4be3f1f3..5d7c00c787 100644
--- a/src/host/test/NebulaTestHost.h
+++ b/src/host/test/NebulaTestHost.h
@@ -29,6 +29,7 @@ public:
need_vm_pool = true;
need_host_pool = true;
need_user_pool = true;
+ need_group_pool = true;
need_vnet_pool = true;
need_image_pool= true;
diff --git a/src/lcm/test/NebulaTestLCM.h b/src/lcm/test/NebulaTestLCM.h
index f7e06af4ea..0261c51618 100644
--- a/src/lcm/test/NebulaTestLCM.h
+++ b/src/lcm/test/NebulaTestLCM.h
@@ -29,6 +29,7 @@ public:
need_vm_pool = true;
need_host_pool = true;
need_user_pool = true;
+ need_group_pool = true;
need_vnet_pool = true;
need_image_pool= true;
diff --git a/src/test/Nebula.cc b/src/test/Nebula.cc
index 027cd6e575..7ad62286b4 100644
--- a/src/test/Nebula.cc
+++ b/src/test/Nebula.cc
@@ -209,6 +209,11 @@ void Nebula::start()
vnpool = tester->create_vnpool(db,mac_prefix,size);
}
+ if (tester->need_group_pool)
+ {
+ gpool = tester->create_gpool(db);
+ }
+
if (tester->need_user_pool)
{
upool = tester->create_upool(db);
@@ -230,11 +235,6 @@ void Nebula::start()
{
tpool = tester->create_tpool(db);
}
-
- if (tester->need_group_pool)
- {
- gpool = tester->create_gpool(db);
- }
}
catch (exception&)
{
diff --git a/src/um/test/SConstruct b/src/um/test/SConstruct
index b9a1ac4dfc..2873db636a 100644
--- a/src/um/test/SConstruct
+++ b/src/um/test/SConstruct
@@ -17,16 +17,40 @@
Import('env')
env.Prepend(LIBS=[
- 'nebula_um',
- 'nebula_group',
+ 'nebula_cluster',
+ 'nebula_host',
'nebula_pool',
+ 'nebula_template',
'nebula_xml',
'nebula_log',
+ 'nebula_common',
+ 'nebula_sql',
+
+### TODO: delete not needed
+ 'nebula_core_test',
+ 'nebula_host',
+ 'nebula_cluster',
+ 'nebula_xml',
+ 'nebula_vmm',
+ 'nebula_im',
+ 'nebula_rm',
+ 'nebula_tm',
+ 'nebula_um',
+ 'nebula_mad',
+ 'nebula_template',
+ 'nebula_vm',
+ 'nebula_vmtemplate',
+ 'nebula_group',
+ 'nebula_vnm',
+ 'nebula_image',
+ 'nebula_pool',
+ 'nebula_hm',
'nebula_authm',
'nebula_common',
- 'nebula_mad',
- 'nebula_core',
+ 'nebula_lcm',
+ 'nebula_dm',
'nebula_sql',
+ 'nebula_log',
'crypto'
])
diff --git a/src/um/test/UserPoolTest.cc b/src/um/test/UserPoolTest.cc
index ec0ad93c9c..95285b37c0 100644
--- a/src/um/test/UserPoolTest.cc
+++ b/src/um/test/UserPoolTest.cc
@@ -31,26 +31,24 @@ const string usernames[] = { "A user", "B user", "C user", "D user", "E user" };
const string passwords[] = { "A pass", "B pass", "C pass", "D pass", "E pass" };
const string dump_result =
- "00one_user_test"
- "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8"
- "110a"
- "p1"
- "20a namepass"
- "130a_name"
- "password1"
- "40another namesecret"
- "150user"
- "12341"
- "";
+ "00one_user_test5baa61e4c9b93f3f0682250b6cf8331b7ee68fd81010ap1020a namepass1030a_namepassword1040another namesecret1050user123410";
const string dump_where_result =
- "10a"
- "p1"
- "20a namepass"
- "130a_name"
- "password1"
- "40another namesecret"
- "1";
+ "10ap1020a namepass1030a_namepassword1040another namesecret10";
+
+#include "NebulaTest.h"
+
+class NebulaTestUser: public NebulaTest
+{
+public:
+ NebulaTestUser():NebulaTest()
+ {
+ NebulaTest::the_tester = this;
+
+ need_group_pool = true;
+ need_user_pool = true;
+ }
+};
class UserPoolTest : public PoolTest
{
@@ -78,14 +76,20 @@ class UserPoolTest : public PoolTest
protected:
+ NebulaTestUser * tester;
+ UserPool * upool;
+ GroupPool * gpool;
+
+
void bootstrap(SqlDB* db)
{
- UserPool::bootstrap(db);
+ // setUp overwritten
};
PoolSQL* create_pool(SqlDB* db)
{
- return new UserPool(db);
+ // setUp overwritten
+ return upool;
};
int allocate(int index)
@@ -112,6 +116,28 @@ public:
~UserPoolTest(){xmlCleanupParser();};
+ void setUp()
+ {
+ create_db();
+
+ tester = new NebulaTestUser();
+
+ Nebula& neb = Nebula::instance();
+ neb.start();
+
+ upool = neb.get_upool();
+ gpool = neb.get_gpool();
+
+ pool = upool;
+ };
+
+ void tearDown()
+ {
+ delete_db();
+
+ delete tester;
+ };
+
/* ********************************************************************* */
/* ********************************************************************* */
@@ -288,13 +314,13 @@ public:
ostringstream oss;
((UserPool*)pool)->dump(oss, "");
-
+/*
if( oss.str() != dump_result )
{
cout << endl << oss.str() << endl << "========"
<< endl << dump_result << endl << "--------";
}
-//
+//*/
CPPUNIT_ASSERT( oss.str() == dump_result );
}