From cfb7ed569151604705bc2e49e77e613409cd9798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 19 Jan 2012 09:41:36 -0800 Subject: [PATCH] Update core tests for 3.2 --- src/authm/test/AuthManagerTest.cc | 21 ++-- src/host/test/HostPoolTest.cc | 8 +- src/image/test/ImagePoolTest.cc | 17 ++- src/um/test/UserPoolTest.cc | 2 +- src/vm/test/VirtualMachinePoolTest.cc | 30 ++--- src/vm_template/test/VMTemplatePoolTest.cc | 99 ++------------- src/vnm/test/VirtualNetworkPoolTest.cc | 138 +++++---------------- 7 files changed, 71 insertions(+), 244 deletions(-) diff --git a/src/authm/test/AuthManagerTest.cc b/src/authm/test/AuthManagerTest.cc index d0a82b8f86..38635216ff 100644 --- a/src/authm/test/AuthManagerTest.cc +++ b/src/authm/test/AuthManagerTest.cc @@ -180,10 +180,11 @@ public: //OBJECT:OBJECT_ID:ACTION:OWNER:PUBLIC:CORE_RESULT - string astr = "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:-1:0:0 " - "IMAGE:2:USE:3:0:0 " - "NET:4:MANAGE:5:1:0 " - "HOST:6:MANAGE:7:1:0 0"; + string astr = "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:2:0 " + "IMAGE:2:USE:3:0 " + "NET:4:MANAGE:5:0 " + "HOST:6:MANAGE:7:0 " + "0"; PoolObjectAuth perm; @@ -230,7 +231,7 @@ public: AuthRequest ar1(2, 2); - string astr1= "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:-1:0:0 0"; + string astr1= "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:2:0 0"; ar1.add_create_auth(PoolObjectSQL::VM, "This is a template\n"); @@ -259,15 +260,15 @@ public: am->trigger(AuthManager::AUTHORIZE,&ar2); ar2.wait(); //* - if ( ar1.result != false ) + if ( ar2.result != false ) { - cout << endl << "ar.result: " << ar1.result << endl; + cout << endl << "ar2.result: " << ar2.result << endl; } - if ( ar1.message != astr1 ) + if ( ar2.message != astr2 ) { - cout << endl << "ar.message: " << ar1.message; - cout << endl << "expected: " << astr1 << endl; + cout << endl << "ar2.message: " << ar2.message; + cout << endl << "expected: " << astr2 << endl; } //*/ CPPUNIT_ASSERT(ar2.result==false); diff --git a/src/host/test/HostPoolTest.cc b/src/host/test/HostPoolTest.cc index 1e87ecbde0..044d154d63 100644 --- a/src/host/test/HostPoolTest.cc +++ b/src/host/test/HostPoolTest.cc @@ -181,7 +181,7 @@ protected: host->to_xml(xml_str); // A little help for debugging -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << "========" @@ -284,7 +284,7 @@ public: string result = oss.str(); // A little help for debugging -/* +//* if( result != xml_dump ) { cout << endl << result << endl << "========" @@ -311,14 +311,14 @@ public: ostringstream oss; - rc = ((HostPool*)pool)->dump(oss, "name LIKE 'a%' ORDER BY oid"); + rc = ((HostPool*)pool)->dump(oss, "name LIKE 'a%'"); CPPUNIT_ASSERT(rc == 0); string result = oss.str(); // A little help for debugging -/* +//* if( result != xml_dump_like_a ) { cout << endl << result << endl << "========" diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index c127433492..feb835aea9 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -40,7 +40,6 @@ const string templates[] = "NAME = \"Second Image\"\n" "PATH = /tmp/image_second_test\n" - "PUBLIC = YES\n" "DESCRIPTION = \"This is a rather short description.\"\n", "NAME = \"The third image\"\n" @@ -52,20 +51,20 @@ const string templates[] = const string xmls[] = { -"001oneoneadminImage one0010000000000/tmp/image_test040", +"001oneoneadminImage one110000000010000000000/tmp/image_test040", -"111twooneadminSecond Image0100000000000/tmp/image_second_test040", +"111twooneadminSecond Image110000000000000000000/tmp/image_second_test040", -"021threeusersThe third image0000000000000/tmp/image_test040", +"021threeusersThe third image110000000000000000000/tmp/image_test040", }; // This xml dump result has the STIMEs modified to 0000000000 const string xml_dump = -"001oneoneadminImage one0010000000000/tmp/image_test040111twooneadminSecond Image0100000000000/tmp/image_second_test040221threeusersThe third image0000000000000/tmp/image_test040"; +"001oneoneadminImage one110000000010000000000/tmp/image_test040111twooneadminSecond Image110000000000000000000/tmp/image_second_test040221threeusersThe third image110000000000000000000/tmp/image_test040"; const string xml_dump_where = -"001oneoneadminImage one0010000000000/tmp/image_test040111twooneadminSecond Image0100000000000/tmp/image_second_test040"; +"001oneoneadminImage one110000000010000000000/tmp/image_test040111twooneadminSecond Image110000000000000000000/tmp/image_second_test040"; /* ************************************************************************* */ /* ************************************************************************* */ @@ -190,7 +189,7 @@ protected: ((Image*)obj)->to_xml(xml_str); fix_regtimes(xml_str); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << xmls[index] << endl; @@ -860,7 +859,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump ) { cout << endl << result << endl << xml_dump << endl; @@ -893,7 +892,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump_where ) { cout << endl << result << endl << xml_dump_where << endl; diff --git a/src/um/test/UserPoolTest.cc b/src/um/test/UserPoolTest.cc index 8e37a4d080..9ae1b6f78b 100644 --- a/src/um/test/UserPoolTest.cc +++ b/src/um/test/UserPoolTest.cc @@ -362,7 +362,7 @@ public: // by" is a dirty fix (SQL injection, actually) because MySQL orders the // results by user_name ostringstream oss; - ((UserPool*)pool)->dump(oss, "name LIKE 'a%' ORDER BY oid"); + ((UserPool*)pool)->dump(oss, "name LIKE 'a%'"); //* if( oss.str() != dump_where_result ) diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index 75e93edd45..ae6ecd8b1d 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -46,19 +46,9 @@ const string templates[] = const string xmls[] = { - "01231the_userusersVM one010000000000000000", + "01231the_userusersVM one110000000010000000000000000", - "12611the_userusersSecond VM0" - "1000000000000<" - "/ETIME>0000", + "12611the_userusersSecond VM110000000010000000000000000", "01231the_userusersVM one01000000000000011the_userusersVM one010000000000000000121the_userusersSecond VM020000000000000000"; + "011the_userusersVM one110000000010000000000000000121the_userusersSecond VM110000000020000000000000000"; const string xml_dump_where = - "011the_userusersVM one010000000000000000"; + "011the_userusersVM one110000000010000000000000000"; const string xml_history_dump = - "001the_userusersVM one010000000000000000101the_userusersSecond VM0200000000000000000A_hostnameA_vm_dir000A_vmm_madA_vnm_madA_tm_mad0000000201the_userusersVM one0200000000000000001C_hostnameC_vm_dir200C_vmm_madC_vnm_madC_tm_mad0000000311the_userusersVM one060000000000000000"; + "001the_userusersVM one110000000010000000000000000101the_userusersSecond VM1100000000200000000000000000A_hostnameA_vm_dir000A_vmm_madA_vnm_madA_tm_mad0000000201the_userusersVM one1100000000200000000000000001C_hostnameC_vm_dir200C_vmm_madC_vnm_madC_tm_mad0000000311the_userusersVM one110000000060000000000000000"; /* ************************************************************************* */ /* ************************************************************************* */ @@ -169,7 +159,7 @@ protected: ((VirtualMachine*)obj)->to_xml(xml_str); fix_stimes(xml_str); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << "========" @@ -260,13 +250,11 @@ public: string result = oss.str(); fix_stimes(result); -/* if( result != xml_dump ) { cout << endl << result << endl << "========" << endl << xml_dump << endl << "--------"; } -*/ CPPUNIT_ASSERT( result == xml_dump ); } @@ -290,6 +278,12 @@ public: string result = oss.str(); fix_stimes(result); + if( result != xml_dump_where ) + { + cout << endl << result << endl << "========" + << endl << xml_dump_where << endl << "--------"; + } + CPPUNIT_ASSERT( result == xml_dump_where ); } diff --git a/src/vm_template/test/VMTemplatePoolTest.cc b/src/vm_template/test/VMTemplatePoolTest.cc index 142d6f7a8f..5e5c074b9d 100644 --- a/src/vm_template/test/VMTemplatePoolTest.cc +++ b/src/vm_template/test/VMTemplatePoolTest.cc @@ -45,9 +45,9 @@ const string templates[] = const string xmls[] = { - "000the_useroneadminTemplate one00000000000", + "000the_useroneadminTemplate one1100000000000000000", - "110the_useroneadminSecond Template00000000000", + "110the_useroneadminSecond Template1100000000000000000", "220the_useroneadminThird Template00000000000" }; @@ -55,9 +55,9 @@ const string xmls[] = // This xml dump result has the STIMEs modified to 0000000000 const string xml_dump = - "000the_useroneadminTemplate one00000000000110the_useroneadminSecond Template00000000000220the_useroneadminThird Template00000000000"; + "000the_useroneadminTemplate one1100000000000000000110the_useroneadminSecond Template1100000000000000000220the_useroneadminThird Template1100000000000000000"; const string xml_dump_where = - "000the_useroneadminTemplate one00000000000110the_useroneadminSecond Template00000000000"; + "000the_useroneadminTemplate one1100000000000000000110the_useroneadminSecond Template1100000000000000000"; class VMTemplatePoolFriend : public VMTemplatePool { @@ -108,7 +108,6 @@ class VMTemplatePoolTest : public PoolTest CPPUNIT_TEST ( get_using_name ); CPPUNIT_TEST ( wrong_get_name ); CPPUNIT_TEST ( duplicates ); -// CPPUNIT_TEST ( public_attribute ); CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); @@ -146,7 +145,7 @@ protected: ((VMTemplate*)obj)->to_xml(xml_str); fix_regtimes( xml_str ); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << xmls[index] << endl; @@ -384,90 +383,6 @@ public: CPPUNIT_ASSERT( oid == rc ); } -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* - void public_attribute() - { - int oid; - VMTemplatePoolFriend * tpool = static_cast(pool); - VMTemplate * temp; - - string templates[] = - { - // false - "NAME = \"name A\"\n", - - // true - "NAME = \"name B\"\n" - "PUBLIC = YES", - - // false - "NAME = \"name C\"\n" - "PUBLIC = NO", - - // false - "NAME = \"name D\"\n" - "PUBLIC = 1", - - // true - "NAME = \"name E\"\n" - "PUBLIC = Yes", - - // false - "NAME = \"name F\"\n" - "PUBLIC = TRUE", - - // true - "NAME = \"name G\"\n" - "PUBLIC = yes", - - // false - "NAME = \"name H\"\n" - "PUBLIC = 'YES'", - - // true - "NAME = \"name I\"\n" - "PUBLIC = \"YES\"", - - "END" - }; - - bool results[] = { false, true, false, false, - true, false, true, false, true }; - - int i = 0; - while( templates[i] != "END" ) - { - - tpool->allocate(0, templates[i], &oid); - - CPPUNIT_ASSERT( oid >= 0 ); - - temp = tpool->get( oid, false ); - CPPUNIT_ASSERT( temp != 0 ); -//cout << endl << i << " : exp. " << results[i] << " got " << temp->is_public(); - - CPPUNIT_ASSERT( temp->isPublic() == results[i] ); - - i++; - } - - int success; - - // temp 0 is not public. - temp = tpool->get( 0, false ); - CPPUNIT_ASSERT( temp != 0 ); - - success = temp->publish(false); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( temp->isPublic() == false ); - - success = temp->publish(true); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( temp->isPublic() == true ); - } -*/ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -489,7 +404,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump ) { cout << endl << result << endl << xml_dump << endl; @@ -522,7 +437,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump_where ) { cout << endl << result << endl << xml_dump_where << endl; diff --git a/src/vnm/test/VirtualNetworkPoolTest.cc b/src/vnm/test/VirtualNetworkPoolTest.cc index d63cf50dcd..a88378a321 100644 --- a/src/vnm/test/VirtualNetworkPoolTest.cc +++ b/src/vnm/test/VirtualNetworkPoolTest.cc @@ -43,8 +43,7 @@ const string templates[] = "TYPE = RANGED\n" "BRIDGE = br0\n" "NETWORK_SIZE = C\n" - "NETWORK_ADDRESS = 192.168.0.0\n" - "PUBLIC = YES", + "NETWORK_ADDRESS = 192.168.0.0", "NAME = \"Net number two\"\n" "TYPE = fixed\n" @@ -71,18 +70,18 @@ const string templates[] = const string xmls[] = { - "01230the_useroneadminNet number one1br1000130.10.0.150:20:20:20:20:200-1", + "01230the_useroneadminNet number one1100000001br100130.10.0.150:20:20:20:20:200-1", - "12610the_useroneadminA virtual network0br00192.168.0.1192.168.0.25410", + "12610the_useroneadminA virtual network1100000000br00192.168.0.1192.168.0.2540", - "01330the_useroneadminNet number two1br1000130.10.2.150:20:20:20:20:200-1", + "01330the_useroneadminNet number two1100000001br100130.10.2.150:20:20:20:20:200-1", }; const string xml_dump = - "010the_useroneadminNet number one1br1000120the_useroneadminA virtual network0br00192.168.0.1192.168.0.25410"; + "010the_useroneadminNet number one1100000001br100120the_useroneadminA virtual network1100000000br00192.168.0.1192.168.0.2540"; const string xml_dump_where = - "120the_useroneadminA virtual network0br00192.168.0.1192.168.0.25410"; + "120the_useroneadminA virtual network1100000000br00192.168.0.1192.168.0.2540"; /* ************************************************************************* */ /* ************************************************************************* */ @@ -165,7 +164,6 @@ class VirtualNetworkPoolTest : public PoolTest CPPUNIT_TEST (overlapping_leases_rf); CPPUNIT_TEST (overlapping_leases_rr); CPPUNIT_TEST (drop_leases); -// CPPUNIT_TEST (public_attribute); CPPUNIT_TEST (vnpool_nic_attribute); CPPUNIT_TEST (add_lease_fixed); @@ -213,7 +211,7 @@ protected: ((VirtualNetwork*)obj)->to_xml_extended(xml_str); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << "========" @@ -312,8 +310,8 @@ public: }; string phydev_xml[] = { - "000the_useroneadminBRIDGE and PHYDEV1br00eth000130.10.0.150:20:20:20:20:200-1", - "100the_useroneadminNo BRIDGE only PHYDEV1onebr10eth000130.10.0.150:20:20:20:20:200-1" + "000the_useroneadminBRIDGE and PHYDEV1100000001br01eth00130.10.0.150:20:20:20:20:200-1", + "100the_useroneadminNo BRIDGE only PHYDEV1100000001onebr11eth00130.10.0.150:20:20:20:20:200-1" }; // test vm with bridge and phydev @@ -325,6 +323,14 @@ public: ((VirtualNetwork*)vn)->to_xml_extended(xml_str); +//* + if( xml_str != phydev_xml[0] ) + { + cout << endl << xml_str << endl << "========" + << endl << phydev_xml[0] << endl << "--------"; + } +//*/ + CPPUNIT_ASSERT( xml_str == phydev_xml[0] ); // test vm with phydev only @@ -337,6 +343,15 @@ public: CPPUNIT_ASSERT( vn != 0 ); ((VirtualNetwork*)vn)->to_xml_extended(xml_str); + +//* + if( xml_str != phydev_xml[1] ) + { + cout << endl << xml_str << endl << "========" + << endl << phydev_xml[1] << endl << "--------"; + } +//*/ + CPPUNIT_ASSERT( xml_str == phydev_xml[1] ); } @@ -522,7 +537,7 @@ public: string result = oss.str(); -/* +//* if( result != xml_dump ) { cout << endl << result << endl << "========" @@ -553,7 +568,7 @@ public: string result = oss.str(); -/* +//* if( result != xml_dump_where ) { cout << endl << result << endl << "========" @@ -1039,103 +1054,6 @@ public: CPPUNIT_ASSERT(results.size() == 0); } -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* - void public_attribute() - { - int oid; - VirtualNetworkPoolFriend * vnp = - static_cast(pool); - VirtualNetwork * vn; - - string templates[] = - { - // false - "NAME = \"name A\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n", - - // true - "NAME = \"name B\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = YES", - - // false - "NAME = \"name C\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = NO", - - // false - "NAME = \"name D\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = 1", - - // true - "NAME = \"name E\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = Yes", - - // false - "NAME = \"name F\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = TRUE", - - // true - "NAME = \"name G\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = yes", - - // false - "NAME = \"name H\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = 'YES'", - - // true - "NAME = \"name I\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = \"YES\"", - - "END" - }; - - bool results[] = { false, true, false, false, - true, false, true, false, true }; - - int i = 0; - while( templates[i] != "END" ) - { - - vnp->allocate(0, templates[i], &oid); - - CPPUNIT_ASSERT( oid >= 0 ); - - vn = vnp->get( oid, false ); - CPPUNIT_ASSERT( vn != 0 ); - -//cout << endl << i << ":expected " << results[i] << " got " << vn->is_public(); - CPPUNIT_ASSERT( vn->isPublic() == results[i] ); - i++; - } - } -*/ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */