|
27 | 27 | import org.junit.Test;
|
28 | 28 | import org.springframework.test.annotation.Rollback;
|
29 | 29 | import org.springframework.test.context.ContextConfiguration;
|
| 30 | +import org.springframework.transaction.annotation.Propagation; |
30 | 31 | import org.springframework.transaction.annotation.Transactional;
|
31 | 32 |
|
| 33 | +import com.imageworks.spcue.DispatchFrame; |
32 | 34 | import com.imageworks.spcue.DispatchHost;
|
33 |
| -import com.imageworks.spcue.FrameInterface; |
| 35 | +import com.imageworks.spcue.DispatchJob; |
| 36 | +import com.imageworks.spcue.FrameDetail; |
34 | 37 | import com.imageworks.spcue.JobDetail;
|
35 | 38 | import com.imageworks.spcue.LayerDetail;
|
36 | 39 | import com.imageworks.spcue.VirtualProc;
|
| 40 | +import com.imageworks.spcue.dao.FrameDao; |
37 | 41 | import com.imageworks.spcue.dao.LayerDao;
|
38 | 42 | import com.imageworks.spcue.dispatcher.Dispatcher;
|
| 43 | +import com.imageworks.spcue.dispatcher.DispatchSupport; |
39 | 44 | import com.imageworks.spcue.dispatcher.FrameCompleteHandler;
|
40 | 45 | import com.imageworks.spcue.grpc.host.HardwareState;
|
| 46 | +import com.imageworks.spcue.grpc.job.FrameState; |
41 | 47 | import com.imageworks.spcue.grpc.report.FrameCompleteReport;
|
42 | 48 | import com.imageworks.spcue.grpc.report.RenderHost;
|
43 | 49 | import com.imageworks.spcue.grpc.report.RunningFrameInfo;
|
@@ -70,12 +76,18 @@ public class FrameCompleteHandlerTests extends TransactionalTest {
|
70 | 76 | @Resource
|
71 | 77 | JobManager jobManager;
|
72 | 78 |
|
| 79 | + @Resource |
| 80 | + FrameDao frameDao; |
| 81 | + |
73 | 82 | @Resource
|
74 | 83 | LayerDao layerDao;
|
75 | 84 |
|
76 | 85 | @Resource
|
77 | 86 | Dispatcher dispatcher;
|
78 | 87 |
|
| 88 | + @Resource |
| 89 | + DispatchSupport dispatchSupport; |
| 90 | + |
79 | 91 | private static final String HOSTNAME = "beta";
|
80 | 92 |
|
81 | 93 | @Before
|
@@ -232,5 +244,88 @@ public void testGpuReportOver() {
|
232 | 244 | (jobManager.isJobComplete(job1) ? 1 : 0) +
|
233 | 245 | (jobManager.isJobComplete(job2) ? 1 : 0));
|
234 | 246 | }
|
| 247 | + |
| 248 | + private void executeDepend( |
| 249 | + FrameState frameState, int exitStatus, int dependCount, FrameState dependState) { |
| 250 | + JobDetail job = jobManager.findJobDetail("pipe-default-testuser_test_depend"); |
| 251 | + LayerDetail layerFirst = layerDao.findLayerDetail(job, "layer_first"); |
| 252 | + LayerDetail layerSecond = layerDao.findLayerDetail(job, "layer_second"); |
| 253 | + FrameDetail frameFirst = frameDao.findFrameDetail(job, "0000-layer_first"); |
| 254 | + FrameDetail frameSecond = frameDao.findFrameDetail(job, "0000-layer_second"); |
| 255 | + |
| 256 | + assertEquals(1, frameSecond.dependCount); |
| 257 | + assertEquals(FrameState.DEPEND, frameSecond.state); |
| 258 | + |
| 259 | + jobManager.setJobPaused(job, false); |
| 260 | + |
| 261 | + DispatchHost host = getHost(); |
| 262 | + List<VirtualProc> procs = dispatcher.dispatchHost(host); |
| 263 | + assertEquals(1, procs.size()); |
| 264 | + VirtualProc proc = procs.get(0); |
| 265 | + assertEquals(job.getId(), proc.getJobId()); |
| 266 | + assertEquals(layerFirst.getId(), proc.getLayerId()); |
| 267 | + assertEquals(frameFirst.getId(), proc.getFrameId()); |
| 268 | + |
| 269 | + RunningFrameInfo info = RunningFrameInfo.newBuilder() |
| 270 | + .setJobId(proc.getJobId()) |
| 271 | + .setLayerId(proc.getLayerId()) |
| 272 | + .setFrameId(proc.getFrameId()) |
| 273 | + .setResourceId(proc.getProcId()) |
| 274 | + .build(); |
| 275 | + FrameCompleteReport report = FrameCompleteReport.newBuilder() |
| 276 | + .setFrame(info) |
| 277 | + .setExitStatus(exitStatus) |
| 278 | + .build(); |
| 279 | + |
| 280 | + DispatchJob dispatchJob = jobManager.getDispatchJob(proc.getJobId()); |
| 281 | + DispatchFrame dispatchFrame = jobManager.getDispatchFrame(report.getFrame().getFrameId()); |
| 282 | + dispatchSupport.stopFrame(dispatchFrame, frameState, report.getExitStatus(), |
| 283 | + report.getFrame().getMaxRss()); |
| 284 | + frameCompleteHandler.handlePostFrameCompleteOperations(proc, |
| 285 | + report, dispatchJob, dispatchFrame, frameState); |
| 286 | + |
| 287 | + assertTrue(jobManager.isLayerComplete(layerFirst)); |
| 288 | + assertFalse(jobManager.isLayerComplete(layerSecond)); |
| 289 | + |
| 290 | + frameSecond = frameDao.findFrameDetail(job, "0000-layer_second"); |
| 291 | + assertEquals(dependCount, frameSecond.dependCount); |
| 292 | + assertEquals(dependState, frameSecond.state); |
| 293 | + } |
| 294 | + |
| 295 | + @Test |
| 296 | + @Transactional |
| 297 | + @Rollback(true) |
| 298 | + public void testDependOnSuccess() { |
| 299 | + assertTrue(frameCompleteHandler.getSatisfyDependOnlyOnFrameSuccess()); |
| 300 | + executeDepend(FrameState.SUCCEEDED, 0, 0, FrameState.WAITING); |
| 301 | + } |
| 302 | + |
| 303 | + @Test |
| 304 | + @Transactional |
| 305 | + @Rollback(true) |
| 306 | + public void testDependOnFailure() { |
| 307 | + assertTrue(frameCompleteHandler.getSatisfyDependOnlyOnFrameSuccess()); |
| 308 | + executeDepend(FrameState.EATEN, -1, 1, FrameState.DEPEND); |
| 309 | + } |
| 310 | + |
| 311 | + @Test |
| 312 | + @Transactional |
| 313 | + @Rollback(true) |
| 314 | + public void testDependOnSuccessSatifyOnAny() { |
| 315 | + frameCompleteHandler.setSatisfyDependOnlyOnFrameSuccess(false); |
| 316 | + assertFalse(frameCompleteHandler.getSatisfyDependOnlyOnFrameSuccess()); |
| 317 | + executeDepend(FrameState.SUCCEEDED, 0, 0, FrameState.WAITING); |
| 318 | + frameCompleteHandler.setSatisfyDependOnlyOnFrameSuccess(true); |
| 319 | + } |
| 320 | + |
| 321 | + @Test |
| 322 | + @Transactional |
| 323 | + @Rollback(true) |
| 324 | + public void testDependOnFailureSatisfyOnAny() { |
| 325 | + frameCompleteHandler.setSatisfyDependOnlyOnFrameSuccess(false); |
| 326 | + assertFalse(frameCompleteHandler.getSatisfyDependOnlyOnFrameSuccess()); |
| 327 | + executeDepend(FrameState.EATEN, -1, 0, FrameState.WAITING); |
| 328 | + frameCompleteHandler.setSatisfyDependOnlyOnFrameSuccess(true); |
| 329 | + } |
235 | 330 | }
|
236 | 331 |
|
0 commit comments