Mercurial > stress-tester
changeset 708:3abcfc512e5f
converter - request only
author | Devel 1 |
---|---|
date | Wed, 29 Nov 2017 10:12:08 +0100 |
parents | 490739826756 |
children | 6505c7c305e6 |
files | stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java stress-tester/src/main/java/com/passus/st/ConverterMain.java stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java stress-tester/src/main/java/com/passus/st/source/NcEventDestination.java stress-tester/src/test/java/com/passus/st/source/NcEventDestinationTest.java |
diffstat | 5 files changed, 28 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java Wed Nov 29 10:05:12 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java Wed Nov 29 10:12:08 2017 +0100 @@ -24,12 +24,17 @@ private NcEventDestination dst; private boolean allowOverwrite; + private boolean requestOnly; private boolean started; public ConverterHttpClient(String ncFile) { this.ncFile = ncFile; } + void setRequestOnly(boolean requestOnly) { + this.requestOnly = requestOnly; + } + void setAllowOverwrite(boolean overwrite) { this.allowOverwrite = overwrite; } @@ -47,6 +52,7 @@ dst = new NcEventDestination(ncFile); dst.setAllowOverwrite(allowOverwrite); + dst.setRequestOnly(requestOnly); dst.start(); started = true;
--- a/stress-tester/src/main/java/com/passus/st/ConverterMain.java Wed Nov 29 10:05:12 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/ConverterMain.java Wed Nov 29 10:12:08 2017 +0100 @@ -66,38 +66,15 @@ .build() ); -// options.addOption(option("rd", "reporterDirectory").desc("Reporter directory.") -// .hasArg().argName("ip") -// .build() -// ); -// options.addOption(option("ri", "reporterIp").desc("Reporter ip address.") -// .hasArg().argName("ip") -// .build() -// ); -// options.addOption(option("nrt", "numReporterThreads").desc("Number of sending threads. (range 1 - 8, default 2)") -// .hasArg().argName("threads") -// .build() -// ); -// -// options.addOption(option("wf", "writeFile").desc("Write result to file.") -// .hasArg().argName("file").optionalArg(true) -// .build() -// ); -// -// options.addOption(option("wd", "writeDirectory").desc("Write HTTP messages to separate files.") -// .hasArg().argName("directory") -// .build() -// ); -// -// options.addOption(option("wdro", "writeDirectoryRequestsOnly").desc("Write only HTTP requests.") -// .hasArg(false) -// .build() -// ); -// // options.addOption(option("wm", "writeMetrics").desc("Write metrics to file.") // .hasArg().argName("file") // .build() // ); + options.addOption(option("req", "requestOnly").desc("Write only HTTP requests") + .hasArg(false) + .build() + ); + return options; } @@ -159,6 +136,8 @@ } client.setAllowOverwrite(overwrite); + client.setRequestOnly(cl.hasOption("req")); + client.start(); PcapSessionEventSource eventSrc = new PcapSessionEventSource();
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java Wed Nov 29 10:05:12 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java Wed Nov 29 10:12:08 2017 +0100 @@ -68,7 +68,7 @@ return len; } - public long encodeVersion(HttpMessage msg, ByteBuff buff) throws IOException { + private long encodeVersion(HttpMessage msg, ByteBuff buff) throws IOException { if (HttpConsts.VERSION_1_0.equals(msg.getVersion())) { buff.append(NcHttpDataUtils.VERSION_1_0); } else if (HttpConsts.VERSION_1_1.equals(msg.getVersion())) { @@ -80,7 +80,7 @@ return 1; } - public long encodeRequest(HttpRequest req, ByteBuff buff) throws IOException { + private long encodeRequest(HttpRequest req, ByteBuff buff) throws IOException { long size = 0; size += ncDataHelper.writeByteStringNullTerminated(buff, req.getMethod().toByteString()); size += ncDataHelper.writeByteStringNullTerminated(buff, req.getUri()); @@ -89,7 +89,7 @@ return size; } - public long encodeResponse(HttpResponse resp, ByteBuff buff) throws IOException { + private long encodeResponse(HttpResponse resp, ByteBuff buff) throws IOException { long size = 0; dataHelper.writeInt2(buff, resp.getStatus().getCode()); size += 2;
--- a/stress-tester/src/main/java/com/passus/st/source/NcEventDestination.java Wed Nov 29 10:05:12 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/source/NcEventDestination.java Wed Nov 29 10:12:08 2017 +0100 @@ -37,6 +37,8 @@ private boolean allowOverwrite; + private boolean requestOnly; + public NcEventDestination() { } @@ -77,6 +79,15 @@ this.allowOverwrite = allowOverwrite; } + public boolean isRequestOnly() { + return requestOnly; + } + + public void setRequestOnly(boolean requestOnly) { + this.requestOnly = requestOnly; + httpPayloadWriter.setEncodeResponse(!requestOnly); + } + @Override public void start() { if (started) { @@ -132,7 +143,7 @@ writer.writeSessionPayload(event.getTimestamp(), event.getSessionInfo(), (byte) 1, buff); } - if (event.getResponse() != null) { + if (event.getResponse() != null && !requestOnly) { ByteBuff buff = new HeapByteBuff(); responseEncoder.encode(event.getResponse(), buff); writer.writeSessionPayload(event.getTimestamp(), event.getSessionInfo(), (byte) 1, buff);
--- a/stress-tester/src/test/java/com/passus/st/source/NcEventDestinationTest.java Wed Nov 29 10:05:12 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/source/NcEventDestinationTest.java Wed Nov 29 10:12:08 2017 +0100 @@ -17,8 +17,6 @@ import java.util.Properties; import static org.testng.AssertJUnit.assertEquals; import org.testng.annotations.Test; -import static com.passus.commons.utils.ResourceUtils.createTmpFile; -import static com.passus.commons.utils.ResourceUtils.createTmpFile; /** *