Skip to content

Commit bd0c450

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent 200219a commit bd0c450

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/primarytosecondary/JobReconciler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* needed, and to show the use cases when some mechanisms would not work without that. It's not
1818
* intended to be a reusable code as it is, rather serves for deeper understanding of the problem.
1919
*/
20-
@ControllerConfiguration()
20+
@ControllerConfiguration
2121
public class JobReconciler implements Reconciler<Job> {
2222

2323
private static final String JOB_CLUSTER_INDEX = "job-cluster-index";

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/primarytosecondary/PrimaryToSecondaryIT.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,43 @@ class PrimaryToSecondaryIT {
1818

1919
public static final String CLUSTER_VALUE = "clusterValue";
2020
public static final String JOB_1 = "job1";
21+
public static final String CHANGED_VALUE = "CHANGED_VALUE";
2122

2223
@RegisterExtension
23-
LocallyRunOperatorExtension operator =
24+
LocallyRunOperatorExtension extension =
2425
LocallyRunOperatorExtension.builder()
2526
.withAdditionalCustomResourceDefinition(Cluster.class)
2627
.withReconciler(new JobReconciler())
2728
.build();
2829

2930
@Test
3031
void readsSecondaryInManyToOneCases() throws InterruptedException {
31-
operator.create(cluster());
32+
var cluster = extension.create(cluster());
3233
Thread.sleep(MIN_DELAY);
33-
operator.create(job());
34+
extension.create(job());
3435

3536
await()
3637
.pollDelay(Duration.ofMillis(300))
3738
.untilAsserted(
3839
() -> {
39-
assertThat(operator.getReconcilerOfType(JobReconciler.class).getNumberOfExecutions())
40+
assertThat(extension.getReconcilerOfType(JobReconciler.class).getNumberOfExecutions())
4041
.isEqualTo(1);
41-
var job = operator.get(Job.class, JOB_1);
42+
var job = extension.get(Job.class, JOB_1);
4243
assertThat(job.getStatus()).isNotNull();
4344
assertThat(job.getStatus().getValueFromCluster()).isEqualTo(CLUSTER_VALUE);
4445
});
46+
47+
cluster.getSpec().setClusterValue(CHANGED_VALUE);
48+
extension.replace(cluster);
49+
50+
// cluster change triggers job reconciliations
51+
await()
52+
.pollDelay(Duration.ofMillis(300))
53+
.untilAsserted(
54+
() -> {
55+
var job = extension.get(Job.class, JOB_1);
56+
assertThat(job.getStatus().getValueFromCluster()).isEqualTo(CHANGED_VALUE);
57+
});
4558
}
4659

4760
public static Job job() {

0 commit comments

Comments
 (0)