📄 automatedtest.cxx
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const Automated_Test_cxx_Version = "$Id: AutomatedTest.cxx,v 1.3.36.1 2003/01/22 18:07:02 sprajpat Exp $";#include "AutomatedTest.h"#include "ConnectPserver.h"#include "Cdr.h"#include "Feature.h"#include "Heartbeat.h"#include "Jtapi.h"#include "Marshal.h"#include "Osp.h"#include "Policy.h"#include "Provision.h"#include "Redirect.h"#include "Data.hxx"#include <unistd.h>const int NUM_ITERATION_FIRST = 1;const int NUM_ITERATION_SECOND = 100000;const string pserver1 = "cktam-lnx";const int pserver1port = 6005;//const string pserver2 = "208.184.140.114";const string pserver2 = "roebuck.vovida.com";const int pserver2port = 6005;static bool psConnected = false;voidprintBars(){ printf("*****************************************************\n"); printf("*****************************************************\n");}long tv_diff ( const timeval& lhs, const timeval& rhs){ return (lhs.tv_sec - rhs.tv_sec) * 1000000 + ( lhs.tv_usec - rhs.tv_usec);}voidautomatedTest(){ if ( !psConnected ) { connectPserver( pserver2, pserver2port, pserver2, pserver2port ); cout << "**** connectPserver called! ****" <<endl; psConnected = true; } groupServerTest(); serverDataTest();}voidgroupServerTest(){ cout << "\n===================================================" << endl; cout << "== Begin: Group & Server Test... ==" << endl; cout << "===================================================" << endl; for (int i = 0; i < NUM_ITERATION_FIRST; i ++ ) { printBars(); getCdrGroup(); getCdrServers(); printBars(); getFeatureGroups(); getFeatureServers(); printBars(); getHeartbeatGroups(); getHeartbeatServers(); printBars(); getJtapiGroups(); getJtapiServers(); printBars(); getMarshalGroups(); getMarshalServers(); printBars(); getPolicyGroups(); getPolicyServers(); printBars(); getRedirectGroups(); getRedirectServers(); } cout << "===================================================" << endl; cout << "== End Group & Server Test ==" << endl; cout << "===================================================\n" << endl;}voidserverDataTest(){ cout << "\n===================================================" << endl; cout << "== Begin ServerData Test... ==" << endl; cout << "===================================================" << endl; timeval first; int err = gettimeofday( &first, NULL); for (int i = 0; i < NUM_ITERATION_SECOND; i++ ) { getAllCdrData(); getAllFeatureData(); // getDialPlan(1); // getDialPlan(2); getAllJtapiData(); getAllMarshalData(); // getGlobalData(); // getOspServerData(); getAllPolicyData(); getAllRedirectData(); // getAllAliases(); // getSubscribers(); if ( i % 100 == 0) { timeval now; err = gettimeofday (&now, NULL); long temptime = tv_diff(now, first); cout << "\n***** " << i << " hits in: " << temptime/1000000 << " sec *****\n"; } } cout << "===================================================" << endl; cout << "== End ServerData Test ==" << endl; cout << "===================================================\n" << endl;};voidsubscriberTest(){/* ProvisionInterface& ps = ProvisionInterface::instance("roebuck", 6005, "roebuck", 6005);*/ connectPserver( pserver2, pserver2port, pserver2, pserver2port ); ProvisionInterface& ps = ProvisionInterface::instance(); for (int count = 0; count < NUM_ITERATION_SECOND; count ++ ) { vector<Data> tmp; ps.getSubscribers(tmp); vector<Data>::iterator i = tmp.begin();// cerr << (*i).getData(); if ( count % 100 == 0) { cerr << (*i).logData(); cerr << "\n***** " << count << " hits *****\n"; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -