|
9 | 9 | import jenkins.util.Timer;
|
10 | 10 | import org.junit.Rule;
|
11 | 11 | import org.junit.Test;
|
12 |
| -import org.jvnet.hudson.test.SleepBuilder; |
13 | 12 | import org.jvnet.hudson.test.WithoutJenkins;
|
14 | 13 | import org.openstack4j.model.compute.Server;
|
15 | 14 |
|
@@ -113,20 +112,31 @@ public void avoidRunningOutOfScopeDuringProvisioning() throws Exception {
|
113 | 112 | @Test
|
114 | 113 | public void runScope() throws Exception {
|
115 | 114 | FreeStyleProject asdf = j.createFreeStyleProject("asdf");
|
116 |
| - asdf.getBuildersList().add(new SleepBuilder(1000000)); |
| 115 | + JCloudsCleanupThreadTest.BuildBlocker bb = new JCloudsCleanupThreadTest.BuildBlocker(); |
| 116 | + asdf.getBuildersList().add(bb); |
117 | 117 | FreeStyleBuild build = asdf.scheduleBuild2(0).waitForStart();
|
118 | 118 |
|
119 |
| - ServerScope.Build alive = new ServerScope.Build(build); |
120 |
| - assertFalse(alive.isOutOfScope(mockServer)); |
121 |
| - assertEquals("run:asdf:1", alive.getValue()); |
122 |
| - |
123 |
| - ServerScope.Build rotated = new ServerScope.Build("asdf:42"); |
124 |
| - assertTrue(rotated.isOutOfScope(mockServer)); |
125 |
| - assertEquals("run:asdf:42", rotated.getValue()); |
| 119 | + bb.awaitStarted(); |
| 120 | + try { |
| 121 | + |
| 122 | + ServerScope.Build alive = new ServerScope.Build(build); |
| 123 | + assertFalse(alive.isOutOfScope(mockServer)); |
| 124 | + assertEquals("run:asdf:1", alive.getValue()); |
| 125 | + |
| 126 | + ServerScope.Build rotated = new ServerScope.Build("asdf:42"); |
| 127 | + assertTrue(rotated.isOutOfScope(mockServer)); |
| 128 | + assertEquals("run:asdf:42", rotated.getValue()); |
| 129 | + |
| 130 | + ServerScope.Build jobGone = new ServerScope.Build("nonono:1"); |
| 131 | + assertTrue(jobGone.isOutOfScope(mockServer)); |
| 132 | + assertEquals("run:nonono:1", jobGone.getValue()); |
| 133 | + } finally { |
| 134 | + // Make sure the build terminates before ending the test. |
| 135 | + // Active build is causing test harness to fail when deleting log files |
| 136 | + bb.signalDone(); |
| 137 | + j.waitForCompletion(build); |
| 138 | + } |
126 | 139 |
|
127 |
| - ServerScope.Build jobGone = new ServerScope.Build("nonono:1"); |
128 |
| - assertTrue(jobGone.isOutOfScope(mockServer)); |
129 |
| - assertEquals("run:nonono:1", jobGone.getValue()); |
130 | 140 | }
|
131 | 141 |
|
132 | 142 | @Test @WithoutJenkins
|
|
0 commit comments