searcher/tsrc/robustnesstest/inc/crobustnesstest.h
changeset 0 671dee74050a
equal deleted inserted replaced
-1:000000000000 0:671dee74050a
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CROBUSTNESSTEST_H_
       
    20 #define CROBUSTNESSTEST_H_
       
    21 
       
    22 #define PROVIDE_TESTING_UTILITY
       
    23 
       
    24 #include <e32base.h>
       
    25 #include "CProcessMonitor.h"
       
    26 #include "CLog.h"
       
    27 
       
    28 class CStressWorker; 
       
    29 class CRobustnessTest; 
       
    30 class CTicker;
       
    31 
       
    32 class MRobustnessTestObserver 
       
    33 	{
       
    34 public: 
       
    35 	virtual void FinishedL( CRobustnessTest& aTest ) = 0; 
       
    36 	};
       
    37 
       
    38 /**
       
    39  * Robustness test is designed to set heavy stress on cpix 
       
    40  * services over long period of time and record the results. 
       
    41  * 
       
    42  * To stress the search server, two indexers are provided for
       
    43  * usage, where the other is the 'normal' index and the other
       
    44  * is the 'busy' index. There is one thread doing indexing
       
    45  * and another performing searching on the normal index. 
       
    46  * There are three threads for both indexing and searching 
       
    47  * for the busy index. As an addition to these, there is one
       
    48  * multisearcher, which searchers over both normal and busy 
       
    49  * indeces. 
       
    50  * 
       
    51  * The time period of robustness test is divided into 'ticks',
       
    52  * where during each tick one entry to the test record is added. 
       
    53  * The record will contain information around average and peak 
       
    54  * memory usages in the server, about the index sizes and 
       
    55  * operation counts and times. If the search server closes or 
       
    56  * panics the test is terminated and the server exit/panic code 
       
    57  * is added to the test report.
       
    58  */
       
    59 class CRobustnessTest : public CBase, 
       
    60 						public MProcessMonitorObserver
       
    61 	{
       
    62 public: 
       
    63 	
       
    64 	CRobustnessTest( CConsoleBase& iConsole, MRobustnessTestObserver& aObserver ); 
       
    65 
       
    66 	void ConstructL(); 
       
    67 
       
    68 	void StartL( ); 
       
    69 
       
    70 	~CRobustnessTest(); 
       
    71 	
       
    72 protected: 
       
    73 	
       
    74 	TInt ReadNumberL( TPtrC8& left );
       
    75 	
       
    76 	void ConfigureL(); 
       
    77 	
       
    78 public: // From process monitor observer
       
    79 	
       
    80 	virtual void ProcessFinished( CProcessMonitor& aMonitor, 
       
    81 							      TExitType aExitType ,
       
    82 							      TExitCategoryName aCategory,
       
    83 							      TInt aExitReason ); 
       
    84 
       
    85 	virtual void Failed( CProcessMonitor& aMonitor,
       
    86 					     TInt aError ); 
       
    87 	
       
    88 public: // For Periodic
       
    89 	
       
    90 	/**
       
    91 	 * Updates robustness test record and requests the server
       
    92 	 * to update its record. If this is the last tick; it will finalize
       
    93 	 * the records and terminate the test. 
       
    94 	 */
       
    95 	virtual void Tick();
       
    96 	
       
    97 	/**
       
    98 	 * Used as a parameter for CPeriodic. Calls CPeriodic::Tick
       
    99 	 */
       
   100 	static TInt CallTick(TAny* ptr); 
       
   101 
       
   102 protected: 
       
   103 
       
   104 	/**
       
   105 	 * Combines the temporary robustness record and the search 
       
   106 	 * server record to form the final robustness test record.
       
   107 	 */
       
   108 	void FinalizeRecordsL(); 
       
   109 
       
   110 	/**
       
   111 	 * Formats a record row so that each member of the given 
       
   112 	 * aStats array is formatted nicely on its own column.
       
   113 	 */
       
   114 	void AppendRecordL( RPointerArray<HBufC8>& aStats ); 
       
   115 
       
   116 	/**
       
   117 	 * Requests the record labels from the stress worker object,
       
   118 	 * and forms a row having the labels in nicely formatted form. 
       
   119 	 */
       
   120 	void AddStatsLabelsL(); 
       
   121 	
       
   122 	/**
       
   123 	 * Requests the record values from the stress worker object,
       
   124 	 * and forms a row having the labels in nicely formatted form. 
       
   125 	 */
       
   126 	void AddStatsEntryL(); 
       
   127 	
       
   128 	/**
       
   129 	 * Terminates the test and notifies the test observer that the 
       
   130 	 * test has finished. At the moment the observer is called, this
       
   131 	 * object has no more active components alive (e.g. threads, active
       
   132 	 * objects) and it can be freely destroyed. 
       
   133 	 */
       
   134 	void FinishL(); 
       
   135 
       
   136 private: // Infra
       
   137 
       
   138 	CConsoleBase& iConsole;
       
   139 
       
   140 	RFs iFs; 
       
   141 	
       
   142 	CLog* iOwnedLog; 
       
   143 
       
   144 	TShortTimeStampLog iLog;
       
   145 
       
   146 private: // Testing utilities
       
   147 
       
   148 	MRobustnessTestObserver& iObserver;
       
   149 	
       
   150 	CPeriodic* iPeriodic; 
       
   151 	
       
   152 	CProcessMonitor* iSearchServerMonitor; 
       
   153 
       
   154 	CStressWorker* iStressWorker; 
       
   155 	
       
   156 private: // State
       
   157 	
       
   158 	TInt iTick;
       
   159 	
       
   160 private: // Configuration
       
   161 
       
   162 	TInt iTickLengthSeconds; 
       
   163 
       
   164 	TInt iTickCount;
       
   165 
       
   166 	TInt iPreIndex; 
       
   167 
       
   168 	TInt iIndexAverageItems; 
       
   169 
       
   170 	TBool iIndexingEnabled; 
       
   171 
       
   172 	TBool iDeletesEnabled; 
       
   173 
       
   174 	TBool iSearchersEnabled;
       
   175 	
       
   176 	TBool iCancellingEnabled;
       
   177 
       
   178 	TInt iIndexerSleep; 
       
   179 
       
   180 	TInt iSearcherSleep; 
       
   181 
       
   182 	};
       
   183 
       
   184 #endif /* CROBUSTNESSTEST_H_ */