|
20 | 20 | import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
|
21 | 21 | import oracle.kubernetes.operator.helpers.JobHelper;
|
22 | 22 | import oracle.kubernetes.operator.helpers.KubernetesTestSupport;
|
| 23 | +import oracle.kubernetes.operator.steps.WatchDomainIntrospectorJobReadyStep; |
23 | 24 | import oracle.kubernetes.operator.watcher.WatchListener;
|
24 | 25 | import oracle.kubernetes.operator.work.Step;
|
25 | 26 | import oracle.kubernetes.operator.work.TerminalStep;
|
26 | 27 | import oracle.kubernetes.utils.SystemClock;
|
| 28 | +import oracle.kubernetes.weblogic.domain.model.DomainCondition; |
27 | 29 | import oracle.kubernetes.weblogic.domain.model.DomainResource;
|
28 | 30 | import oracle.kubernetes.weblogic.domain.model.DomainSpec;
|
| 31 | +import oracle.kubernetes.weblogic.domain.model.DomainStatus; |
29 | 32 | import org.junit.jupiter.api.AfterEach;
|
30 | 33 | import org.junit.jupiter.api.BeforeEach;
|
31 | 34 | import org.junit.jupiter.api.Test;
|
32 | 35 |
|
33 | 36 | import static oracle.kubernetes.operator.DomainProcessorTestSetup.NS;
|
34 | 37 | import static oracle.kubernetes.operator.DomainProcessorTestSetup.UID;
|
35 | 38 | import static oracle.kubernetes.operator.JobWatcher.NULL_LISTENER;
|
| 39 | +import static oracle.kubernetes.operator.KubernetesConstants.DOMAIN; |
36 | 40 | import static oracle.kubernetes.operator.LabelConstants.CREATEDBYOPERATOR_LABEL;
|
37 | 41 | import static oracle.kubernetes.operator.LabelConstants.DOMAINUID_LABEL;
|
| 42 | +import static oracle.kubernetes.operator.ProcessingConstants.JOBWATCHER_COMPONENT_NAME; |
| 43 | +import static oracle.kubernetes.weblogic.domain.model.DomainConditionType.FAILED; |
| 44 | +import static oracle.kubernetes.weblogic.domain.model.DomainFailureReason.ABORTED; |
38 | 45 | import static org.hamcrest.Matchers.both;
|
39 | 46 | import static org.hamcrest.Matchers.hasEntry;
|
40 | 47 | import static org.hamcrest.Matchers.instanceOf;
|
@@ -385,6 +392,16 @@ private void startWaitForReadyThenReadJob(Function<V1Job,V1Job> jobFunction, Ste
|
385 | 392 | }
|
386 | 393 | }
|
387 | 394 |
|
| 395 | + private void startWatchDomainIntrospectorJobReadyStep(Function<V1Job,V1Job> jobFunction) { |
| 396 | + V1Job persistedJob = jobFunction.apply(createJob()); |
| 397 | + testSupport.defineResources(persistedJob); |
| 398 | + testSupport.defineResources(domain); |
| 399 | + testSupport.getPacket().put(ProcessingConstants.DOMAIN_INTROSPECTOR_JOB, this.dontChangeJob(persistedJob)); |
| 400 | + domain.getOrCreateStatus().addCondition(new DomainCondition(FAILED).withReason(ABORTED).withMessage("ugh")); |
| 401 | + |
| 402 | + testSupport.runSteps(testSupport.getPacket(), new WatchDomainIntrospectorJobReadyStep()); |
| 403 | + } |
| 404 | + |
388 | 405 | private void startWaitForReadyWithJobPodFluentdThenReadJob(Function<V1Job,V1Job> jobFunction) {
|
389 | 406 | AtomicBoolean stopping = new AtomicBoolean(false);
|
390 | 407 | JobWatcher watcher = createWatcher(stopping);
|
@@ -438,6 +455,18 @@ void whenReceivedCallbackForIncompleteJob_ignoreIt() {
|
438 | 455 | assertThat(terminalStep.wasRun(), is(false));
|
439 | 456 | }
|
440 | 457 |
|
| 458 | + @Test |
| 459 | + void whenJobWithReady_performNextStep() { |
| 460 | + testSupport.addComponent(JOBWATCHER_COMPONENT_NAME, JobAwaiterStepFactory.class, new JobAwaiterStepFactoryStub()); |
| 461 | + startWatchDomainIntrospectorJobReadyStep(this::dontChangeJob); |
| 462 | + |
| 463 | + assertThat(getDomainStatus().hasConditionWithType(FAILED), is(false)); |
| 464 | + } |
| 465 | + |
| 466 | + private DomainStatus getDomainStatus() { |
| 467 | + return ((DomainResource)testSupport.getResources(DOMAIN).get(0)).getStatus(); |
| 468 | + } |
| 469 | + |
441 | 470 | @SuppressWarnings("unused")
|
442 | 471 | private V1Job createCompletedJobWithDifferentTimestamp(V1Job job) {
|
443 | 472 | clock = clock.plusSeconds(1);
|
@@ -470,4 +499,11 @@ public void receivedEvents_areNotSentToListenersWhenWatchersPaused() {
|
470 | 499 | // Override as JobWatcher doesn't currently implement listener for callback
|
471 | 500 | }
|
472 | 501 |
|
| 502 | + private static class JobAwaiterStepFactoryStub implements JobAwaiterStepFactory { |
| 503 | + @Override |
| 504 | + public Step waitForReady(V1Job job, Step next) { |
| 505 | + return next; |
| 506 | + } |
| 507 | + } |
| 508 | + |
473 | 509 | }
|
0 commit comments