// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
//
+#include <vector>
+
#include "virtualservice.h"
#include "logger_enum.h"
#include "logger.h"
}
void l7vs::virtualservice_tcp::add_realserver( const l7vs::virtualservice_element& in, l7vs::error_code& err ){
+ //lock rs_list_ref_count_inc_mutex
+ boost::mutex::scoped_lock inc_lock( rs_list_ref_count_inc_mutex );
+
+ //waiting for become rs_list_ref_count to 0
+
+ l7vs::virtualservice_element& in_element = const_cast<l7vs::virtualservice_element&>( in );
+
+ //add realserver
+ for( std::vector<realserver_element>::iterator itr = in_element.realserver_vector.begin();
+ itr != in_element.realserver_vector.end();
+ ++itr ){
+ realserver rs;
+ rs_list.push_back( rs );
+ }
err.setter( true, "" );
}
void l7vs::virtualservice_tcp::edit_realserver( const l7vs::virtualservice_element& in, l7vs::error_code& err ){
void l7vs::replication::finalize(){}
void l7vs::replication::switch_to_master(){}
void l7vs::replication::switch_to_slave(){}
-void* l7vs::replication::pay_memory( std::string& inid, unsigned int& outsize ){
+void* l7vs::replication::pay_memory( const std::string& inid, unsigned int& outsize ){
return NULL;
}
void l7vs::replication::dump_memory(){}
int l7vs::replication::handle_receive(){
return 0;
}
-int l7vs::replication::lock( std::string& inid ){
+int l7vs::replication::lock( const std::string& inid ){
return 0;
}
-int l7vs::replication::unlock( std::string& inid ){
+int l7vs::replication::unlock( const std::string& inid ){
return 0;
}
-int l7vs::replication::refer_lock_mutex( std::string& inid, boost::mutex& outmutex ){
+int l7vs::replication::refer_lock_mutex( const std::string& inid, mutex_ptr outmutex ){
return 0;
}
#include "tcp_session.h"
#include "udp_session.h"
#include "parameter.h"
+#include "replication.h"
#include "stub.h"
+int l7vs::replication::initialize(){
+ return 0;
+}
+void l7vs::replication::finalize(){}
+void l7vs::replication::switch_to_master(){}
+void l7vs::replication::switch_to_slave(){}
+void* l7vs::replication::pay_memory( const std::string& inid, unsigned int& outsize ){
+ return NULL;
+}
+void l7vs::replication::dump_memory(){}
+void l7vs::replication::start(){}
+void l7vs::replication::stop(){}
+void l7vs::replication::force_replicate(){}
+void l7vs::replication::reset(){}
+l7vs::replication::REPLICATION_MODE_TAG l7vs::replication::get_status(){
+ l7vs::replication::REPLICATION_MODE_TAG retmode = l7vs::replication::REPLICATION_OUT;
+ return retmode;
+}
+int l7vs::replication::check_interval(){
+ return 0;
+}
+int l7vs::replication::handle_send(){
+ return 0;
+}
+int l7vs::replication::handle_receive(){
+ return 0;
+}
+int l7vs::replication::lock( std::string& inid ){
+ return 0;
+}
+int l7vs::replication::unlock( std::string& inid ){
+ return 0;
+}
+int l7vs::replication::refer_lock_mutex( std::string& inid, boost::mutex& outmutex ){
+ return 0;
+}
+
+
// parameter stub
l7vs::Parameter::Parameter(){}
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
+#include "stub.h"
+
#include "virtualservice.h"
#include "vs_test.h"
// unit_test[17] update_up_recv_sizeメソッド(Updateされることを確認)
BOOST_MESSAGE( "-------17" );
vs->update_up_recv_size( 12ULL );
+ // unit_test[18] get_up_recv_sizeメソッドで上り総受信サイズを取得
BOOST_CHECK( 12ULL == vs->get_up_recv_size() );
BOOST_MESSAGE( "up recv size : " << vs->get_up_recv_size() );
- // unit_test[18] update_up_recv_sizeメソッド(以前の値に加算されることを確認)
+ // unit_test[19] update_up_recv_sizeメソッド(以前の値に加算されることを確認)
BOOST_MESSAGE( "-------18" );
vs->update_up_recv_size( 28ULL );
BOOST_CHECK( 40ULL == vs->get_up_recv_size() );
BOOST_MESSAGE( "up recv size : " << vs->get_up_recv_size() );
- // unit_test[19] update_up_recv_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
+ // unit_test[20] update_up_recv_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
BOOST_MESSAGE( "-------19" );
vs->update_up_recv_size( ULLONG_MAX );
BOOST_CHECK( 40ULL == vs->get_up_recv_size() );
BOOST_MESSAGE( "up recv size : " << vs->get_up_recv_size() );
- // unit_test[20] update_up_recv_sizeメソッド(Updateされることを確認)
+ // unit_test[21] update_up_send_sizeメソッド(Updateされることを確認)
BOOST_MESSAGE( "-------20" );
vs->update_up_send_size( 1024ULL );
BOOST_CHECK( 1024ULL == vs->get_up_send_size() );
BOOST_MESSAGE( "up send size : " << vs->get_up_send_size() );
- // unit_test[21] update_up_recv_sizeメソッド(以前の値に加算されることを確認)
+ // unit_test[22] update_up_send_sizeメソッド(以前の値に加算されることを確認)
BOOST_MESSAGE( "-------21" );
vs->update_up_send_size( 2048ULL );
BOOST_CHECK( 3072ULL == vs->get_up_send_size() );
BOOST_MESSAGE( "up send size : " << vs->get_up_send_size() );
- // unit_test[22] update_up_recv_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
+ // unit_test[23] update_up_send_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
BOOST_MESSAGE( "-------22" );
vs->update_up_send_size( ULLONG_MAX );
BOOST_CHECK( 3072ULL == vs->get_up_send_size() );
BOOST_MESSAGE( "up send size : " << vs->get_up_send_size() );
- // unit_test[23] update_up_recv_sizeメソッド(Updateされることを確認)
+ // unit_test[24] update_down_recv_sizeメソッド(Updateされることを確認)
BOOST_MESSAGE( "-------24" );
vs->update_down_recv_size( 101010ULL );
+ // unit_test[25] get_down_recv_sizeメソッドで下り総受信サイズを取得
BOOST_CHECK( 101010ULL == vs->get_down_recv_size() );
BOOST_MESSAGE( "down recv size : " << vs->get_down_recv_size() );
- // unit_test[25] update_up_recv_sizeメソッド(以前の値に加算されることを確認)
+ // unit_test[26] update_down_recv_sizeメソッド(以前の値に加算されることを確認)
BOOST_MESSAGE( "-------25" );
vs->update_down_recv_size( 505050ULL );
BOOST_CHECK( 606060ULL == vs->get_down_recv_size() );
BOOST_MESSAGE( "down recv size : " << vs->get_down_recv_size() );
- // unit_test[26] update_up_recv_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
+ // unit_test[27] update_down_recv_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
BOOST_MESSAGE( "-------26" );
vs->update_down_recv_size( ULLONG_MAX );
BOOST_CHECK( 606060ULL == vs->get_down_recv_size() );
BOOST_MESSAGE( "down recv size : " << vs->get_down_recv_size() );
- // unit_test[27] update_up_recv_sizeメソッド(Updateされることを確認)
+ // unit_test[28] update_down_send_sizeメソッド(Updateされることを確認)
BOOST_MESSAGE( "-------27" );
vs->update_down_send_size( 123456789ULL );
BOOST_CHECK( 123456789ULL == vs->get_down_send_size() );
BOOST_MESSAGE( "down send size : " << vs->get_down_send_size() );
- // unit_test[28] update_up_recv_sizeメソッド(以前の値に加算されることを確認)
+ // unit_test[29] update_down_send_sizeメソッド(以前の値に加算されることを確認)
BOOST_MESSAGE( "-------28" );
vs->update_down_send_size( 987654321ULL );
BOOST_CHECK( 1111111110ULL == vs->get_down_send_size() );
BOOST_MESSAGE( "down send size : " << vs->get_down_send_size() );
- // unit_test[29] update_up_recv_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
+ // unit_test[30] update_down_send_sizeメソッド上限境界値(加算するとULLONG_MAXを越える場合)
BOOST_MESSAGE( "-------29" );
vs->update_down_send_size( ULLONG_MAX );
BOOST_CHECK( 1111111110ULL == vs->get_down_send_size() );
BOOST_MESSAGE( "down send size : " << vs->get_down_send_size() );
- //
- // unit_test[30] スループット計算のテスト
+ // unit_test[31] スループット計算のテスト
BOOST_MESSAGE( "-------30" );
//計算(curr_sizeクリアのため)
vs->call_handle_throughput_update( test_err );
//それから計算
vs->call_handle_throughput_update( test_err );
//コンソールに出して確認
- // unit_test[31] get_throughput_upstreamメソッドで値を取得
+ // unit_test[32] get_throughput_upstreamメソッドで値を取得
BOOST_MESSAGE( "-------31" );
BOOST_MESSAGE( "bps up : " << vs->get_throughput_upstream() );
- // unit_test[32] get_throughput_downstreamメソッドで値を取得
+ // unit_test[33] get_throughput_downstreamメソッドで値を取得
BOOST_MESSAGE( "-------32" );
BOOST_MESSAGE( "bps down : " << vs->get_throughput_downstream() );
+
+ // unit_test[34] load_parameterでパラメータをロードする(パラメータが存在しないケース)
+ session_pool_debugger::getInstance().param_exist_flag() = false;
+ vs->call_load_parameter();
+ BOOST_CHECK( vs->get_param_data().session_pool_size == SESSION_POOL_NUM_DEFAULT );
+
+ // unit_test[35] load_parameterでパラメータをロードする(パラメータが存在するケース)
+ session_pool_debugger::getInstance().param_exist_flag() = true;
+ vs->call_load_parameter();
+ BOOST_CHECK( vs->get_param_data().session_pool_size == SESSION_POOL_NUM_PARAM );
}
//test case3 replication data serialization test
session_map_type& get_active_sessions(){
return active_sessions;
}
+ std::list<realserver>& get_rs_list(){
+ return rs_list;
+ }
};
}
using namespace boost::unit_test;
+typedef boost::asio::ip::tcp::endpoint tcp_ep_type;
//test case1 create,initialize,run,stop,finalize,destroy(normal case)
void virtualservice_tcp_test1(){
BOOST_CHECK( SCHEDMOD_LOAD_ERROR_MSG == vs_err.get_message() );
delete vs;
+
+ vs = new l7vs::vs_tcp( vsd, rep, element );
+ l7vs::vs_tcp* vs2 = new l7vs::vs_tcp( vsd, rep, element );
+ // unit_test[] initialize method call(procotol_module_control::module_load error case)
+ BOOST_MESSAGE( "-------" );
+ BOOST_CHECK( *vs == *vs2 );
+ delete vs;
+ delete vs2;
+ // unit_test[] initialize method call(procotol_module_control::module_load error case)
+ element.tcp_accept_endpoint = tcp_ep_type( boost::asio::ip::address::from_string( "192.168.10.10" ), 8080 );
+ vs = new l7vs::vs_tcp( vsd, rep, element );
+ element.tcp_accept_endpoint = tcp_ep_type( boost::asio::ip::address::from_string( "192.168.10.10" ), 80 );
+ vs2 = new l7vs::vs_tcp( vsd, rep, element );
+ BOOST_MESSAGE( "-------" );
+ BOOST_CHECK( *vs != *vs2 );
+ delete vs;
+ delete vs2;
+
+ vs = new l7vs::vs_tcp( vsd, rep, element );
+ l7vs::virtualservice_element add_element;
+ for( unsigned int i = 0; i < 10; ++i ){
+ l7vs::realserver_element rs_elem;
+ rs_elem.tcp_endpoint = tcp_ep_type( boost::asio::ip::address::from_string( "192.168.10.10" ), (i+8080) );
+ add_element.realserver_vector.push_back( rs_elem );
+ }
+ // unit_test[] add_realserver method call
+ BOOST_MESSAGE( "-------" );
+ vs->add_realserver( add_element, vs_err );
+ std::list<l7vs::realserver>& rslist = vs->get_rs_list();
+ std::list<l7vs::realserver>::iterator itr = rslist.begin();
+ for( unsigned int i = 0; i < rslist.size(); ++i ){
+ BOOST_CHECK( itr->tcp_endpoint == tcp_ep_type( boost::asio::ip::address::from_string( "192.168.10.10" ), (i+8080) ) );
+ }
+// edit_realserver
+ BOOST_MESSAGE( "-------" );
+ l7vs::virtualservice_element edit_element;
+// vs->edit_realserver( edit_element, vs_err );
+// del_realserver
+ BOOST_MESSAGE( "-------" );
+ l7vs::virtualservice_element del_element;
+// vs->del_realserver( del_element, vs_err );
+
+// connection_active
+// vs->connection_active( const tcp_endpoint_type& );
+// connection_inactive
+// vs->connection_inactive( const tcp_endpoint_type& );
+ delete vs;
+
}
//test case3
rs_list_ref_count = in;
}
- unsigned long long get_up_recv_size(){ return recvsize_up; }
unsigned long long get_up_send_size(){ return sendsize_up; }
- unsigned long long get_down_recv_size(){ return recvsize_down; }
unsigned long long get_down_send_size(){ return sendsize_down; }
unsigned long long get_curr_up_recv_size(){
BOOST_CHECK( a2.qos_up == a1.qos_up );
BOOST_CHECK( a2.qos_down == a1.qos_down );
}
+ parameter_data& get_param_data(){
+ return param_data;
+ }
+ void call_load_parameter(){
+ load_parameter();
+ }
};
}