-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sample to primary to secondary missing issue (#1847)
Co-authored-by: Sébastien CROCQUESEL <[email protected]>
- Loading branch information
1 parent
eaddc24
commit d76a47c
Showing
3 changed files
with
114 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ator-framework/src/test/java/io/javaoperatorsdk/operator/PrimaryToSecondaryMissingIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.javaoperatorsdk.operator; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension; | ||
import io.javaoperatorsdk.operator.sample.primarytosecondary.Cluster; | ||
import io.javaoperatorsdk.operator.sample.primarytosecondary.JobReconciler; | ||
|
||
import static io.javaoperatorsdk.operator.PrimaryToSecondaryIT.cluster; | ||
import static io.javaoperatorsdk.operator.PrimaryToSecondaryIT.job; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.awaitility.Awaitility.await; | ||
|
||
/** | ||
* The intention with this IT is to show the use cases why the PrimaryToSecondary Mapper is needed, | ||
* and the situation when it is not working. | ||
*/ | ||
class PrimaryToSecondaryMissingIT { | ||
|
||
@RegisterExtension | ||
LocallyRunOperatorExtension operator = | ||
LocallyRunOperatorExtension.builder() | ||
.withAdditionalCustomResourceDefinition(Cluster.class) | ||
.withReconciler(new JobReconciler(false)) | ||
.build(); | ||
|
||
@Test | ||
void missingPrimaryToSecondaryCausesIssueAccessingSecondary() throws InterruptedException { | ||
var reconciler = operator.getReconcilerOfType(JobReconciler.class); | ||
operator.create(cluster()); | ||
Thread.sleep(300); | ||
operator.create(job()); | ||
|
||
await().untilAsserted(() -> { | ||
assertThat(reconciler.isErrorOccurred()).isTrue(); | ||
assertThat(reconciler.getNumberOfExecutions()).isZero(); | ||
}); | ||
} | ||
|
||
@Test | ||
void accessingDirectlyTheCacheWorksWithoutPToSMapper() throws InterruptedException { | ||
var reconciler = operator.getReconcilerOfType(JobReconciler.class); | ||
reconciler.setGetResourceDirectlyFromCache(true); | ||
operator.create(cluster()); | ||
Thread.sleep(300); | ||
operator.create(job()); | ||
|
||
await().untilAsserted(() -> { | ||
assertThat(reconciler.isErrorOccurred()).isFalse(); | ||
assertThat(reconciler.getNumberOfExecutions()).isPositive(); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters