1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.actions.loadtest;
14
15 import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
16 import com.eviware.soapui.impl.wsdl.support.HelpUrls;
17 import com.eviware.soapui.model.settings.Settings;
18 import com.eviware.soapui.settings.HttpSettings;
19 import com.eviware.soapui.support.UISupport;
20 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21 import com.eviware.x.form.XFormDialog;
22 import com.eviware.x.form.XFormField;
23 import com.eviware.x.form.XFormFieldListener;
24 import com.eviware.x.form.support.ADialogBuilder;
25 import com.eviware.x.form.support.AField;
26 import com.eviware.x.form.support.AForm;
27 import com.eviware.x.form.support.APage;
28 import com.eviware.x.form.support.AField.AFieldType;
29
30 /***
31 * Displays the LoadTest Options dialog
32 *
33 * @author Ole.Matzura
34 */
35
36 public class LoadTestOptionsAction extends AbstractSoapUIAction<WsdlLoadTest>
37 {
38 public static final String SOAPUI_ACTION_ID = "LoadTestOptionsAction";
39 private XFormDialog dialog;
40
41 public LoadTestOptionsAction()
42 {
43 super( "Options", "Sets options for this LoadTest" );
44 }
45
46 public void perform( WsdlLoadTest loadTest, Object param )
47 {
48 if( dialog == null )
49 buildDialog();
50
51 dialog.setIntValue( SettingsForm.THREAD_STARTUP_DELAY, loadTest.getStartDelay() );
52 dialog.setBooleanValue( SettingsForm.RESET_STATISTICS, loadTest.getResetStatisticsOnThreadCountChange() );
53 dialog.setBooleanValue( SettingsForm.CALC_TPS, loadTest.getCalculateTPSOnTimePassed() );
54 dialog.setIntValue( SettingsForm.SAMPLE_INTERVAL, ( int )loadTest.getSampleInterval() );
55 dialog.setBooleanValue( SettingsForm.DISABLE_HISTORY, loadTest.getHistoryLimit() == 0 );
56 dialog.setIntValue( SettingsForm.MAX_ASSERTIONS, ( int )loadTest.getMaxAssertionErrors() );
57 dialog.setBooleanValue( SettingsForm.CANCEL_RUNNING, loadTest.getCancelOnReachedLimit() );
58 dialog.setIntValue( SettingsForm.STRATEGY_INTERVAL, ( int )loadTest.getStrategyInterval() );
59 dialog.setBooleanValue( SettingsForm.CANCEL_EXCESSIVE, loadTest.getCancelExcessiveThreads() );
60 dialog.setBooleanValue( SettingsForm.TESTSTEP_STATISTICS, loadTest.getUpdateStatisticsPerTestStep() );
61
62 Settings settings = loadTest.getSettings();
63
64 dialog.setBooleanValue( SettingsForm.INCLUDE_REQUEST, settings
65 .getBoolean( HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN ) );
66 dialog.setBooleanValue( SettingsForm.INCLUDE_RESPONSE, settings
67 .getBoolean( HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN ) );
68 dialog.setBooleanValue( SettingsForm.CLOSE_CONNECTIONS, settings.getBoolean( HttpSettings.CLOSE_CONNECTIONS ) );
69
70 dialog.setValue( LogForm.LOG_FOLDER, loadTest.getStatisticsLogFolder() );
71 dialog.setIntValue( LogForm.LOG_INTERVAL, ( int )loadTest.getStatisticsLogInterval() );
72 dialog.setBooleanValue( LogForm.LOG_ON_THREADCOUNT_CHANGE, loadTest.getLogStatisticsOnThreadChange() );
73
74 if( dialog.show() && !loadTest.isRunning() )
75 {
76 try
77 {
78 loadTest.setStartDelay( dialog.getIntValue( SettingsForm.THREAD_STARTUP_DELAY, loadTest.getStartDelay() ) );
79 loadTest.setResetStatisticsOnThreadCountChange( dialog.getBooleanValue( SettingsForm.RESET_STATISTICS ) );
80 loadTest.setCalculateTPSOnTimePassed( dialog.getBooleanValue( SettingsForm.CALC_TPS ) );
81 loadTest.setSampleInterval( dialog.getIntValue( SettingsForm.SAMPLE_INTERVAL, ( int )loadTest
82 .getSampleInterval() ) );
83 loadTest.setHistoryLimit( dialog.getBooleanValue( SettingsForm.DISABLE_HISTORY ) ? 0 : -1 );
84 loadTest.setMaxAssertionErrors( dialog.getIntValue( SettingsForm.MAX_ASSERTIONS, 1000 ) );
85 loadTest.setCancelOnReachedLimit( dialog.getBooleanValue( SettingsForm.CANCEL_RUNNING ) );
86 loadTest.setStrategyInterval( dialog.getIntValue( SettingsForm.STRATEGY_INTERVAL,
87 WsdlLoadTest.DEFAULT_STRATEGY_INTERVAL ) );
88 loadTest.setCancelExcessiveThreads( dialog.getBooleanValue( SettingsForm.CANCEL_EXCESSIVE ) );
89 loadTest.setUpdateStatisticsPerTestStep( dialog.getBooleanValue( SettingsForm.TESTSTEP_STATISTICS ) );
90
91 settings.setBoolean( HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN, dialog
92 .getBooleanValue( SettingsForm.INCLUDE_REQUEST ) );
93 settings.setBoolean( HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN, dialog
94 .getBooleanValue( SettingsForm.INCLUDE_RESPONSE ) );
95 settings.setBoolean( HttpSettings.CLOSE_CONNECTIONS, dialog
96 .getBooleanValue( SettingsForm.CLOSE_CONNECTIONS ) );
97
98 loadTest.setLogStatisticsOnThreadChange( dialog.getBooleanValue( LogForm.LOG_ON_THREADCOUNT_CHANGE ) );
99 loadTest.setStatisticsLogFolder( dialog.getValue( LogForm.LOG_FOLDER ) );
100 loadTest.setStatisticsLogInterval( dialog.getIntValue( LogForm.LOG_INTERVAL, ( int )loadTest
101 .getStatisticsLogInterval() ) );
102 }
103 catch( NumberFormatException ex )
104 {
105 ex.printStackTrace();
106 }
107 }
108 }
109
110 private void buildDialog()
111 {
112 dialog = ADialogBuilder.buildTabbedDialog( WizardForm.class, null );
113 dialog.getFormField( SettingsForm.DISABLE_HISTORY ).addFormFieldListener( new XFormFieldListener()
114 {
115 public void valueChanged( XFormField sourceField, String newValue, String oldValue )
116 {
117 dialog.getFormField( SettingsForm.SAMPLE_INTERVAL ).setEnabled( !Boolean.parseBoolean( newValue ) );
118 }
119 } );
120 }
121
122 @AForm( description = "Set options for this LoadTest", name = "LoadTest Options", helpUrl = HelpUrls.LOADTESTOPTIONS_HELP_URL, icon = UISupport.TOOL_ICON_PATH )
123 private interface WizardForm
124 {
125 @APage( name = "Settings" )
126 public final static SettingsForm INPUT = null;
127
128 @APage( name = "Statistics Log" )
129 public final static LogForm LogForm = null;
130 }
131
132 @AForm( name = "LoadTest Options", description = "", helpUrl = HelpUrls.LOADTESTOPTIONS_HELP_URL, icon = UISupport.OPTIONS_ICON_PATH )
133 private interface SettingsForm
134 {
135 @AField( name = "Thread Startup Delay", description = "The delay before starting a thread in ms", type = AFieldType.INT )
136 public final static String THREAD_STARTUP_DELAY = "Thread Startup Delay";
137
138 @AField( name = "Reset Statistics", description = "when the number of threads changes", type = AFieldType.BOOLEAN )
139 public final static String RESET_STATISTICS = "Reset Statistics";
140
141 @AField( name = "Calculate TPS/BPS", description = "based on actual time passed", type = AFieldType.BOOLEAN )
142 public final static String CALC_TPS = "Calculate TPS/BPS";
143
144 @AField( name = "TestStep Statistics", description = "update statistics every TestStep", type = AFieldType.BOOLEAN )
145 public final static String TESTSTEP_STATISTICS = "TestStep Statistics";
146
147 @AField( name = "Include Request Write", description = "in calculated time", type = AFieldType.BOOLEAN )
148 public final static String INCLUDE_REQUEST = "Include Request Write";
149
150 @AField( name = "Include Response Read", description = "in calculated time", type = AFieldType.BOOLEAN )
151 public final static String INCLUDE_RESPONSE = "Include Response Read";
152
153 @AField( name = "Close Connections", description = "between each request", type = AFieldType.BOOLEAN )
154 public final static String CLOSE_CONNECTIONS = "Close Connections";
155
156 @AField( name = "Sample Interval", description = "statistics sample interval in milliseconds", type = AFieldType.INT )
157 public final static String SAMPLE_INTERVAL = "Sample Interval";
158
159 @AField( name = "Disable History", description = "to preserve memory (will disable diagrams)", type = AFieldType.BOOLEAN )
160 public final static String DISABLE_HISTORY = "Disable History";
161
162 @AField( name = "Max Assertions in Log", description = "the maximum number of assertion errors to keep in log (to preserve memory)", type = AFieldType.INT )
163 public final static String MAX_ASSERTIONS = "Max Assertions in Log";
164
165 @AField( name = "Cancel Running", description = "Cancel running TestCases when Limit has been reached", type = AFieldType.BOOLEAN )
166 public final static String CANCEL_RUNNING = "Cancel Running";
167
168 @AField( name = "Cancel Excessive", description = "Cancel excessive threads when ThreadCount decreases", type = AFieldType.BOOLEAN )
169 public final static String CANCEL_EXCESSIVE = "Cancel Excessive";
170
171 @AField( name = "Strategy Interval", description = "LoadTest Strategy application interval in milliseconds", type = AFieldType.INT )
172 public final static String STRATEGY_INTERVAL = "Strategy Interval";
173
174 }
175
176 @AForm( name = "Logging", description = "", helpUrl = HelpUrls.LOADTESTOPTIONS_HELP_URL, icon = UISupport.OPTIONS_ICON_PATH )
177 private interface LogForm
178 {
179 @AField( name = "Log Folder", description = "The folder in which to create log files", type = AFieldType.FOLDER )
180 public final static String LOG_FOLDER = "Log Folder";
181
182 @AField( name = "Log Interval", description = "The log interval in milliseconds, 0 only logs at end", type = AFieldType.INT )
183 public final static String LOG_INTERVAL = "Log Interval";
184
185 @AField( name = "Log on ThreadCount change", description = "Log every time the number of threads changes", type = AFieldType.BOOLEAN )
186 public final static String LOG_ON_THREADCOUNT_CHANGE = "Log on ThreadCount change";
187 }
188 }