I try to implement this : https://www.testautomationguru.com/jmeter-how-to-create-a-data-keyword-driven-framework-for-performance-testing/
I have a .csv file with the test case name in the first column. So I want to run a specfic test case according to the value in the .csv.
Test Plan
|--- Test Fragment
|--- Switch Controller
|--- Transaction Controller (TestCase1)
|--- JSR223 Sample (TestCase1 script)
|--- Transaction Controller (TestCase2)
|--- JSR223 Sample (TestCase2 script)
|--- Transaction Controller (TestCase3)
|--- JSR223 Sample (TestCase3 script)
|--- Thread Group
|--- CSV Data Set Config
|--- Debug Sampler
|--- ForEach Controller
|--- Module Controller
|--- View Result Tree
However if I put some code in JSR223 into Transaction Controller, like log.info("TEST !") nothing is display into the console.
Is there a solution to execute code write into JSR223 and display it into the console?
Moreover, in the View Result Tree I found this information: testcasename=TestCase1. So it seems to work but no log...
Thanks a lot.
Simpy use OUT instead of log:
OUT.println("Hello Console");
OUT - System.out - e.g. OUT.println("message")
Given you use log shorthand you will be able to see your TEST ! message only in jmeter.log file
If you want to see the message in STDOUT you should use println instead like:
println("TEST !")
If you want to continue using log shorthand and to see the messages both in jmeter.log file and STDOUT - you will need to amend JMeter logging configuration like:
in log4j2.xml file (lives in "bin" folder of your JMeter installation)
Under <Appenders> tag add the following block:
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout>
<pattern>%d %p %c{1.}: %m%n</pattern>
</PatternLayout>
</Console>
Under <Root> tag add the following line:
<AppenderRef ref="STDOUT"/>
Once you restart JMeter you should start seeing the same information as in the jmeter.log file in the STDOUT including your custom messages
Related
I just start working on maintaining a Spring application which is deployed on WebSphere enterprise (version 8.5). It is my first time using the container. I need to have log messages in the debug level for tracing down a bug. The bug error log message shows up in the trace.log. After the system admin configures the container log level to debug, we don't see any debug level log messages. The application didn't have a log property file although log4j and Slf4j are its dependencies. I add a log4j.properties file which configures both a log file output and the console output. I, however, don't see the log file nor any log messages on console according to the system admin. It seems to me that the debug log level configuration is special in Websphere. How to solve this log level configuration problem?
The followings are Java code segment
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class MyClass {
private static final Logger log = LoggerFactory.getLogger(MyClass.class);
public void method01(){
log.debug("....");
}
and the property file:
# Root logger option
log4j.rootLogger=DEBUG, file, stdout
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${SERVER_LOG_ROOT}/portal-server.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %C:%M:%L - %m%n
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %C:%M:%L - %m%n
Notes: ${SERVER_LOG_ROOT} is replaced by a real path on the container box without a luck either.
Your application is using log4j logger trough the slf4j logging interface. This is a pretty standard setup. WebSphere doesn't interfere with this kind of logging configuration.
These are steps for proper setup of this configuration:
First exclude commons-logging dependency from your project. It is a popular logging interface required by Spring and various different projects. Instead, we will use slf4j.
Add dependencies to:
slf4j-api - our logging interface
jcl-over-slf4j - commons-logging implementation
slf4j-log4j12 - sl4j log4j bridge
log4j - logging api
Create log4j.properties in /WEB-INF/log4j.properties location.
Bootstrap log4j. Simplest way to bootstrap in spring web app is by using Log4jConfigListener utility class. Add following entries to web.xml. You should add this at the very top of web.xml in order to bootstrap logging before anything other happens.
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
That's it. This should work.
Now that logging is working you should probably make more detailed configuration with console logging during development; and more concise logging in deployment.The simplest way to do it is by using parameterized configuration log4j.properties:
log4j.rootLogger=${LOG4J_SERVER_LOGLEVEL}, fileAppender
log4j.appender.console=org.apache.log4j.ConsoleAppender
... console appender configuration ...
log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender
... file appender configuration ..
In a production LOG4J_SERVER_LOGLEVEL environment variable is set to "INFO". On my development machine, it is set to "DEBUG, console". This way servers log only to fileAppender, and development machine logs to console and fileAppender.
You can always add more environment variables to fine tune specific loggers or even make log4j.properties external and provide "file:" location as param-value. In case of external log4j.properties Log4jConfigListener can be setup to monitor changes in log4j properties and change the logging configuration in real time.
Nothing of this is WebSphere specific and these steps are the same in any Java web container. Now if you need logging which is configurable from WebSphere console you can accomplish this by replacing log4j with jul logger. WebSphere provides admin interface for jul logging under "Logs and trace" section.
I'm using the maven-failsafe plugin to trigger testng suites with configuration similar to
<suiteXmlFiles>
<file>src/test/resources/suites/somesuite.xml</file>
<file>src/test/resources/suites/anothersuite.xml</file>
<file>src/test/resources/suites/yetanothersuite.xml</file>
</suiteXmlFiles>
but the suites or the tests within them are not getting executed in the correct order. Is there a way to specifiy that the suites should be executed in the below order
somesuite.xml
anothersuite.xml
yet another suite.xml
I don't care about the order in which the tests within a suite is executed, but would like to execute one suite only after the previous one has completed. Is there some configuration which I could use to achieve the same?
Create a seperate testng.xml file and add something like below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<suite-files>
<suite-file
path="path-to\suite1.xml" />
<suite-file
path="path-to\suite2.xml" />
</suite-files>
</suite>
And then add this testng.xml file to your maven suite
I am using Log4j2 and Spring Boot (1.2.4). Following the documentation (and the log4j2-file.xml as example in spring-boot.jar), here is my configuration
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<File name="Logs" fileName="${sys:LOG_FILE}" append="false">
...
<Logger level="warn">
<AppenderRef ref="Logs"/>
</Logger>
In application.properties file :
logging.file: /var/tmp/logs/mylog.log
As a result, 2 files are generated :
One file named ${sys:LOG_FILE} which remains empty
One file /var/tmp/logs/mylog.log properly filled
I do not understand why the file ${sys:LOG_FILE} is generated.
Any idea ?
Thanks a lot.
I'm using version 1.2.5.RELEASE of Spring Boot (including the starter parent) and I'm seeing the same issue.
My assumption is that Log4j2 tries to initalize the file before Spring Boot loaded the configuration, resulting in an empty file called ${sys:LOG_FILE} or ${sys (on Windows).
One way of avoiding this is to just set the system property (-DLOG_FILE=/var/tmp/logs/mylog.log) and remove logger.file from your configuration.
It seem log4j2.xml is loaded and log file is created before application.properties being loaded. One way to fix this is to change the name of log4j2.xml to something else, for example log4j2-example.xml to present auto loading and then add the following line into application.properties:
logging.config=classpath:log4j2-example.xml
This will ensure the LOG_PATH are loaded before creating logger.
logging.file is just used for default logger configured by spring only.
In this case, your LOG_FILE must be passed into system variable before execute the jar by -DLOG_FILE=/location/of/log.file
I have one single protractor project with following dependencies in packages.json:
'protractor'
'grunt-protractor-runner'
'grunt-jasmine-node'
'jasmine-reporters'
I have this protractor-config:
exports.config =
specs: [
'build/test/e2e/**/*_spec.js'
]
capabilities:
browserName: "chrome"
onPrepare: () ->
require('jasmine-reporters')
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter("test/reports/e2e",
false, true))
It ran 20 tests and they finished properly, but under the "test/reports/e2e" directory multiple XML files were generated (1 XML file is generated per test). How can I generate results of these 20 tests into one only xml file, like this?
<testsuite ....>
<testcase classname="..." name="..." time="0.008"/>
<testcase classname="..." name="..." time="0.002"/>
<testcase classname="..." name="..." time="0.108"/>
<testcase classname="..." name="..." time="0.004"/>
<testcase classname="..." name="..." time="0.002"/>
</testsuite>
Is there a framework or plugin for translating this XML result into a readable format (e.g. html)
Note: I am not using mocha nor karma.
JUnitXmlReporter() and JUnit format specifically was not designed to be read by humans. It is a specific format that your Continuous Integration server (like jenkins) knows how to understand, parse and show readable results.
If you want to see an HTML report, there is protractor-html-screenshot-reporter package.
I have a JMeter Java Sampler that extends AbstractJavaSamplerClient.
I'd like to use SLF4J & LogBack as my logger rather than:
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
Ideally I'd like the sampler logs to also go to the jmeter.log file.
Any have any success with this and where do you configure logback.xml?
I Found I just needed to do the following before calling jmeter.bat
set JVM_ARGS=-Dlogback.debug=true -Dlogback.configurationFile=logback.xml