OSDN Git Service

update command tests
authortakamaru <takamaru@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Wed, 4 Feb 2009 04:48:21 +0000 (04:48 +0000)
committertakamaru <takamaru@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Wed, 4 Feb 2009 04:48:21 +0000 (04:48 +0000)
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-shamshel@6581 1ed66053-1c2d-0410-8867-f7571e6e31d3

include/l7vsd.h
src/command_session.cpp
src/l7vsd.cpp
unit_tests/command_session_test/l7vsd_stub.h
unit_tests/command_thread_test/l7vsd_stub.h
unit_tests/command_thread_test/stub.cpp

index df566f2..55d54c3 100644 (file)
@@ -8,6 +8,7 @@
 #include <boost/thread.hpp>
 #include <boost/asio.hpp>
 #include <boost/format.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 #include "error_code.h"
 #include "l7vs_command.h"
 #include "command_receiver.h"
@@ -74,6 +75,8 @@ protected:
        bool                                            help;                           //!< help mode
        bool                                            debug;                          //!< debug mode
 
+       boost::posix_time::ptime        starttime;                      //!< l7vsd startup time
+
        //! option parse function object type.
        typedef boost::function< bool ( int&, int, char*[] ) >
                        parse_opt_func_type;
index 121958c..1196828 100644 (file)
@@ -29,11 +29,7 @@ command_session::command_session(    boost::asio::io_service& io_service, l7vsd& pa
                                                                                                                        &response_data.virtualservice_status_list, _1 );
        command_handler_map[l7vsadm_request::CMD_LIST_VERBOSE]
                                                                                        = boost::bind(  &l7vsd::list_virtual_service_verbose, &vsd,
-                                                                                                                       &response_data.virtualservice_status_list,
-                                                                                                                       &response_data.replication_mode_status,
-                                                                                                                       &response_data.log_status_list,
-                                                                                                                       &response_data.snmp_connection_status,
-                                                                                                                       &response_data.snmp_log_status_list, _1 );
+                                                                                                                       &response_data, _1 );
        command_handler_map[l7vsadm_request::CMD_ADD_VS]
                                                                                        = boost::bind( &l7vsd::add_virtual_service, &vsd, &request_data.vs_element, _1 );
        command_handler_map[l7vsadm_request::CMD_DEL_VS]
index 6ce3de1..8b7432c 100644 (file)
@@ -38,6 +38,7 @@ l7vsd::l7vsd()
        option_dic["-d"]                = boost::bind( &l7vsd::parse_debug, this, _1, _2, _3 );
        option_dic["--debug"]   = boost::bind( &l7vsd::parse_debug, this, _1, _2, _3 );
 
+       starttime = boost::posix_time::second_clock::local_time();
 }
 
 //! destructor
@@ -70,47 +71,14 @@ void        l7vsd::list_virtual_service( vselist_type* out_vslist, error_code& err ){
 //! virtual_service list verbose command
 //! @param[out]        arry of vs_element
 //! @param[out]        error_code
-void   l7vsd::list_virtual_service_verbose(    vselist_type* out_vslist, 
-                                                                                               replication::REPLICATION_MODE_TAG* repmode,
-                                                                                               logstatus_list_type* logstatus,
-                                                                                               bool*   snmpstatus,
-                                                                                               logstatus_list_type* snmplogstatus,
-                                                                                               error_code& err ){
+void   l7vsd::list_virtual_service_verbose( l7vsd_response* response, error_code& err ){
        Logger  logger( LOG_CAT_L7VSD_MAINTHREAD, 1, "l7vsd::list_virtual_service_verbose", __FILE__, __LINE__ );
 
        boost::mutex::scoped_lock command_lock( command_mutex );
        boost::mutex::scoped_lock vslist_lock( vslist_mutex );
 
-       if( !out_vslist ){
-               std::string msg("out_vslist pointer is null.");
-               Logger::putLogFatal(LOG_CAT_L7VSD_VIRTUALSERVICE, 1, msg, __FILE__, __LINE__);
-               err.setter( true, msg );
-               return;
-       }
-
-       if( !repmode ){
-               std::string msg("repmode pointer is null.");
-               Logger::putLogFatal(LOG_CAT_L7VSD_VIRTUALSERVICE, 1, msg, __FILE__, __LINE__);
-               err.setter( true, msg );
-               return;
-       }
-
-       if( !logstatus ){
-               std::string msg("logstatus pointer is null.");
-               Logger::putLogFatal(LOG_CAT_L7VSD_VIRTUALSERVICE, 1, msg, __FILE__, __LINE__);
-               err.setter( true, msg );
-               return;
-       }
-
-       if( !snmpstatus ){
-               std::string msg("snmpstatus pointer is null.");
-               Logger::putLogFatal(LOG_CAT_L7VSD_VIRTUALSERVICE, 1, msg, __FILE__, __LINE__);
-               err.setter( true, msg );
-               return;
-       }
-
-       if( !snmplogstatus ){
-               std::string msg("snmplogstatus pointer is null.");
+       if( !response ){
+               std::string msg("response pointer is null.");
                Logger::putLogFatal(LOG_CAT_L7VSD_VIRTUALSERVICE, 1, msg, __FILE__, __LINE__);
                err.setter( true, msg );
                return;
@@ -120,17 +88,17 @@ void       l7vsd::list_virtual_service_verbose(    vselist_type* out_vslist,
        for( vslist_type::iterator itr = vslist.begin();
                 itr != vslist.end();
                 ++itr ){
-               out_vslist->push_back( (*itr)->get_element() );
+               response->virtualservice_status_list.push_back( (*itr)->get_element() );
        }
 
        // get_replication_mode
-       *repmode = rep->get_status();
+       response->replication_mode_status = rep->get_status();
 
        // get all category log level
-       Logger::getLogLevelAll( *logstatus );
+       Logger::getLogLevelAll( response->log_status_list );
 
        // get snmp connect status
-       *snmpstatus = bridge->get_connectionstate();
+       response->snmp_connection_status = bridge->get_connectionstate();
 
        // get snmp all category log level
        typedef std::map< LOG_CATEGORY_TAG, LOG_LEVEL_TAG > snmplogmap_type; 
@@ -139,7 +107,7 @@ void        l7vsd::list_virtual_service_verbose(    vselist_type* out_vslist,
        for( snmplogmap_type::iterator itr = snmplogmap.begin();
                 itr != snmplogmap.end();
                 ++itr ){
-               snmplogstatus->push_back( *itr );
+               response->snmp_log_status_list.push_back( *itr );
        }
 }
 
index 938b5eb..8a34e30 100644 (file)
@@ -52,12 +52,7 @@ public:
                list_vs_called = true;
                if(list_vs_fail)        err.setter( true, "");
        }
-       void    list_virtual_service_verbose(   vselist_type*,
-                                                                                       replication::REPLICATION_MODE_TAG*,
-                                                                                       logstatus_list_type*,
-                                                                                       bool*,
-                                                                                       logstatus_list_type*,
-                                                                                       error_code& err )
+       void    list_virtual_service_verbose( l7vsd_response*, error_code& err )
        {
                list_vs_v_called = true;
                if(list_vs_v_fail)      err.setter( true, "");
index b5d0d6b..3c78f0a 100644 (file)
@@ -88,12 +88,7 @@ protected:
 
 public:
        void    list_virtual_service( vselist_type*, error_code&  );                            //!< virtual_service list command
-       void    list_virtual_service_verbose(   vselist_type*,
-                                                                                       replication::REPLICATION_MODE_TAG*,
-                                                                                       logstatus_list_type*,
-                                                                                       bool*,
-                                                                                       logstatus_list_type*,
-                                                                                       error_code&  );                                         //!< virtual_service verbose list command
+       void    list_virtual_service_verbose( l7vsd_response*, error_code&  );          //!< virtual_service verbose list command
        void    add_virtual_service( const virtualservice_element*, error_code& );      //!< virtual_service add command
        void    del_virtual_service( const virtualservice_element*, error_code& );      //!< virtual_service del command
        void    edit_virtual_service( const virtualservice_element*, error_code& );     //!< virtual_service edit command
index 1d3e51c..0367322 100644 (file)
@@ -40,12 +40,7 @@ void l7vsd::list_virtual_service( vselist_type*, error_code&  )
        ++call_num_map[l7vs::l7vsadm_request::CMD_LIST];
 }
 
-void   l7vsd::list_virtual_service_verbose(    vselist_type*,
-                                                                               replication::REPLICATION_MODE_TAG*,
-                                                                               logstatus_list_type*,
-                                                                               bool*,
-                                                                               logstatus_list_type*,
-                                                                               error_code&  )
+void   l7vsd::list_virtual_service_verbose( l7vsd_response*, error_code& )
 {
        boost::mutex::scoped_lock lock(command_mutex);
        ++call_num_map[l7vs::l7vsadm_request::CMD_LIST_VERBOSE];