liferay-labs / arquillian-liferay

Arquillian Liferay Extension
Apache License 2.0
8 stars 13 forks source link

Doesn't work in Liferay 7.0.10 fixpack 13 #19

Closed ntrp closed 7 years ago

ntrp commented 7 years ago

The tests fail to start because the osgi MBeans are missing: org.jboss.arquillian.container.spi.client.container.LifecycleException: Cannot start Karaf container at org.jboss.arquillian.container.osgi.karaf.remote.KarafRemoteDeployableContainer.start(KarafRemoteDeployableContainer.java:105) Caused by: java.util.concurrent.TimeoutException at java.util.concurrent.FutureTask.get(FutureTask.java:205) at org.jboss.arquillian.container.osgi.jmx.JMXDeployableContainer.getMBeanProxy(JMXDeployableContainer.java:395)

Is there a workaround for that?

gamerson commented 7 years ago

Aries jmx bundles were removed in recent portal release. I don't know if that is the reason, if Liferay-Arquillian is assuming that aries jmx bundles will be there or not.

On Wed, Apr 19, 2017 at 5:10 AM, Ivan Gregurić Ortolan < notifications@github.com> wrote:

The tests stop because the osgi MBeans are missing: org.jboss.arquillian.container.spi.client.container.LifecycleException: Cannot start Karaf container at org.jboss.arquillian. container.osgi.karaf.remote.KarafRemoteDeployableContainer.start( KarafRemoteDeployableContainer.java:105) Caused by: java.util.concurrent.TimeoutException at java.util.concurrent.FutureTask.get(FutureTask.java:205) at org.jboss.arquillian.container.osgi.jmx.JMXDeployableContainer. getMBeanProxy(JMXDeployableContainer.java:395)

Is there a workaround for that?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/liferay-labs/arquillian-liferay/issues/19, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkVFeZhas4KV2c7TEwRNBVGqBipBcFkks5rxd2CgaJpZM4NBeHX .

-- Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

cgoncas commented 7 years ago

Hey guys!!!

We have an example of how we are deploying JMX into the bundle, so the test can be executed in DXP recent versions.

In https://github.com/liferay/com-liferay-adaptive-media/blob/master/build.gradle we have created the configuration runtimeLib, so you can use it in your test modules to deploy JMX and all the libs needed: https://github.com/liferay/com-liferay-adaptive-media/blob/164a6f35a8b244664ecd13841336679fa8328368/adaptive-media-image-test/build.gradle.

Thanks!

ntrp commented 7 years ago

Thank you, this informations were really helpful!

ntrp commented 7 years ago

@cgoncas do you have also some example using a webdriver to do client side tests? I cannot find any example in that project and I searched also inside other liferay projects..

@PortalURL("sample_portlet")
private URL _portlerURL;

@Drone
private WebDriver browser;

do not inject anything resulting in a null pointer exception..

I have an arquillian.xml with phantomjs configured as a browser inside src/testIntegration/resources

    <extension qualifier="webdriver">
        <property name="browser">phantomjs</property>
    </extension>

    <extension qualifier="graphene">
        <property name="url">http://localhost:8080</property>
    </extension>

and I have this libraries inside the build.gradle file:

testIntegrationCompile group: 'org.jboss.arquillian.graphene', name: 'graphene-webdriver', version: '2.2.0'
testIntegrationCompile group: "com.liferay", name: "com.liferay.arquillian.extension.junit.bridge", version: "1.0.7"
cgoncas commented 7 years ago

hey @ntrp,

We hae this example: https://github.com/liferay-labs/arquillian-blade-example. You can't use the com.liferay.arquillian.extension.junit.bridge if you want to use injection points in the tests.

Thanks!

kriegaex commented 6 years ago

Aries jmx bundles were removed in recent portal release. I don't know if that is the reason, if Liferay-Arquillian is assuming that aries jmx bundles will be there or not.

What does that mean and and how can it be fixed? I already posted a PR to fix this project for Windows with Liferay 7.0 GA3. Now I tried upgrading to 7.1.0 GA1 and am seeing this Karaf error. Can you please tell me how to exactly fix this by myself or maybe even maintain and fix the project to support the latest Liferay version?

kriegaex commented 6 years ago

Update: Arquillian Container Liferay does this:

ObjectName oname = new ObjectName("osgi.core:type=framework,*");
_frameworkMBean = _getMBeanProxy(mbeanServer, oname, FrameworkMBean.class, 30, TimeUnit.SECONDS);

oname = new ObjectName("osgi.core:type=bundleState,*");
_bundleStateMBean = _getMBeanProxy(mbeanServer, oname, BundleStateMBean.class, 30, TimeUnit.SECONDS);

The problem is: In Liferay 7.0 the osgi.core JMX component exists, in 7.1 it does not:

lr-7 0_jmx

lr-7 1_jmx

Is is just not activated? Or not prepackaged in the downloadable Liferay + Tomcat package? Does it need to be installed from the marketplace? I would be grateful for some assistance.

csierra commented 6 years ago

hi @kriegaex,

can you try downloading and installing aries jmx core extension? you can download it from here: https://search.maven.org/search?q=g:org.apache.aries.jmx

that should make osgi jmx extensions available.

kriegaex commented 6 years ago

Thanks for your answer. I think that I am missing one or more dependencies here. And sorry, I am really an OSGi beginner. GoGo shell says:

g! lb aries
START LEVEL 20
   ID|State      |Level|Name
  548|Active     |   10|Apache Aries JAX-RS Specification API (0.0.1.201805141451)
  549|Active     |   10|Apache Aries JAX-RS Whiteboard (0.0.1.201806261926)
  561|Active     |   10|Apache Aries JAX-RS JAX-RS JAXB JSON (0.0.1.201806080923)
  943|Installed  |   10|Apache Aries JMX Core (1.1.8)

g! start 943
org.osgi.framework.BundleException: Could not resolve module: org.apache.aries.jmx.core [94
3]
  Unresolved requirement: Import-Package: org.osgi.service.provisioning; version="[1.2.0,2.
0.0)"; resolution:="optional"
  Unresolved requirement: Import-Package: org.osgi.service.useradmin; version="[1.1.0,2.0.0
)"; resolution:="optional"
  Unresolved requirement: Import-Package: org.osgi.jmx; version="[1.1.0,2.0.0)"

Update: Okay, I looked for dependencies in mvnrepository.com and added the two on the bottom:

aries_jms_core_dependencies

Now I can activate the bundle.

csierra commented 6 years ago

hey @kriegaex,

could you try with this one? https://search.maven.org/search?q=org.osgi.jmx

kriegaex commented 6 years ago

Sorry, we wrote at the same time. See comment update above.

kriegaex commented 6 years ago

Next problem: Integration test fails with message:

org.jboss.arquillian.container.spi.client.container.LifecycleException: The bundle in the path ...\.m2\repository\com\liferay\com.liferay.hot.deploy.jmx.listener\1.0.1\com.liferay.hot.deploy.jmx.listener-1.0.1.jar can't be found, so it can't be installed

GoGo shell says:

g! lb jmx
START LEVEL 20
   ID|State      |Level|Name
  467|Active     |   10|Liferay Portal JMX API (2.0.0)
  479|Active     |   10|Liferay Portal JMX (5.0.2)
  943|Active     |   10|Apache Aries JMX Core (1.1.8)
  944|Active     |   10|Apache Aries JMX API (1.1.5)
  946|Installed  |    1|Liferay Hot Deploy JMX Listener (1.0.1)
g! start 946
org.osgi.framework.BundleException: Could not resolve module: com.liferay.hot.deploy.jmx.li
stener [946]
  Unresolved requirement: Import-Package: com.liferay.portal.kernel.messaging; version="[7.
0.0,8.0.0)"

Hunting for the next dependency: com.liferay.portal.kernel is needed by com.liferay.hot.deploy.jmx.listener. I also deployed it manually.

Now I am getting an actual Selenium error, the expected result of adding 2+3 is 5, but the value in the result field is 0. Investigating further... Update: When using the portlet manually in the browser, it works. Must be the way the Selenium test clicks the button. I am going to fix that and report back.

kriegaex commented 6 years ago

Okay, there was a problem with

@FindBy(css = "button[type=submit]")
private WebElement add;

in the test because there are two submit buttons in the DOM (also the Liferay search button). So I modified it to:

@FindBy(css = "button[type=submit][id^='_arquillian_sample']")
private WebElement add;

Maybe it is not the nicest thing to do to rely on automatic web element naming, but in a way the input field elements do the same, just relying on another part of their names.

Now the test is running. I will need to adapt missing component deployment and activation, though, before I can create a PR for Liferay 7.1. Just like JMX Core is installed from the local Maven repo before starting the test, the remaining set of components missing in Liferay 7.1 should also be installed automatically.

kriegaex commented 6 years ago

@csierra, I would like to have your advice for my next PR (upgrade to Liferay 7.1). How do you suggest to go about implementing the deployment of the set of needed dependencies in order to enable JMX hot deployment? I could

My preference is the first option, but I think I should wait for your answer first. I do not want to implement anything which then is rejected by the maintainers.

BTW, did you inspect my PR #24 yet? My next PR would branch off of that.

kriegaex commented 6 years ago

My solution can be found in #25. It is not perfect, but working for me.