connect to remote osgi container using -Dosgi.console vm arg - eclipse-plugin

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.

Related

Start TestExecute from TeamCity

To test our desktop application we are using TestComplete/TestExecute.
We have a Master project that is started on a Management machine.
This Master project doesn't require interaction with the Desktop, it is not testing our App.
This project will start the Slave remote project (actual UI tests of our app that require Desktop Interaction) on different VMs through TestExecute directly.
We are currently moving our Build process to TeamCity. On this Management machine we have a Build Agent from TeamCity. The Build Agent is running as service with a System Account (not the Local System Account).
We are not using the Local System Account (that can interact to the Desktop) because we need a domain account to access domain resources. And we don't want to start the Agent as a process, we want to keep it at a service.
Right now, we can't start TestExecute directly from TeamCity because TestExecute requires an interactive session and the Account of the Build Agent can't interact with Desktop.
We tried with a script (executed from TeamCity) to create a PSSession with a normal user that have access to Desktop and start TestExecute from this PSSession. But this is not working either.
Here is the exception that we had with both cases (directly and through PSSession):
Start-Process : This command cannot be run due to the error: This operation requires an interactive window station.
At line:3 char:9
+ Start-Process "D:\SmartBear\TestExecute 12\Bin\TestExecute.ex ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
Does anyone have a solution to start tests with TestExecute from TeamCity ? As I said this project doesn't need to interact with desktop, it will start the UI test on different VMs through TestExecute directly.
Or is it possible for a domain system account (like the one we are using) to interact with the Desktop ?
Inside the installation directory of TestExecute, you can find the manifest File TCLauncher.exe.Manifest :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!-- Here is the relevant part -->
<requestedExecutionLevel level="asInvoker" uiAccess="true">
</requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
You can configure the uiAccess to false.
If you don't use the TCLauncher, but directly TestExecute.exe, there is also a Manifest file, with the same section <Security> that you can configure.
You also can specify the level, from asInvoker to highestAvailable, but you might be prompted by the UAC.
The easiest thing you can do is to run the master project from Team City and the master project will invoke UI tests on slave machines. Since the master project does not require access to UI elements, there will not be any problems running it within a non-UI session.

Why do my Jenkins / Ant builds always fail?

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.

Phpunit and Jenkins

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

How to start selenium server with log4j

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.

Error URL for Prerrequisites Setup.exe Click Once VS 2008

I have this trouble:
I am using VS 2008 Team Suite, and I have WinForms csproj. I want Publish it using ClickOnce.
In Publish Properties of csproj, I have these values:
Publishing Folder Location (web site,
ftp server, or file path):
C:\ClickOnce\Frk.Security.CarWin.WebInstall\Publicacion\
Installation Folder URL (if different
than above):
http://CHANGETHESERVER/carwinclickonce/Publicacion/
Publish Version: 1.0.0.0
Prerrequisites: Windows Installer 3.1,
.NET 35. sp1
Now, I publish and all is OK. I need deploy my app to several machines (Development, Preproduction, production environments...), and I use Msbuild...
<Microsoft.Sdc.Tasks.Folder.CopyFolder
Source="Publicacion"
Destination="$(Directorio_Destination)\Publicacion" />
I copy C:\ClickOnce\Frk.Security.CarWin.WebInstall\Publicacion\ to another machine, in folder (this folder is root of a Web Site)
\\desiis\c$\Webs\carwinclickonce\Publicacion\
(http://desiis/carwinclickonce/Publicacion/)
I use MSBUILD and Mage like this; variable $(ProviderUrl) = http://desiis/carwinclickonce/Publicacion/
<Target Name="PublishClickOnce">
<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -pu $(ProviderUrl)" />
<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -cf $(CertDir)\Frk.Security.CarWin_TemporaryKey.pfx" />
</Target>
Now, I have my publish.htm in http://desiis/carwinclickonce/Publicacion/publish.htm.
There are two links to install application:
1. ) http://desiis/Carwinclickonce/Publicacion/Frk.Security.CarWin.application
Everything is OK for this option.
) http://desiis/Carwinclickonce/Publicacion/Setup.exe
This option gets errors!
The errors are the following:
Error al intentar descargar
'http://CHANGETHESERVER/carwinclickonce/Publicacion/Frk.Security.CarWin.application'.
(FAILS when try download
'http....Frk.Security.CarWin.application')
Vea el archivo de registro de la
instalación que se encuentra en
'C:\DOCUME~1\xxxxxx\CONFIG~1\Temp\VSD5B7.tmp\install.log'
para obtener más información.
install.log contents:
The following properties have been
set: Property: [AdminUser] = true
{boolean} Property:
[ProcessorArchitecture] = Intel
{string} Property: [VersionNT] = 5.1.3
{version} Running checks for package
'Windows Installer 3.1', phase
BuildList The following properties
have been set for package 'Windows
Installer 3.1': Running checks for
command
'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe'
Result of running operator
'VersionGreaterThanOrEqualTo' on
property 'VersionMsi' and value '3.1':
true Result of checks for command
'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe'
is 'Bypass' 'Windows Installer 3.1'
RunCheck result: No Install Needed
Launching Application.
URLDownloadToCacheFile failed with
HRESULT '-2146697211' Error: Error al
intentar descargar
'http://CHANGETHESERVER/carwinclickonce/Publicacion/Frk.Security.CarWin.application'.
(FAILS when try download
'http....Frk.Security.CarWin.application')
Any ideas? Can I use Mage.exe commands? How can I modify setup.exe?
Update:
use msbuild for using setup -url=http://desiis/....
<Exec Command="$(PublishDir)\setup -url=$(ProviderUrl)" />
Another problem is that after using the /url switch to change out the URL, a message box appears for manually confirming that the signature will be invalided for the assembly.
How can use setup -url=http://.... in silent mode?
How can I sign the setup.exe again?
My msbuild
<Target Name="PublishClickOnce">
<Exec Command="$(PublishDir)\setup -url=$(ProviderUrl)" />
<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -pu $(ProviderUrl)" />
<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -cf $(CertDir)\Frk.Security.CarWin_TemporaryKey.pfx" />
</Target>
To clarify, ClickOnce works. Your problem is with the setup.exe bootstrapper file that Visual Studio generates to install prerequisites. You use a bogus server name (CHANGETHESERVER) and change it later depending on what server you deploy to. The server name can easily be changed for the .application file but you're unsure how to fix the setup.exe file since it tries to launch http://CHANGETHESERVER/... after installs the prereqs. Is all this correct?
I'm not sure how to update your setup.exe file to point to the proper url. However, I wouldn't worry about updating it. I would go to Visual Studio, change "CHANGETHESERVER" to an actual server (like your Development server), and publish. The setup.exe that's generated will be good for the server you used. Keep a copy of that .exe and do the process again for your other servers (QA, Production, etc.). Deploy the server specific files to each server and you're done.
The setup.exe files aren't going to change unless you're adding/removing prerequisites. There's no need to generate and deploy a new one every time you deploy.
update:
Now, Publish and All is OK done. I need deploy my Publish in several machines (Development, Preproduction, production environments...), and I use Msbuild.
Then, using MSBUILD
<Microsoft.Sdc.Tasks.Folder.CopyFolder Source="Publicacion" Destination="$(Directorio_Destination)\Publicacion" />
I copy C:\ClickOnce\Frk.Security.CarWin.WebInstall\Publicacion\ to another machine, in folder (this folder is root of a Web Site)
\desiis\c$\Webs\carwinclickonce\Publicacion\
(http://desiis/carwinclickonce/Publicacion/)
I use MSBUILD and Mage like this; variable $(ProviderUrl) = http://desiis/carwinclickonce/Publicacion/
<Target Name="PublishClickOnce">
<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -pu $(ProviderUrl)" />
<Exec Command="$(Mage) -u $(PublishDir)\Frk.Security.CarWin.application -cf $(CertDir)\Frk.Security.CarWin_TemporaryKey.pfx" />
</Target>