|
72 | 72 | import static oracle.kubernetes.operator.DomainProcessorTestSetup.NS;
|
73 | 73 | import static oracle.kubernetes.operator.DomainProcessorTestSetup.UID;
|
74 | 74 | import static oracle.kubernetes.operator.DomainUpPlanTest.StepChainMatcher.hasChainWithStepsInOrder;
|
| 75 | +import static oracle.kubernetes.operator.LabelConstants.INTROSPECTION_STATE_LABEL; |
75 | 76 | import static oracle.kubernetes.operator.ProcessingConstants.DOMAIN_INTROSPECTOR_JOB;
|
76 | 77 | import static oracle.kubernetes.operator.ProcessingConstants.DOMAIN_TOPOLOGY;
|
77 | 78 | import static oracle.kubernetes.operator.ProcessingConstants.EXCEEDED_INTROSPECTOR_MAX_RETRY_COUNT_ERROR_MSG;
|
@@ -780,6 +781,75 @@ void whenJobHasImagePullBackOffError_correctStepsExecuted() {
|
780 | 781 | "DomainIntrospectorJobStep"));
|
781 | 782 | }
|
782 | 783 |
|
| 784 | + @Test |
| 785 | + void whenJobInProgressAndIntrospectVersionAdded_correctStepsExecuted() { |
| 786 | + List<Step> nextSteps = new ArrayList<>(); |
| 787 | + V1Job job = new V1Job().metadata(new V1ObjectMeta().name(getJobName()).namespace(NS).uid(JOB_UID)) |
| 788 | + .status(new V1JobStatus()); |
| 789 | + testSupport.defineResources(job); |
| 790 | + getConfigurator().withIntrospectVersion("v2"); |
| 791 | + IntrospectionTestUtils.defineResources(testSupport, "passed"); |
| 792 | + testSupport.addToPacket(DOMAIN_INTROSPECTOR_JOB, testSupport.getResourceWithName(JOB, getJobName())); |
| 793 | + |
| 794 | + JobHelper.ReplaceOrCreateStep.createNextSteps(nextSteps, testSupport.getPacket(), job, terminalStep); |
| 795 | + |
| 796 | + assertThat(nextSteps.get(0), hasChainWithStepsInOrder("DeleteDomainIntrospectorJobStep", |
| 797 | + "DomainIntrospectorJobStep")); |
| 798 | + } |
| 799 | + |
| 800 | + @Test |
| 801 | + void whenJobInProgressAndIntrospectVersionChanged_correctStepsExecuted() { |
| 802 | + List<Step> nextSteps = new ArrayList<>(); |
| 803 | + V1Job job = new V1Job().metadata(new V1ObjectMeta().name(getJobName()).namespace(NS).uid(JOB_UID)) |
| 804 | + .status(new V1JobStatus()); |
| 805 | + job.getMetadata().putLabelsItem(INTROSPECTION_STATE_LABEL, "v1"); |
| 806 | + testSupport.defineResources(job); |
| 807 | + getConfigurator().withIntrospectVersion("v2"); |
| 808 | + IntrospectionTestUtils.defineResources(testSupport, "passed"); |
| 809 | + testSupport.addToPacket(DOMAIN_INTROSPECTOR_JOB, testSupport.getResourceWithName(JOB, getJobName())); |
| 810 | + |
| 811 | + JobHelper.ReplaceOrCreateStep.createNextSteps(nextSteps, testSupport.getPacket(), job, terminalStep); |
| 812 | + |
| 813 | + assertThat(nextSteps.get(0), hasChainWithStepsInOrder("DeleteDomainIntrospectorJobStep", |
| 814 | + "DomainIntrospectorJobStep")); |
| 815 | + } |
| 816 | + |
| 817 | + @Test |
| 818 | + void whenJobInProgressAndIntrospectVersionUnchanged_correctStepsExecuted() { |
| 819 | + List<Step> nextSteps = new ArrayList<>(); |
| 820 | + V1Job job = new V1Job().metadata(new V1ObjectMeta().name(getJobName()).namespace(NS).uid(JOB_UID)) |
| 821 | + .status(new V1JobStatus()); |
| 822 | + job.getMetadata().putLabelsItem(INTROSPECTION_STATE_LABEL, "v2"); |
| 823 | + testSupport.defineResources(job); |
| 824 | + getConfigurator().withIntrospectVersion("v2"); |
| 825 | + IntrospectionTestUtils.defineResources(testSupport, "passed"); |
| 826 | + testSupport.addToPacket(DOMAIN_INTROSPECTOR_JOB, testSupport.getResourceWithName(JOB, getJobName())); |
| 827 | + |
| 828 | + JobHelper.ReplaceOrCreateStep.createNextSteps(nextSteps, testSupport.getPacket(), job, terminalStep); |
| 829 | + |
| 830 | + assertThat(nextSteps.get(0), hasChainWithStepsInOrder("WatchDomainIntrospectorJobReadyStep", |
| 831 | + "ReadDomainIntrospectorPodStep", "ReadDomainIntrospectorPodLogStep", |
| 832 | + "DeleteDomainIntrospectorJobStep", "IntrospectionConfigMapStep", "TerminalStep")); |
| 833 | + } |
| 834 | + |
| 835 | + @Test |
| 836 | + void whenJobInProgressAndNullIntrospectVersionUnchanged_correctStepsExecuted() { |
| 837 | + List<Step> nextSteps = new ArrayList<>(); |
| 838 | + V1Job job = new V1Job().metadata(new V1ObjectMeta().name(getJobName()).namespace(NS).uid(JOB_UID)) |
| 839 | + .status(new V1JobStatus()); |
| 840 | + job.getMetadata().putLabelsItem(INTROSPECTION_STATE_LABEL, null); |
| 841 | + testSupport.defineResources(job); |
| 842 | + getConfigurator().withIntrospectVersion(null); |
| 843 | + IntrospectionTestUtils.defineResources(testSupport, "passed"); |
| 844 | + testSupport.addToPacket(DOMAIN_INTROSPECTOR_JOB, testSupport.getResourceWithName(JOB, getJobName())); |
| 845 | + |
| 846 | + JobHelper.ReplaceOrCreateStep.createNextSteps(nextSteps, testSupport.getPacket(), job, terminalStep); |
| 847 | + |
| 848 | + assertThat(nextSteps.get(0), hasChainWithStepsInOrder("WatchDomainIntrospectorJobReadyStep", |
| 849 | + "ReadDomainIntrospectorPodStep", "ReadDomainIntrospectorPodLogStep", |
| 850 | + "DeleteDomainIntrospectorJobStep", "IntrospectionConfigMapStep", "TerminalStep")); |
| 851 | + } |
| 852 | + |
783 | 853 | @Test
|
784 | 854 | void whenCurrentJobIsNull_correctStepsExecuted() {
|
785 | 855 | List<Step> nextSteps = new ArrayList<>();
|
|
0 commit comments