Mercurial > stress-tester
changeset 1057:b3d44dd719f1
PgSql - bugfixes
author | Devel 2 |
---|---|
date | Thu, 16 Apr 2020 09:20:53 +0200 |
parents | c0ada9453f53 |
children | 8535ce392b5e |
files | stress-tester/src/main/java/com/passus/st/Protocols.java stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandlerDataDecoder.java stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandlerNetflowFlowHandler.java stress-tester/src/main/java/com/passus/st/source/PcapPgSqlListener.java stress-tester/src/test/java/com/passus/st/emitter/RuleBasedSessionMapperTest.java |
diffstat | 5 files changed, 23 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/Protocols.java Wed Apr 15 11:56:03 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/Protocols.java Thu Apr 16 09:20:53 2020 +0200 @@ -28,8 +28,12 @@ return "DNS"; case NETFLOW: return "Netflow"; + case PGSQL: + return "PgSql"; + case MYSQL: + return "Mysql"; default: - return "unknown"; + return "unknown (" + protocolId + ")"; } } }
--- a/stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandlerDataDecoder.java Wed Apr 15 11:56:03 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandlerDataDecoder.java Thu Apr 16 09:20:53 2020 +0200 @@ -17,10 +17,8 @@ private PgSqlDecoder decoder = new PgSqlDecoder(false); - private final PgSqlFlowHandlerNetflowFlowHandler handler; + public PgSqlFlowHandlerDataDecoder() { - public PgSqlFlowHandlerDataDecoder(PgSqlFlowHandlerNetflowFlowHandler handler) { - this.handler = handler; } @Override @@ -42,17 +40,15 @@ public int decode(ByteBuff buffer, FlowContext flowContext) { int res = decoder.decode(buffer); if (decoder.state() == DataDecoder.STATE_FINISHED) { - long now = handler.timeGenerator.currentTimeMillis(); - + long now = System.currentTimeMillis(); if (LOGGER.isDebugEnabled()) { debug(LOGGER, flowContext, - "Response decoded (size: {} B, downloaded: {} ms)", + "Response decoded (size: {} B, downloaded: {} ms). {}", res, - now - flowContext.receivedStartTimestamp() + now - flowContext.receivedStartTimestamp(), + decoder.getResult() ); } - - } return res;
--- a/stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandlerNetflowFlowHandler.java Wed Apr 15 11:56:03 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandlerNetflowFlowHandler.java Thu Apr 16 09:20:53 2020 +0200 @@ -16,6 +16,7 @@ public class PgSqlFlowHandlerNetflowFlowHandler extends AbstractFlowHandler<PgSqlMetric> implements TimeAware { private final PgSqlFlowHandlerDataEncoder encoder; + private final PgSqlFlowHandlerDataDecoder decoder; TimeGenerator timeGenerator = TimeGenerator.getDefaultGenerator(); @@ -25,6 +26,7 @@ public PgSqlFlowHandlerNetflowFlowHandler() { this.encoder = new PgSqlFlowHandlerDataEncoder(); + this.decoder = new PgSqlFlowHandlerDataDecoder(); } @Override @@ -39,7 +41,7 @@ @Override public FlowHandlerDataDecoder getResponseDecoder(FlowContext flowContext) { - return null; + return decoder; } @Override @@ -73,7 +75,7 @@ @Override public void init(FlowContext flowContext) { - flowContext.setBidirectional(false); + flowContext.setBidirectional(true); }
--- a/stress-tester/src/main/java/com/passus/st/source/PcapPgSqlListener.java Wed Apr 15 11:56:03 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/source/PcapPgSqlListener.java Thu Apr 16 09:20:53 2020 +0200 @@ -1,6 +1,7 @@ package com.passus.st.source; import com.passus.net.pgsql.PgSqlMessage; +import com.passus.net.pgsql.PgSqlMessageType; import com.passus.net.session.SessionContext; import com.passus.st.client.EventHandler; @@ -16,7 +17,12 @@ @Override public void onMessageReceived(SessionContext context, PgSqlMessage msg, long timestamp) { //Nie przetwarzamy odpowiedzi - if (!msg.isRequest()) { + if (msg.isRequest()) { + //TODO Usunac + if (msg.getType() == PgSqlMessageType.SSL_REQUEST) { + return; + } + firePayloadEvent(msg, null, context, timestamp); } }
--- a/stress-tester/src/test/java/com/passus/st/emitter/RuleBasedSessionMapperTest.java Wed Apr 15 11:56:03 2020 +0200 +++ b/stress-tester/src/test/java/com/passus/st/emitter/RuleBasedSessionMapperTest.java Thu Apr 16 09:20:53 2020 +0200 @@ -57,7 +57,6 @@ "1.1.1.1:* -> 2.2.2.2:90");// cannot map IP to domain testParsePrintRule("1.1.1.1:* -> 2.2.2.2:90"); - testParsePrintRule("1.1.1.1:* -> 2.2.2.2:90; ssl"); testParsePrintRule("1.1.1.1:* -> 2.2.2.2:90"); testParsePrintRule("*:80 -> 2.2.2.2:90"); testParsePrintRule("*:* -> 2.2.2.2:90"); @@ -74,6 +73,8 @@ "1.1.1.1:80 -> 2.2.2.2:90 bind 172.16.40.10-172.16.40.11:2001-6000"); // mask -> range testParsePrintRule("1.1.1.1:80 -> 2.2.2.2:90 bind 172.16.40.10, 172.16.40.20:2001-6000"); testParsePrintRule("1.1.1.1:80 -> 2.2.2.2:90 bind 172.16.40.10-172.16.40.20:2001-6000"); + + testParsePrintRule("1.1.1.1:* -> 2.2.2.2:90; ssl"); } public void testParsePrintRule(String inputRule) throws Exception {