"parent.lock" for firefox profile when running selenium maven plugin - maven

When my integration tests are run with selenium plugin for maven
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
the following message is received:
Lock file still present! C:\Users\ADM\AppData\Local\Temp\customProfileDirbb53fd86ecaf4236bf538b7a1171814b\parent.lock
If I delete parent.lock file immediately after the firefox profile is created the tests are working properly.
Does anyone know how to avoid creation of parent.lock file? or any other solution
I'm using selenium 2.33.0
the whole exception is
ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Firefox refused shutdown while preparing a profile
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:367)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirectory(FirefoxChromeLauncher.java:120)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:90)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.java:412)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRemoteSession(FirefoxLauncher.java:114)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:381)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:86)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:810)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:437)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:407)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:151)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$FileLockRemainedException: Lock file still present! C:\Users\ADM\AppData\Local\Temp\customProfileDirbb53fd86ecaf4236bf538b7a1171814b\parent.lock
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFileLockToGoAway(FirefoxChromeLauncher.java:318)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:365)
... 20 more

please ensure the following has been configured correctly
http://girliemangalo.wordpress.com/2009/02/05/creating-firefox-profile-for-your-selenium-rc-tests/

Related

gradle - How to start spring boot server before integarion test - so easy with maven

We are switching from maven to gradle. In maven we are starting the Spring Boot server in "pre-integration-test" phase with the use of the spring-boot-mvane-plugin as documented here https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<executions>
<execution>
<id>run e2e tests</id>
<phase>integration-test</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run verify</arguments>
</configuration>
</execution>
</executions>
</plugin>
I didn't find a way to fork a process in gradle. The gradle Spring Boot Plugin doesn't help either.
How can I achieve this in gradle?
I got it work with gradle-spawn-plugin, but it looks very complicated to me
backend/build.gradle
plugins {
id "com.wiredforcode.spawn" version "0.8.2"
}
task startServer(type: SpawnProcessTask, dependsOn: 'bootJar') {
command "java -jar ${projectDir}/build/libs/project-${version}.jar --spring.profiles.active=integration"
ready 'Started'
}
task stopServer(type: KillProcessTask)
frontend/build.gradle
task verify(dependsOn: ':backend:startServer', type: NpmTask) {
// Copy from 'dist'
inputs.files(fileTree('tests/e2e'))
dependsOn 'npmBuild'
args = ['run', 'verify']
}
check.dependsOn verify
verify.finalizedBy ':backend:stopServer'
But pay attention to some quirks: If you are logging to the console you get some problems. First everything looks fine. But after some minutes of testing the logging does not work anymore.
Many threads are blocked like this:
"http-nio-127.0.0.1-8082-exec-2" #27 daemon prio=5 os_prio=0 cpu=462,00ms elapsed=531,88s tid=0x00007f1442a32000 nid=0x76d5 waiting on condition [0x00007f136f021000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base#11.0.7/Native Method)
- parking to wait for <0x0000000454d81218> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(java.base#11.0.7/LockSupport.java:194)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(java.base#11.0.7/AbstractQueuedSynchronizer.java:885)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(java.base#11.0.7/AbstractQueuedSynchronizer.java:917)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base#11.0.7/AbstractQueuedSynchronizer.java:1240)
at java.util.concurrent.locks.ReentrantLock.lock(java.base#11.0.7/ReentrantLock.java:267)
at ch.qos.logback.core.OutputStreamAppender.writeBytes(OutputStreamAppender.java:197)
at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:231)
at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:102)
at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)
at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
at ch.qos.logback.classic.Logger.info(Logger.java:579)
I don't know exactly why but it seems to me that gradle-spawn-plugin is something doing with STDOUT. Maybe because of searching for the "ready" string. And as we do not log to console in production it is best not to do it when integration testing. So I disabled logging to console and everything works fine again.

How do I configure proxy settings for install4j-maven-plugin?

I tried passing the proxy settings in via <jvmArguments> just like you do with an install4j-generated installer:
<plugin>
<groupId>org.sonatype.install4j</groupId>
<artifactId>install4j-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>compile-installers</id>
<phase>package</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<jvmArguments>
<arg>-DproxySet=true</arg>
<arg>-Dhttps.proxyHost=...</arg>
<arg>-Dhttps.proxyPort=443</arg>
<arg>-DproxyAuth=true</arg>
<arg>-DproxyAuthUser=${...}</arg>
<arg>-DproxyPassword=${...}</arg>
</jvmArguments>
...
</configuration>
</execution>
</executions>
</plugin>
but that failed.
On a machine where proxy settings are injected via the IDE, the above works, even if I intentionally pass in a wrong password or even a nonexistent proxy server, so I guess I'm Doing It Wrong(tm).
Turns out it was a misconfiguration.
Lesson to take home: If you see "connection refused", "forbidden", or any other connection failure messages, it might be the proxy or the target server talking, you don't know and the install4j-maven-plugin output does not tell you.
It would be nice if a future install4j-maven-plugin version could output that information, but currently it does not.

jmeter-maven-plugin libraries management

I have such plugin configuration in my pom.xml
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter.maven.plugin.version}</version>
<configuration>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-json:2.4</artifact>
<artifact>kg.apc:jmeter-plugins-casutg:2.1</artifact>
</jmeterExtensions>
<junitLibraries>
<artifact>com.microsoft.sqlserver:sqljdbc4:4.0</artifact>
</junitLibraries>
<testFilesIncluded>
<jMeterTestFile>${tests.include}</jMeterTestFile>
</testFilesIncluded>
<jMeterProcessJVMSettings>
<xms>2048</xms>
<xmx>2048</xmx>
</jMeterProcessJVMSettings>
<customPropertiesFiles>
<!-- Custom property file -->
</customPropertiesFiles>
<propertiesJMeter>
<!-- Some properties that I pass into jmeter -->
</propertiesJMeter>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
After I run mvn clean verify I get such libsat /target/jmeter/lib/:
json-path-2.1.0.jar
json-path-2.2.0.jar
and in log file I see that jmeter fails from time to time with such exception:
jmeter.extractor.json.jsonpath.JSONPostProcessor: Error processing JSON content in Select Team Name, message:Could not compile inline filter : [?(#.id=="29011")]
Note that this [?(#.id=="29011")] is only a part of expression. Full expression is looks like similar to this: $.teamData[?(#.id=="29011")].name
I expect that this error somehow related to this multiple libs
Use last version of the plugin which has solved this issue as described in release notes:
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/master/CHANGELOG.md

Connecting to db2 from java client

I am trying to connect to db2 from a java client running the application as a jar. The jar is a super-jar with all dependencies generated by the shade plugin.
When I run the program from my ide(Netbeans) it runs fine, but when I run it from commandline like this it fails:
java -jar target/locationImporter.jar
The exception I get is:
Exception in thread "main" java.lang.NullPointerException
at com.ibm.as400.access.PortMapper.getServerSocket(PortMapper.java:216)
at com.ibm.as400.access.AS400ImplRemote.signonConnect(AS400ImplRemote.java:2363)
at com.ibm.as400.access.AS400ImplRemote.signon(AS400ImplRemote.java:2278)
at com.ibm.as400.access.AS400.sendSignonRequest(AS400.java:3142)
at com.ibm.as400.access.AS400.promptSignon(AS400.java:2706)
at com.ibm.as400.access.AS400.signon(AS400.java:4035)
at com.ibm.as400.access.AS400.connectService(AS400.java:1184)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3338)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1419)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1256)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:395)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at dataprep.ConnectionSupplier.getConnection(ConnectionSupplier.java:18)
at dataprep.SqlFileRunner.runScript(SqlFileRunner.java:65)
at dataprep.SqlFileRunner.runSqlFile(SqlFileRunner.java:26)
at dataprep.PrepareDatabase.main(PrepareDatabase.java:26)
The code that fails is:
Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();
return DriverManager.getConnection(JDBC_URL, JDBC_USER, JDBC_PASSWORD);
Since it runs in my ide, I know that the url, user and password is correct.
My shade plugin is configured like this in my pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>launcher</shadedClassifierName>
<finalName>locationImporter</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
After hours of debugging a colleague of mine pointed me in the right direction. Removing the minimizeJar fixes the problem since the shade plugin removed the file "SocketContainerInet" since it was not directly instantiated but via a string-value..

Issue with stopping weblogic server using wls-maven-plugin

This is part of my pom.xml of my .ear file
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>wls-maven-plugin</artifactId>
<version>12.1.1.0</version>
<configuration>
<adminurl>${adminURL}</adminurl>
<user>${username}</user>
<password>${pswrd}</password>
<upload>true</upload>
<remote>false</remote>
<verbose>true</verbose>
<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
<name>${project.build.finalName}</name>
<targets>${serverName}</targets>
<noExit>true</noExit>
<middlewareHome>${middlewareH}</middlewareHome>
<domainHome>${domainH}</domainHome>
</configuration>
<executions>
<execution>
<id>stopserver</id>
<phase>install</phase>
<goals>
<goal>stop-server</goal>
</goals>
<configuration>
<action>stopserver</action>
<workingDir>${stopScriptDirectory}</workingDir>
<command>stopScript.sh</command>
</configuration>
</execution>
</executions>
</plugin>
I am trying to stop the server by running the stopScript.sh
This is the error I am getting when it is trying to execute the stop-server goal:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.oracle.weblogic:wls-maven-plugin:12.1.1.0:stop-server (stopserver) on project OventusEAR2: Unable to parse configuration of mojo com.oracle.weblogic:wls-maven-plugin:12.1.1.0:stop-server for parameter command: Cannot assign configuration entry 'command' with value 'stopScript.sh' of type java.lang.String to property of type java.lang.String[]
Any ideas?
Though I am not familiar with this particular plugin, however I have seen similar issues before, I guess command parameter is expecting an array instead.
Please try replacing
<command>stopScript.sh</command>
with
<command>
<value>stopScript.sh</value>
</command>
and test again.

Resources