ops4j / org.ops4j.pax.web

OSGi R7 Http Service, Whiteboard and Web Applications (OSGi CMPN Release chapters 102, 140 and 128) implementation using Jetty 9, Tomcat 9 or Undertow 2.
https://ops4j1.jira.com/wiki/display/paxweb/Pax+Web
Other
142 stars 184 forks source link

Attempt to run OSGi TCK #1803

Open grgrzybek opened 1 year ago

grgrzybek commented 1 year ago

Whiteboard (CMPN 8.1) tests: https://github.com/osgi/osgi/tree/main/org.osgi.test.cases.servlet Official test project: https://github.com/osgi/osgi-test Helper library: https://github.com/laeubisoft/osgi-test-framework

grgrzybek commented 1 year ago

Chapter 128 TCK: https://github.com/osgi/osgi/tree/main/org.osgi.test.cases.webcontainer/src/org/osgi/test/cases/webcontainer/junit Chapter 140 TCK: https://github.com/osgi/osgi/tree/main/org.osgi.test.cases.servlet/src/org/osgi/test/cases/servlet/junit and https://github.com/osgi/osgi/tree/main/org.osgi.test.cases.servlet.secure/src/org/osgi/test/cases/servlet/secure/junit

grgrzybek commented 1 year ago

From osgi/osgi#548:

But I don't see osgi.tck.cmpn folder in osgi/osgi project

The build on GHA uses some code to cause the TCK extraction:

https://github.com/osgi/osgi/blob/ec62218646e12d2cb8069a7f685b80a159f61805/osgi.tck/build.gradle#L105-L121

The task is :osgi.tck:preptck.cmpn. If you run that gradle task after the :build task, you will have a osgi.tck/generated/osgi.tck.cmpn folder that you can cd into the run the TCKs.

The GHA build uploads these folders

https://github.com/osgi/osgi/blob/ec62218646e12d2cb8069a7f685b80a159f61805/.github/workflows/cibuild.yml#L79-L86

which are then downloaded and used by the tck execution job.

https://github.com/osgi/osgi/blob/ec62218646e12d2cb8069a7f685b80a159f61805/.github/workflows/cibuild.yml#L191-L199

Also:

I have added a TCK to the Microsoft JDBC driver here that shows how to do the maven setup: https://github.com/microsoft/mssql-jdbc/pull/2066/files

grgrzybek commented 1 year ago

According to https://github.com/osgi/osgi/blob/main/CONTRIBUTING.md#run--debug-a-tck, I can run a test using:

$ gradle :org.osgi.test.cases.webcontainer:testOSGi

testOSGi comes from bnd gradle plugin: https://github.com/bndtools/bnd/tree/6.4.0/gradle-plugins#additional-tasks

grgrzybek commented 1 year ago

Here's how I managed to relatively easily run TCK tests.

Build what's needed:

$ gradle :build :publish
$ gradle :osgi.specs:specifications :osgi.tck:tck.core :osgi.tck:tck.cmpn

Then the goal is to be able to use bnd runtests inside osgi.tck/generated/osgi.tck.cmpn directory.

For example, I've replaced Virgo&Gemini with Pax Web by adding to cnf/repo/org.osgi.impl.bundle.webcontainer/org.osgi.impl.bundle.webcontainer-7.0.0.lib this:

org.osgi.service.repository;version=1.1.0
jakarta.servlet-api;version="[4.0,5.0)"
javax.el-api;version=3.0.3
jakarta.annotation-api;version="[1.3.5,2.0)"
javax.security.auth.message-api;version=1.1.3
org.eclipse.jdt.core.compiler.batch;version=3.26.0
org.osgi.util.promise;version=1.3.0
org.osgi.util.function;version=1.2.0
biz.aQute.bndlib;version=6.4.0
biz.aQute.bnd.util;version=6.4.0
biz.aQute.bnd.transform;version=6.4.0
org.ops4j.base;version=1.5.1
org.ops4j.pax.swissbox.bnd;version=1.8.5
org.ops4j.pax.swissbox.property;version=1.8.5
org.ops4j.pax.url.commons;version=2.6.12
org.ops4j.pax.url.war;version=2.6.12
org.ops4j.pax.logging.pax-logging-api;version=2.2.2
org.ops4j.pax.logging.pax-logging-log4j2;version=2.2.2
org.ops4j.pax.web.pax-web-api;version=8.0.18
org.ops4j.pax.web.pax-web-spi;version=8.0.18
org.ops4j.pax.web.pax-web-runtime;version=8.0.18
org.ops4j.pax.web.pax-web-tomcat-common;version=8.0.18
org.ops4j.pax.web.pax-web-tomcat;version=8.0.18
org.ops4j.pax.web.pax-web-compatibility-el2;version=8.0.18
org.ops4j.pax.web.pax-web-jsp;version=8.0.18
org.ops4j.pax.web.pax-web-extender-war;version=8.0.18

After changing the above, I could run:

$ gradle :osgi.impl:clean :osgi.impl:build
$ gradle :osgi.tck:clean :osgi.tck:preptck.cmpn

Finally, when being in osgi.tck/generated/osgi.tck.cmpn, I can run individual tests:

$ bnd runtests -t 'org.osgi.test.cases.webcontainer.junit.BundleManifestHeadersTest#testManifestHeaders001' org.osgi.test.cases.webcontainer.bnd

My bnd command is:

#!/bin/bash

java -jar /home/ggrzybek/.m2/repository/biz/aQute/bnd/biz.aQute.bnd/6.4.0/biz.aQute.bnd-6.4.0.jar $@

To debug the tests, I've copied osgi.tck/generated/osgi.tck.cmpn/org.osgi.test.cases.webcontainer.bnd to osgi.tck/generated/osgi.tck.cmpn/org.osgi.test.cases.webcontainer-d.bnd adding this at the end:

-runvm="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"

Finally to get fresh OSGi TCK jars in ~/.m2/repository, it's enough to run:

$ gradle :org.osgi.test.cases.webcontainer:release

(or any other TCK lib). pom, jar, source-jar is copied to Maven local repo.

grgrzybek commented 1 year ago

Also, to make changes to Pax Web and Pax URL easier, I've replaced some libs in osgi.tck/generated/osgi.tck.cmpn/jar with symbolic links:

$ ls -l *pax*
-rw-r--r--. 1 ggrzybek ggrzybek  809830 04-03 15:14 org.ops4j.pax.logging.pax-logging-api-2.2.2.jar
-rw-r--r--. 1 ggrzybek ggrzybek 2160942 04-03 15:14 org.ops4j.pax.logging.pax-logging-log4j2-2.2.2.jar
-rw-r--r--. 1 ggrzybek ggrzybek    9744 04-03 15:14 org.ops4j.pax.swissbox.bnd-1.8.5.jar
-rw-r--r--. 1 ggrzybek ggrzybek    4009 04-03 15:14 org.ops4j.pax.swissbox.property-1.8.5.jar
-rw-r--r--. 1 ggrzybek ggrzybek    9641 04-03 15:14 org.ops4j.pax.url.commons-2.6.12.jar
lrwxrwxrwx. 1 ggrzybek ggrzybek      90 04-05 10:33 org.ops4j.pax.url.war-2.6.12.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.url/pax-url-war/target/pax-url-war-2.6.12.jar
lrwxrwxrwx. 1 ggrzybek ggrzybek      94 04-05 10:28 org.ops4j.pax.web.pax-web-api-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-api/target/pax-web-api-8.0.18.jar
-rw-r--r--. 1 ggrzybek ggrzybek    3013 04-03 15:14 org.ops4j.pax.web.pax-web-compatibility-el2-8.0.18.jar
lrwxrwxrwx. 1 ggrzybek ggrzybek     112 04-05 10:30 org.ops4j.pax.web.pax-web-extender-war-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-extender-war/target/pax-web-extender-war-8.0.18.jar
-rw-r--r--. 1 ggrzybek ggrzybek 1026193 04-03 15:14 org.ops4j.pax.web.pax-web-jsp-8.0.18.jar
-rw-r--r--. 1 ggrzybek ggrzybek  160674 04-03 15:14 org.ops4j.pax.web.pax-web-runtime-8.0.18.jar
lrwxrwxrwx. 1 ggrzybek ggrzybek      94 04-05 10:30 org.ops4j.pax.web.pax-web-spi-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-spi/target/pax-web-spi-8.0.18.jar
lrwxrwxrwx. 1 ggrzybek ggrzybek     100 04-05 10:31 org.ops4j.pax.web.pax-web-tomcat-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-tomcat/target/pax-web-tomcat-8.0.18.jar
-rw-r--r--. 1 ggrzybek ggrzybek  552160 04-03 15:14 org.ops4j.pax.web.pax-web-tomcat-common-8.0.18.jar
mattrpav commented 1 year ago

Is it feasible to add the TCK run to CI?

From: Grzegorz Grzybek @.> Date: Wednesday, April 5, 2023 at 6:40 AM To: ops4j/org.ops4j.pax.web @.> Cc: Subscribed @.***> Subject: Re: [ops4j/org.ops4j.pax.web] Attempt to run OSGi TCK (Issue #1803)

Also, to make changes to Pax Web and Pax URL easier, I've replaced some libs in osgi.tck/generated/osgi.tck.cmpn/jar with symbolic links:

$ ls -l pax

-rw-r--r--. 1 ggrzybek ggrzybek 809830 04-03 15:14 org.ops4j.pax.logging.pax-logging-api-2.2.2.jar

-rw-r--r--. 1 ggrzybek ggrzybek 2160942 04-03 15:14 org.ops4j.pax.logging.pax-logging-log4j2-2.2.2.jar

-rw-r--r--. 1 ggrzybek ggrzybek 9744 04-03 15:14 org.ops4j.pax.swissbox.bnd-1.8.5.jar

-rw-r--r--. 1 ggrzybek ggrzybek 4009 04-03 15:14 org.ops4j.pax.swissbox.property-1.8.5.jar

-rw-r--r--. 1 ggrzybek ggrzybek 9641 04-03 15:14 org.ops4j.pax.url.commons-2.6.12.jar

lrwxrwxrwx. 1 ggrzybek ggrzybek 90 04-05 10:33 org.ops4j.pax.url.war-2.6.12.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.url/pax-url-war/target/pax-url-war-2.6.12.jar

lrwxrwxrwx. 1 ggrzybek ggrzybek 94 04-05 10:28 org.ops4j.pax.web.pax-web-api-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-api/target/pax-web-api-8.0.18.jar

-rw-r--r--. 1 ggrzybek ggrzybek 3013 04-03 15:14 org.ops4j.pax.web.pax-web-compatibility-el2-8.0.18.jar

lrwxrwxrwx. 1 ggrzybek ggrzybek 112 04-05 10:30 org.ops4j.pax.web.pax-web-extender-war-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-extender-war/target/pax-web-extender-war-8.0.18.jar

-rw-r--r--. 1 ggrzybek ggrzybek 1026193 04-03 15:14 org.ops4j.pax.web.pax-web-jsp-8.0.18.jar

-rw-r--r--. 1 ggrzybek ggrzybek 160674 04-03 15:14 org.ops4j.pax.web.pax-web-runtime-8.0.18.jar

lrwxrwxrwx. 1 ggrzybek ggrzybek 94 04-05 10:30 org.ops4j.pax.web.pax-web-spi-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-spi/target/pax-web-spi-8.0.18.jar

lrwxrwxrwx. 1 ggrzybek ggrzybek 100 04-05 10:31 org.ops4j.pax.web.pax-web-tomcat-8.0.18.jar -> /data/sources/github.com/ops4j/org.ops4j.pax.web-8.0/pax-web-tomcat/target/pax-web-tomcat-8.0.18.jar

-rw-r--r--. 1 ggrzybek ggrzybek 552160 04-03 15:14 org.ops4j.pax.web.pax-web-tomcat-common-8.0.18.jar

— Reply to this email directly, view it on GitHubhttps://github.com/ops4j/org.ops4j.pax.web/issues/1803#issuecomment-1497344165, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAD5A5ZSQXKJPEKV4BCMNYTW7VKZFANCNFSM6AAAAAASLG3LZY. You are receiving this because you are subscribed to this thread.Message ID: @.***>

grgrzybek commented 1 year ago

Is it feasible to add the TCK run to CI?

Sure! I plan to use something similar to https://github.com/microsoft/mssql-jdbc/pull/2066/files