1 j.alex 1.2 //%2006////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 j.alex 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Aruran, IBM (aruran.shanmug@in.ibm.com)
33 //
34 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
38 #include "../TestStressTestClient.h"
39
40 PEGASUS_USING_PEGASUS;
41 PEGASUS_USING_STD;
42
43 j.alex 1.2 Boolean verboseTest = false;
44
45 Boolean quit = false;
46 Boolean nextCheck = false;
47 int status = CLIENT_UNKNOWN;
48 char clientName[] = "ModelWalkStressClient";
49
50 String errorInfo;
51
52 /**
53 Signal handler for SIGALARM.
54 @param signum - the alarm identifier.
55 */
56 void endTest(int signum)
57 {
58 PEGASUS_STD(cout) << "\nRecieved interrupt signal SIGINT!\n"
59 << PEGASUS_STD(endl);
60 quit = true;
61 }
62
63 class TestModelWalkStressClient:public TestStressTestClient
64 j.alex 1.2 {
65 };
66
67 /**
68 GetNameSpaces
69 If no nameSpace is supplied on the command line, this method looks into
70 the root and test nameSpaces for the _Namespace class. The names of the
71 instances of that class are retrued by this method.
72 */
73 Array<CIMNamespaceName> getNameSpaces(
74 TestModelWalkStressClient &tmsc,
75 CIMClient* client,
76 OptionManager &om,
77 pid_t clientPid,
78 String& clientLog,
79 String &clientId,
80 int status,
81 String &pidFile)
82 {
83 Array<CIMNamespaceName> topNamespaceNames;
84 Array<CIMNamespaceName> returnNamespaces;
85 j.alex 1.2 String tmpNamespace;
86
87 om.lookupValue("namespace",tmpNamespace);
88 if (tmpNamespace != String::EMPTY)
89 {
90 returnNamespaces.append(CIMNamespaceName (tmpNamespace));
91 }
92 else
93 {
94 //
95 // Get all namespaces for display using the __Namespaces function.
96 //
97 CIMName className = "__NameSpace";
98
99 //
100 // We have to append any new top level root namespace if created in
101 // repository.
102 //
103 topNamespaceNames.append("root");
104 topNamespaceNames.append("test");
105
106 j.alex 1.2 Uint32 start = 0;
107 Uint32 end = topNamespaceNames.size();
108
109 //
110 // for all new elements in the output array.
111 //
112 for (Uint32 range = start; range < end; range ++)
113 {
114 //
115 // Get the next increment in naming for all name element in
116 // the array.
117 //
118 Array<CIMInstance> instances = client->enumerateInstances(
119 topNamespaceNames[range], className);
120
121 if (status != CLIENT_PASS)
122 {
123 status = CLIENT_PASS;
124 tmsc.logInfo(clientId, clientPid, status, pidFile);
125 }
126 for (Uint32 i = 0 ; i < instances.size(); i++)
127 j.alex 1.2 {
128 Uint32 pos;
129 //
130 // if we find the property and it is a string, use it.
131 //
132 if ((pos = instances[i].findProperty("name")) != PEG_NOT_FOUND)
133 {
134 CIMValue value;
135 String namespaceComponent;
136 value = instances[i].getProperty(pos).getValue();
137 if (value.getType() == CIMTYPE_STRING)
138 {
139 value.get(namespaceComponent);
140 String ns = topNamespaceNames[range].getString();
141 ns.append("/");
142 ns.append(namespaceComponent);
143 returnNamespaces.append(ns);
144 }
145 }
146 }
147 }
148 j.alex 1.2 }//else block ends here...
149
150 if (verboseTest)
151 {
152 errorInfo.clear();
153 errorInfo.append("+++++ Successfully Enumerated all Namespaces that ");
154 errorInfo.append("have a _NameSpace instance defined for them in the");
155 errorInfo.append(" root of test namespaces +++++");
156 tmsc.errorLog(clientPid, clientLog, errorInfo);
157 errorInfo.clear();
158 }
159 return returnNamespaces;
160 }
161 /**
162 EnumerateAllQualifiers
163 This method enumerates all the qualifiers in each of the nameSpaces
164 of the "nameSpacesArray"
165 */
166 static void enumerateAllQualifiers(
167 TestModelWalkStressClient &tmsc,
168 CIMClient* client,
169 j.alex 1.2 Array<CIMNamespaceName> nameSpacesArray,
170 pid_t clientPid,
171 String& clientLog,
172 String &clientId,
173 int status,
174 String &pidFile)
175 {
176 Array<CIMQualifierDecl> qualifierDecls;
177 qualifierDecls.clear();
178
179 for (Uint32 i=0; i < nameSpacesArray.size();i++)
180 {
181 try
182 {
183 qualifierDecls = client->enumerateQualifiers(nameSpacesArray[i]);
184
185 if (status != CLIENT_PASS)
186 {
187 status = CLIENT_PASS;
188 tmsc.logInfo(clientId, clientPid, status, pidFile);
189 }
190 j.alex 1.2 }
191 //
192 // Following exceptions will be caught in the Main method.
193 //
194 catch (CIMException &e)
195 {
196 errorInfo.clear();
197 errorInfo.append("CIMException in enumerateQualifiers : ");
198 errorInfo.append(e.getMessage());
199 CIMException cimExp(e.getCode(), errorInfo);
200 throw cimExp;
201 }
202 catch (Exception &e)
203 {
204 errorInfo.clear();
205 errorInfo.append("Exception in enumerateQualifiers : ");
206 errorInfo.append(e.getMessage());
207 Exception exp(errorInfo);
208 throw exp;
209 }
210 catch (...)
211 j.alex 1.2 {
212 Exception exp("General Exception in enumerateQualifiers ");
213 throw exp;
214 }
215 }
216
217 if (verboseTest)
218 {
219 errorInfo.clear();
220 errorInfo.append("+++++ Successfully Enumerated Qualifiers for ");
221 errorInfo.append("Namespaces +++++");
222 tmsc.errorLog(clientPid, clientLog, errorInfo);
223 errorInfo.clear();
224 }
225 }
226 /**
227 EnumerateReferenceNames
228 This method enumerates the references to each instance in the array
229 "cimInstances" for the "nameSpace"
230 */
231 static void enumerateReferenceNames(
232 j.alex 1.2 TestModelWalkStressClient &tmsc,
233 CIMClient* client,
234 Array<CIMInstance> cimNInstances,
235 CIMNamespaceName nameSpace,
236 CIMName referenceClass,
237 pid_t clientPid,
238 String& clientLog,
239 String &clientId,
240 int status,
241 String &pidFile)
242 {
243 String role = String::EMPTY;
244 Array<CIMObjectPath> resultObjectPaths;
245
246 for (Uint32 i=0; i < cimNInstances.size(); i++)
247 {
248 try
249 {
250 resultObjectPaths = client->referenceNames(
251 nameSpace, cimNInstances[i].getPath(),
252 referenceClass, role);
253 j.alex 1.2
254 if (status != CLIENT_PASS)
255 {
256 status = CLIENT_PASS;
257 tmsc.logInfo(clientId, clientPid, status, pidFile);
258 }
259 }
260 //
261 // Following exceptions will be caught in the Main method.
262 //
263 catch (CIMException &e)
264 {
265 errorInfo.clear();
266 errorInfo.append("CIMException in enumerateReferenceNames : ");
267 errorInfo.append(e.getMessage());
268 CIMException cimExp(e.getCode(), errorInfo);
269 throw cimExp;
270 }
271 catch (Exception &e)
272 {
273 errorInfo.clear();
274 j.alex 1.2 errorInfo.append("Exception in enumerateReferenceNames : ");
275 errorInfo.append(e.getMessage());
276 Exception exp(errorInfo);
277 throw exp;
278 }
279 catch (...)
280 {
281 Exception exp("General Exception in enumerateReferenceNames ");
282 throw exp;
283 }
284 }
285 }
286 /**
287 EnumerateAssociatorNames
288 This method enumerates the associators to each instance in the array
289 "cimInstances" for the "nameSpace"
290 */
291 static void enumerateAssociatorNames(
292 TestModelWalkStressClient &tmsc,
293 CIMClient* client,
294 Array<CIMInstance> cimNInstances,
295 j.alex 1.2 CIMNamespaceName nameSpace,
296 CIMName assocClass,
297 pid_t clientPid,
298 String& clientLog,
299 String &clientId,
300 int status,
301 String &pidFile)
302 {
303 CIMName resultClass = CIMName();
304 String role = String::EMPTY;
305 String resultRole = String::EMPTY;
306 Array<CIMObjectPath> resultObjectPaths;
307
308 for (Uint32 i=0; i < cimNInstances.size(); i++)
309 {
310 try
311 {
312 resultObjectPaths = client->associatorNames(
313 nameSpace, cimNInstances[i].getPath(),
314 assocClass, resultClass, role, resultRole);
315
316 j.alex 1.2 if (status != CLIENT_PASS)
317 {
318 status = CLIENT_PASS;
319 tmsc.logInfo(clientId, clientPid, status, pidFile);
320 }
321 }
322 //
323 // Following exceptions will be caught in the Main method.
324 //
325 catch (CIMException &e)
326 {
327 errorInfo.clear();
328 errorInfo.append("CIMException in enumerateAssociatorNames : ");
329 errorInfo.append(e.getMessage());
330 CIMException cimExp(e.getCode(), errorInfo);
331 throw cimExp;
332 }
333 catch (Exception &e)
334 {
335 errorInfo.clear();
336 errorInfo.append("Exception in enumerateAssociatorNames : ");
337 j.alex 1.2 errorInfo.append(e.getMessage());
338 Exception exp(errorInfo);
339 throw exp;
340 }
341 catch (...)
342 {
343 Exception exp("General Exception in enumerateAssociatorNames ");
344 throw exp;
345 }
346 }
347 }
348 /**
349 EnumerateInstanceRelatedInfo
350 This method enumerates instances, referances (by way of subrotine) and
351 associators (by way of subrotine.Exceptions are caught, modified and
352 re-thrown so that generic exception handling can be used in Main
353 */
354 static void enumerateInstanceRelatedInfo(
355 TestModelWalkStressClient &tmsc,
356 CIMClient *client,
357 Array<CIMName> classNames,
358 j.alex 1.2 CIMNamespaceName nameSpace,
359 pid_t clientPid,
360 String& clientLog,
361 String &clientId,
362 int status,
363 String &pidFile )
364 {
365 Boolean deepInheritance = true;
366 Boolean localOnly = true;
367 Boolean includeQualifiers = false;
368 Boolean includeClassOrigin = false;
369 Array<CIMInstance> cimNInstances;
370
371 for (Uint32 i=0; i < classNames.size(); i++)
372 {
373 try
374 {
375 cimNInstances = client->enumerateInstances(
376 nameSpace, classNames[i], deepInheritance,
377 localOnly, includeQualifiers, includeClassOrigin);
378
379 j.alex 1.2 if (status != CLIENT_PASS)
380 {
381 status = CLIENT_PASS;
382 tmsc.logInfo(clientId, clientPid, status, pidFile);
383 }
384 }
385 //
386 // Following exceptions will be caught in the Main method.
387 //
388 catch (CIMException &e)
389 {
390 errorInfo.clear();
391 errorInfo.append("CIMException thrown from ");
392 errorInfo.append("enumerateInstanceRelatedInfo, class = ");
393 errorInfo.append(classNames[i].getString());
394 errorInfo.append(" ");
395 errorInfo.append(e.getMessage());
396 CIMException cimExp(e.getCode(), errorInfo);
397 throw cimExp;
398 }
399 catch (Exception &e)
400 j.alex 1.2 {
401 errorInfo.clear();
402 errorInfo.append("Exception thrown from ");
403 errorInfo.append("enumerateInstanceRelatedInfo, class = ");
404 errorInfo.append(classNames[i].getString());
405 errorInfo.append(" ");
406 errorInfo.append(e.getMessage());
407 Exception exp(errorInfo);
408 throw exp;
409 }
410 catch (...)
411 {
412 Exception exp("General Exception in EnumerateInstanceRelatedInfo ");
413 throw exp;
414 }
415
416 enumerateReferenceNames (tmsc, client, cimNInstances, nameSpace,
417 CIMName(), clientPid, clientLog, clientId, status, pidFile);
418 enumerateAssociatorNames (tmsc, client, cimNInstances, nameSpace,
419 CIMName(), clientPid, clientLog, clientId, status, pidFile);
420
421 j.alex 1.2 if (verboseTest)
422 {
423 errorInfo.clear();
424 errorInfo.append("+++++ Successfully Done Instance Operations ");
425 errorInfo.append("on class = ");
426 errorInfo.append(classNames[i].getString());
427 tmsc.errorLog(clientPid, clientLog, errorInfo);
428 errorInfo.clear();
429 }
430 }
431
432 }
433 /**
434 EnumerateClassRelatedInfo
435 This method enumerates classes and instances (by way of subrotine)
436 */
437 static void enumerateClassRelatedInfo(
438 TestModelWalkStressClient &tmsc,
439 CIMClient* client,
440 OptionManager &om,
441 Array<CIMNamespaceName> nameSpacesArray,
442 j.alex 1.2 pid_t clientPid,
443 String& clientLog,
444 String &clientId,
445 int status,
446 String &pidFile)
447 {
448 Array<CIMName> classNames;
449 String tmpClassName;
450
451 om.lookupValue("classname",tmpClassName);
452 if (tmpClassName != String::EMPTY)
453 {
454 classNames.append(CIMName(tmpClassName));
455 enumerateInstanceRelatedInfo(tmsc, client, classNames,
456 *nameSpacesArray.getData(), clientPid, clientLog, clientId,
457 status, pidFile);
458 }
459 else
460 {
461 Boolean deepInheritance = true;
462 CIMName className;
463 j.alex 1.2 for (Uint32 i=0; i < nameSpacesArray.size();i++)
464 {
465 classNames = client->enumerateClassNames(nameSpacesArray[i],
466 className, deepInheritance);
467
468 if (status != CLIENT_PASS)
469 {
470 status = CLIENT_PASS;
471 tmsc.logInfo(clientId, clientPid, status, pidFile);
472 }
473 enumerateInstanceRelatedInfo(tmsc, client, classNames,
474 nameSpacesArray[i], clientPid, clientLog, clientId, status,
475 pidFile );
476 }
477 }
478 if (verboseTest)
479 {
480 errorInfo.clear();
481 errorInfo.append("+++++ Successfully Enumerated classes ");
482 errorInfo.append("in Namespaces +++++");
483 tmsc.errorLog(clientPid, clientLog, errorInfo);
484 j.alex 1.2 errorInfo.clear();
485 }
486 }
487 /**
488 MAIN
489 */
490
491 int main(int argc, char** argv)
492 {
493 OptionManager om;
494 TestModelWalkStressClient tmsc;
495 Uint32 validArg = 0;
496 struct OptionRow *newOptionsTable = 0;
497 Uint32 newOptionsCount = 0;
498 Uint32 cOptionCount = 0;
499
500 //
501 // Variables need to connect to server.
502 //
503 Boolean useSSL;
504 String host;
505 j.alex 1.2 Uint32 portNumber = 0;
506 String portStr;
507 String userName;
508 String password;
509 String help;
510 Boolean connectedToHost = false;
511
512 //
513 // Variables needed to do loging and status checking.
514 //
515 String pidFile;
516 String clientId;
517 pid_t clientPid;
518 String clientLog, stopClient;
519 char pid_str[15];
520
521 //
522 // Number of times the command succeeded.
523 //
524 Uint32 successCount=0;
525
526 j.alex 1.2 //
527 // Number of iterations after which logErrorPercentage() is called.
528 //
529 Uint32 iteration=0;
530
531 //
532 // Total number of times the command was executed.
533 //
534 Uint32 totalCount=0;
535
536 //
537 // timeout.
538 //
539 Uint32 timeout = 30000;
540
541 //
542 // This try block includes all the options gathering function.
543 //
544 try
545 {
546 //
547 j.alex 1.2 // client specific options if any.
548 //
549 struct OptionRow *cOptionTable = 0;
550 newOptionsCount = cOptionCount;
551
552 try
553 {
554 //
555 // Generate new option table for this client using
556 // the OptionManager.
557 //
558
559 newOptionsTable = tmsc.generateClientOptions(cOptionTable,
560 cOptionCount,newOptionsCount);
561 validArg = tmsc.GetOptions(om, argc, argv, newOptionsTable,
562 newOptionsCount);
563 }
564 catch (Exception& e)
565 {
566 PEGASUS_STD(cerr) << argv[0] << ": " << e.getMessage()
567 << PEGASUS_STD(endl);
568 j.alex 1.2 exit(1);
569 }
570 catch (...)
571 {
572 PEGASUS_STD(cerr) << argv[0] << ": Error in Options operation "
573 << PEGASUS_STD(endl);
574 exit(1);
575 }
576
577 verboseTest = om.isTrue("verbose");
578
579 om.lookupValue("username", userName);
580
581 om.lookupValue("password", password);
582
583 om.lookupIntegerValue("timeout",timeout);
584
585 useSSL = om.isTrue("ssl");
586
587 om.lookupValue("hostname",host);
588 om.lookupValue("port",portStr);
589 j.alex 1.2
590 if (portStr.getCString())
591 {
592 sscanf (portStr.getCString (), "%u", &portNumber);
593 }
594
595 //
596 // Setting default ports.
597 //
598 if (!portNumber)
599 {
600 if (useSSL)
601 {
602 portNumber = 5989;
603 }
604 else
605 {
606 portNumber = 5988;
607 }
608 }
609
610 j.alex 1.2 //
611 // default host is localhost.
612 //
613 if (host == String::EMPTY)
614 {
615 host = String("localhost");
616 }
617
618 //
619 // Signal Handling - SIGINT
620 //
621 signal(SIGINT, endTest);
622
623 om.lookupValue("clientid", clientId);
624
625 om.lookupValue("pidfile", pidFile);
626
627 clientPid = getpid();
628
629 om.lookupValue("clientlog", clientLog);
630
631 j.alex 1.2 om.lookupValue("help", help);
632
633 }// end of option Try block
634 catch (Exception& e)
635 {
636 PEGASUS_STD(cerr) << argv[0] << ": " << e.getMessage()
637 << PEGASUS_STD(endl);
638 exit(1);
639 }
640 catch (...)
641 {
642 PEGASUS_STD(cerr) << argv[0] << ": Unknown Error gathering options "
643 << PEGASUS_STD(endl);
644 exit(1);
645 }
646
647 /* Checking whether the user asked for HELP Info...
648 if (om.valueEquals("help", "true"))
649 {
650 String header = "Usage ";
651 header.append(argv[0]);
652 j.alex 1.2 header.append(" -parameters -n [namespace] -c [classname] ");
653 header.append(" -clientId [clientId] -pidFile [pidFile] ");
654 header.append(" -clientLog [clientLog]");
655 String trailer = "Assumes localhost:5988 if host not specified";
656 trailer.append("\nHost may be of the form name or name:port");
657 trailer.append("\nPort 5988 assumed if port number missing.");
658 om.printOptionsHelpTxt(header, trailer);
659 exit(0);
660 } */
661
662 try
663 {
664 //
665 // Timer Start.
666 //
667 tmsc.startTime();
668
669 tmsc.logInfo(clientId, clientPid, status, pidFile);
670
671 //
672 // connect the client.
673 j.alex 1.2 //
674 CIMClient* client = new CIMClient();
675
676 sprintf(pid_str, "%d", clientPid);
677
678 stopClient = String::EMPTY;
679 stopClient.append(FileSystem::extractFilePath(pidFile));
680 stopClient.append("STOP_");
681 stopClient.append(pid_str);
682
683 //
684 // This loop executes till the client gets stop signal from
685 // controller.
686 //
687 while (!quit)
688 {
689 if (FileSystem::exists(stopClient))
690 {
691 if (verboseTest)
692 {
693 String mes("Ending client. ");
694 j.alex 1.2 tmsc.errorLog(clientPid, clientLog, mes);
695 }
696 break;
697 }
698
699 if (!verboseTest)
700 {
701 #ifdef PEGASUS_OS_TYPE_WINDOWS
702 freopen("nul","w",stdout);
703 #else
704 freopen("/dev/null","w",stdout);
705 #endif
706 }
707
708 if (!connectedToHost)
709 {
710 try
711 {
712 tmsc.connectClient( client, host, portNumber, userName,
713 password, useSSL, timeout, verboseTest);
714 connectedToHost = true;
715 j.alex 1.2
716 //
717 // Client has successfully connected to server.
718 // update status if previously not Success.
719 //
720 if (status != CLIENT_PASS)
721 {
722 status = CLIENT_PASS;
723 tmsc.logInfo(clientId, clientPid, status, pidFile);
724 }
725 }
726 catch (CannotConnectException)
727 {
728 status = CLIENT_UNKNOWN;
729 tmsc.logInfo(clientId, clientPid, status, pidFile);
730 connectedToHost = false;
731 }
732 catch (CIMException &e)
733 {
734 status = CLIENT_UNKNOWN;
735 tmsc.logInfo(clientId, clientPid, status, pidFile);
736 j.alex 1.2 connectedToHost = false;
737 String mes(e.getMessage());
738 tmsc.errorLog(clientPid, clientLog, mes);
739 }
740 catch (Exception &e)
741 {
742 status = CLIENT_UNKNOWN;
743 tmsc.logInfo(clientId, clientPid, status, pidFile);
744 connectedToHost = false;
745 String mes(e.getMessage());
746 tmsc.errorLog(clientPid, clientLog, mes);
747 }
748 catch (...)
749 {
750 status = CLIENT_UNKNOWN;
751 tmsc.logInfo(clientId, clientPid, status, pidFile);
752 connectedToHost = false;
753 String mes("Error connencting to server in ModleWalk");
754 mes.append(" client ");
755 tmsc.errorLog(clientPid, clientLog,mes);
756 }
757 j.alex 1.2 }/* end of if (!connectedToHost). */
758 iteration++;
759 totalCount++;
760 if (connectedToHost)
761 {
762 try
763 {
764 Array<CIMNamespaceName> nameSpacesArray;
765
766 //
767 // Enumerate all the namespaces here.
768 //
769 nameSpacesArray = getNameSpaces(
770 tmsc,
771 client,
772 om,
773 clientPid,
774 clientLog,
775 clientId,
776 status,
777 pidFile);
778 j.alex 1.2
779 //
780 // Enumerate all qualifiers in the namespaces.
781 //
782 enumerateAllQualifiers(
783 tmsc,
784 client,
785 nameSpacesArray,
786 clientPid,
787 clientLog,
788 clientId,
789 status,
790 pidFile);
791
792 //
793 // Enumerate all the class related info here.
794 //
795 enumerateClassRelatedInfo(
796 tmsc,
797 client,
798 om,
799 j.alex 1.2 nameSpacesArray,
800 clientPid,
801 clientLog,
802 clientId,
803 status,
804 pidFile);
805
806 successCount++;
807 }
808 //
809 // This specail catch block in needed so that we will know if
810 // the connenction was lost. We then connect on the next time
811 // through the loop.
812 //
813
814 catch (CannotConnectException)
815 {
816 status = CLIENT_UNKNOWN;
817 tmsc.logInfo(clientId, clientPid, status, pidFile);
818 connectedToHost = false;
819 }
820 j.alex 1.2 catch (CIMException &cimE)
821 {
822 status = CLIENT_FAIL;
823 tmsc.logInfo(clientId, clientPid, status, pidFile);
824 String mes(cimE.getMessage());
825 tmsc.errorLog(clientPid, clientLog, mes);
826 }
827 catch (Exception &exp)
828 {
829 status = CLIENT_FAIL;
830 tmsc.logInfo(clientId, clientPid, status, pidFile);
831 String mes(exp.getMessage());
832 tmsc.errorLog(clientPid, clientLog, mes);
833 }
834 catch (...)
835 {
836 status = CLIENT_FAIL;
837 tmsc.logInfo(clientId, clientPid, status, pidFile);
838 String mes("Unknown Error during ModelWalk Execution");
839 tmsc.errorLog(clientPid, clientLog, mes);
840 }
841 j.alex 1.2
842 nextCheck = tmsc.checkTime();
843 if (nextCheck)
844 {
845 tmsc.logInfo(clientId, clientPid, status, pidFile);
846 nextCheck = false;
847 }
848
849 //
850 // If verbose is set, log success percentage for every 100
851 // iterations. If verbose is not set, log success percentage
852 // for every 10000 iterations.
853 //
854 if (verboseTest)
855 {
856 if (iteration == 100)
857 {
858 tmsc.logErrorPercentage(
859 successCount,
860 totalCount,
861 clientPid,
862 j.alex 1.2 clientLog,
863 clientName);
864 iteration = 0;
865 }
866 }
867 else
868 {
869 if (iteration == 1000)
870 {
871 tmsc.logErrorPercentage(
872 successCount,
873 totalCount,
874 clientPid,
875 clientLog,
876 clientName);
877 iteration = 0;
878 }
879 }
880 }
881 } // end of while (!quit).
882 }
883 j.alex 1.2 catch (Exception &exp)
884 {
885 String expStr("Exception in ModelWalk client, causing it to exit: ");
886 expStr.append(exp.getMessage());
887 tmsc.errorLog(clientPid, clientLog, expStr);
888
889 if (verboseTest)
890 {
891 PEGASUS_STD(cerr) << expStr.getCString() << PEGASUS_STD(endl);
892 }
893 }
894 catch (...)
895 {
896 String expStr("General Exception in ModelWalk, causing it to exit");
897 tmsc.errorLog(clientPid, clientLog, expStr);
898
899 if (verboseTest)
900 {
901 PEGASUS_STD(cerr) << expStr.getCString() << PEGASUS_STD(endl);
902 }
903 }
904 j.alex 1.2
905 //
906 // One second delay before shutdown.
907 //
908 #ifndef PEGASUS_OS_TYPE_WINDOWS
909 sleep(1);
910 #else
911 Sleep(1000);
912 #endif
913 if (FileSystem::exists(stopClient))
914 {
915 //
916 // Remove STOP file here.
917 //
918 FileSystem::removeFile(stopClient);
919 }
920
921 if (verboseTest)
922 {
923 errorInfo.clear();
924 errorInfo.append("+++++ TestModelWalkStressClient Terminated ");
925 j.alex 1.2 errorInfo.append("Normally +++++");
926 tmsc.errorLog(clientPid, clientLog, errorInfo);
927 errorInfo.clear();
928 }
929 return 0;
930 }
|