I am trying to use ANT to start a Selenium Grid instance. Using the response found here, How can I run Selenium 2 Grid from an Ant build? , I was able to start the Grid successfully using the following build.xml
<project name="selenium-grid" default="launch-hub" basedir=".">
<property name="selenium.version" value="2.28.0"/>
<property name="sauce.version" value="1.0.8"/>
<path id="selenium.classpath">
<pathelement path="${basedir}/"/>
<fileset dir="${basedir}/">
<include name="selenium-server-standalone-${selenium.version}.jar"/>
<include name="sauce-grid-plugin-${sauce.version}.jar"/>
</fileset>
<pathelement path="${java.class.path}/"/>
</path>
<target name="launch-hub"
description="Launch Selenium Hub">
<java classname="org.openqa.grid.selenium.GridLauncher"
classpathref="selenium.classpath"
fork="true"
failonerror="true">
<arg value="-role"/>
<arg value="hub"/>
</java>
</target>
</project>
ant launch-hub
Moving on, I would like to use Sauce Labs Grid plug-in with the Selenium Grid which can be found here: https://github.com/rossrowe/sauce-grid-plugin/wiki
Following the wiki, I can start the two on my windows machine using the following from DOS
java -cp selenium-server-standalone-2.25.0.jar;sauce-grid-plugin-1.0.7.jar org.openqa.grid.selenium.GridLauncher -role hub -servlets com.saucelabs.grid.SauceOnDemandAdminServlet,com.saucelabs.grid.SauceOnDemandConsoleServlet
Now I want to incorporate the Sauce lab Servlets by adding to the target "launch-hub" to the arguments for the Sauce labs "servlets" (sorry having trouble posting the real code)
arg value="-servlets"
arg value="com.saucelabs.grid.SauceOnDemandAdminServlet,com.saucelabs.grid.SauceOnDemandConsoleServlet"
I relaunched using ant launch and here here is the error returned by windows:
launch-hub:
[java] 17 janv. 2013 10:58:40 org.openqa.grid.selenium.GridLauncher main
[java] INFO: Launching a selenium grid server
[java] 17 janv. 2013 10:58:50 org.openqa.grid.web.utils.ExtraServletUtil createServlet
[java] ATTENTION: The specified class : com.saucelabs.grid.SauceOnDemandAdminServlet cannot be instanciated com.sau
celabs.grid.SauceOnDemandAdminServlet
[java] 17 janv. 2013 10:58:50 org.openqa.grid.web.utils.ExtraServletUtil createServlet
[java] ATTENTION: The specified class : com.saucelabs.grid.SauceOnDemandConsoleServlet cannot be instanciated com.s
aucelabs.grid.SauceOnDemandConsoleServlet
[java] 2013-01-17 10:58:50.806:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
[java] 2013-01-17 10:58:50.866:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
[java] 2013-01-17 10:58:50.876:INFO:osjs.AbstractConnector:Started SocketConnector#0.0.0.0:4444`enter code here
The Selenium Grid starts but without the servlets, thus no Saucelabs access
Any ideas?
Update Got it working using 1.0.7 of the sauce plugin. No go with version 1.0.8
I was able to get a Grid server running successfully with the Sauce Grid plugin by using your build.xml with the extra arguments, eg
<project name="selenium-grid" default="launch-hub" basedir=".">
<property name="selenium.version" value="2.25.0"/>
<property name="sauce.version" value="1.0.8"/>
<path id="selenium.classpath">
<pathelement path="${basedir}/"/>
<fileset dir="${basedir}">
<include name="selenium-server-standalone-${selenium.version}.jar"/>
<include name="sauce-grid-plugin-${sauce.version}.jar"/>
</fileset>
<pathelement path="${java.class.path}/"/>
</path>
<target name="launch-hub"
description="Launch Selenium Hub">
<java classname="org.openqa.grid.selenium.GridLauncher"
classpathref="selenium.classpath"
fork="true"
failonerror="true">
<arg value="-servlets"/>
<arg value="com.saucelabs.grid.SauceOnDemandAdminServlet,com.saucelabs.grid.SauceOnDemandConsoleServlet"/>
<arg value="-role"/>
<arg value="hub"/>
</java>
</target>
</project>
From looking at the Selenium Grid code, the error that appeared in the build output is generated when a ClassNotFoundException is thrown...can you check to see if the sauce-grid-plugin jar file is located in the ${basedir}?
Related
I am using Ant script to deploy a war file in mobile first server to create run time. But I am not sure about the ANT Script, I am getting errors regarding database configuration.
This is the error I am getting by running Ant Script:
Building project
command: 'C:\Program Files\agent\opt\apache-ant-1.8.4\bin\ant.bat' -f 'C:\Program Files\agent\var\work\MF-Component\wardeploy.xml'
Buildfile: C:\Program Files\agent\var\work\MF-Component\wardeploy.xml
install:
[configureapplicationserver] Logging output of task <configureApplicationServer> to file C:\Users\miracle\Documents\IBM MobileFirst Platform Server Data\Configuration Logs\configureApplicationServer_2016_02_12_03_35_41.log
[configureapplicationserver] WARNING: The Reports database is deprecated in IBM MobileFirst Platform Foundation since V7.0.0.
[configureapplicationserver] Use Operational Analytics instead.
[configureapplicationserver] See http://ibm.biz/knowctr#SSHS8R_7.1.0/com.ibm.worklight.monitor.doc/monitor/c_op_analytics_overview.html
BUILD FAILED
C:\Program Files\agent\var\work\MF-Component\wardeploy.xml:33: Element <db2> inside <database kind="Worklight"> inside <configureApplicationServer>: Database does not contain the expected tables. The test table GADGET_USER_PREF was not found.
You may create the required tables through an invocation of <configureDatabase>.
Total time: 4 seconds
Caught: com.urbancode.air.ExitCodeException: Command failed with exit code: 1
com.urbancode.air.ExitCodeException: Command failed with exit code: 1
at com.urbancode.air.CommandHelper.runCommand(CommandHelper.groovy:195)
at com.urbancode.air.CommandHelper$runCommand$0.callCurrent(Unknown Source)
at com.urbancode.air.CommandHelper.runCommand(CommandHelper.groovy:121)
at com.urbancode.air.CommandHelper$runCommand.call(Unknown Source)
at ant.run(ant.groovy:123)
Here I don't need any tables to deploy the war file but it was asking for table. For deploying the war file it needs to have database. That I have given the credentials but it shows some errors as above.
Here Is the Ant script I am using.
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="install">
<taskdef resource="com/worklight/ant/deployers/antlib.xml">
<classpath>
<pathelement location="C:\Program Files\IBM\MobileFirst_Platform_Server\WorklightServer\worklight-ant-deployer.jar"/>
</classpath>
</taskdef>
<target name="databases">
<configuredatabase kind="Worklight">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4">
</db2>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</configuredatabase>
<configuredatabase kind="WorklightReports">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4">
</db2>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</configuredatabase>
</target>
<target name="install">
<configureapplicationserver>
<project warfile="C:\Program Files\agent\var\work\MF-Component\bin\Git_Demo.war" libraryfile="C:\Program Files\IBM\MobileFirst_Platform_Server\WorklightServer\worklight-jee-library.jar"/>
<!-- Here you can define values which override the
default values of Worklight configuration properties -->
<property name="serverSessionTimeout" value="10"/>
<applicationserver>
<websphereapplicationserver installdir="C:\Program Files\IBM\WebSphere\Liberty"
profile="Liberty"
user="admin" password="admin">
<server name="UCDServer"/>
</websphereapplicationserver>
</applicationserver>
<database kind="Worklight">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4"/>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</database>
<database kind="WorklightReports">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4"/>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</database>
</configureapplicationserver>
</target>
</project>
This is correct, the WAR file needs to have a database. Before creating the datasource in the application server, the configuredatabase Ant task verifies that the datasource exists and has the correct tables. It didn't find it and failed with an error.
To create the database tables run the 'databases' target in your ant file.
For more information, see https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.deploy.doc/devref/c_project_war_file_ant_tasks.html
I am trying to execute the class file in a jar through ant script. I ran the command through CMD it worked fine
Command is like :-
java com.CodeReview -p “<Project Path>”
I tried to run this command through the ant script
<target name="build">
<java fork="true" failonerror="yes" classname="com.CodeReview">
<arg line="-p"/>
<arg line="D:\Test"/>
</java>
</target>
It is giving me error
build:
[java] Error: Could not find or load main class com.CodeReview
but through command line it is working and no issue with classpath. Do I need to set classpath in script also.
You are missing the classpath within your java task:
<classpath>
<pathelement location="yourjar.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
I have a zend framework 2 project and i am trying to set up my jenkins so that unit tests can be executed. Jenkins is running on ubuntu and i am developing under Windows 7 with PHPStorm.
build.xml
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true">
<arg value="${basedir}/module/Addressbook/test"/>
</exec>
</target>
Folder structure:
project
module
Addressbook
test
AddressbookTest
Controller
AddressbookControllerTest.php
Boostrap.php
phpunit.xml.dist
TestConfig.php
build.xml
Jenkins Output:
phpunit:
[exec] PHPUnit 3.7.13 by Sebastian Bergmann.
[exec]
[exec] PHP Fatal error: Class 'AddressbookTest\Bootstrap' not found in /var/lib/jenkins/workspace/Test/src/module/Addressbook/test/AddressbookTest/Controller/AddressbookControllerTest.php on line 28
PHPStorm on my local machine does this when running phpunit.xml.dist
D:\Zend\ZendServer\bin\php.exe -d auto_prepend_file=D:/Zend/Apache2/htdocs/demoshop/vendor/autoload.php C:\Users\ChristianB\AppData\Local\Temp\ide-phpunit.php --configuration D:/Zend/Apache2/htdocs/demoshop/module/Addressbook/test/phpunit.xml.dist
How can i use that for jenkins?
It looks like your include path isn't setup correctly, I wouldn't use exec directly with PHPUNIT when there's better options.
You should look into using PHING tasks with Jenkins, they work excellent together.
You then setup Jenking to trigger your PHING target to run the unit tests for you via the PHPUNIT task, an example phing target for PHPUNIT:
<target name="phpunit">
<phpunit bootstrap="${srcdir}/tests/bootstrap.php">
<formatter todir="${builddir}/reports" type="xml"/>
<batchtest>
<fileset dir="${srcdir}/tests">
<include name="**/*Test*.php"/>
<exclude name="**/Abstract*.php"/>
<exclude name="${srcdir}/vendor/**"/>
</fileset>
</batchtest>
</phpunit>
<!--
Generate a report from the XML data created..
note: error when using format="frames"
-->
<phpunitreport infile="${builddir}/reports/testsuites.xml"
format="noframes"
todir="${builddir}/reports/tests"
/>
</target>
I have a small program that displays some database tables. The program has a class with a main() method. I have an ant script that builds and runs the program.
The ant script is able to build the program and runs its tests but not run it. When i run it I get the following error:
[java] Could not find com.my.MyProgram. Make sure you have it in your classpath
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:138)
The issue here is that my java task target is not finding my classpath. I have printed my classpath and it has all the necessary jars and classes.
Here is part of my build.xml:
<path id="classpath">
<pathelement location="${build.src}" />
<pathelement location="${build.test}" />
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="run" depends="compile">
<java classname="MyProgram" fork="false">
<classpath refid="classpath"/>
</java>
</target>
Does anyone know why the run task cannot find my classpath?
I have the following Sonar Ant target defined:
<target name='sonar'>
<property name='sonar.sources' value='${src.dir}'/>
<property name='sonar.tests' value='${test.src.dir}'/>
<property name='sonar.binaries' value='build/classes'/>
<path id='jars'>
<fileset dir='${env.JAVA_HOME}/jre/lib' includes='*.jar'/>
<fileset dir='build/lib/test' includes='*.jar'/>
</path>
<pathconvert property='sonar.libraries' refid='jars' pathsep=','/>
<exec executable='p4' outputproperty='p4.P4CLIENT'>
<arg value='set'/>
<arg value='P4CLIENT'/>
</exec>
<propertyregex
property='p4client'
input='${p4.P4CLIENT}'
regexp='P4CLIENT=([^ ]+) *.*'
replace='\1'/>
<propertyregex
property='sonar.timestamp'
input='${build.time}'
regexp='_'
replace='T'/>
<sonar:sonar key='com.netflix:${module.name}' version='${p4client}#${sonar.timestamp}' xmlns:sonar='antlib:org.sonar.ant'/>
<property name='sonar.dynamicAnalysis' value='reuseReports'/>
<property name='sonar.emma.reportPath' value='${coverage.dir}'/>
</target>
When I run 'ant sonar' and bring up Sonar in my browser, I see info about the classes in the src directory, but nothing about the stuff in the test directory.
If I add ${test.src.dir} to sonar.sources and not set sonar.tests, I see some info about the test classes, but Sonar still reports 0 Test Successes.
How do I get it so I can drill down to each test method and their stats?
For anyone else that runs across this issue, I finally got Sonar to report on our Emma Code coverage. The first problem was that the Emma plugin did not come with the version of Sonar I was using (3.1.1). I had to download it and install it to the extensions/plugins directory of Sonar and restart it.
Then I had to set the following properties in my build.xml:
<property name="sonar.core.codeCoveragePlugin" value="emma" />
<property name="sonar.emma.reportPath" value="${coverage.dir}" />
After this, I atleast saw the following output after running the Sonar ant task:
[sonar:sonar] 13:41:49.705 WARN org.sonar.INFO - No coverage (*.ec) file found in /my/local/path
[sonar:sonar] 13:41:49.708 WARN org.sonar.INFO - No metadata (*.em) file found in /my/local/path
After some digging, I found that inside of the Sonar Emma plugin, it is hard-coded to look for a .ec (coverage) file and a .em (metadata) file. Unfortunately, my coverage file had a .emma extension as did my metadata file and I was unable to rename them as it would break other functionality. So I wrote the following Ant task to copy the files to match the naming standard that the Sonar Emma plugin expects.
<target name="createEmmaFilesWithSonarNamingStandard" depends="defineAntContribTasks">
<if>
<available file="${coverage.dir}/metadata.emma" />
<then>
<copyfile src="${coverage.dir}/metadata.emma" dest="${coverage.dir}/metadata.em" />
</then>
</if>
<if>
<available file="${coverage.dir}/coverage.emma" />
<then>
<copyfile src="${coverage.dir}/coverage.emma" dest="${coverage.dir}/coverage.ec" />
</then>
</if>
</target>
After running this again, I came across a new problem:
org.sonar.api.utils.SonarException: java.io.IOException: cannot read [/my/local/path/build/coverage/metadata.em]: created by another EMMA version [2.0.5312]
After some more digging, I found that the Sonar Emma 1.0.1 plugin was compiled against Emma 2.0.5312 and the Sonar Emma 1.1 and 1.2.x against Emma version 2.1.5320 as stated on the Sonar Emma plugin page.
I downloaded the 2.1.5320 version of Emma, replaced both emma.jar as well as emma_ant.jar in my Ant lib directory. After a clean re-compile and test, I was able to re-run the Sonar Ant task and have my code coverage reflected on Sonar.
The property 'sonar.surefire.reportsPath' needs to be defined before the definition of the sonar target.
The following definition gets the test info exported (although it's still not exporting coverage info):
<property name='sonar.surefire.reportsPath' value='${test.dir}'/>
<property name='sonar.dynamicAnalysis' value='reuseReports'/>
<property name='sonar.emma.reportPath' value='${coverage.report.dir}'/>
<target name='sonar'>
<property name='sonar.sources' value='${src.dir}'/>
<property name='sonar.tests' value='${test.src.dir}'/>
<property name='sonar.binaries' value='${build.dir}'/>
<path id='jars'>
<fileset dir='${env.JAVA_HOME}/jre/lib' includes='*.jar'/>
<fileset dir='${ivy.lib.dir}/test' includes='*.jar'/>
</path>
<pathconvert property='sonar.libraries' refid='jars' pathsep=','/>
<exec executable='p4' outputproperty='p4.P4CLIENT'>
<arg value='set'/>
<arg value='P4CLIENT'/>
</exec>
<propertyregex
property='p4client'
input='${p4.P4CLIENT}'
regexp='P4CLIENT=([^ ]+) *.*'
replace='\1'/>
<propertyregex
property='sonar.timestamp'
input='${build.time}'
regexp='_'
replace='T'/>
<sonar:sonar key='com.netflix:${module.name}' version='${p4client}#${sonar.timestamp}' xmlns:sonar='antlib:org.sonar.ant'/>
</target>