Skip to content

Commit 8bb7f74

Browse files
Zakaria-Kofirozkofiro
andauthored
Tank Debugger: separate sleep/think time controls and fix debugger logging (#449)
* feat: separate sleep/think time controls and fix debugger logging * add log4j to parent pom + update child poms --------- Co-authored-by: zkofiro <zakaria_kofiro@intuit.com>
1 parent b768376 commit 8bb7f74

File tree

8 files changed

+89
-16
lines changed

8 files changed

+89
-16
lines changed

agent/http_client_4/src/main/java/com/intuit/tank/httpclient4/TankHttpClient4.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ public TankHttpClient4() {
9393
context.setUserToken(UUID.randomUUID());
9494
context.setCookieStore(new BasicCookieStore());
9595
context.setRequestConfig(requestConfig);
96-
97-
LOG.info("TANK_CONNECTION_LEAK_FIX_V2: TankHttpClient4 initialized with COMPREHENSIVE LEAK FIX (EntityUtils + explicit close)");
9896
}
9997

10098
public Object createHttpClient() {

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<version.spring-webmvc>6.2.11</version.spring-webmvc>
5353
<version.wiremock>3.13.1</version.wiremock>
5454
<version.jackson>2.19.2</version.jackson>
55+
<version.log4j>2.25.3</version.log4j>
5556

5657
<!-- maven-compiler-plugin -->
5758
<version.compiler.plugin>3.14.0</version.compiler.plugin>
@@ -529,7 +530,7 @@
529530
<dependency>
530531
<groupId>org.apache.logging.log4j</groupId>
531532
<artifactId>log4j-core</artifactId>
532-
<version>2.25.3</version>
533+
<version>${version.log4j}</version>
533534
</dependency>
534535

535536
<dependency>

tools/agent_debugger/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,22 @@
3030
</dependency>
3131
</dependencies>
3232

33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-compiler-plugin</artifactId>
38+
<configuration>
39+
<annotationProcessorPaths>
40+
<path>
41+
<groupId>org.apache.logging.log4j</groupId>
42+
<artifactId>log4j-core</artifactId>
43+
<version>${version.log4j}</version>
44+
</path>
45+
</annotationProcessorPaths>
46+
</configuration>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
3351
</project>

tools/agent_debugger/src/main/java/com/intuit/tank/tools/debugger/ActionComponents.java

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
import java.awt.FlowLayout;
1717
import java.awt.Insets;
18+
import java.io.File;
19+
import java.io.FileInputStream;
20+
import java.util.Properties;
1821

1922
import javax.swing.JCheckBox;
2023
import javax.swing.JComboBox;
@@ -34,7 +37,12 @@ public class ActionComponents implements ScriptChangedListener {
3437
private JMenuBar menuBar;
3538
private JPopupMenu popupMenu;
3639
private ActionProducer actions;
37-
private JCheckBox runTimingStepsCB;
40+
private static final String DEBUGGER_PROPERTIES = "debugger.properties";
41+
private static final String PROP_RUN_SLEEP_STEPS = "run.sleep.steps";
42+
private static final String PROP_RUN_THINK_STEPS = "run.think.steps";
43+
44+
private JCheckBox runSleepStepsCB;
45+
private JCheckBox runThinkStepsCB;
3846
private JLabel titleLabel;
3947

4048
/**
@@ -46,7 +54,9 @@ public class ActionComponents implements ScriptChangedListener {
4654
public ActionComponents(boolean standalone, JComboBox testPlanChooser, JComboBox<TankClientChoice> tankClientChooser, ActionProducer actions) {
4755
super();
4856
this.actions = actions;
49-
runTimingStepsCB = new JCheckBox("Run Timing Steps", false);
57+
boolean[] defaults = loadTimingStepDefaults();
58+
runSleepStepsCB = new JCheckBox("Run Sleep Steps", defaults[0]);
59+
runThinkStepsCB = new JCheckBox("Run Think Steps", defaults[1]);
5060
createMenuBar(actions, standalone);
5161
createToolBar(testPlanChooser, tankClientChooser, actions, standalone);
5262
createPopupMenu();
@@ -216,10 +226,17 @@ private void createToolBar(JComboBox testPlanChooser, JComboBox<TankClientChoice
216226
}
217227

218228
/**
219-
* @return the runTimingStepsCB
229+
* @return the runSleepStepsCB
230+
*/
231+
public JCheckBox getRunSleepStepsCB() {
232+
return runSleepStepsCB;
233+
}
234+
235+
/**
236+
* @return the runThinkStepsCB
220237
*/
221-
public JCheckBox getRunTimingStepsCB() {
222-
return runTimingStepsCB;
238+
public JCheckBox getRunThinkStepsCB() {
239+
return runThinkStepsCB;
223240
}
224241

225242
/**
@@ -264,7 +281,8 @@ private void createMenuBar(ActionProducer actions, boolean standalone) {
264281
menuBar.add(runMenu);
265282

266283
JMenu actionsMenu = new JMenu("Actions");
267-
actionsMenu.add(runTimingStepsCB);
284+
actionsMenu.add(runSleepStepsCB);
285+
actionsMenu.add(runThinkStepsCB);
268286
actionsMenu.addSeparator();
269287
actionsMenu.add(actions.getSaveReqResponseAction());
270288
actionsMenu.add(actions.getSaveLogAction());
@@ -278,4 +296,25 @@ public void setCurrentTitle(String string) {
278296
this.titleLabel.setText(string);
279297
}
280298

299+
/**
300+
* Load timing step defaults from debugger.properties
301+
* @return boolean array [runSleepSteps, runThinkSteps]
302+
*/
303+
private boolean[] loadTimingStepDefaults() {
304+
boolean runSleep = false;
305+
boolean runThink = false;
306+
File f = new File(DEBUGGER_PROPERTIES);
307+
if (f.exists()) {
308+
try (FileInputStream in = new FileInputStream(f)) {
309+
Properties props = new Properties();
310+
props.load(in);
311+
runSleep = Boolean.parseBoolean(props.getProperty(PROP_RUN_SLEEP_STEPS, "false"));
312+
runThink = Boolean.parseBoolean(props.getProperty(PROP_RUN_THINK_STEPS, "false"));
313+
} catch (Exception e) {
314+
// Use defaults if properties can't be loaded
315+
}
316+
}
317+
return new boolean[] { runSleep, runThink };
318+
}
319+
281320
}

tools/agent_debugger/src/main/java/com/intuit/tank/tools/debugger/AgentDebuggerFrame.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,12 @@ public void addScriptChangedListener(ScriptChangedListener l) {
324324
scriptChangedListeners.add(l);
325325
}
326326

327-
public boolean runTimingSteps() {
328-
return actionComponents.getRunTimingStepsCB().isSelected();
327+
public boolean runSleepSteps() {
328+
return actionComponents.getRunSleepStepsCB().isSelected();
329+
}
330+
331+
public boolean runThinkSteps() {
332+
return actionComponents.getRunThinkStepsCB().isSelected();
329333
}
330334

331335
/**

tools/agent_debugger/src/main/java/com/intuit/tank/tools/debugger/DebuggerFlowController.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ public boolean shouldExecute(TestStepContext context) {
118118
context.setTestStep(debuggerFrame.getStep(context.getTestStep().getStepIndex()));
119119
TestStep step = context.getTestStep();
120120
if (!toSkip.contains(context.getTestStep().getStepIndex())) {// move if skiplist does not contain line
121-
if (debuggerFrame.runTimingSteps()) {
122-
return true;
123-
} else if (!(step instanceof SleepTimeStep) && !(step instanceof ThinkTimeStep)) {
121+
if (step instanceof SleepTimeStep) {
122+
return debuggerFrame.runSleepSteps();
123+
} else if (step instanceof ThinkTimeStep) {
124+
return debuggerFrame.runThinkSteps();
125+
} else {
124126
return true;
125127
}
126128
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
#Add any instances that should be included in the tank selection dropdown.
22
tank.instance.TANK=http://tank-url
3+
4+
# Timing step execution settings
5+
# Set to true to run sleep/think steps, false to skip them
6+
run.sleep.steps=false
7+
run.think.steps=false

tools/agent_debugger/src/test/java/com/intuit/tank/tools/debugger/ActionComponentsTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ public void testMenuBar() {
5656
}
5757

5858
@Test
59-
public void testRunTimingStepsCB() {
60-
JCheckBox jCheckBox = actionComponents.getRunTimingStepsCB();
59+
public void testRunSleepStepsCB() {
60+
JCheckBox jCheckBox = actionComponents.getRunSleepStepsCB();
61+
assertNotNull(jCheckBox);
62+
}
63+
64+
@Test
65+
public void testRunThinkStepsCB() {
66+
JCheckBox jCheckBox = actionComponents.getRunThinkStepsCB();
6167
assertNotNull(jCheckBox);
6268
}
6369

0 commit comments

Comments
 (0)