From fc848e27275da04c9c889c58ecf16787335a2193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 10 Nov 2011 09:14:37 -0800 Subject: [PATCH] Feature #863: Fix tests --- src/host/test/HostHookTest.cc | 8 ++--- src/host/test/HostPoolTest.cc | 51 ++++++++++++++------------- src/lcm/test/LifeCycleManagerTest.cc | 23 ++++++------ src/vm/test/VirtualMachinePoolTest.cc | 12 ++++--- 4 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/host/test/HostHookTest.cc b/src/host/test/HostHookTest.cc index 406241597e..62361519ef 100644 --- a/src/host/test/HostHookTest.cc +++ b/src/host/test/HostHookTest.cc @@ -96,7 +96,7 @@ public: { string err; - hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err); + hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err); CPPUNIT_ASSERT( oid >= 0 ); sleep(1); @@ -114,7 +114,7 @@ public: { string err; - hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err); + hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err); CPPUNIT_ASSERT( oid >= 0 ); host = hpool->get(oid, true); @@ -140,7 +140,7 @@ public: { string err; - hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err); + hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err); CPPUNIT_ASSERT( oid >= 0 ); host = hpool->get(oid, true); @@ -166,7 +166,7 @@ public: { string err; - hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err); + hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err); CPPUNIT_ASSERT( oid >= 0 ); host = hpool->get(oid, true); diff --git a/src/host/test/HostPoolTest.cc b/src/host/test/HostPoolTest.cc index 2b63af6a50..1dab8f08d5 100644 --- a/src/host/test/HostPoolTest.cc +++ b/src/host/test/HostPoolTest.cc @@ -25,6 +25,7 @@ using namespace std; const string im_mad = "im_mad"; const string vmm_mad = "vmm_mad"; +const string vnm_mad = "vnm_mad"; const string tm_mad = "tm_mad"; const string names[] = {"Host one", "Second host"}; @@ -32,7 +33,7 @@ const string names[] = {"Host one", "Second host"}; const string xmls[] = { "0Host one0" - "im_madvmm_madtm_mad" + "im_madvmm_madvnm_madtm_mad" "0" "000" "000" @@ -41,7 +42,7 @@ const string xmls[] = "0", "1Second host0" - "im_madvmm_madtm_mad" + "im_madvmm_madvnm_madtm_mad" "0" "000" "000" @@ -53,34 +54,34 @@ const string xmls[] = // This xml dump result has the LAST_MON_TIMEs modified to 0000000000 const string xml_dump = "0a0im_madvmm_madtm_mad0" + "M_MAD>vmm_madvnm_madtm_mad0" "0000000000000" "1a name0im_madvmm_madtm_mad0vmm_madvnm_madtm_mad000000" "000000002a_name0im_madvmm_madtm_mad0vnm_madtm_mad000000000000003another " "name0im_madvmm_mad" - "tm_mad0vnm_madtm_mad000000000000004host0im_madvmm_madtm_mad" + "ATE>0im_madvmm_madvnm_madtm_mad" "0" "000" "0000" @@ -90,28 +91,28 @@ const string xml_dump = const string xml_dump_like_a = "0a0im_madvmm_madtm_mad0" + "M_MAD>vmm_madvnm_madtm_mad0" "0000000000000" "1a name0im_madvmm_madtm_mad0vmm_madvnm_madtm_mad000000" "000000002a_name0im_madvmm_madtm_mad0vnm_madtm_mad000000000000003another " "name0im_madvmm_mad" - "tm_mad0vnm_madtm_mad00000000000Host one0im_madvmm_madtm_mad00000000000000"; + "0Host one0im_madvmm_madvnm_madtm_mad00000000000000"; const string host_0_cluster = - "0Host one0im_madvmm_madtm_mad0cluster_a0000000000000"; + "0Host one0im_madvmm_madvnm_madtm_mad0cluster_a0000000000000"; /* ************************************************************************* */ /* ************************************************************************* */ @@ -162,7 +163,7 @@ protected: int oid; string err; return ((HostPool*)pool)->allocate(&oid, names[index], im_mad, - vmm_mad, tm_mad, err); + vmm_mad, vnm_mad, tm_mad, err); }; void check(int index, PoolObjectSQL* obj) @@ -184,7 +185,7 @@ protected: if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << "========" - << endl << xmls[index]; + << endl << xmls[index] << endl; } //*/ CPPUNIT_ASSERT( xml_str == xmls[index]); @@ -242,16 +243,16 @@ public: // If we try to allocate two hosts with the same name and drivers, // should fail - rc = hp->allocate(&oid_0, names[0], im_mad, vmm_mad, tm_mad, err); + rc = hp->allocate(&oid_0, names[0], im_mad, vmm_mad, vnm_mad, tm_mad, err); CPPUNIT_ASSERT( oid_0 == 0 ); CPPUNIT_ASSERT( rc == oid_0 ); - rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, tm_mad, err); + rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, vnm_mad, tm_mad, err); CPPUNIT_ASSERT( oid_1 == -1 ); CPPUNIT_ASSERT( rc == oid_1 ); // the hostname can not be repeated if the drivers change - rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, tm_mad_2, err); + rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, vnm_mad, tm_mad_2, err); CPPUNIT_ASSERT( oid_1 == -1 ); CPPUNIT_ASSERT( rc == oid_1 ); @@ -272,7 +273,7 @@ public: for(int i=0; i<5; i++) { ((HostPool*)pool)->allocate(&oid, names[i], - im_mad, vmm_mad, tm_mad, err); + im_mad, vmm_mad, vnm_mad, tm_mad, err); } ostringstream oss; @@ -287,7 +288,7 @@ public: if( result != xml_dump ) { cout << endl << result << endl << "========" - << endl << xml_dump; + << endl << xml_dump << endl; } //*/ @@ -305,7 +306,7 @@ public: for(int i=0; i<5; i++) { ((HostPool*)pool)->allocate(&oid, names[i], - im_mad, vmm_mad, tm_mad, err); + im_mad, vmm_mad, vnm_mad, tm_mad, err); } @@ -321,7 +322,7 @@ public: if( result != xml_dump_like_a ) { cout << endl << result << endl << "========" - << endl << xml_dump_like_a; + << endl << xml_dump_like_a << endl; } //*/ @@ -346,7 +347,7 @@ public: { oss << "host" << i; - hp->allocate(&oid, oss.str().c_str(), im_mad, vmm_mad, tm_mad, err); + hp->allocate(&oid, oss.str().c_str(), im_mad, vmm_mad, vnm_mad, tm_mad, err); CPPUNIT_ASSERT(oid == i); if (i >=8 ) @@ -404,7 +405,7 @@ public: { oss << "host" << j; - hp->allocate(&oid, oss.str().c_str(),im_mad,vmm_mad,tm_mad,err); + hp->allocate(&oid, oss.str().c_str(),im_mad,vmm_mad,vnm_mad,tm_mad,err); } the_time2 = time(0) - the_time; @@ -433,7 +434,7 @@ public: for (i=10000,oss.str(""); i<30000 ; i++,oss.str("")) { oss << "host" << i; - hp->allocate(&oid,oss.str().c_str(),im_mad,vmm_mad,tm_mad,err); + hp->allocate(&oid,oss.str().c_str(),im_mad,vmm_mad,vnm_mad,tm_mad,err); host = hp->get(oid, false); diff --git a/src/lcm/test/LifeCycleManagerTest.cc b/src/lcm/test/LifeCycleManagerTest.cc index c2d4386d2e..2f333133d5 100644 --- a/src/lcm/test/LifeCycleManagerTest.cc +++ b/src/lcm/test/LifeCycleManagerTest.cc @@ -47,6 +47,7 @@ const string templates[] = static int hid = 123; static string hostname = "test_hostname"; static string vmm_mad = "vmm_mad"; +static string vnm_mad = "vnm_mad"; static string tm_mad = "tm_mad"; static string vmdir = "vmdir"; @@ -225,7 +226,7 @@ private: vm->lock(); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -489,7 +490,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -573,7 +574,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -594,7 +595,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -615,7 +616,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -637,7 +638,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -661,7 +662,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -685,7 +686,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -749,7 +750,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -772,7 +773,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -795,7 +796,7 @@ public: { vm = allocate_running(0); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index 5bcd6c1e7d..10f87c22ff 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -302,6 +302,7 @@ public: string hostnames[] = {"A_hostname", "B_hostname", "C_hostname"}; string vm_dirs[] = {"A_vm_dir", "B_vm_dir", "C_vm_dir"}; string vmm_mads[] = {"A_vmm_mad", "B_vmm_mad", "C_vmm_mad"}; + string vnm_mads[] = {"A_vnm_mad", "B_vnm_mad", "C_vnm_mad"}; string tm_mads[] = {"A_tm_mad", "B_tm_mad", "C_tm_mad"}; int oid, rc; @@ -324,7 +325,7 @@ public: CPPUNIT_ASSERT( vm != 0 ); // Add a history item - vm->add_history(0, hostnames[0], vm_dirs[0], vmm_mads[0], tm_mads[0]); + vm->add_history(0, hostnames[0], vm_dirs[0], vmm_mads[0], vnm_mads[0], tm_mads[0]); rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -342,7 +343,7 @@ public: CPPUNIT_ASSERT( vm != 0 ); // Add a history item - vm->add_history(1, hostnames[1], vm_dirs[1], vmm_mads[1], tm_mads[1]); + vm->add_history(1, hostnames[1], vm_dirs[1], vmm_mads[1], vnm_mads[1], tm_mads[1]); rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -351,7 +352,7 @@ public: CPPUNIT_ASSERT( rc == 0 ); // Add another history item - vm->add_history(2, hostnames[2], vm_dirs[2], vmm_mads[2], tm_mads[2]); + vm->add_history(2, hostnames[2], vm_dirs[2], vmm_mads[2], vnm_mads[2], tm_mads[2]); rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -408,6 +409,7 @@ public: string new_hostname = "new_hostname"; string vm_dir = "vm_dir"; string vmm_mad = "vm_mad"; + string vnm_mad = "vn_mad"; string tm_mad = "tm_mad"; // Allocate a VM @@ -418,7 +420,7 @@ public: CPPUNIT_ASSERT( vm != 0 ); // Add a history item - vm->add_history(0, hostname, vm_dir, vmm_mad, tm_mad); + vm->add_history(0, hostname, vm_dir, vmm_mad, vnm_mad, tm_mad); rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 ); @@ -426,7 +428,7 @@ public: rc = vmp->update_history(vm); CPPUNIT_ASSERT( rc == 0 ); - vm->add_history(0, new_hostname, vm_dir, vmm_mad, tm_mad); + vm->add_history(0, new_hostname, vm_dir, vmm_mad, vnm_mad, tm_mad); rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 );