Skip to content

Commit b8c5ded

Browse files
Merge pull request #32 from kevinmcgoldrick/master
Update Version to 2.2.4
2 parents 4fef7f5 + a4bbda8 commit b8c5ded

File tree

136 files changed

+1048
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1048
-544
lines changed

agent/agent_common/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
<parent>
66
<groupId>com.intuit.tank</groupId>
77
<artifactId>agent-parent</artifactId>
8-
<version>2.2.3</version>
8+
<version>2.2.4</version>
99
</parent>
1010

1111
<artifactId>agent-common</artifactId>
1212

1313
<packaging>jar</packaging>
14-
<name>Intuit Tank Agent (apiharness)</name>
14+
<name>Intuit Tank Agent Common</name>
1515

1616

1717
<dependencies>
@@ -42,6 +42,11 @@
4242
<groupId>jdom</groupId>
4343
<artifactId>jdom</artifactId>
4444
</dependency>
45+
46+
<dependency>
47+
<groupId>xml-apis</groupId>
48+
<artifactId>xml-apis</artifactId>
49+
</dependency>
4550

4651
</dependencies>
4752

agent/agent_common/src/main/java/com/intuit/tank/http/BaseRequest.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
public abstract class BaseRequest {
1515

16-
public static final String CONTENT_TYPE_MULTIPART = "multipart/form-data";
17-
private static final char NEWLINE = '\n';
18-
static Logger logger = LogManager.getLogger(BaseRequest.class);
16+
static Logger LOG = LogManager.getLogger(BaseRequest.class);
1917

18+
public static final String CONTENT_TYPE_MULTIPART = "multipart/form-data";
19+
private static final char NEWLINE = '\n';
20+
2021
protected BaseResponse response = null;
2122
private TankHttpLogger logUtil;
2223

@@ -152,6 +153,17 @@ public void doDelete(BaseResponse response) {
152153
httpclient.doDelete(this);
153154
}
154155

156+
/**
157+
* Execute the options request.
158+
*
159+
* @param response
160+
* The response object to populate
161+
*/
162+
public void doOptions(BaseResponse response) {
163+
this.response = response;
164+
requestUrl = TankHttpUtil.buildUrl(protocol, host, port, path, urlVariables).toString();
165+
httpclient.doOptions(this);
166+
}
155167
/**
156168
* Execute the POST.
157169
*/
@@ -289,11 +301,11 @@ public void logRequest(String url, String body, String method, Map<String, Strin
289301
sb.append("REQUEST BODY: " + body).append(NEWLINE);
290302
}
291303
this.logMsg = sb.toString();
292-
logger.debug("******** REQUEST *********");
293-
logger.debug(this.logMsg);
304+
LOG.debug("******** REQUEST *********");
305+
LOG.debug(this.logMsg);
294306

295307
} catch (Exception ex) {
296-
logger.error("Unable to log request", ex);
308+
LOG.error("Unable to log request", ex);
297309
}
298310
}
299311

agent/agent_common/src/main/java/com/intuit/tank/http/TankHttpClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ public interface TankHttpClient {
2626
*/
2727
public void doDelete(BaseRequest request);
2828

29+
/**
30+
* Execute the options request.
31+
*
32+
* @param response
33+
* The response object to populate
34+
*/
35+
public void doOptions(BaseRequest request);
36+
2937
/**
3038
* Execute the POST.
3139
*/

agent/agent_standalone/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.intuit.tank</groupId>
77
<artifactId>agent-parent</artifactId>
8-
<version>2.2.3</version>
8+
<version>2.2.4</version>
99
</parent>
1010

1111
<artifactId>agent-standalone</artifactId>

agent/agent_standalone_pkg/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.intuit.tank</groupId>
77
<artifactId>agent-parent</artifactId>
8-
<version>2.2.3</version>
8+
<version>2.2.4</version>
99
</parent>
1010

1111
<artifactId>agent-standalone-pkg</artifactId>
@@ -40,7 +40,6 @@
4040
<finalName>agent-standalone</finalName>
4141
<descriptors>
4242
<descriptor>src/main/assembly/assembly.xml</descriptor>
43-
<descriptor>src/main/assembly/zip-assembly.xml</descriptor>
4443
</descriptors>
4544
<archive>
4645
<manifest>

agent/agent_startup/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.intuit.tank</groupId>
77
<artifactId>agent-parent</artifactId>
8-
<version>2.2.3</version>
8+
<version>2.2.4</version>
99
</parent>
1010

1111
<artifactId>agent-startup</artifactId>

agent/agent_startup_pkg/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.intuit.tank</groupId>
77
<artifactId>agent-parent</artifactId>
8-
<version>2.2.3</version>
8+
<version>2.2.4</version>
99
</parent>
1010

1111
<artifactId>agent-startup-pkg</artifactId>

agent/apiharness/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.intuit.tank</groupId>
77
<artifactId>agent-parent</artifactId>
8-
<version>2.2.3</version>
8+
<version>2.2.4</version>
99
</parent>
1010

1111
<artifactId>agent</artifactId>

agent/apiharness/src/main/java/com/intuit/tank/harness/APIMonitor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.intuit.tank.CloudServiceClient;
2222
import com.intuit.tank.api.model.v1.cloud.CloudVmStatus;
23+
import com.intuit.tank.api.model.v1.cloud.VMStatus;
2324
import com.intuit.tank.api.model.v1.cloud.ValidationStatus;
2425
import com.intuit.tank.harness.logging.LogUtil;
2526
import com.intuit.tank.reporting.api.TPSInfoContainer;
@@ -122,11 +123,13 @@ public static void setDoMonitor(boolean monitor) {
122123
public synchronized static void setJobStatus(JobStatus jobStatus) {
123124
if (status.getJobStatus() != JobStatus.Completed) {
124125
try {
126+
VMStatus vmStatus = (jobStatus.equals(JobStatus.Stopped)) ? VMStatus.stopping : status.getVmStatus();
127+
vmStatus = (jobStatus.equals(JobStatus.Completed)) ? VMStatus.terminated : vmStatus;
125128
WatsAgentStatusResponse stats = APITestHarness.getInstance().getStats();
126129
Date endTime = (jobStatus == JobStatus.Completed) ? new Date() : status
127130
.getEndTime();
128131
status = new CloudVmStatus(status.getInstanceId(), status.getJobId(), status.getSecurityGroup(),
129-
jobStatus, status.getRole(), status.getVmRegion(), status.getVmStatus(),
132+
jobStatus, status.getRole(), status.getVmRegion(), vmStatus,
130133
new ValidationStatus(stats.getKills(), stats.getAborts(),
131134
stats.getGotos(), stats.getSkips(), stats.getSkipGroups(), stats.getRestarts()),
132135
stats.getMaxVirtualUsers(),

agent/apiharness/src/main/java/com/intuit/tank/harness/APITestHarness.java

Lines changed: 39 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
* #L%
1414
*/
1515

16-
import java.io.BufferedWriter;
1716
import java.io.File;
18-
import java.io.FileOutputStream;
1917
import java.io.IOException;
20-
import java.io.InputStream;
21-
import java.io.OutputStreamWriter;
22-
import java.io.Writer;
2318
import java.net.InetAddress;
2419
import java.net.URL;
2520
import java.net.UnknownHostException;
@@ -34,7 +29,6 @@
3429
import java.util.concurrent.CountDownLatch;
3530

3631
import org.apache.commons.io.FileUtils;
37-
import org.apache.commons.io.IOUtils;
3832
import org.apache.commons.lang3.StringUtils;
3933
import org.apache.commons.lang3.math.NumberUtils;
4034
import org.apache.logging.log4j.Level;
@@ -110,7 +104,7 @@ public class APITestHarness {
110104

111105
private Calendar c = Calendar.getInstance();
112106
private Date send = new Date();
113-
private int interval = 20; // SECONDS
107+
private int interval = 15; // SECONDS
114108

115109
static {
116110
try {
@@ -123,11 +117,6 @@ public class APITestHarness {
123117
} catch (Throwable e1) {
124118
LOG.warn(LogUtil.getLogMessage("Error setting dns negative timeout: " + e1.toString(), LogEventType.System));
125119
}
126-
try {
127-
System.setProperty("jsse.enableSNIExtension", "false");
128-
} catch (Throwable e1) {
129-
LOG.warn(LogUtil.getLogMessage("Error disabling SNI extension: " + e1.toString(), LogEventType.System));
130-
}
131120
try {
132121
System.setProperty("jdk.certpath.disabledAlgorithms", "");
133122
} catch (Throwable e1) {
@@ -173,11 +162,6 @@ public static void main(String[] args) {
173162
} catch (Throwable e1) {
174163
LOG.warn(LogUtil.getLogMessage("Error setting dns negative timeout: " + e1.toString(), LogEventType.System));
175164
}
176-
try {
177-
System.setProperty("jsse.enableSNIExtension", "false");
178-
} catch (Throwable e1) {
179-
LOG.warn(LogUtil.getLogMessage("Error disabling SNI extension: " + e1.toString(), LogEventType.System));
180-
}
181165
if (args.length < 1) {
182166
usage();
183167
return;
@@ -217,6 +201,18 @@ private void initializeFromArgs(String[] args) {
217201
agentRunData.setActiveProfile(LoggingProfile.VERBOSE);
218202
setFlowControllerTemplate(new DebugFlowController());
219203
continue;
204+
} else if (values[0].equalsIgnoreCase("-t")) {
205+
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
206+
Configuration config = ctx.getConfiguration();
207+
LoggerConfig loggerConfig = new LoggerConfig();
208+
loggerConfig.setLevel(Level.DEBUG);
209+
config.addLogger("com.intuit.tank.http", loggerConfig);
210+
config.addLogger("com.intuit.tank", loggerConfig);
211+
ctx.updateLoggers(config);
212+
DEBUG = true;
213+
agentRunData.setActiveProfile(LoggingProfile.VERBOSE);
214+
setFlowControllerTemplate(new TraceFlowController());
215+
continue;
220216
} else if (values[0].equalsIgnoreCase("-local")) {
221217
isLocal = true;
222218
continue;
@@ -306,6 +302,7 @@ private static void usage() {
306302
.println("-start=<# of users to start with>: The number of users to run concurrently when test begins");
307303
System.out.println("-http=<controller_base_url>: The url of the controller to get test info from");
308304
System.out.println("-d: Turns debug on to step through each request");
305+
System.out.println("-t: Turns trace on to print each request");
309306
}
310307

311308
private void startHttp(String baseUrl) {
@@ -394,10 +391,10 @@ private void startHttp(String baseUrl) {
394391
saveDataFile(dfRequest);
395392
}
396393
}
397-
Thread t = new Thread(new StartedChecker());
398-
t.setName("StartedChecker");
399-
t.setDaemon(false);
400-
t.start();
394+
Thread thread = new Thread(new StartedChecker());
395+
thread.setName("StartedChecker");
396+
thread.setDaemon(false);
397+
thread.start();
401398
} catch (Exception e) {
402399
LOG.error("Error communicating with controller: " + e, e);
403400
System.exit(0);
@@ -409,36 +406,27 @@ private void startHttp(String baseUrl) {
409406
*
410407
*/
411408
public void writeXmlToFile(String scriptUrl) throws IOException {
412-
File f = new File("script.xml");
413-
LOG.info(LogUtil.getLogMessage("Writing xml to " + f.getAbsolutePath()));
414-
Writer out = null;
415-
InputStream is = null;
409+
File file = new File("script.xml");
410+
LOG.info(LogUtil.getLogMessage("Writing xml to " + file.getAbsolutePath()));
416411
int count = 0;
417412

418413
while (count++ < MAX_RETRIES) {
419414
try {
420-
if (f.exists()) {
421-
f.delete();
422-
f = new File("script.xml");
415+
if (file.exists()) {
416+
file.delete();
417+
file = new File("script.xml");
423418
}
424419
URL url = new URL(scriptUrl);
425-
LOG.info("Downloading file from url " + scriptUrl + " to file " + f.getAbsolutePath());
426-
is = url.openStream();
427-
out = new BufferedWriter(new OutputStreamWriter(
428-
new FileOutputStream(f), "UTF8"));
429-
IOUtils.copy(is, out);
430-
IOUtils.closeQuietly(is);
431-
IOUtils.closeQuietly(out);
432-
String scriptXML = FileUtils.readFileToString(f, "UTF-8");
420+
LOG.info("Downloading file from url " + scriptUrl + " to file " + file.getAbsolutePath());
421+
FileUtils.copyURLToFile(url, file);
422+
String scriptXML = FileUtils.readFileToString(file, "UTF-8");
433423
List<String> tps = new ArrayList<String>();
434424
tps.add(scriptXML);
435425
setTestPlans(tps);
436426
TestPlanSingleton.getInstance().setTestPlans(tps);
437427
break;
438428
} catch (Exception e) {
439429
if (count < MAX_RETRIES) {
440-
IOUtils.closeQuietly(is);
441-
IOUtils.closeQuietly(out);
442430
LOG.warn(LogUtil.getLogMessage("Failed to download script file because of: " + e.toString()
443431
+ ". Will try "
444432
+ (MAX_RETRIES - count) + " more times.", LogEventType.System));
@@ -451,9 +439,6 @@ public void writeXmlToFile(String scriptUrl) throws IOException {
451439
LOG.error(LogUtil.getLogMessage("Error writing script file: " + e, LogEventType.IO), e);
452440
throw new RuntimeException(e);
453441
}
454-
} finally {
455-
IOUtils.closeQuietly(is);
456-
IOUtils.closeQuietly(out);
457442
}
458443
}
459444
}
@@ -467,19 +452,14 @@ private void saveDataFile(DataFileRequest dataFileRequest) {
467452
}
468453
}
469454
File dataFile = new File(dataFileDir, dataFileRequest.getFileName());
470-
FileOutputStream fos = null;
471-
InputStream is = null;
472455
int count = 0;
473456
while (count++ < MAX_RETRIES) {
474457
try {
475458
URL url = new URL(dataFileRequest.getFileUrl());
476459
LOG.info(LogUtil.getLogMessage(
477460
"writing file " + dataFileRequest.getFileName() + " to " + dataFile.getAbsolutePath()
478461
+ " from url " + url.toExternalForm(), LogEventType.System));
479-
is = url.openStream();
480-
fos = new FileOutputStream(dataFile);
481-
IOUtils.copy(is, fos);
482-
IOUtils.closeQuietly(fos);
462+
FileUtils.copyURLToFile(url, dataFile);
483463
if (dataFileRequest.isDefault()
484464
&& !dataFileRequest.getFileName().equals(TankConstants.DEFAULT_CSV_FILE_NAME)) {
485465
File defaultFile = new File(dataFileDir, TankConstants.DEFAULT_CSV_FILE_NAME);
@@ -503,9 +483,6 @@ private void saveDataFile(DataFileRequest dataFileRequest) {
503483
LOG.error(LogUtil.getLogMessage("Error downloading csv file: " + e, LogEventType.IO), e);
504484
throw new RuntimeException(e);
505485
}
506-
} finally {
507-
IOUtils.closeQuietly(is);
508-
IOUtils.closeQuietly(fos);
509486
}
510487
}
511488

@@ -889,22 +866,21 @@ public WatsAgentCommand getCmd() {
889866
}
890867

891868
public void queueTimingResult(TankResult result) {
892-
if (logTiming) {
893-
results.add(result);
894-
//if (results.size() >= BATCH_SIZE) {
895-
if (send.before(new Date())) {
896-
sendBatchToDB(true);
897-
898-
c.setTime(new Date());
899-
c.add(Calendar.SECOND, interval);
900-
send = new Date(c.getTime().getTime());
901-
}
902-
903-
}
869+
if (logTiming) {
870+
results.add(result);
871+
//if (results.size() >= BATCH_SIZE) {
872+
if (send.before(new Date())) {
873+
sendBatchToDB(true);
874+
875+
c.setTime(new Date());
876+
c.add(Calendar.SECOND, interval);
877+
send = new Date(c.getTime().getTime());
878+
}
879+
}
904880
}
905881

906882
private void sendBatchToDB(boolean asynch) {
907-
if (results.size() != 0 && logTiming) {
883+
if (results.size() > 1 && logTiming) {
908884
final List<TankResult> l = new ArrayList<TankResult>();
909885
synchronized (results) {
910886
l.addAll(results);

0 commit comments

Comments
 (0)