From fa69b9aa1a4f24068d1530140c324097a84a7785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 20 Jan 2011 13:00:15 +0100 Subject: [PATCH] Features #455 & #379: Unit testing for new resubmit action --- src/host/test/HostHookTest.cc | 2 - src/host/test/HostHookTest.h | 3 +- src/lcm/test/LifeCycleManagerTest.cc | 2 - src/lcm/test/LifeCycleManagerTest.h | 149 ++++++++++++++++++++++++--- 4 files changed, 138 insertions(+), 18 deletions(-) diff --git a/src/host/test/HostHookTest.cc b/src/host/test/HostHookTest.cc index 32be98f998..5e4e1ef5a8 100644 --- a/src/host/test/HostHookTest.cc +++ b/src/host/test/HostHookTest.cc @@ -16,8 +16,6 @@ #include "HostHookTest.h" -string HostHookTest::db_name; - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/host/test/HostHookTest.h b/src/host/test/HostHookTest.h index a4c4ea494b..67cdb754ba 100644 --- a/src/host/test/HostHookTest.h +++ b/src/host/test/HostHookTest.h @@ -37,6 +37,7 @@ using namespace std; +static string db_name = "ONE_test_database"; class HostHookTest : public CppUnit::TestFixture { @@ -60,8 +61,6 @@ private: int rc; public: - static string db_name; - void setUp() { diff --git a/src/lcm/test/LifeCycleManagerTest.cc b/src/lcm/test/LifeCycleManagerTest.cc index 953c68421e..fd97754ed1 100644 --- a/src/lcm/test/LifeCycleManagerTest.cc +++ b/src/lcm/test/LifeCycleManagerTest.cc @@ -16,8 +16,6 @@ #include "LifeCycleManagerTest.h" -string LifeCycleManagerTest::db_name; - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/lcm/test/LifeCycleManagerTest.h b/src/lcm/test/LifeCycleManagerTest.h index 67b286186a..40bd078212 100644 --- a/src/lcm/test/LifeCycleManagerTest.h +++ b/src/lcm/test/LifeCycleManagerTest.h @@ -62,7 +62,7 @@ static string hostname = "test_hostname"; static string vmm_mad = "vmm_mad"; static string tm_mad = "tm_mad"; static string vmdir = "vmdir"; - +static string db_name = "ONE_test_database"; class LifeCycleManagerTest : public CppUnit::TestFixture { @@ -98,35 +98,35 @@ class LifeCycleManagerTest : public CppUnit::TestFixture CPPUNIT_TEST ( prolog_migrate_to_boot ); CPPUNIT_TEST ( prolog_migrate_to_failed ); -// CPPUNIT_TEST ( prolog_migrate_to_pending ); + CPPUNIT_TEST ( prolog_migrate_to_pending ); CPPUNIT_TEST ( cancel_to_done ); CPPUNIT_TEST ( cancel_to_running ); -// CPPUNIT_TEST ( cancel_to_pending ); + CPPUNIT_TEST ( cancel_to_pending ); CPPUNIT_TEST ( migrate_to_running ); CPPUNIT_TEST ( migrate_to_failed ); -// CPPUNIT_TEST ( migrate_to_pending ); + CPPUNIT_TEST ( migrate_to_pending ); CPPUNIT_TEST ( save_suspend_to_suspended ); CPPUNIT_TEST ( save_suspend_to_running ); -// CPPUNIT_TEST ( save_suspend_to_pending ); + CPPUNIT_TEST ( save_suspend_to_pending ); CPPUNIT_TEST ( shutdown_to_epilog ); CPPUNIT_TEST ( shutdown_to_running ); -// CPPUNIT_TEST ( shutdown_to_pending ); + CPPUNIT_TEST ( shutdown_to_pending ); CPPUNIT_TEST ( save_stop_to_epilog_stop ); CPPUNIT_TEST ( save_stop_to_running ); -// CPPUNIT_TEST ( save_stop_to_pending ); + CPPUNIT_TEST ( save_stop_to_pending ); CPPUNIT_TEST ( epilog_to_done ); CPPUNIT_TEST ( epilog_to_failed ); -// CPPUNIT_TEST ( epilog_to_pending ); + CPPUNIT_TEST ( epilog_to_pending ); CPPUNIT_TEST ( epilog_stop_to_stop ); CPPUNIT_TEST ( epilog_stop_to_failed ); -// CPPUNIT_TEST ( epilog_stop_to_pending ); + CPPUNIT_TEST ( epilog_stop_to_pending ); CPPUNIT_TEST_SUITE_END (); @@ -267,8 +267,6 @@ private: } public: - static string db_name; - void setUp() { @@ -396,7 +394,6 @@ public: vm->unlock(); rc = dm->resubmit(vm->get_oid()); - wait_assert(vm, VirtualMachine::PENDING); } @@ -691,6 +688,30 @@ public: wait_assert(vm, VirtualMachine::FAILED); } +/* -------------------------------------------------------------------------- */ + + void prolog_migrate_to_pending() + { + vm = allocate_running(0); + + vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + + rc = vmpool->update_history(vm); + CPPUNIT_ASSERT( rc == 0 ); + + vmpool->update(vm); //Insert last_seq in the DB + + vmm_actions.push_back(LifeCycleManager::SAVE_SUCCESS); + vmm->set_actions(vmm_actions); + + dm->migrate(vm); + + wait_assert(vm, VirtualMachine::ACTIVE,VirtualMachine::PROLOG_MIGRATE ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } + /* -------------------------------------------------------------------------- */ void cancel_to_done() @@ -719,6 +740,18 @@ public: wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::RUNNING ); } +/* -------------------------------------------------------------------------- */ + + void cancel_to_pending() + { + vm = allocate_running(0); + dm->cancel(vm->get_oid()); + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::CANCEL ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } + /* -------------------------------------------------------------------------- */ void migrate_to_running() @@ -765,6 +798,28 @@ public: wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::RUNNING ); } +/* -------------------------------------------------------------------------- */ + + void migrate_to_pending() + { + vm = allocate_running(0); + + vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + rc = vmpool->update_history(vm); + CPPUNIT_ASSERT( rc == 0 ); + + vmpool->update(vm); //Insert last_seq in the DB + + CPPUNIT_ASSERT( vm->hasHistory() ); + CPPUNIT_ASSERT( vm->hasPreviousHistory() ); + + dm->live_migrate(vm); + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::MIGRATE ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } + /* -------------------------------------------------------------------------- */ void save_suspend_to_suspended() @@ -793,6 +848,18 @@ public: wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::RUNNING ); } +/* -------------------------------------------------------------------------- */ + + void save_suspend_to_pending() + { + vm = allocate_running(0); + dm->suspend(vm->get_oid()); + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::SAVE_SUSPEND ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } + /* -------------------------------------------------------------------------- */ void shutdown_to_epilog() @@ -821,6 +888,18 @@ public: wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::RUNNING ); } +/* -------------------------------------------------------------------------- */ + + void shutdown_to_pending() + { + vm = allocate_running(0); + dm->shutdown(vm->get_oid()); + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::SHUTDOWN ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } + /* -------------------------------------------------------------------------- */ void save_stop_to_epilog_stop() @@ -849,6 +928,19 @@ public: wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::RUNNING ); } + +/* -------------------------------------------------------------------------- */ + + void save_stop_to_pending() + { + vm = allocate_running(0); + dm->stop(vm->get_oid()); + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::SAVE_STOP ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } + /* -------------------------------------------------------------------------- */ void epilog_to_done() @@ -883,6 +975,22 @@ public: wait_assert(vm, VirtualMachine::FAILED ); } +/* -------------------------------------------------------------------------- */ + + void epilog_to_pending() + { + vm = allocate_running(0); + + vmm_actions.push_back(LifeCycleManager::SHUTDOWN_SUCCESS); + vmm->set_actions(vmm_actions); + + dm->shutdown(vm->get_oid()); + + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::EPILOG ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } /* -------------------------------------------------------------------------- */ @@ -918,6 +1026,23 @@ public: wait_assert(vm, VirtualMachine::FAILED ); } +/* -------------------------------------------------------------------------- */ + + void epilog_stop_to_pending() + { + vm = allocate_running(0); + + vmm_actions.push_back(LifeCycleManager::SAVE_SUCCESS); + vmm->set_actions(vmm_actions); + + dm->stop(vm->get_oid()); + + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::EPILOG_STOP ); + + rc = dm->resubmit(vm->get_oid()); + wait_assert(vm, VirtualMachine::PENDING); + } + /* -------------------------------------------------------------------------- */ };