Skip to content

Commit 8c9660c

Browse files
committed
Add lazy-deploy extension to test extensions without startup hooks
1 parent 5c2254a commit 8c9660c

File tree

6 files changed

+286
-2
lines changed

6 files changed

+286
-2
lines changed

.github/workflows/deployment-tests.yml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,28 @@ jobs:
4343
echo "Extension built:"
4444
unzip -l target/*.lex
4545
46+
- name: Build lazy-deploy extension
47+
run: |
48+
cd custom/deployment-tests/extensions/lazy-deploy
49+
mvn package -q
50+
ls -la target/
51+
echo "Extension built:"
52+
unzip -l target/*.lex
53+
4654
- name: Upload slow-startup extension
4755
uses: actions/upload-artifact@v4
4856
with:
4957
name: slow-startup-extension
5058
path: custom/deployment-tests/extensions/slow-startup/target/*.lex
5159
retention-days: 1
5260

61+
- name: Upload lazy-deploy extension
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: lazy-deploy-extension
65+
path: custom/deployment-tests/extensions/lazy-deploy/target/*.lex
66+
retention-days: 1
67+
5368
# Build Lucee from source (for build-from-source entries)
5469
build-lucee:
5570
runs-on: ubuntu-latest
@@ -165,6 +180,25 @@ jobs:
165180
artifactName: "7.1-native"
166181
delay: 0
167182
testMode: "stress"
183+
# Lazy deploy tests - NO startup hook, should expose LDEV-5960
184+
- name: "7.0-lazy-immediate"
185+
source: "download"
186+
luceeVersion: "7.0/snapshot/jar"
187+
delay: 0
188+
extension: "lazy-deploy"
189+
testPage: "test-lazy-deploy.cfm"
190+
- name: "7.0-lazy-delayed"
191+
source: "download"
192+
luceeVersion: "7.0/snapshot/jar"
193+
delay: 10
194+
extension: "lazy-deploy"
195+
testPage: "test-lazy-deploy.cfm"
196+
- name: "6.2-lazy-immediate"
197+
source: "download"
198+
luceeVersion: "6.2/snapshot/jar"
199+
delay: 0
200+
extension: "lazy-deploy"
201+
testPage: "test-lazy-deploy.cfm"
168202
steps:
169203
- name: Checkout
170204
uses: actions/checkout@v4
@@ -176,11 +210,19 @@ jobs:
176210
distribution: temurin
177211

178212
- name: Download slow-startup extension
213+
if: matrix.extension != 'lazy-deploy'
179214
uses: actions/download-artifact@v4
180215
with:
181216
name: slow-startup-extension
182217
path: extensions/
183218

219+
- name: Download lazy-deploy extension
220+
if: matrix.extension == 'lazy-deploy'
221+
uses: actions/download-artifact@v4
222+
with:
223+
name: lazy-deploy-extension
224+
path: extensions/
225+
184226
- name: Download Lucee Express template
185227
run: |
186228
curl -L -o express-template.zip "$EXPRESS_TEMPLATE_URL"
@@ -224,7 +266,12 @@ jobs:
224266
echo "" >> $GITHUB_STEP_SUMMARY
225267
226268
# Copy test script to webroot
227-
cp custom/deployment-tests/test-slow-startup.cfm express/webapps/ROOT/
269+
TEST_PAGE="${{ matrix.testPage }}"
270+
if [ -z "$TEST_PAGE" ]; then
271+
TEST_PAGE="test-slow-startup.cfm"
272+
fi
273+
cp "custom/deployment-tests/$TEST_PAGE" express/webapps/ROOT/
274+
echo "Test page: $TEST_PAGE"
228275
229276
# Copy extension to deploy folder BEFORE starting Lucee
230277
mkdir -p express/lucee-server/deploy/
@@ -330,9 +377,13 @@ jobs:
330377
fi
331378
332379
# Normal test mode - single endpoint
380+
TEST_PAGE="${{ matrix.testPage }}"
381+
if [ -z "$TEST_PAGE" ]; then
382+
TEST_PAGE="test-slow-startup.cfm"
383+
fi
333384
for i in {1..60}; do
334385
echo "Attempt $i..."
335-
HTTP_CODE=$(curl -s -o /tmp/response.txt -w "%{http_code}" http://127.0.0.1:8888/test-slow-startup.cfm 2>/dev/null) || HTTP_CODE="000"
386+
HTTP_CODE=$(curl -s -o /tmp/response.txt -w "%{http_code}" "http://127.0.0.1:8888/$TEST_PAGE" 2>/dev/null) || HTTP_CODE="000"
336387
echo "HTTP Code: $HTTP_CODE"
337388
if [ "$HTTP_CODE" != "000" ] && [ -f /tmp/response.txt ]; then
338389
echo "=== Response ==="
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project default="clean" basedir="." name="lazy-deploy-extension">
3+
<description>Build Lazy Deploy Test Extension</description>
4+
5+
<property name="src" location="source/java/src"/>
6+
<property name="srcFld" location="source/fld"/>
7+
<property name="temp" location="temp"/>
8+
<property name="build" location="build"/>
9+
<property name="dist" location="target"/>
10+
11+
<!-- These get passed in from pom.xml -->
12+
<property name="bundleversion" value="1.0.0"/>
13+
<property name="bundlename" value="lazy.deploy.extension"/>
14+
<property name="id" value="LAZY-DEPLOY-TEST-0000-0000-000000000001"/>
15+
<property name="label" value="Lazy Deploy Test Extension"/>
16+
<property name="description" value="Test extension demonstrating lazy deployment race condition"/>
17+
<property name="luceeCoreVersion" value="6.0.0.0"/>
18+
19+
<target name="init">
20+
<tstamp/>
21+
<delete dir="${temp}"/>
22+
<delete dir="${dist}"/>
23+
<mkdir dir="${temp}"/>
24+
<mkdir dir="${build}"/>
25+
<mkdir dir="${dist}/extension/jars"/>
26+
<mkdir dir="${dist}/extension/flds"/>
27+
<mkdir dir="${dist}/extension/META-INF"/>
28+
</target>
29+
30+
<target name="copy" depends="init">
31+
<copy todir="${temp}">
32+
<fileset dir="${src}">
33+
<include name="**/*.java"/>
34+
</fileset>
35+
</copy>
36+
37+
<tstamp>
38+
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss"/>
39+
</tstamp>
40+
41+
<!-- NO startup-hook - this is the key difference from slow-startup extension -->
42+
<echo file="${dist}/extension/META-INF/MANIFEST.MF">Manifest-Version: 1.0
43+
Built-Date: ${NOW}
44+
version: "${bundleversion}"
45+
id: "${id}"
46+
name: "${label}"
47+
description: "${description}"
48+
lucee-core-version: "${luceeCoreVersion}"
49+
start-bundles: true
50+
</echo>
51+
</target>
52+
53+
<target name="compile" depends="copy">
54+
<javac srcdir="${temp}" source="11" target="11" destdir="${build}" debug="true" debuglevel="lines,vars,source" includeantruntime="false">
55+
<classpath>
56+
<fileset dir="${basedir}">
57+
<include name="libs/*.jar"/>
58+
</fileset>
59+
</classpath>
60+
</javac>
61+
</target>
62+
63+
<target name="dist" depends="compile">
64+
<!-- Create the bundle JAR -->
65+
<jar jarfile="${dist}/extension/jars/${bundlename}-${bundleversion}.jar" basedir="${build}">
66+
<manifest>
67+
<attribute name="Bundle-Version" value="${bundleversion}"/>
68+
<attribute name="Built-Date" value="${NOW}"/>
69+
<attribute name="Bundle-SymbolicName" value="${bundlename}"/>
70+
<attribute name="Bundle-Name" value="${label}"/>
71+
<attribute name="Bundle-ManifestVersion" value="2"/>
72+
<attribute name="Export-Package" value="org.lucee.test.lazydeploy;version=&quot;${bundleversion}&quot;"/>
73+
<attribute name="DynamicImport-Package" value="*"/>
74+
</manifest>
75+
</jar>
76+
77+
<!-- Copy FLD -->
78+
<copy file="${srcFld}/lazy-deploy.fld" tofile="${dist}/extension/flds/lazy-deploy.fld"/>
79+
<replaceregexp file="${dist}/extension/flds/lazy-deploy.fld" match="\{bundle-name\}" replace="${bundlename}" byline="true"/>
80+
<replaceregexp file="${dist}/extension/flds/lazy-deploy.fld" match="\{bundle-version\}" replace="${bundleversion}" byline="true"/>
81+
82+
<!-- Create the .lex file -->
83+
<zip destfile="${dist}/lazy-deploy-extension-${bundleversion}.lex">
84+
<zipfileset dir="${dist}/extension"/>
85+
</zip>
86+
</target>
87+
88+
<target name="clean" depends="dist">
89+
<delete dir="${build}"/>
90+
<delete dir="${temp}"/>
91+
</target>
92+
</project>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.lucee.test</groupId>
8+
<artifactId>lazy-deploy-extension</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>pom</packaging>
11+
<name>Lazy Deploy Test Extension</name>
12+
<description>Test extension demonstrating ESAPI-style lazy deployment race condition (LDEV-5960)</description>
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<maven.compiler.source>11</maven.compiler.source>
17+
<maven.compiler.target>11</maven.compiler.target>
18+
<id>LAZY-DEPLOY-TEST-0000-0000-000000000001</id>
19+
<bundlename>lazy.deploy.extension</bundlename>
20+
<luceeCoreVersion>6.0.0.0</luceeCoreVersion>
21+
<label>Lazy Deploy Test Extension</label>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.lucee</groupId>
27+
<artifactId>lucee</artifactId>
28+
<version>[5.0,)</version>
29+
<scope>provided</scope>
30+
</dependency>
31+
</dependencies>
32+
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-dependency-plugin</artifactId>
38+
<version>3.6.0</version>
39+
<executions>
40+
<execution>
41+
<id>copy-lucee</id>
42+
<phase>initialize</phase>
43+
<goals>
44+
<goal>copy</goal>
45+
</goals>
46+
<configuration>
47+
<artifactItems>
48+
<artifactItem>
49+
<groupId>org.lucee</groupId>
50+
<artifactId>lucee</artifactId>
51+
<version>6.2.0.321-SNAPSHOT</version>
52+
<type>jar</type>
53+
<destFileName>lucee.jar</destFileName>
54+
</artifactItem>
55+
</artifactItems>
56+
<outputDirectory>${project.basedir}/libs</outputDirectory>
57+
</configuration>
58+
</execution>
59+
</executions>
60+
</plugin>
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-antrun-plugin</artifactId>
64+
<version>3.1.0</version>
65+
<executions>
66+
<execution>
67+
<phase>package</phase>
68+
<goals>
69+
<goal>run</goal>
70+
</goals>
71+
<configuration>
72+
<target>
73+
<ant antfile="build.xml" target="clean">
74+
<property name="bundleversion" value="${project.version}"/>
75+
<property name="bundlename" value="${bundlename}"/>
76+
<property name="id" value="${id}"/>
77+
<property name="label" value="${label}"/>
78+
<property name="description" value="${project.description}"/>
79+
<property name="luceeCoreVersion" value="${luceeCoreVersion}"/>
80+
</ant>
81+
</target>
82+
</configuration>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
89+
<repositories>
90+
<repository>
91+
<id>central</id>
92+
<url>https://repo1.maven.org/maven2</url>
93+
</repository>
94+
</repositories>
95+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE func-lib PUBLIC "-//Lucee//DTD CFML Function Library 1.0//EN" "dtd/web-cfmfunctionlibrary_1_0.dtd">
3+
<func-lib>
4+
<flib-version>1.0</flib-version>
5+
<short-name>lazy-deploy</short-name>
6+
<uri>http://lucee.org/test/lazy-deploy</uri>
7+
<display-name>Lazy Deploy Test Extension</display-name>
8+
<description>Test extension demonstrating ESAPI-style lazy deployment race condition (LDEV-5960)</description>
9+
10+
<function>
11+
<name>GetLazyConfig</name>
12+
<class bundle-name="{bundle-name}" bundle-version="{bundle-version}">org.lucee.test.lazydeploy.GetLazyConfig</class>
13+
<description>Returns config value - will fail if called before LazyDeployer runs</description>
14+
<return>
15+
<type>string</type>
16+
</return>
17+
</function>
18+
</func-lib>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.lucee.test.lazydeploy;
2+
3+
import lucee.runtime.PageContext;
4+
import lucee.runtime.exp.PageException;
5+
import lucee.runtime.ext.function.Function;
6+
7+
/**
8+
* Simple BIF that returns OK.
9+
* This extension has NO startup hook - it relies purely on lazy loading.
10+
*
11+
* If this function is available on first request, the extension was
12+
* deployed successfully. But there's no guarantee of pre-initialisation.
13+
*/
14+
public class GetLazyConfig implements Function {
15+
16+
private static final long serialVersionUID = 1L;
17+
18+
public static String call( PageContext pc ) throws PageException {
19+
// Simple test - just return OK
20+
// The fact this function exists proves the extension was loaded
21+
return "LazyConfig OK - extension loaded without startup hook";
22+
}
23+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<cfscript>
2+
// Test for LDEV-5960 - extension without startup hook
3+
// This tests if extensions without startup hooks are available on first request
4+
writeOutput( GetLazyConfig() );
5+
</cfscript>

0 commit comments

Comments
 (0)