From cbbd7176e72079b2c1065ea61b5c547a03722dc9 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Fri, 31 Oct 2025 19:50:14 -0400 Subject: [PATCH 1/6] tests(persistence): remove legacy DB sample files superseded by DBGenerator --- impl/test/db-samples/running.db | Bin 16384 -> 0 bytes impl/test/db-samples/running_v1.db | Bin 16384 -> 0 bytes impl/test/db-samples/suspended.db | Bin 12288 -> 0 bytes impl/test/db-samples/suspended_v1.db | Bin 12288 -> 0 bytes .../impl/test/DBGeneratorCli.java | 4 ++++ .../impl/test/ForkedDbGen.java | 4 ++++ 6 files changed, 8 insertions(+) delete mode 100644 impl/test/db-samples/running.db delete mode 100644 impl/test/db-samples/running_v1.db delete mode 100644 impl/test/db-samples/suspended.db delete mode 100644 impl/test/db-samples/suspended_v1.db create mode 100644 impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java create mode 100644 impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java diff --git a/impl/test/db-samples/running.db b/impl/test/db-samples/running.db deleted file mode 100644 index 461b7996b3fac60d9835b840c9ebc2a600053526..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3&u`>36vyo;?XF5G7r4L$jX>f@CQUNQBx4D&3p;d0w_>4Hkr2|#<2apkl6Xiw zvmI6|apJlc4xIT{kPrv{4mj}-aN@<8PPZ#nt<-{w^m6cX9OpUy*pBplvhOp`8fHq2 z_tNhqa~;RAL@BwJF?0L>_GZ*HgYTD=&dQ^t6W2^!O*?s~IIqr{PmtOxsa7Fl12 zXp!wfDfs@LkoRD9(L01Z_zf)Fr}b)s`)8YA;rjE3#$t*DkN^@u0!RP}AOR$R1dzbh z37pm6r-J&qefDuT^dfPsl6vWEy=mV&qyN1||HDy$TK|WQ{*R3Q=bjLa{_pl>vJ3!t zO#r}e0sv94^nWdxTB7_x?-IIkfzUK^GyIR`=DQb5QxK+l`v2FZUtX+^o1QL?kSqc* z5FR>LDlesOXvFT{t%{O0a?8w0+r5nF{gIw5A#;ocwzHfKWo7A1J~Uyi?lP=Zm+eA` z%UewG-bwuG+(_57m{u~rt53Uhx>OfIFG~qAoj?R)&fEy3c(Y)I- w{QUdXe=Fz#2_OL^fCP{L5dIp}}?U(^5p09~k=(*OVf diff --git a/impl/test/db-samples/running_v1.db b/impl/test/db-samples/running_v1.db deleted file mode 100644 index fa4c2bebeb8825fe11610f648fc7c28337226283..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3O>f&a7{^JcaoeoxF6*Ve3`Pg+MOG+Ewk%%StZ`bb3F) z8?PwPPq1OYKEd{7b{O_CcGz*)X{S+?;~)is1Z`Giz@q~ny*zyTkreQMKt5vB=_N{x zcH{3P^9Ui1$RyXY&%7ua_+gLGUg!)|Hs+f7&LELm3}wc8Eid4nC)W^MKmZ5;0U!Vb zfB+Bx0zd!=00AHX1c1OLC-4aL|0N$GXdVy%0zd!=00AHX1b_e#00KY&2mpb%Cm@E? zbi_O-k*P^1d|&3Q;f(nq^CdBM!kSK|lxBh18bFBTLDSLkSTaheGm}{!t0H464~yLa zS_$LW_~=5fVu!&G=rdHQple>x8iWHLT@zj}7*G*9D%*F5)E&=qtupEALwB!imF(~F zWGcJ!iM+eTh50(Kz3yzjxleirQs_;tdEt5v7t@??@dLby(R;Uv_c+{r+9A(K_u*Gh zX?KfIfA4W;tG$74;)iy4hJSs3>wVOSm7B}V5KCm9KUdjkkf`TwJf0-(SoLM%9&j!R;&tjRyTGd|OKp1^s+TpDWo+O*9K#LIWt=wI~YiQNX z8JF7Bw`pM0hE1Cv7sa`!Q>$y9kMgSZ`sS83Y9iBa#?#!4p_y#?=k~3Zxvu9@*ONHc zGOcS>=jpsoT+b!-IL$Rrh0JeS-)Y)c+iKtSY`Lr~m%U!D^<_)nc9E5xuNr40=WID6 zXFOp?^YorA<*fdmo*y?c#XfG}zzpWsD}P@>tLUm3dhW*kYOyX&r>vo+X_Tgky|r?| zMxKz1TN)9*xDAA8EpD6UtttBzLZ6z2hVLV^{j0I&IW88SdH(TtW6kyFR%syx0zd!= z00AHX1b_e#00KbZ4GEmo-^YS_xz9c#eLtivaiNlWS=d@xKRu!UX{rCsQGi1Kho$~+ zS^dwc5T*Y2qcB7J(QO9y(PYFZFF`74AQk9HT0_YG6u&w((lt$|x$JM~<1QU9)kV3B3 zLC&MU?;HKyDgPlq|MrIe637MwfB+Bx0zd!=00AHX1c1QhCU8=JABhTje9k`NM*j!@ Hng0J5x`dh5 diff --git a/impl/test/db-samples/suspended.db b/impl/test/db-samples/suspended.db deleted file mode 100644 index 0450b6af36164390f1eebb029355f45b85877464..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2KX21O6u{4Eo0d|FkYIrYMIcpRySC%R$t|GLv=#jWQc49Z=yJX!ZfsxhUDAfC z5+f6=NPH1S2E@R`#JAu(aJH)!Dpf(ELx<<#z4P&)}0-sVX}BrfaikV)EQ39ef$$FEhqSp*jl00KY&2mk>f00e*l z5C8%|00;m9AaKD6tik#Jg6|Nd2Lyls5C8%|00;m9AOHk_01yBIK;Zug(C#4aVOtMb ztYn{bn7~y%BKz2-mePIf=?Ui&yQ($7vTfU~=`x5^tAMKySt0_S&WqW8+8iJ`#cr#7 z`&_TI!QcZjP@#ZkRP?sjCiNL=x7@ZvJ)I{Vv+J1AP)MFIQ|_BPc~;EdA>n{+kNWJ+ z3Zd%hsC3#{Ju{!Qb{Un+M3U6?A6!&AueBv@N<)`#TK2lvc)8x(dEu^C?V9_@-dx#w z?p3x|(Y&^r?N0aC+_x*J5^z(nL=g*_5PLl7wL`vV22npWBkr@%+$FRpcx*n-^=4{R z3lt6xmHepTLQw_0tAcwgly2Vy>R9K=4~;2qP>62N%^_;do9FFy8dq*L*~<)io5 z2p?Dakc8@`%j^F^w#qm#XU|_6pGE#l&t5{SYK~UcDw?OcsuJSKdsC>0rd3@MGw_S) zH$#!hl#{DUuBy56Gb{%ae?jQ|SA>wVfBK=cGF@BCGzcI71b_e#00KY&2mk>fa1jXnef~Z{svF|s-pk^ diff --git a/impl/test/db-samples/suspended_v1.db b/impl/test/db-samples/suspended_v1.db deleted file mode 100644 index 1acb73558fb43fecccaaf451ce0c4a91c4fa7954..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&2G~`5P)~n|5D1Oy}$)UAXUO~*N$r^dnsxYsGz?jRNTLQ;QH{ z_%UaS*Qr%3Hu7GLI5loGMBHJD=8ZGscUrDA$5GBb(eZZEQF$tZVe!o<&c7*f{tz#u#Fy%WgwDy5kE|t1C;Qo?iRRz ztyj`u@CoHmCW9s|r_k^ktT^dgHK$?wo+09<*|N<}Pbv{}QyrSS{j7L>mxcShder3) zo-kiOJ<6VU*3ZnX+8*~+i7A%2UcyDE^9HZrF^q2ACDwDVva@Zuq_Rm~xVBSWb=_CH zYh(w_;-~5Ew0?h_zm1jxVM-orVj-9EK*a4vC=Se^(+$mzsPoX=V}4tT$b8n<8;Mab zkU2il@*BpPaUJkpT`ZEtx~PZ_SFIpwu5jI%!OJ}!DIM_;qp8)cjqUYvwOmS~UorUH zaW-Ndo~7A6)(dzXD3LvxK^Wc9d02}+3&WB~(CSc5MvhDjVWJS4s=Tahmp4mEe)!kO z_fb59#&nsPb}I9!bW*vLN;j3>!z2;&V%|B$WLu7>Ua#jA<&~Or@90$7u5-Iw<-c3+dliVL4r87?_LauME$k|4T1k0=wA8dAx)@?C45}MwiFX zIGWHU%FLiXo_szunN-<*wbWN`UwPP?PCqZC$cyB3Xcv5TI&}O(;dJPpS&LR7iS`bm zg`c{X9wW5=L2G^AO74Fk^yNK5NZY@D)>@n9CQ}Up2mk>f00e*l5C8%|00{gy0{@=B Y&rZ~XKKml6=RN&r_*&1@gT Date: Fri, 31 Oct 2025 19:55:29 -0400 Subject: [PATCH 2/6] chore: fix CI by removing examples module; remove *.db files from tests module Signed-off-by: Ricardo Zanini --- .../impl/test/DBGenerator.java | 21 +++-- .../impl/test/DBGeneratorCli.java | 24 +++++- .../impl/test/ForkedDbGen.java | 52 +++++++++++- .../impl/test/MvStorePersistenceTest.java | 83 +++++++++++++------ .../workflows-samples/set-listen-to-any.yaml | 4 +- pom.xml | 16 +++- 6 files changed, 163 insertions(+), 37 deletions(-) diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java index 706f5277..b2c0b404 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java @@ -16,10 +16,12 @@ package io.serverlessworkflow.impl.test; import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath; +import static org.awaitility.Awaitility.await; import io.serverlessworkflow.impl.WorkflowApplication; import io.serverlessworkflow.impl.WorkflowDefinition; import io.serverlessworkflow.impl.WorkflowInstance; +import io.serverlessworkflow.impl.WorkflowStatus; import io.serverlessworkflow.impl.persistence.PersistenceApplicationBuilder; import io.serverlessworkflow.impl.persistence.PersistenceInstanceHandlers; import io.serverlessworkflow.impl.persistence.bigmap.BytesMapPersistenceInstanceHandlers; @@ -27,16 +29,13 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Duration; import java.util.Map; -public class DBGenerator { +public final class DBGenerator { - public static void main(String[] args) throws IOException { - runInstance("db-samples/running_v1.db", false); - runInstance("db-samples/suspended_v1.db", true); - } - - private static void runInstance(String dbName, boolean suspend) throws IOException { + public static void generate(String dbName, boolean suspend) + throws IOException, InterruptedException { Files.deleteIfExists(Path.of(dbName)); try (PersistenceInstanceHandlers factories = BytesMapPersistenceInstanceHandlers.builder(new MVStorePersistenceStore(dbName)) @@ -51,8 +50,16 @@ private static void runInstance(String dbName, boolean suspend) throws IOExcepti readWorkflowFromClasspath("workflows-samples/set-listen-to-any.yaml")); WorkflowInstance instance = definition.instance(Map.of()); instance.start(); + + await() + .atMost(Duration.ofSeconds(5)) + .until(() -> instance.status() == WorkflowStatus.WAITING); + if (suspend) { instance.suspend(); + await() + .atMost(Duration.ofSeconds(5)) + .until(() -> instance.status() == WorkflowStatus.SUSPENDED); } } } diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java index 96564f79..4b4eabd4 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java @@ -1,4 +1,26 @@ +/* + * Copyright 2020-Present The Serverless Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package io.serverlessworkflow.impl.test; -public class DBGeneratorCli { +public final class DBGeneratorCli { + public static void main(String[] args) throws Exception { + if (args.length < 2) { + System.err.println("Usage: DBGeneratorCli "); + System.exit(2); + } + DBGenerator.generate(args[0], Boolean.parseBoolean(args[1])); + } } diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java index 375d487b..b556f3dc 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java @@ -1,4 +1,54 @@ +/* + * Copyright 2020-Present The Serverless Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package io.serverlessworkflow.impl.test; -public class ForkedDbGen { +import java.io.*; +import java.nio.file.*; +import java.util.Optional; + +final class ForkedDbGen { + private static String detectJavaCmd() { + Optional cmd = ProcessHandle.current().info().command(); + if (cmd.isPresent() && Files.isRegularFile(Path.of(cmd.get()))) return cmd.get(); + String home = System.getProperty("java.home"); + String exe = System.getProperty("os.name").toLowerCase().contains("win") ? "java.exe" : "java"; + Path p = Path.of(home, "bin", exe); + return Files.isRegularFile(p) ? p.toString() : "java"; + } + + static void run(Path db, boolean suspend) throws IOException, InterruptedException { + Files.createDirectories(db.getParent()); + String javaCmd = detectJavaCmd(); + String cp = System.getProperty("java.class.path"); + + ProcessBuilder pb = + new ProcessBuilder( + javaCmd, + "-cp", + cp, + DBGeneratorCli.class.getCanonicalName(), + db.toString(), + String.valueOf(suspend)); + pb.redirectErrorStream(true); + + Process p = pb.start(); + try (BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()))) { + for (String line; (line = r.readLine()) != null; ) System.out.println("[dbgen] " + line); + } + int code = p.waitFor(); + if (code != 0) throw new IllegalStateException("DB gen failed (" + code + ") for " + db); + } } diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java index d814a25f..e5fdc6e6 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java @@ -27,31 +27,59 @@ import io.serverlessworkflow.impl.persistence.bigmap.BytesMapPersistenceInstanceHandlers; import io.serverlessworkflow.impl.persistence.mvstore.MVStorePersistenceStore; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; import java.util.Map; +import java.util.stream.Stream; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -public class MvStorePersistenceTest { +@Execution(ExecutionMode.SAME_THREAD) +class MvStorePersistenceTest { + + @TempDir static Path tmp; + + static Path runningV1, suspendedV1, runningV0, suspendedV0; + + @BeforeAll + static void prepareDbSamples() throws IOException, InterruptedException { + runningV1 = tmp.resolve("running_v1.db"); + suspendedV1 = tmp.resolve("suspended_v1.db"); + runningV0 = tmp.resolve("running.db"); + suspendedV0 = tmp.resolve("suspended.db"); + + ForkedDbGen.run(runningV1, false); + ForkedDbGen.run(suspendedV1, true); + ForkedDbGen.run(runningV0, false); + ForkedDbGen.run(suspendedV0, true); + } @Test void testSimpleRun() throws IOException { - final String dbName = "db-samples/simple.db"; + final Path dbPath = tmp.resolve("simple.db"); try (PersistenceInstanceHandlers handlers = - BytesMapPersistenceInstanceHandlers.builder(new MVStorePersistenceStore(dbName)) + BytesMapPersistenceInstanceHandlers.builder( + new MVStorePersistenceStore(dbPath.toString())) .build(); WorkflowApplication application = PersistenceApplicationBuilder.builder(WorkflowApplication.builder(), handlers.writer()) - .build(); ) { + .build()) { + WorkflowDefinition definition = application.workflowDefinition( readWorkflowFromClasspath("workflows-samples/simple-expression.yaml")); + assertThat(handlers.reader().readAll(definition).values()).isEmpty(); + definition.instance(Map.of()).start().join(); + assertThat(handlers.reader().readAll(definition).values()).isEmpty(); - } finally { - Files.delete(Path.of(dbName)); } } @@ -60,40 +88,38 @@ void testWaitingInstance() throws IOException { TaskCounterPerInstanceListener taskCounter = new TaskCounterPerInstanceListener(); try (WorkflowApplication application = WorkflowApplication.builder().withListener(taskCounter).build()) { + WorkflowDefinition definition = application.workflowDefinition( readWorkflowFromClasspath("workflows-samples/set-listen-to-any.yaml")); WorkflowInstance instance = definition.instance(Map.of()); instance.start(); + assertThat(taskCounter.taskCounter(instance.id()).completed()).isEqualTo(1); } } - @Test - void testRestoreWaitingInstanceV0() throws IOException { - runIt("db-samples/running.db", WorkflowStatus.WAITING); + @ParameterizedTest(name = "{index} ⇒ {0} should restore as {1}") + @MethodSource("dbSamples") + void testRestoreInstances(Path dbFile, WorkflowStatus expectedStatus) throws IOException { + runIt(dbFile, expectedStatus); } - @Test - void testRestoreSuspendedInstanceV0() throws IOException { - runIt("db-samples/suspended.db", WorkflowStatus.SUSPENDED); + private static Stream dbSamples() { + return Stream.of( + Arguments.of(runningV0, WorkflowStatus.WAITING), + Arguments.of(suspendedV0, WorkflowStatus.SUSPENDED), + Arguments.of(runningV1, WorkflowStatus.WAITING), + Arguments.of(suspendedV1, WorkflowStatus.SUSPENDED)); } - @Test - void testRestoreWaitingInstanceV1() throws IOException { - runIt("db-samples/running_v1.db", WorkflowStatus.WAITING); - } - - @Test - void testRestoreSuspendedInstanceV1() throws IOException { - runIt("db-samples/suspended_v1.db", WorkflowStatus.SUSPENDED); - } - - private void runIt(String dbName, WorkflowStatus expectedStatus) throws IOException { + private void runIt(Path dbFile, WorkflowStatus expectedStatus) throws IOException { TaskCounterPerInstanceListener taskCounter = new TaskCounterPerInstanceListener(); + try (PersistenceInstanceHandlers handlers = - BytesMapPersistenceInstanceHandlers.builder(new MVStorePersistenceStore(dbName)) + BytesMapPersistenceInstanceHandlers.builder( + new MVStorePersistenceStore(dbFile.toString())) .build(); WorkflowApplication application = PersistenceApplicationBuilder.builder( @@ -101,13 +127,18 @@ private void runIt(String dbName, WorkflowStatus expectedStatus) throws IOExcept .withListener(taskCounter) .withListener(new TraceExecutionListener()), handlers.writer()) - .build(); ) { + .build()) { + WorkflowDefinition definition = application.workflowDefinition( readWorkflowFromClasspath("workflows-samples/set-listen-to-any.yaml")); + Collection instances = handlers.reader().readAll(definition).values(); + assertThat(instances).hasSize(1); + instances.forEach(WorkflowInstance::start); + assertThat(instances) .singleElement() .satisfies( diff --git a/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml b/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml index d82936e9..b9406522 100644 --- a/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml +++ b/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml @@ -10,4 +10,6 @@ do: - callDoctor: listen: to: - any: [] \ No newline at end of file + any: + - with: + type: com.acme.any \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8e9bc2d1..a450fa30 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,6 @@ annotations generators serialization - examples experimental fluent mermaid @@ -584,8 +583,23 @@ + + examples + + + performRelease + !true + + + + examples + + release + + true + From ad7cd48601cf77a8a59f372fc3e9c7112f98f2d1 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Fri, 31 Oct 2025 20:06:43 -0400 Subject: [PATCH 3/6] Fix performRelase var; remove unneeded exception Signed-off-by: Ricardo Zanini --- .github/workflows/release.yml | 2 +- .../test/java/io/serverlessworkflow/impl/test/DBGenerator.java | 3 +-- pom.xml | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c313af3..bd34741d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,7 +60,7 @@ jobs: - name: Maven release ${{steps.metadata.outputs.current-version}} run: | git checkout -b release - mvn -B release:prepare -Prelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} + mvn -B release:prepare -DperformRelease -Prelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} cat release.properties git checkout ${{github.base_ref}} git rebase release diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java index b2c0b404..5fa08f91 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGenerator.java @@ -34,8 +34,7 @@ public final class DBGenerator { - public static void generate(String dbName, boolean suspend) - throws IOException, InterruptedException { + public static void generate(String dbName, boolean suspend) throws IOException { Files.deleteIfExists(Path.of(dbName)); try (PersistenceInstanceHandlers factories = BytesMapPersistenceInstanceHandlers.builder(new MVStorePersistenceStore(dbName)) diff --git a/pom.xml b/pom.xml index a450fa30..3bfc05b6 100644 --- a/pom.xml +++ b/pom.xml @@ -597,9 +597,6 @@ release - - true - From a4f685bc6ff4d9acdb9fa0d48b38ab63a9820f53 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Mon, 3 Nov 2025 11:23:00 -0500 Subject: [PATCH 4/6] Revert impl/tests to match origin/main --- impl/test/db-samples/running.db | Bin 0 -> 16384 bytes impl/test/db-samples/running_v1.db | Bin 0 -> 16384 bytes impl/test/db-samples/suspended.db | Bin 0 -> 12288 bytes impl/test/db-samples/suspended_v1.db | Bin 0 -> 12288 bytes .../impl/test/DBGenerator.java | 20 ++--- .../impl/test/DBGeneratorCli.java | 26 ------ .../impl/test/ForkedDbGen.java | 54 ------------ .../impl/test/MvStorePersistenceTest.java | 83 ++++++------------ .../workflows-samples/set-listen-to-any.yaml | 4 +- 9 files changed, 34 insertions(+), 153 deletions(-) create mode 100644 impl/test/db-samples/running.db create mode 100644 impl/test/db-samples/running_v1.db create mode 100644 impl/test/db-samples/suspended.db create mode 100644 impl/test/db-samples/suspended_v1.db delete mode 100644 impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java delete mode 100644 impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java diff --git a/impl/test/db-samples/running.db b/impl/test/db-samples/running.db new file mode 100644 index 0000000000000000000000000000000000000000..461b7996b3fac60d9835b840c9ebc2a600053526 GIT binary patch literal 16384 zcmeI3&u`>36vyo;?XF5G7r4L$jX>f@CQUNQBx4D&3p;d0w_>4Hkr2|#<2apkl6Xiw zvmI6|apJlc4xIT{kPrv{4mj}-aN@<8PPZ#nt<-{w^m6cX9OpUy*pBplvhOp`8fHq2 z_tNhqa~;RAL@BwJF?0L>_GZ*HgYTD=&dQ^t6W2^!O*?s~IIqr{PmtOxsa7Fl12 zXp!wfDfs@LkoRD9(L01Z_zf)Fr}b)s`)8YA;rjE3#$t*DkN^@u0!RP}AOR$R1dzbh z37pm6r-J&qefDuT^dfPsl6vWEy=mV&qyN1||HDy$TK|WQ{*R3Q=bjLa{_pl>vJ3!t zO#r}e0sv94^nWdxTB7_x?-IIkfzUK^GyIR`=DQb5QxK+l`v2FZUtX+^o1QL?kSqc* z5FR>LDlesOXvFT{t%{O0a?8w0+r5nF{gIw5A#;ocwzHfKWo7A1J~Uyi?lP=Zm+eA` z%UewG-bwuG+(_57m{u~rt53Uhx>OfIFG~qAoj?R)&fEy3c(Y)I- w{QUdXe=Fz#2_OL^fCP{L5dIp}}?U(^5p09~k=(*OVf literal 0 HcmV?d00001 diff --git a/impl/test/db-samples/running_v1.db b/impl/test/db-samples/running_v1.db new file mode 100644 index 0000000000000000000000000000000000000000..fa4c2bebeb8825fe11610f648fc7c28337226283 GIT binary patch literal 16384 zcmeI3O>f&a7{^JcaoeoxF6*Ve3`Pg+MOG+Ewk%%StZ`bb3F) z8?PwPPq1OYKEd{7b{O_CcGz*)X{S+?;~)is1Z`Giz@q~ny*zyTkreQMKt5vB=_N{x zcH{3P^9Ui1$RyXY&%7ua_+gLGUg!)|Hs+f7&LELm3}wc8Eid4nC)W^MKmZ5;0U!Vb zfB+Bx0zd!=00AHX1c1OLC-4aL|0N$GXdVy%0zd!=00AHX1b_e#00KY&2mpb%Cm@E? zbi_O-k*P^1d|&3Q;f(nq^CdBM!kSK|lxBh18bFBTLDSLkSTaheGm}{!t0H464~yLa zS_$LW_~=5fVu!&G=rdHQple>x8iWHLT@zj}7*G*9D%*F5)E&=qtupEALwB!imF(~F zWGcJ!iM+eTh50(Kz3yzjxleirQs_;tdEt5v7t@??@dLby(R;Uv_c+{r+9A(K_u*Gh zX?KfIfA4W;tG$74;)iy4hJSs3>wVOSm7B}V5KCm9KUdjkkf`TwJf0-(SoLM%9&j!R;&tjRyTGd|OKp1^s+TpDWo+O*9K#LIWt=wI~YiQNX z8JF7Bw`pM0hE1Cv7sa`!Q>$y9kMgSZ`sS83Y9iBa#?#!4p_y#?=k~3Zxvu9@*ONHc zGOcS>=jpsoT+b!-IL$Rrh0JeS-)Y)c+iKtSY`Lr~m%U!D^<_)nc9E5xuNr40=WID6 zXFOp?^YorA<*fdmo*y?c#XfG}zzpWsD}P@>tLUm3dhW*kYOyX&r>vo+X_Tgky|r?| zMxKz1TN)9*xDAA8EpD6UtttBzLZ6z2hVLV^{j0I&IW88SdH(TtW6kyFR%syx0zd!= z00AHX1b_e#00KbZ4GEmo-^YS_xz9c#eLtivaiNlWS=d@xKRu!UX{rCsQGi1Kho$~+ zS^dwc5T*Y2qcB7J(QO9y(PYFZFF`74AQk9HT0_YG6u&w((lt$|x$JM~<1QU9)kV3B3 zLC&MU?;HKyDgPlq|MrIe637MwfB+Bx0zd!=00AHX1c1QhCU8=JABhTje9k`NM*j!@ Hng0J5x`dh5 literal 0 HcmV?d00001 diff --git a/impl/test/db-samples/suspended.db b/impl/test/db-samples/suspended.db new file mode 100644 index 0000000000000000000000000000000000000000..0450b6af36164390f1eebb029355f45b85877464 GIT binary patch literal 12288 zcmeI2KX21O6u{4Eo0d|FkYIrYMIcpRySC%R$t|GLv=#jWQc49Z=yJX!ZfsxhUDAfC z5+f6=NPH1S2E@R`#JAu(aJH)!Dpf(ELx<<#z4P&)}0-sVX}BrfaikV)EQ39ef$$FEhqSp*jl00KY&2mk>f00e*l z5C8%|00;m9AaKD6tik#Jg6|Nd2Lyls5C8%|00;m9AOHk_01yBIK;Zug(C#4aVOtMb ztYn{bn7~y%BKz2-mePIf=?Ui&yQ($7vTfU~=`x5^tAMKySt0_S&WqW8+8iJ`#cr#7 z`&_TI!QcZjP@#ZkRP?sjCiNL=x7@ZvJ)I{Vv+J1AP)MFIQ|_BPc~;EdA>n{+kNWJ+ z3Zd%hsC3#{Ju{!Qb{Un+M3U6?A6!&AueBv@N<)`#TK2lvc)8x(dEu^C?V9_@-dx#w z?p3x|(Y&^r?N0aC+_x*J5^z(nL=g*_5PLl7wL`vV22npWBkr@%+$FRpcx*n-^=4{R z3lt6xmHepTLQw_0tAcwgly2Vy>R9K=4~;2qP>62N%^_;do9FFy8dq*L*~<)io5 z2p?Dakc8@`%j^F^w#qm#XU|_6pGE#l&t5{SYK~UcDw?OcsuJSKdsC>0rd3@MGw_S) zH$#!hl#{DUuBy56Gb{%ae?jQ|SA>wVfBK=cGF@BCGzcI71b_e#00KY&2mk>fa1jXnef~Z{svF|s-pk^ literal 0 HcmV?d00001 diff --git a/impl/test/db-samples/suspended_v1.db b/impl/test/db-samples/suspended_v1.db new file mode 100644 index 0000000000000000000000000000000000000000..1acb73558fb43fecccaaf451ce0c4a91c4fa7954 GIT binary patch literal 12288 zcmeI2&2G~`5P)~n|5D1Oy}$)UAXUO~*N$r^dnsxYsGz?jRNTLQ;QH{ z_%UaS*Qr%3Hu7GLI5loGMBHJD=8ZGscUrDA$5GBb(eZZEQF$tZVe!o<&c7*f{tz#u#Fy%WgwDy5kE|t1C;Qo?iRRz ztyj`u@CoHmCW9s|r_k^ktT^dgHK$?wo+09<*|N<}Pbv{}QyrSS{j7L>mxcShder3) zo-kiOJ<6VU*3ZnX+8*~+i7A%2UcyDE^9HZrF^q2ACDwDVva@Zuq_Rm~xVBSWb=_CH zYh(w_;-~5Ew0?h_zm1jxVM-orVj-9EK*a4vC=Se^(+$mzsPoX=V}4tT$b8n<8;Mab zkU2il@*BpPaUJkpT`ZEtx~PZ_SFIpwu5jI%!OJ}!DIM_;qp8)cjqUYvwOmS~UorUH zaW-Ndo~7A6)(dzXD3LvxK^Wc9d02}+3&WB~(CSc5MvhDjVWJS4s=Tahmp4mEe)!kO z_fb59#&nsPb}I9!bW*vLN;j3>!z2;&V%|B$WLu7>Ua#jA<&~Or@90$7u5-Iw<-c3+dliVL4r87?_LauME$k|4T1k0=wA8dAx)@?C45}MwiFX zIGWHU%FLiXo_szunN-<*wbWN`UwPP?PCqZC$cyB3Xcv5TI&}O(;dJPpS&LR7iS`bm zg`c{X9wW5=L2G^AO74Fk^yNK5NZY@D)>@n9CQ}Up2mk>f00e*l5C8%|00{gy0{@=B Y&rZ~XKKml6=RN&r_*&1@gT instance.status() == WorkflowStatus.WAITING); - if (suspend) { instance.suspend(); - await() - .atMost(Duration.ofSeconds(5)) - .until(() -> instance.status() == WorkflowStatus.SUSPENDED); } } } diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java deleted file mode 100644 index 4b4eabd4..00000000 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/DBGeneratorCli.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2020-Present The Serverless Workflow Specification Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.serverlessworkflow.impl.test; - -public final class DBGeneratorCli { - public static void main(String[] args) throws Exception { - if (args.length < 2) { - System.err.println("Usage: DBGeneratorCli "); - System.exit(2); - } - DBGenerator.generate(args[0], Boolean.parseBoolean(args[1])); - } -} diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java deleted file mode 100644 index b556f3dc..00000000 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkedDbGen.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2020-Present The Serverless Workflow Specification Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.serverlessworkflow.impl.test; - -import java.io.*; -import java.nio.file.*; -import java.util.Optional; - -final class ForkedDbGen { - private static String detectJavaCmd() { - Optional cmd = ProcessHandle.current().info().command(); - if (cmd.isPresent() && Files.isRegularFile(Path.of(cmd.get()))) return cmd.get(); - String home = System.getProperty("java.home"); - String exe = System.getProperty("os.name").toLowerCase().contains("win") ? "java.exe" : "java"; - Path p = Path.of(home, "bin", exe); - return Files.isRegularFile(p) ? p.toString() : "java"; - } - - static void run(Path db, boolean suspend) throws IOException, InterruptedException { - Files.createDirectories(db.getParent()); - String javaCmd = detectJavaCmd(); - String cp = System.getProperty("java.class.path"); - - ProcessBuilder pb = - new ProcessBuilder( - javaCmd, - "-cp", - cp, - DBGeneratorCli.class.getCanonicalName(), - db.toString(), - String.valueOf(suspend)); - pb.redirectErrorStream(true); - - Process p = pb.start(); - try (BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()))) { - for (String line; (line = r.readLine()) != null; ) System.out.println("[dbgen] " + line); - } - int code = p.waitFor(); - if (code != 0) throw new IllegalStateException("DB gen failed (" + code + ") for " + db); - } -} diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java index e5fdc6e6..d814a25f 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/MvStorePersistenceTest.java @@ -27,59 +27,31 @@ import io.serverlessworkflow.impl.persistence.bigmap.BytesMapPersistenceInstanceHandlers; import io.serverlessworkflow.impl.persistence.mvstore.MVStorePersistenceStore; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; import java.util.Map; -import java.util.stream.Stream; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import org.junit.jupiter.api.parallel.Execution; -import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -@Execution(ExecutionMode.SAME_THREAD) -class MvStorePersistenceTest { - - @TempDir static Path tmp; - - static Path runningV1, suspendedV1, runningV0, suspendedV0; - - @BeforeAll - static void prepareDbSamples() throws IOException, InterruptedException { - runningV1 = tmp.resolve("running_v1.db"); - suspendedV1 = tmp.resolve("suspended_v1.db"); - runningV0 = tmp.resolve("running.db"); - suspendedV0 = tmp.resolve("suspended.db"); - - ForkedDbGen.run(runningV1, false); - ForkedDbGen.run(suspendedV1, true); - ForkedDbGen.run(runningV0, false); - ForkedDbGen.run(suspendedV0, true); - } +public class MvStorePersistenceTest { @Test void testSimpleRun() throws IOException { - final Path dbPath = tmp.resolve("simple.db"); + final String dbName = "db-samples/simple.db"; try (PersistenceInstanceHandlers handlers = - BytesMapPersistenceInstanceHandlers.builder( - new MVStorePersistenceStore(dbPath.toString())) + BytesMapPersistenceInstanceHandlers.builder(new MVStorePersistenceStore(dbName)) .build(); WorkflowApplication application = PersistenceApplicationBuilder.builder(WorkflowApplication.builder(), handlers.writer()) - .build()) { - + .build(); ) { WorkflowDefinition definition = application.workflowDefinition( readWorkflowFromClasspath("workflows-samples/simple-expression.yaml")); - assertThat(handlers.reader().readAll(definition).values()).isEmpty(); - definition.instance(Map.of()).start().join(); - assertThat(handlers.reader().readAll(definition).values()).isEmpty(); + } finally { + Files.delete(Path.of(dbName)); } } @@ -88,38 +60,40 @@ void testWaitingInstance() throws IOException { TaskCounterPerInstanceListener taskCounter = new TaskCounterPerInstanceListener(); try (WorkflowApplication application = WorkflowApplication.builder().withListener(taskCounter).build()) { - WorkflowDefinition definition = application.workflowDefinition( readWorkflowFromClasspath("workflows-samples/set-listen-to-any.yaml")); WorkflowInstance instance = definition.instance(Map.of()); instance.start(); - assertThat(taskCounter.taskCounter(instance.id()).completed()).isEqualTo(1); } } - @ParameterizedTest(name = "{index} ⇒ {0} should restore as {1}") - @MethodSource("dbSamples") - void testRestoreInstances(Path dbFile, WorkflowStatus expectedStatus) throws IOException { - runIt(dbFile, expectedStatus); + @Test + void testRestoreWaitingInstanceV0() throws IOException { + runIt("db-samples/running.db", WorkflowStatus.WAITING); } - private static Stream dbSamples() { - return Stream.of( - Arguments.of(runningV0, WorkflowStatus.WAITING), - Arguments.of(suspendedV0, WorkflowStatus.SUSPENDED), - Arguments.of(runningV1, WorkflowStatus.WAITING), - Arguments.of(suspendedV1, WorkflowStatus.SUSPENDED)); + @Test + void testRestoreSuspendedInstanceV0() throws IOException { + runIt("db-samples/suspended.db", WorkflowStatus.SUSPENDED); } - private void runIt(Path dbFile, WorkflowStatus expectedStatus) throws IOException { - TaskCounterPerInstanceListener taskCounter = new TaskCounterPerInstanceListener(); + @Test + void testRestoreWaitingInstanceV1() throws IOException { + runIt("db-samples/running_v1.db", WorkflowStatus.WAITING); + } + + @Test + void testRestoreSuspendedInstanceV1() throws IOException { + runIt("db-samples/suspended_v1.db", WorkflowStatus.SUSPENDED); + } + private void runIt(String dbName, WorkflowStatus expectedStatus) throws IOException { + TaskCounterPerInstanceListener taskCounter = new TaskCounterPerInstanceListener(); try (PersistenceInstanceHandlers handlers = - BytesMapPersistenceInstanceHandlers.builder( - new MVStorePersistenceStore(dbFile.toString())) + BytesMapPersistenceInstanceHandlers.builder(new MVStorePersistenceStore(dbName)) .build(); WorkflowApplication application = PersistenceApplicationBuilder.builder( @@ -127,18 +101,13 @@ private void runIt(Path dbFile, WorkflowStatus expectedStatus) throws IOExceptio .withListener(taskCounter) .withListener(new TraceExecutionListener()), handlers.writer()) - .build()) { - + .build(); ) { WorkflowDefinition definition = application.workflowDefinition( readWorkflowFromClasspath("workflows-samples/set-listen-to-any.yaml")); - Collection instances = handlers.reader().readAll(definition).values(); - assertThat(instances).hasSize(1); - instances.forEach(WorkflowInstance::start); - assertThat(instances) .singleElement() .satisfies( diff --git a/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml b/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml index b9406522..d82936e9 100644 --- a/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml +++ b/impl/test/src/test/resources/workflows-samples/set-listen-to-any.yaml @@ -10,6 +10,4 @@ do: - callDoctor: listen: to: - any: - - with: - type: com.acme.any \ No newline at end of file + any: [] \ No newline at end of file From e1502db2d103663a38565d77d5ddb846cfe3d068 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Mon, 3 Nov 2025 12:08:40 -0500 Subject: [PATCH 5/6] Adjusting exec-maven-plugin to not run DbGenerator Signed-off-by: Ricardo Zanini --- impl/test/pom.xml | 30 ++++++++++++++++++++++++++++++ pom.xml | 7 ------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/impl/test/pom.xml b/impl/test/pom.xml index 35d900e4..f964efde 100644 --- a/impl/test/pom.xml +++ b/impl/test/pom.xml @@ -96,4 +96,34 @@ + + + dbgen + + + dbgen + true + + + + + + org.codehaus.mojo + exec-maven-plugin + + + generate-db-samples + + java + + + io.serverlessworkflow.impl.test.DBGeneratorCli + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3bfc05b6..17fc21b5 100644 --- a/pom.xml +++ b/pom.xml @@ -558,13 +558,6 @@ org.codehaus.mojo exec-maven-plugin ${version.org.codehaus.mojo} - - - - java - - - From 011dc4e33e2367568c617e9599ae4f62d5843567 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Mon, 3 Nov 2025 12:36:38 -0500 Subject: [PATCH 6/6] Fix DbGenerator classname Signed-off-by: Ricardo Zanini --- impl/test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impl/test/pom.xml b/impl/test/pom.xml index f964efde..7672bbef 100644 --- a/impl/test/pom.xml +++ b/impl/test/pom.xml @@ -117,7 +117,7 @@ java - io.serverlessworkflow.impl.test.DBGeneratorCli + io.serverlessworkflow.impl.test.DBGenerator