Mercurial > stress-tester
changeset 904:ede69c8df2fa
lookups - bugfixes
author | Devel 1 |
---|---|
date | Wed, 18 Apr 2018 13:50:02 +0200 |
parents | 8b26804049d4 |
children | a28637ab1e4f |
files | stress-tester/src/main/java/com/passus/st/CliHelper.java stress-tester/src/main/java/com/passus/st/ConverterMain.java stress-tester/src/main/java/com/passus/st/Main.java stress-tester/src/main/java/com/passus/st/Main2.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java |
diffstat | 5 files changed, 25 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/CliHelper.java Wed Apr 18 10:47:13 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/CliHelper.java Wed Apr 18 13:50:02 2018 +0200 @@ -3,14 +3,12 @@ import com.passus.commons.Assert; import com.passus.config.Configuration; import com.passus.config.ConfigurationContext; -import com.passus.config.ConfigurationContextImpl; import com.passus.config.YamlConfigurationReader; import com.passus.config.validation.Errors; import static com.passus.config.validation.ErrorsUtils.objectErrorToString; import com.passus.config.validation.ObjectError; import com.passus.filter.ValueExtractor; import com.passus.lookup.Lookup; -import com.passus.lookup.LookupList; import com.passus.net.PortRangeSet; import com.passus.st.client.http.HttpClient; import com.passus.st.client.http.filter.HttpFilter; @@ -26,6 +24,7 @@ import com.passus.st.source.EventSource; import com.passus.st.source.NcEventSource; import com.passus.st.source.PcapSessionEventSource; +import com.passus.st.utils.ConfigurationContextConsts; import com.passus.st.vars.VarsConfigurator; import java.io.File; import java.io.InputStream; @@ -160,15 +159,15 @@ return client; } - public void fillLookupList(CommandLine cl) throws Exception { - LookupList.getInstance().addAll(readLookups(cl)); + public void readLookupsToContext(CommandLine cl, ConfigurationContext context) throws Exception { + List<Lookup> lookups = readLookups(cl, context); + context.add(ConfigurationContextConsts.LOOKUPS, lookups); } - public List<Lookup> readLookups(CommandLine cl) throws Exception { + public List<Lookup> readLookups(CommandLine cl, ConfigurationContext context) throws Exception { if (cl.hasOption("lf")) { File file = new File(cl.getOptionValue("lf")); Errors errors = new Errors(); - ConfigurationContext context = new ConfigurationContextImpl(); List<Lookup> lookups = LookupsDomainConfigurator.getLookups(file, errors, context); handleErrors(errors, file); return lookups; @@ -178,11 +177,10 @@ } @SuppressWarnings("unchecked") - public List<HttpFilter> readHttpFilters(CommandLine cl) throws Exception { + public List<HttpFilter> readHttpFilters(CommandLine cl, ConfigurationContext context) throws Exception { if (cl.hasOption("ff")) { File file = new File(cl.getOptionValue("ff")); Errors errors = new Errors(); - ConfigurationContext context = new ConfigurationContextImpl(); List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(file, errors, context); handleErrors(errors, file); return filters; @@ -195,11 +193,12 @@ * Implicitly adds VarsFilter at the end. * * @param cl + * @param context * @return * @throws Exception */ - public List<HttpFilter> readHttpClientFilters(CommandLine cl) throws Exception { - List<HttpFilter> filters = readHttpFilters(cl); + public List<HttpFilter> readHttpClientFilters(CommandLine cl, ConfigurationContext context) throws Exception { + List<HttpFilter> filters = readHttpFilters(cl, context); if (filters == null) { filters = new ArrayList<>(); }
--- a/stress-tester/src/main/java/com/passus/st/ConverterMain.java Wed Apr 18 10:47:13 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/ConverterMain.java Wed Apr 18 13:50:02 2018 +0200 @@ -1,5 +1,6 @@ package com.passus.st; +import com.passus.config.ConfigurationContext; import com.passus.st.client.http.filter.HttpFilter; import com.passus.st.reader.nc.HttpWriteMode; import com.passus.st.source.NcEventDestination; @@ -72,7 +73,6 @@ .build() ); - // options.addOption(option("wm", "writeMetrics").desc("Write metrics to file.") // .hasArg().argName("file") // .build() @@ -131,9 +131,11 @@ ConverterHttpClient client = new ConverterHttpClient(dst); - cliHelper.fillLookupList(cl); + ConfigurationContext context = ConfigurationContext.create(); - List<HttpFilter> httpFilters = cliHelper.readHttpFilters(cl); + cliHelper.readLookupsToContext(cl, context); + + List<HttpFilter> httpFilters = cliHelper.readHttpFilters(cl, context); if (httpFilters != null) { httpFilters.forEach(client::addFilter); }
--- a/stress-tester/src/main/java/com/passus/st/Main.java Wed Apr 18 10:47:13 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/Main.java Wed Apr 18 13:50:02 2018 +0200 @@ -3,6 +3,7 @@ import com.passus.commons.ConversionException; import com.passus.commons.metric.Metric; import com.passus.commons.service.Registry; +import com.passus.config.ConfigurationContext; import com.passus.st.client.MemoryEventsCache; import com.passus.st.client.http.*; import com.passus.st.client.http.filter.HttpFilter; @@ -242,9 +243,11 @@ collector.addHandler(reporterDestination); } - cliHelper.fillLookupList(cl); + ConfigurationContext context = ConfigurationContext.create(); - List<HttpFilter> httpFilters = cliHelper.readHttpClientFilters(cl); + cliHelper.readLookupsToContext(cl, context); + + List<HttpFilter> httpFilters = cliHelper.readHttpClientFilters(cl, context); if (httpFilters != null) { httpFilters.forEach(client::addFilter); }
--- a/stress-tester/src/main/java/com/passus/st/Main2.java Wed Apr 18 10:47:13 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/Main2.java Wed Apr 18 13:50:02 2018 +0200 @@ -3,6 +3,7 @@ import com.passus.commons.ConversionException; import com.passus.commons.metric.Metric; import com.passus.commons.service.Registry; +import com.passus.config.ConfigurationContext; import com.passus.net.PortRangeSet; import com.passus.st.client.MemoryEventsCache; import com.passus.st.client.http.DumperHttpClientListener; @@ -248,9 +249,11 @@ collector.addHandler(reporterDestination); } - cliHelper.fillLookupList(cl); + ConfigurationContext context = ConfigurationContext.create(); - List<HttpFilter> httpFilters = cliHelper.readHttpClientFilters(cl); + cliHelper.readLookupsToContext(cl, context); + + List<HttpFilter> httpFilters = cliHelper.readHttpClientFilters(cl, context); if (httpFilters != null) { httpFilters.forEach(client::addFilter); }
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java Wed Apr 18 10:47:13 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java Wed Apr 18 13:50:02 2018 +0200 @@ -72,7 +72,7 @@ try { valueExtractor = (ValueExtractor) lookupValueTransformer.transform(valNode); } catch(NodeConversionException e) { - errors.reject("Invalid lookup definition. " + e.getMessage(), valNode); + errors.reject(valNode, "Invalid lookup definition. " + e.getMessage()); } catch(Exception e) { errors.reject("Invalid lookup definition.", valNode); }