I want to start selenium server with log4j so that all server related logs go there. I'm starting the server with ANT using the following ANT target
<target name="startserver" depends="setClassPath">
<java jar="${test.home}/lib/selenium-server-standalone-2.20.0.jar" fork="true">
<arg line="-Djava.util.logging.config.file=log4j.properties"/>
<arg line="-firefoxProfileTemplate 'D:\selenium.default'"/>
<arg line="-browserSideLog"/>
</java>
</target>
My log4j.properties is as below:
log4j.rootLogger=INFO, R, stdout
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=./logs/sellog.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
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=%5p [%t] (%F:%L) - %m%n
But I'm not getting any server logs after I start the server from the target.
Also, I have a selenium test where I'm throwing the log into log4j as below:
private LogManager lm;
private Logger logger = lm.getLogger(this.getClass().getName());
logger.info("Selenium Client started...");
I'm getting application logs in log4j log.
What I want is to have all the logs (selenium server log + app log) in log4j log.
Any help is greatly appreciated.
You've mixed up two logging frameworks here:
java.util.logging.config.file=log4j.properties
That constant is for configuring java.util.logging, AKA 'JDK logging'.
Are you sure that Selenium Server actually uses log4j? If it does, you should have
log4j.configuration=log4j.properties
Edit: Based on http://code.google.com/p/selenium/source/browse/trunk/java/server/src/org/openqa/selenium/server/log/LoggingManager.java, looks like it uses JDK logging, so you can't (easily) redirect it to log4j.
Selenium uses slf4j, which can be told to send the log data to log4j. But you'll have to crack open the JAR manifest and specify the classpath and main class explicitly, instead of using the -jar option. Then add slf4j's log4j adapter jar (slf4j-log4j12-1.6.4.jar) to the classpath, and it will all work.
Related
I've set up dotCover to run using an .xml
<?xml version="1.0" encoding="utf-8"?>
<CoverageParams>
<TargetExecutable>
c:\dotcover\xunit\xunit.console.exe
</TargetExecutable>
<TargetArguments>
"INWK.Configuration.UnitTests.dll"
</TargetArguments>
<TargetWorkingDir>
..\bin\x64\Debug\
</TargetWorkingDir>
<TempDir>
<!-- Directory for auxiliary files. Set to the system temp by default. -->
</TempDir>
<Output>
dotCover-xunit.dcvr
</Output>
<InheritConsole>
<!-- [True|False] Lets the application being analyzed to inherit dotCover console. True by default. -->
</InheritConsole>
</CoverageParams>
You can see (Service, Shared, UnitTests assemblies correctly included in the test coverage report (Shared, Service and UnitTest assemblies)
However, when running the same on the build server *Service and *Shared are missing.
After replacing Service.dll and Shared.dll and their "pdb's" from local copy to build server and running dotCover on build server again it works correctly.
This leads me to believe that build server runner does something different than msbuild.exe from VS when running build locally.
I found very similar issue description here: https://stackoverflow.com/questions/25855131/dotcover-and-xunit-not-gathering-coverage-statistics-in-some-environments, but not sure how to remedy this in my build server configuration.
Trace log output (one drive)
https://1drv.ms/t/s!AtxuuqGHIqXwgTVqQJ_Y_-rGE8W9?e=HrZgj7
Found the solution:
in my dotcover config xml I had to add: -noshadow switch, like so:
<CoverageParams>
<TargetExecutable>
c:\dotcover\xunit\xunit.console.exe
</TargetExecutable>
<TargetArguments>
"INWK.OrderIndexing.UnitTests.dll" -noshadow
</TargetArguments>
<TargetWorkingDir>
..\bin\x64\Release\
</TargetWorkingDir>
...
Now all assemblies (except the ones I do want to filter) are showing up
I'm trying to get Jenkins figured out. I have a suite of selenium tests that I can build and run via Eclipse or build and run via the command line with ant, but whenever I try Jenkins, they fail.
The console out from Jenkins reports that the value for ws.jars, defined in my build.xml file, doesn't exist; however that directory does exist! Again, no problem building from the command line.
Any suggestions would be greatly appreciated as I've been trying to get this solved now for a couple of days.
Thanks.
My build.xml file:
<property environment="env"/>
<property name="ws.home" value="${basedir}"/>
<property name="ws.jars" value="/Users/username/Documents/All JAR Files/All in one place"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.result" value="test-output"/>
I created a new target in my build.xml file called path. Here is the output when I run with Jenkins.
Started by user anonymous
Building in workspace /Users/<user>/local_repo/qa-automation/selenium-java/my-projects
[my-projects] $ /Users/Shared/Jenkins/Home/tools/hudson.tasks.Ant_AntInstallation/Install_automatically/bin/ant path
Buildfile: /Users/<user>/local_repo/qa-automation/selenium-java/my-projects/build.xml
path:
[echo]
[echo] My path - /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin:/usr/bin:/bin:/usr/sbin:/sbin
[echo]
BUILD SUCCESSFUL
Total time: 0 seconds
Finished: SUCCESS
I suspect this is caused by the spaces within your path of ws.jars. You should escape these spaces by adding \, try change the path :
<property name="ws.jars" value="/Users/username/Documents/All JAR Files/All in one place"/>
with this one:
<property name="ws.jars" value="/Users/username/Documents/All\ JAR\ Files/All\ in\ one\ place/"/>
Thanks everybody for your suggestions. I hadn't thought about this in awhile but last night I had some time and was able to work on this issue again. Turns out it was related to the Jenkins job being executed in the non-interactive shell, just as 'rgulia' pointed out. So finally, I tried copying my ws.jars directory to /Users/Shared/Jenkins, changed the owner to 'jenkins', and boom, my build was able to proceed.
The original error message was just so misleading. It wasn't that the directory didn't exist, but that 'jenkins' didn't have access and/or permissions to it.
I hope this information can help others.
I am trying to access the osgi console of eclipse container in remote machine which is used to run automated test suites. We use ant to run the unit tests in test agents. Below is the ant taks we are using.
I found out that i need to add this command line argument to make the remote agent listen to the port specified."-Dosgi.console=8005". I ran the script but it is not stopping saying"listening to 8005". i was able to successfully remote debug this agent but i need osgi console view to debug the bundles that got installed in the agent.
Did i place the argument in the correct position? Does it have to be in any order?
Any help is appreciated. i do not understand why it never worked.
<java dir="${basedir}" classname="org.eclipse.equinox.launcher.Main" fork="true" classpathref="equinox.launcher.class.path">
<arg line="-application org.eclipse.pde.junit.runtime.uitestapplication -data ${tempWorkspace} -dev bin -testlistener org.eclipse.test.XMLTestListener -clean -port ${pde.test.port} -testpluginname ${testrunner.plugin.name} -classnames ${master.testsuite.name}"/>
<jvmarg value="-Xbootclasspath/a:${project.root}/lib/External/Clover/clover.jar"/>
<jvmarg value="-XX:MaxPermSize=256m" />
<jvmarg value="-Xms512m"/>
<jvmarg value="-Xmx1280m"/>
<jvmarg value="-Dorg.eclipse.equinox.http.jetty.http.port=2910"/>
<jvmarg value="-Dxcp.builder.testsuite.testplugins=xxxx.tests"/>
<jvmarg value="-Dosgi.console=8005"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xnoagent"/>
<jvmarg value="-Djava.compiler=NONE"/>
<jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"/>
If you use Equinox 3.8 or newer, you must use the -Dosgi.console.enable.builtin=true system property as well. See http://hwellmann.blogspot.hu/2012/08/new-osgi-console-in-equinox-380.html
To launch the new OSGi console in Eclipse, you need to ensure that the console bundle and its dependencies are available. These include:
org.eclipse.equinox.console
org.apache.felix.gogo.shell
org.apache.felix.gogo.command
org.apache.felix.gogo.shell
Since it's unlikely your code has any dependencies on these they won't be installed into your test runtime, and therefore won't be available for starting the console.
I have a PHP project written in PHPUnit using Selenium.
The project is structured as below:
PHPProjectName
Source Files
(doesn't contain anything)
Selenium Test Files
contains all my selenium test php files - extending the class PHPUnit_Extensions_SeleniumTestCase
Include Path
c:\program files\PHP
c:\program files\PHP\PEAR\PHPUnit
I then run start the Selenium server manually by running java -jar selenium-server-standalone-2.24.1.jar
The php script to execute all my selenium test php files works fine.
But now I want to use Jenkins as a test management tool to build and execute my PHPunit tests in this folder. I guess the steps are:
Install Jenkins
Write a build script for the PHPunit tests
Execute the build script through Jenkins
Are the steps correct? Has anyone done or know how to set this up?
Thanks very much,
I have done this many times with various platforms. Your steps are generally correct and should work, however managing the server is not always so simple. The Selenium RC server gets unstable if left open for too long, so you will have to manage it somehow.
You could set up a second Jenkins job which runs once or twice a day to reset your server. The better option however would be to write a simple test framework which closes any open servers and then launches a new server instance before running the tests. You could also use a cron job to reset the server of course, but if you have Jenkins installed it will be easier to do this via a jenkins job.
The best option of course is to switch to Webdriver, but that could take some work depending on how complex your tests are.
We have a similar setup to what you describe. We have Jenkins run a job to restart the Selenium server periodically:
#!/bin/bash
# startselenium.sh: Start Selenium up and also start headless screen.
Xvfb :99 -ac &
export DISPLAY=:99
java -jar /opt/selenium/selenium-server-standalone-2.19.0.jar &
Sebastian Bergmann maintains a bunch of templates for using Jenkins with PHP here:
http://jenkins-php.org/
Included is the necessary Ant script to run PHPUnit (which is really simple and just calls PHPUnit):
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
</target>
And the necessary 'phpunit.xml' file:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
strict="true"
verbose="true">
<testsuites>
<testsuite name="ProjectName">
<directory suffix="Test.php">tests/unit/</directory>
<directory suffix="Test.php">tests/integration/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="build/coverage" title="BankAccount"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<file>src/bootstrap.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>
You have to install the selenium plugin in jenkins, then a selenium server will automatically start on jenkins, which will create a hub. Now on the client you have to start a node which connects to this hub.
Note: The jenkins selenium server is always the same version as the selenium plugin from jenkins. So if the selenium plugins name is
selenium plugin 3.1.0 then it runs on selenium server 3.1.0.
After installing the jenkins selenium plugin, then you can find a new option for selenium grid, click on it and you will get more informations:
Now you have to start a jenkins selenium standalone server like this:
Windows (create a .bat file with the following content and execute it, change relevant parts accordingly):
start java -jar -Dwebdriver.gecko.driver="C:\Webdrivers\GeckoDriver\geckodriver.exe" -Dwebdriver.chrome.driver="C:\Webdrivers\ChromeDriver\chromedriver.exe" selenium-server-standalone-<VERSION>.jar -role node -hub http://<YOUR_JENKINS_MACHINE_IP>:<PORT>/grid/register
In my case, I used:
start java -jar -Dwebdriver.gecko.driver="C:\Webdrivers\GeckoDriver\geckodriver.exe" -Dwebdriver.chrome.driver="C:\Webdrivers\ChromeDriver\chromedriver.exe" selenium-server-standalone-3.1.0.jar -role node -hub http://172.25.201.100:4444/grid/register
Make sure to correct the paths to geckodriver and chromedriver to their actual location.
Now the node should connect to the hub and you can start your tests.
More infos:
https://github.com/SeleniumHQ/selenium/wiki/Grid2
I want to prevent maven from displaying INFO messages, I want to see only WARNINGS and ERRORS (if any).
How can I achieve this, preferably by changing the command line that calls maven?
Answering your question
I made a small investigation because I am also interested in the solution.
Maven command line verbosity options
According to http://books.sonatype.com/mvnref-book/reference/running-sect-options.html#running-sect-verbose-option
-e for error
-X for debug
-q for only error
Maven logging config file
Currently maven 3.1.x uses SLF4J to log to the System.out .
You can modify the logging settings at the file:
${MAVEN_HOME}/conf/logging/simplelogger.properties
According to the page : http://maven.apache.org/maven-logging.html
Command line setup
I think you should be able to setup the default Log level of the simple logger via a command line parameter, like this:
$ mvn clean package -Dorg.slf4j.simpleLogger.defaultLogLevel=debug
But I could not get it to work. I guess the only problem with this is, maven picks up the default level from the config file on the classpath. I also tried a couple of other settings via System.properties, but all of them were unsuccessful.
Appendix
You can find the source of slf4j on github here : slf4j github
The source of the simplelogger here : slf4j/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
The plexus loader loads the simplelogger.properties.
Edit: this answer was from 2013, there are probably better ways to do this now, please consider the other answers.
Linux:
mvn validate clean install | egrep -v "(^\[INFO\])"
or
mvn validate clean install | egrep -v "(^\[INFO\]|^\[DEBUG\])"
Windows:
mvn validate clean install | findstr /V /R "^\[INFO\] ^\[DEBUG\]"
You can achieve this with MAVEN_OPTS, for example
MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn mvn clean
Rather than putting the system property directly on the command line. (At least for maven 3.3.1.)
Consider using ~/.mavenrc for setting MAVEN_OPTS if you would like logging changed for your login across all maven invocations.
If you are using Logback, just put this logback-test.xml file into src/test/resources directory:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
you can achieve this by using below in the commandline itself
-e for error
-X for debug
-q for only error
e.g :
mvn test -X -DsomeProperties='SomeValue' [For Debug level Logs]
mvn test -e -DsomeProperties='SomeValue' [For Error level Logs]
mvn test -q -DsomeProperties='SomeValue' [For Only Error Logs]
The simplest way is to upgrade to Maven 3.3.1 or higher to take advantage of the ${maven.projectBasedir}/.mvn/jvm.config support.
Then you can use any options from Maven's SL4FJ's SimpleLogger support to configure all loggers or particular loggers. For example, here is a how to make all warning at warn level, except for a the PMD which is configured to log at error:
cat .mvn/jvm.config
-Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=error
See here for more details on logging with Maven.
Unfortunately, even with maven 3 the only way to do that is to patch source code.
Here is short instruction how to do that.
Clone or fork Maven 3 repo: "git clone https://github.com/apache/maven-3.git"
Edit org.apache.maven.cli.MavenCli#logging, and change
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO );
to
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_WARN );
In current snapshot version it's at line 270
Then just run "mvn install", your new maven distro will be located in "apache-maven\target\" folder
See this diff for the reference: https://github.com/ushkinaz/maven-3/commit/cc079aa75ca8c82658c7ff53f18c6caaa32d2131
Go to simplelogger.properties in ${MAVEN_HOME}/conf/logging/ and set the following properties:
org.slf4j.simpleLogger.defaultLogLevel=warn
org.slf4j.simpleLogger.log.Sisu=warn
org.slf4j.simpleLogger.warnLevelString=warn
And beware: warn, not warning
In Debian this worked for me like a charm to change the log level for Maven 3.6 at runtime without having to change the simplelogger.properties file:
MAVEN_OPTS='-Dorg.slf4j.simpleLogger.defaultLogLevel=error' mvn test
I have noticed when using the 2.20.1 version of the maven sunfire plugin, all warnings are written down to a dumpstream file. e.g. /myproject/target/surefire-reports/2017-11-11T23-02-19_850.dumpstream
Changing the info to error in simplelogging.properties file will help in achieving your requirement.
Just change the value of the below line
org.slf4j.simpleLogger.defaultLogLevel=info
to
org.slf4j.simpleLogger.defaultLogLevel=error