eclipse-ee4j / jakartaee-tck-tools

Other
8 stars 16 forks source link

Archive Name is incorrect for jpa tests #152

Closed scottmarlow closed 1 month ago

scottmarlow commented 1 month ago

The Arquillian TsTestPropsBuilder.vehicleArchiveName() is returning names like jpa_core_EntityGraph_vehicles since deployment.getDescription().getArchive().getName() is returning jpa_core_EntityGraph_vehicles.ear

^ seems to because of the JPA test ear names in use such as https://github.com/jakartaee/platform-tck/commit/817632426d143ce00516fd2c4a4208f8dbd0e6c3#diff-d7378e1899f757a7c97b65acc9dc8dc4d7b727f6019e43b895fe7bfcc8aeb779R157:

EnterpriseArchive jpa_core_EntityGraph_vehicles_ear = ShrinkWrap.create(EnterpriseArchive.class, "jpa_core_EntityGraph_vehicles.ear");

^ leads to failures like:

&amp#27;[0m&amp#27;[31m10:50:32,968 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."jpa_core_EntityGraph_vehicles.ear".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jpa_core_EntityGraph_vehicles.ear".STRUCTURE: WFLYSRV0153: Failed to process phase STRUCTURE of deployment "jpa_core_EntityGraph_vehicles.ear" at org.jboss.as.server@26.0.0.Beta4//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172) at org.jboss.msc@1.5.5.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1617) at org.jboss.msc@1.5.5.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1580) at org.jboss.msc@1.5.5.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1438) at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377) at java.base/java.lang.Thread.run(Thread.java:1583) Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYAC0007: Could not find application client jpa_core_EntityGraph_vehicles_client.jar at org.jboss.as.appclient@34.0.0.Beta1-SNAPSHOT//org.jboss.as.appclient.deployment.ApplicationClientStructureProcessor.deploy(ApplicationClientStructureProcessor.java:69) at org.jboss.as.server@26.0.0.Beta4//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165) ... 8 more

The workaround is :

git diff src/test/resources/javatest-appclient-arquillian.xml
diff --git a/src/test/resources/javatest-appclient-arquillian.xml b/src/test/resources/javatest-appclient-arquillian.xml
index e25d579..b3533d4 100644
--- a/src/test/resources/javatest-appclient-arquillian.xml
+++ b/src/test/resources/javatest-appclient-arquillian.xml
@@ -37,7 +37,7 @@
             <property name="runClient">true</property>
             <property name="runAsVehicle">true</property>
             <property name="clientEarDir">target/appclient</property>
-            <property name="clientCmdLineString">${jboss.home}/bin/appclient.sh;-y=${project.build.testOutputDirectory}/appclient.yml:${project.build.testOutputDirectory}/derby.yml;${clientEarDir}/${vehicleArchiveName}.ear#${vehicleArchiveName}_client.jar</property>
+            <property name="clientCmdLineString">${jboss.home}/bin/appclient.sh;-y=${project.build.testOutputDirectory}/appclient.yml:${project.build.testOutputDirectory}/derby.yml;${clientEarDir}/${vehicleArchiveName}.ear</property>
             <property name="clientEnvString">MY_EN=my-env-stting</property>
             <property name="clientDir">${project.basedir}</property>
             <property name="workDir">${ts.home}/tmp</property>

As far as I understand it, this is only a jpa test issue. Perhaps we can workaround it differently.

scottmarlow commented 1 month ago

I took another look at ^ and I don't think this issue is correct about the cause, so will look again.

scottmarlow commented 1 month ago

The test pattern that seems to work is where the appclient archive has the same name as the ear except with _client added on:

             // the jar with the correct archive name
-            JavaArchive jpa_core_EntityGraph_appmanaged_vehicle_client = ShrinkWrap.create(JavaArchive.class, "jpa_core_EntityGraph_appmanaged_vehicle_client.jar");
+            JavaArchive jpa_core_EntityGraph_appmanaged_vehicle_client = ShrinkWrap.create(JavaArchive.class, "jpa_core_EntityGraph_appmanaged_vehicles_client.jar");
.
.
.
EnterpriseArchive jpa_core_EntityGraph_vehicles_ear = ShrinkWrap.create(EnterpriseArchive.class, "jpa_core_EntityGraph_appmanaged_vehicles.ear");

So we might need to update the jpa tests to only update the client jar name to match the ear.

scottmarlow commented 1 month ago

Trying the following to update 900 JPA tests:

set -x 

function update_tests ()
{
  name=$1

    for updatefile in `find  -name "*$name*"`; do
        # echo "do something with file $updatefile"
        EAR_CLASS="$(grep "EnterpriseArchive.class" $updatefile | cut -d \" -f2 | cut -d'.' -f1)"
        # echo "class is $EAR_CLASS"
        # class is jpa_jpa22_repeatable_namedentitygraph_vehicles.ear
        # update line with JavaArchive jpa_core_annotations_access_field_appmanagedNoTx_vehicle_client = ShrinkWrap.create(JavaArchive.class, "jpa_core_annotations_access_field_appmanagedNoTx_vehicle_client.jar");
        # search pattern will be something like "JavaArchive.class.*_client.jar"
        # ^ will be updated to "$EAR_CLASS_client.jar"
        sed "s%JavaArchive.class.*_client.jar%JavaArchive.class, \"${EAR_CLASS}_client.jar%" -i $updatefile
    done
}

# covers both AppmanagedTest + Appmanagednotx
update_tests "*Appmanaged*.java"
update_tests "*Stateful3Test*.java"
update_tests "*Stateless3Test*.java"

set +x 
scottmarlow commented 1 month ago

Closing as handled via ^