|
33 | 33 | import org.apache.flink.kubernetes.operator.api.spec.UpgradeMode; |
34 | 34 |
|
35 | 35 | import io.fabric8.kubernetes.api.model.ObjectMeta; |
| 36 | +import io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder; |
36 | 37 | import org.junit.jupiter.api.Test; |
37 | 38 |
|
38 | 39 | import java.util.HashMap; |
|
41 | 42 | import static org.junit.jupiter.api.Assertions.assertEquals; |
42 | 43 | import static org.junit.jupiter.api.Assertions.assertThrows; |
43 | 44 |
|
44 | | -/** Tests for FlinkBlueGreenDeploymentSpecDiff. */ |
| 45 | +/** |
| 46 | + * Tests for FlinkBlueGreenDeploymentSpecDiff. |
| 47 | + */ |
45 | 48 | public class FlinkBlueGreenDeploymentSpecDiffTest { |
46 | 49 |
|
47 | 50 | private static final KubernetesDeploymentMode DEPLOYMENT_MODE = KubernetesDeploymentMode.NATIVE; |
@@ -133,6 +136,62 @@ public void testIgnoreForConfigurationDifference() { |
133 | 136 | assertEquals(BlueGreenDiffType.IGNORE, diff.compare()); |
134 | 137 | } |
135 | 138 |
|
| 139 | + @Test |
| 140 | + public void testIgnoreForRootPodTemplateAdditionalProps() { |
| 141 | + FlinkBlueGreenDeploymentSpec spec1 = createBasicSpec(); |
| 142 | + FlinkBlueGreenDeploymentSpec spec2 = createBasicSpec(); |
| 143 | + |
| 144 | + // Set spec1 to have empty podTemplate to not cause valid diff to be detected |
| 145 | + spec1.getTemplate().getSpec().setPodTemplate(new PodTemplateSpecBuilder().build()); |
| 146 | + spec2.getTemplate() |
| 147 | + .getSpec() |
| 148 | + .setPodTemplate( |
| 149 | + new PodTemplateSpecBuilder() |
| 150 | + .withAdditionalProperties(Map.of("apiVersion", "v1")) |
| 151 | + .build()); |
| 152 | + FlinkBlueGreenDeploymentSpecDiff diff = |
| 153 | + new FlinkBlueGreenDeploymentSpecDiff(DEPLOYMENT_MODE, spec1, spec2); |
| 154 | + assertEquals(BlueGreenDiffType.IGNORE, diff.compare()); |
| 155 | + } |
| 156 | + |
| 157 | + @Test |
| 158 | + public void testIgnoreForJobManagerPodTemplateAdditionalProps() { |
| 159 | + FlinkBlueGreenDeploymentSpec spec1 = createBasicSpec(); |
| 160 | + FlinkBlueGreenDeploymentSpec spec2 = createBasicSpec(); |
| 161 | + |
| 162 | + // Set spec1 to have empty podTemplate to not cause valid diff to be detected |
| 163 | + spec1.getTemplate().getSpec().getJobManager().setPodTemplate(new PodTemplateSpecBuilder().build()); |
| 164 | + spec2.getTemplate() |
| 165 | + .getSpec() |
| 166 | + .getJobManager() |
| 167 | + .setPodTemplate( |
| 168 | + new PodTemplateSpecBuilder() |
| 169 | + .withAdditionalProperties(Map.of("apiVersion", "v1")) |
| 170 | + .build()); |
| 171 | + FlinkBlueGreenDeploymentSpecDiff diff = |
| 172 | + new FlinkBlueGreenDeploymentSpecDiff(DEPLOYMENT_MODE, spec1, spec2); |
| 173 | + assertEquals(BlueGreenDiffType.IGNORE, diff.compare()); |
| 174 | + } |
| 175 | + |
| 176 | + @Test |
| 177 | + public void testIgnoreForTaskManagerPodTemplateAdditionalProps() { |
| 178 | + FlinkBlueGreenDeploymentSpec spec1 = createBasicSpec(); |
| 179 | + FlinkBlueGreenDeploymentSpec spec2 = createBasicSpec(); |
| 180 | + |
| 181 | + // Set spec1 to have empty podTemplate to not cause valid diff to be detected |
| 182 | + spec1.getTemplate().getSpec().getTaskManager().setPodTemplate(new PodTemplateSpecBuilder().build()); |
| 183 | + spec2.getTemplate() |
| 184 | + .getSpec() |
| 185 | + .getTaskManager() |
| 186 | + .setPodTemplate( |
| 187 | + new PodTemplateSpecBuilder() |
| 188 | + .withAdditionalProperties(Map.of("apiVersion", "v1")) |
| 189 | + .build()); |
| 190 | + FlinkBlueGreenDeploymentSpecDiff diff = |
| 191 | + new FlinkBlueGreenDeploymentSpecDiff(DEPLOYMENT_MODE, spec1, spec2); |
| 192 | + assertEquals(BlueGreenDiffType.IGNORE, diff.compare()); |
| 193 | + } |
| 194 | + |
136 | 195 | @Test |
137 | 196 | public void testTransitionForNestedSpecDifference() { |
138 | 197 | FlinkBlueGreenDeploymentSpec spec1 = createBasicSpec(); |
|
0 commit comments