Mercurial > stress-tester
changeset 1265:27a1eb5e8069
SessionPayloadEvent.FLAG_SKIP_FILTER, SequenceFilter bugfix
author | Devel 2 |
---|---|
date | Thu, 02 Jul 2020 15:52:49 +0200 |
parents | 25f8930e76c9 |
children | 5cd5df14202d |
files | stress-tester/src/main/java/com/passus/st/client/SessionPayloadEvent.java stress-tester/src/main/java/com/passus/st/filter/SequenceFilter.java stress-tester/src/test/java/com/passus/st/filter/SequenceFilterTest.java |
diffstat | 3 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/SessionPayloadEvent.java Thu Jul 02 15:02:45 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/SessionPayloadEvent.java Thu Jul 02 15:52:49 2020 +0200 @@ -15,6 +15,7 @@ public static final byte FLAG_WAIT = 1 << 1; public static final byte FLAG_RAW = 1 << 2; + public static final byte FLAG_SKIP_FILTER = 1 << 3; private final R request; @@ -74,6 +75,10 @@ return (flags & FLAG_WAIT) > 0; } + public boolean filterable() { + return (flags & FLAG_SKIP_FILTER) == 0; + } + @Override public SessionPayloadEvent instanceForWorker(int index) { return new SessionPayloadEvent(getSessionInfo(), request, response, protocolId, getSourceName());
--- a/stress-tester/src/main/java/com/passus/st/filter/SequenceFilter.java Thu Jul 02 15:02:45 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/filter/SequenceFilter.java Thu Jul 02 15:52:49 2020 +0200 @@ -13,6 +13,7 @@ import com.passus.config.annotations.NodeDefinitionCreate; import com.passus.config.schema.*; import com.passus.filter.ValueExtractor; +import com.passus.net.http.HttpRequest; import com.passus.st.client.FlowContext; import com.passus.st.client.SessionPayloadEvent; import com.passus.st.client.http.filter.HttpFilterRequestWrapper; @@ -47,7 +48,7 @@ private Stage rootStage; - private FilterDirection direction = FilterDirection.IN; + private FilterDirection direction = FilterDirection.OUT; private Action[] actions; @@ -176,13 +177,13 @@ } } + @SuppressWarnings("unchecked") @Override public void configure(Configuration config, ConfigurationContext context) { exact = config.getBoolean("exact", false); List<Stage> stagesList = (List<Stage>) config.get("sequence"); Stage[] stagesArr = stagesList.toArray(new Stage[0]); - List<Action> actionsList = (List<Action>) config.get("action"); Action[] actionsArr = actionsList.toArray(new Action[0]); @@ -281,6 +282,7 @@ valueMap.put("req", value.getReq()); valueMap.put("resp", value.getResp()); if (rootStage.match(valueMap)) { + System.out.println("--- " + ((HttpFilterRequestWrapper)value.getReq()).getUrl()); StageChain chain = new StageChain(valueMap); chain.setStage(now, rootStage, null); if (nextStage(chain, now, value, context)) { @@ -503,12 +505,17 @@ SessionInfo sessionInfo = flowContext.sessionInfo(); SessionPayloadEvent<Object, Object> event; + byte flags = SessionPayloadEvent.FLAG_WAIT | SessionPayloadEvent.FLAG_SKIP_FILTER; if (wrapper.req instanceof HttpFilterRequestWrapper || wrapper.resp instanceof HttpFilterResponseWrapper) { Object req = wrapper.req == null ? null : ((HttpFilterRequestWrapper) wrapper.req).getWrappedMessage(); Object resp = wrapper.resp == null ? null : ((HttpFilterResponseWrapper) wrapper.resp).getWrappedMessage(); - event = new SessionPayloadEvent<>(sessionInfo, req, resp, sessionInfo.getProtocolId(), sessionInfo.getSourceName()); + event = new SessionPayloadEvent<>(sessionInfo, req, resp, flags); } else { - event = new SessionPayloadEvent<>(sessionInfo, wrapper.req, wrapper.resp, sessionInfo.getProtocolId(), sessionInfo.getSourceName()); + if (wrapper.req instanceof byte[]) { + flags |= SessionPayloadEvent.FLAG_RAW; + } + + event = new SessionPayloadEvent<>(sessionInfo, wrapper.req, wrapper.resp, flags); } flowContext.queueAddFirst(event);
--- a/stress-tester/src/test/java/com/passus/st/filter/SequenceFilterTest.java Thu Jul 02 15:02:45 2020 +0200 +++ b/stress-tester/src/test/java/com/passus/st/filter/SequenceFilterTest.java Thu Jul 02 15:52:49 2020 +0200 @@ -136,7 +136,7 @@ filter.init(stages, actions); for (Pair<HttpRequest, HttpResponse> p : pairs) { - filter.filterInbound(p.getValue1(), p.getValue2(), null); + filter.filterOutbound(p.getValue1(), p.getValue2(), null); } PerNameMetricsContainer metricsContainer = new PerNameMetricsContainer(); @@ -171,7 +171,7 @@ filter.init(stages, actions); pairs.forEach((p) -> { - filter.filterInbound(p.getValue1(), p.getValue2(), null); + filter.filterOutbound(p.getValue1(), p.getValue2(), null); }); PerNameMetricsContainer metricsContainer = new PerNameMetricsContainer();