(file) Return to testSnmpHandler.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Handler / snmpIndicationHandler / tests / testclient

Diff for /pegasus/src/Pegasus/Handler/snmpIndicationHandler/tests/testclient/testSnmpHandler.cpp between version 1.1 and 1.5.10.1

version 1.1, 2006/03/14 22:39:31 version 1.5.10.1, 2007/06/25 19:51:16
Line 41 
Line 41 
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/Stopwatch.h> #include <Pegasus/Common/Stopwatch.h>
 #include <Pegasus/Client/CIMClient.h> #include <Pegasus/Client/CIMClient.h>
   #include <Pegasus/Common/HostAddress.h>
  
 PEGASUS_USING_PEGASUS; PEGASUS_USING_PEGASUS;
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 const CIMNamespaceName INTEROP_NAMESPACE = CIMNamespaceName ("root/PG_InterOp");  // Interop namespace used with PEGASUS_NAMESPACENAME_INTEROP in Constants.h
 const CIMNamespaceName SOURCE_NAMESPACE = const CIMNamespaceName SOURCE_NAMESPACE =
     CIMNamespaceName ("root/SampleProvider");     CIMNamespaceName ("root/SampleProvider");
  
Line 56 
Line 57 
 const String FILTER_NAME = String ("IPFilter01"); const String FILTER_NAME = String ("IPFilter01");
  
 enum SNMPVersion {_SNMPV1_TRAP = 2, _SNMPV2C_TRAP = 3}; enum SNMPVersion {_SNMPV1_TRAP = 2, _SNMPV2C_TRAP = 3};
 enum TargetHostFormat {_HOST_NAME = 2, _IPV4_ADDRESS = 3};  enum TargetHostFormat {_HOST_NAME = 2, _IPV4_ADDRESS = 3, _IPV6_ADDRESS = 4};
  
 #define PORT_NUMBER 2006 #define PORT_NUMBER 2006
  
Line 156 
Line 157 
     handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"),     handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"),
         CIMValue ((Uint32) PORT_NUMBER)));         CIMValue ((Uint32) PORT_NUMBER)));
  
     return(client.createInstance (INTEROP_NAMESPACE, handlerInstance));      return(client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, handlerInstance));
 } }
  
 CIMObjectPath _createFilterInstance CIMObjectPath _createFilterInstance
Line 179 
Line 180 
     filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"),     filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"),
         SOURCE_NAMESPACE.getString ()));         SOURCE_NAMESPACE.getString ()));
  
     return(client.createInstance (INTEROP_NAMESPACE, filterInstance));      return(client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, filterInstance));
 } }
  
 CIMObjectPath _createSubscriptionInstance CIMObjectPath _createSubscriptionInstance
Line 195 
Line 196 
     subscriptionInstance.addProperty (CIMProperty     subscriptionInstance.addProperty (CIMProperty
         (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2)));         (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2)));
  
     return(client.createInstance (INTEROP_NAMESPACE, subscriptionInstance));      return(client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, subscriptionInstance));
 } }
  
 void _sendTestIndication(CIMClient* client, const CIMName & methodName, void _sendTestIndication(CIMClient* client, const CIMName & methodName,
Line 233 
Line 234 
 { {
     CIMObjectPath subscriptionObjectPath =     CIMObjectPath subscriptionObjectPath =
        _getSubscriptionObjectPath(filterName, handlerName);        _getSubscriptionObjectPath(filterName, handlerName);
     client.deleteInstance (INTEROP_NAMESPACE, subscriptionObjectPath);      client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, subscriptionObjectPath);
 } }
  
 void _deleteHandlerInstance void _deleteHandlerInstance
Line 241 
Line 242 
      const String & name)      const String & name)
 { {
     CIMObjectPath handlerObjectPath = _getHandlerObjectPath(name);     CIMObjectPath handlerObjectPath = _getHandlerObjectPath(name);
     client.deleteInstance (INTEROP_NAMESPACE, handlerObjectPath);      client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, handlerObjectPath);
 } }
  
 void _deleteFilterInstance void _deleteFilterInstance
Line 249 
Line 250 
      const String & name)      const String & name)
 { {
     CIMObjectPath filterObjectPath = _getFilterObjectPath(name);     CIMObjectPath filterObjectPath = _getFilterObjectPath(name);
     client.deleteInstance (INTEROP_NAMESPACE, filterObjectPath);      client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, filterObjectPath);
 } }
  
 void _usage () void _usage ()
Line 344 
Line 345 
  
     try     try
     {     {
           String ipAddress;
           int af;
           System::getHostIP(System::getFullyQualifiedHostName (), &af, ipAddress);
         // Create SNMPv2 trap handler         // Create SNMPv2 trap handler
         snmpv2HandlerObjectPath = _createHandlerInstance (client,         snmpv2HandlerObjectPath = _createHandlerInstance (client,
             SNMPV2C_HANDLER_NAME,             SNMPV2C_HANDLER_NAME,
             System::getHostIP(System::getFullyQualifiedHostName ()),              ipAddress,
             "public",             "public",
             _IPV4_ADDRESS,              af == AF_INET ? _IPV4_ADDRESS : _IPV6_ADDRESS,
             _SNMPV2C_TRAP);             _SNMPV2C_TRAP);
     }     }
     catch (CIMException& e)     catch (CIMException& e)
Line 464 
Line 468 
         << " seconds" << endl;         << " seconds" << endl;
 } }
  
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _executeTests(void *parm)  ThreadReturnType PEGASUS_THREAD_CDECL _executeTests(void *parm)
 { {
     Thread *my_thread = (Thread *)parm;     Thread *my_thread = (Thread *)parm;
     T_Parms *parms = (T_Parms *)my_thread->get_parm();     T_Parms *parms = (T_Parms *)my_thread->get_parm();
Line 499 
Line 503 
     {     {
         cout << e.getMessage() << endl;         cout << e.getMessage() << endl;
     }     }
     my_thread->exit_self((PEGASUS_THREAD_RETURN)1);      my_thread->exit_self((ThreadReturnType)1);
     return(0);     return(0);
 } }
  
Line 663 
Line 667 
     }     }
 } }
  
 int _beginTest(CIMClient& workClient,  void _receiveExpectedTraps(CIMClient& workClient,
     Uint32 indicationSendCount,     Uint32 indicationSendCount,
     Uint32 runClientThreadCount)     Uint32 runClientThreadCount)
 { {
  
 #ifdef PEGASUS_USE_NET_SNMP  
   
     // Stop snmptrapd process if it is running  
     _stopSnmptrapd();  
   
     // if trapLogFile exists, remove it  
     _removeTrapLogFile();  
   
     FILE * trapInfo;  
   
     try  
     {  
         _startSnmptrapd(&trapInfo);  
     }  
     catch (Exception & e)  
     {  
         cerr << e.getMessage() << endl;  
         return (-1);  
     }  
 #else  
     cerr << "Cannot create a trap receiver." << endl;  
     return (-1);  
 #endif  
   
     CIMClient * clientConnections = new CIMClient[runClientThreadCount];     CIMClient * clientConnections = new CIMClient[runClientThreadCount];
  
     // determine total number of indication send count     // determine total number of indication send count
Line 703 
Line 683 
  
 #define MSG_PER_SEC 4 #define MSG_PER_SEC 4
  
     Uint32 testTimeout = 20000+(indicationSendCountTotal/MSG_PER_SEC)*1000;      Uint32 testTimeout = PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS
                           + (indicationSendCountTotal/MSG_PER_SEC)*1000;
  
     // connect the clients     // connect the clients
     for(Uint32 i = 0; i < runClientThreadCount; i++)     for(Uint32 i = 0; i < runClientThreadCount; i++)
Line 838 
Line 819 
        currentReceivedTrap1Count);        currentReceivedTrap1Count);
     PEGASUS_TEST_ASSERT(indicationSendCountTotal ==     PEGASUS_TEST_ASSERT(indicationSendCountTotal ==
        currentReceivedTrap2Count);        currentReceivedTrap2Count);
   }
   
   int _beginTest(CIMClient& workClient,
       Uint32 indicationSendCount,
       Uint32 runClientThreadCount)
   {
  
 #ifdef PEGASUS_USE_NET_SNMP #ifdef PEGASUS_USE_NET_SNMP
   
       // Stop snmptrapd process if it is running
       _stopSnmptrapd();
   
       // if trapLogFile exists, remove it
       _removeTrapLogFile();
   
       FILE * trapInfo;
   
       try
       {
           _startSnmptrapd(&trapInfo);
       }
       catch (Exception & e)
       {
           cerr << e.getMessage() << endl;
           return (-1);
       }
   
       // Extended for all snmp implementation
       _receiveExpectedTraps(workClient, indicationSendCount,
           runClientThreadCount);
   
     // Stop snmptrapd process if it is running and remove procIdFile     // Stop snmptrapd process if it is running and remove procIdFile
     _stopSnmptrapd();     _stopSnmptrapd();
  
     pclose(trapInfo);     pclose(trapInfo);
 #endif  
  
     // if error encountered then fail the test.     // if error encountered then fail the test.
     if (errorsEncountered.get())     if (errorsEncountered.get())
Line 857 
Line 866 
         cout << "+++++ passed all tests" << endl;         cout << "+++++ passed all tests" << endl;
     }     }
  
     return 0;      return (0);
   
   #else
       cerr << "Cannot create a trap receiver." << endl;
       return (-1);
   #endif
 } }
  
 int main (int argc, char** argv) int main (int argc, char** argv)


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5.10.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2