Skip to content

Commit b5e199f

Browse files
committed
Use sleep in LocalData instead of semaphore
1 parent c09c828 commit b5e199f

File tree

17 files changed

+49
-64
lines changed

17 files changed

+49
-64
lines changed

src/test/java/org/jenkinsci/plugins/workflow/support/storage/BulkFlowNodeStorageTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ public final class BulkFlowNodeStorageTest {
7676
p.addProperty(new DurabilityHintJobProperty(FlowDurabilityHint.PERFORMANCE_OPTIMIZED));
7777
p.setDefinition(new CpsFlowDefinition(
7878
"stage('test') {\n" +
79-
" semaphore('wait')\n" +
79+
" sleep 120\n" +
8080
"}\n", true));
8181
var b = p.scheduleBuild2(0).waitForStart();
82-
SemaphoreStep.waitForStart("wait/1", b);
82+
Thread.sleep(5*1000);
8383
((CpsFlowExecution) b.getExecution()).getStorage().flush();
84-
Thread.sleep(30*1000);
8584
*/
8685
var p = r.jenkins.getItemByFullName("test0", WorkflowJob.class);
8786
var b = p.getLastBuild();
@@ -104,5 +103,6 @@ public static class MyActionAdder implements GraphListener.Synchronous {
104103
public void onNewHead(FlowNode node) {
105104
node.addAction(new MyAction());
106105
}
107-
}*/
106+
}
107+
*/
108108
}

src/test/java/org/jenkinsci/plugins/workflow/support/storage/SimpleXStreamStorageTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
1212
import org.jenkinsci.plugins.workflow.graph.AtomNode;
1313
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
14-
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
1514
import org.junit.Assert;
1615
import org.junit.Rule;
1716
import org.junit.Test;
@@ -94,15 +93,14 @@ public void testDeferWriteAndFlush() throws Exception {
9493
p.addProperty(new DurabilityHintJobProperty(FlowDurabilityHint.MAX_SURVIVABILITY));
9594
p.setDefinition(new CpsFlowDefinition(
9695
"stage('test') {\n" +
97-
" semaphore('wait')\n" +
96+
" sleep 120\n" +
9897
"}\n", true));
9998
var b = p.scheduleBuild2(0).waitForStart();
100-
SemaphoreStep.waitForStart("wait/1", b);
99+
Thread.sleep(5*1000);
101100
((CpsFlowExecution) b.getExecution()).getStorage().flush();
102101
*/
103102
var p = j.jenkins.getItemByFullName("test0", WorkflowJob.class);
104103
var b = p.getLastBuild();
105-
SemaphoreStep.success("wait/1", null);
106104
j.assertBuildStatus(Result.SUCCESS, j.waitForCompletion(b));
107105
var stageBodyStartNode = (StepStartNode) b.getExecution().getNode("4");
108106
assertThat(stageBodyStartNode, not(nullValue()));

src/test/java/org/jenkinsci/plugins/workflow/test/steps/SemaphoreStep.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -234,23 +234,6 @@ public static class Execution extends AbstractStepExecutionImpl {
234234
}
235235
}
236236

237-
@Override public void onResume() {
238-
// Only matters for restarts across different JVMs, for example if using @LocalData.
239-
State s = State.get();
240-
String c = Jenkins.XSTREAM.toXML(getContext());
241-
synchronized (s) {
242-
if (s.returnValues.containsKey(k)) {
243-
getContext().onSuccess(s.returnValues.get(k));
244-
} else if (s.errors.containsKey(k)) {
245-
getContext().onFailure(s.errors.get(k));
246-
} else {
247-
s.contexts.put(k, c);
248-
}
249-
s.started.add(k);
250-
s.notifyAll();
251-
}
252-
}
253-
254237
private static final long serialVersionUID = 1L;
255238

256239
}

src/test/resources/org/jenkinsci/plugins/workflow/support/storage/BulkFlowNodeStorageTest/actionDeserializationShouldBeRobust/jobs/test0/builds/1/build.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
<flow-build plugin="[email protected]">
33
<actions/>
44
<queueId>1</queueId>
5-
<timestamp>1714412222911</timestamp>
6-
<startTime>1714412222924</startTime>
5+
<timestamp>1714512454761</timestamp>
6+
<startTime>1714512454774</startTime>
77
<duration>0</duration>
88
<charset>UTF-8</charset>
99
<keepLog>false</keepLog>
1010
<execution class="org.jenkinsci.plugins.workflow.cps.CpsFlowExecution">
1111
<result>SUCCESS</result>
1212
<script>stage(&apos;test&apos;) {
13-
semaphore(&apos;wait&apos;)
13+
sleep 120
1414
}
1515
</script>
1616
<loadedScripts class="map"/>
1717
<durabilityHint>PERFORMANCE_OPTIMIZED</durabilityHint>
1818
<timings class="map">
1919
<entry>
2020
<string>flowNode</string>
21-
<long>3326252</long>
21+
<long>3116376</long>
2222
</entry>
2323
<entry>
2424
<string>classLoad</string>
25-
<long>94409046</long>
25+
<long>125882830</long>
2626
</entry>
2727
<entry>
2828
<string>run</string>
29-
<long>72661207</long>
29+
<long>80228333</long>
3030
</entry>
3131
<entry>
3232
<string>parse</string>
33-
<long>206498209</long>
33+
<long>213222375</long>
3434
</entry>
3535
</timings>
3636
<internalCalls class="sorted-set"/>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Started
2-
ha:////4HRjCqPkfz1NSKp93SyXqIGMS8sYXTlEz1/aJBi87ebXAAAAoh+LCAAAAAAAAP9tjTEOwjAQBM8BClpKHuFItIiK1krDC0x8GCfWnbEdkooX8TX+gCESFVvtrLSa5wtWKcKBo5UdUu8otU4GP9jS5Mixv3geZcdn2TIl9igbHBs2eJyx4YwwR1SwULBGaj0nRzbDRnX6rmuvydanHMu2V1A5c4MHCFXMWcf8hSnC9jqYxPTz/BXAFEIGsfuclm8zQVqFvQAAAA==[Pipeline] Start of Pipeline
3-
ha:////4H+XLB9Zbb+2k9X1o1EbVc5ol8gfq1RPzPymyR3m6M9NAAAApR+LCAAAAAAAAP9tjTEOwjAUQ3+KOrAycohUghExsUZZOEFIQkgb/d8mKe3EibgadyBQiQlLlmxL1nu+oE4RjhQdby12HpP2vA+jK4lPFLtroIm3dOGaMFGwXNpJkrGnpUrKFhaxClYC1hZ1oOTRZdiIVt1VExS65pxj2Q4CKm8GeAAThZxVzN8yR9jeRpMIf5y/AJj7DGxXvP/86jduZBmjwAAAAA==[Pipeline] stage
4-
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S65pxj2Q4CKm8GeAAThZxVzN8yR9jeRpMIf5y/AJj7DGxXvP/86jduZBmjwAAAAA==[Pipeline] stage
4+
ha:////4JdiHwYzioWlo2ROxl2Zlo74y53NN96hzyE6iT+69Eh0AAAApR+LCAAAAAAAAP9tjTEOwjAUQ3+KOrAycoh0gA0xsUZZOEFIQkgb/d8mKe3EibgadyBQiQlLlmxL1nu+oE4RjhQdby12HpP2vA+jK4lPFLtroIm3dOGaMFGwXNpJkrGnpUrKFhaxClYC1hZ1oOTRZdiIVt1VExS65pxj2Q4CKm8GeAAThZxVzN8yR9jeRpMIf5y/AJj7DGxXvP/86jfoP95RwAAAAA==[Pipeline] { (test)
5+
ha:////4IbbNcCvGzKmOkFNSNkP4IRFXNaMMv4VDyWQd8mj5yT1AAAAoh+LCAAAAAAAAP9tjTEOAiEURD9rLGwtPQTbaGWsbAmNJ0AWEZb8zwLrbuWJvJp3kLiJlZNMMm+a93rDOic4UbLcG+wdZu14DKOti0+U+lugiXu6ck2YKRguzSSpM+cFJRUDS1gDKwEbgzpQdmgLbIVXD9UGhba9lFS/o4DGdQM8gYlqLiqVL8wJdvexy4Q/z18BzLEA29ce4gdpL1fxvAAAAA==[Pipeline] sleep
6+
Sleeping for 2 min 0 sec
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1231 5

src/test/resources/org/jenkinsci/plugins/workflow/support/storage/BulkFlowNodeStorageTest/actionDeserializationShouldBeRobust/jobs/test0/builds/1/workflow/flowNodeStore.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<value>42</value>
1313
</org.jenkinsci.plugins.workflow.support.storage.BulkFlowNodeStorageTest_-MyAction>
1414
<wf.a.TimingAction plugin="[email protected]_">
15-
<startTime>1714412223218</startTime>
15+
<startTime>1714512455074</startTime>
1616
</wf.a.TimingAction>
1717
</actions>
1818
</Tag>
@@ -40,7 +40,7 @@
4040
<isUnmodifiedBySanitization>true</isUnmodifiedBySanitization>
4141
</cps.a.ArgumentsActionImpl>
4242
<wf.a.TimingAction plugin="[email protected]_">
43-
<startTime>1714412223284</startTime>
43+
<startTime>1714512455144</startTime>
4444
</wf.a.TimingAction>
4545
<org.jenkinsci.plugins.workflow.support.storage.BulkFlowNodeStorageTest_-MyAction>
4646
<value>42</value>
@@ -64,7 +64,7 @@
6464
<displayName>test</displayName>
6565
</wf.a.LabelAction>
6666
<wf.a.TimingAction plugin="[email protected]_">
67-
<startTime>1714412223289</startTime>
67+
<startTime>1714512455148</startTime>
6868
</wf.a.TimingAction>
6969
<org.jenkinsci.plugins.workflow.support.storage.BulkFlowNodeStorageTest_-MyAction>
7070
<value>42</value>
@@ -80,21 +80,21 @@
8080
<string>4</string>
8181
</parentIds>
8282
<id>5</id>
83-
<descriptorId>org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep</descriptorId>
83+
<descriptorId>org.jenkinsci.plugins.workflow.steps.SleepStep</descriptorId>
8484
</node>
8585
<actions>
8686
<cps.a.ArgumentsActionImpl plugin="[email protected]_3a_6988277b_2">
8787
<arguments>
8888
<entry>
89-
<string>id</string>
90-
<string>wait</string>
89+
<string>time</string>
90+
<long>120</long>
9191
</entry>
9292
</arguments>
9393
<sensitiveVariables/>
9494
<isUnmodifiedBySanitization>true</isUnmodifiedBySanitization>
9595
</cps.a.ArgumentsActionImpl>
9696
<wf.a.TimingAction plugin="[email protected]_">
97-
<startTime>1714412223294</startTime>
97+
<startTime>1714512455155</startTime>
9898
</wf.a.TimingAction>
9999
<org.jenkinsci.plugins.workflow.support.storage.BulkFlowNodeStorageTest_-MyAction>
100100
<value>42</value>

src/test/resources/org/jenkinsci/plugins/workflow/support/storage/BulkFlowNodeStorageTest/actionDeserializationShouldBeRobust/jobs/test0/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</properties>
99
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="[email protected]_3a_6988277b_2">
1010
<script>stage(&apos;test&apos;) {
11-
semaphore(&apos;wait&apos;)
11+
sleep 120
1212
}
1313
</script>
1414
<sandbox>true</sandbox>

src/test/resources/org/jenkinsci/plugins/workflow/support/storage/SimpleXStreamStorageTest/actionDeserializationShouldBeRobust/jobs/test0/builds/1/build.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22
<flow-build plugin="[email protected]">
33
<actions/>
44
<queueId>1</queueId>
5-
<timestamp>1714413871034</timestamp>
6-
<startTime>1714413871047</startTime>
5+
<timestamp>1714512387063</timestamp>
6+
<startTime>1714512387076</startTime>
77
<duration>0</duration>
88
<charset>UTF-8</charset>
99
<keepLog>false</keepLog>
1010
<execution class="org.jenkinsci.plugins.workflow.cps.CpsFlowExecution">
1111
<result>SUCCESS</result>
1212
<script>stage(&apos;test&apos;) {
13-
semaphore(&apos;wait&apos;)
13+
sleep 120
1414
}
1515
</script>
1616
<loadedScripts class="map"/>
1717
<durabilityHint>MAX_SURVIVABILITY</durabilityHint>
1818
<timings class="map">
1919
<entry>
2020
<string>flowNode</string>
21-
<long>76623167</long>
21+
<long>79993754</long>
2222
</entry>
2323
<entry>
2424
<string>classLoad</string>
25-
<long>83376137</long>
25+
<long>146027039</long>
2626
</entry>
2727
<entry>
2828
<string>run</string>
29-
<long>181214959</long>
29+
<long>213084959</long>
3030
</entry>
3131
<entry>
3232
<string>parse</string>
33-
<long>188712792</long>
33+
<long>233240875</long>
3434
</entry>
3535
<entry>
3636
<string>saveProgram</string>
37-
<long>49106458</long>
37+
<long>58160417</long>
3838
</entry>
3939
</timings>
4040
<internalCalls class="sorted-set"/>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Started
2-
ha:////4OkjLGvkcZAQNTRsuUiu8X+DYYfRK1VZUd93tgM297TIAAAAoh+LCAAAAAAAAP9tjTEOwjAQBM8BClpKHuFItIiK1krDC0x8GCfWnbEdkooX8TX+gCESFVvtrLSa5w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18BzLEA29ce4gdpL1fxvAAAAA==[Pipeline] sleep
6+
Sleeping for 2 min 0 sec

0 commit comments

Comments
 (0)