Skip to content

Commit a808d5a

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent d83e8a2 commit a808d5a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private synchronized void onAddOrUpdate(
194194
}
195195

196196
private boolean canSkipEvent(R newObject, R oldObject, ResourceID resourceID) {
197-
return temporaryResourceCache.isNewerThenKnownResource(newObject, resourceID);
197+
return !temporaryResourceCache.isNewerThenKnownResource(newObject, resourceID);
198198
// if (res.isEmpty()) {
199199
// return false;
200200
// }

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ public synchronized void start() {}
9595

9696
@Test
9797
void skipsEventPropagationIfResourceWithSameVersionInResourceCache() {
98-
when(temporaryResourceCacheMock.getResourceFromCache(any()))
99-
.thenReturn(Optional.of(testDeployment()));
98+
when(temporaryResourceCacheMock.isNewerThenKnownResource(any(), any())).thenReturn(false);
10099

101100
informerEventSource.onAdd(testDeployment());
102101
informerEventSource.onUpdate(testDeployment(), testDeployment());
@@ -106,13 +105,15 @@ void skipsEventPropagationIfResourceWithSameVersionInResourceCache() {
106105

107106
@Test
108107
void processEventPropagationWithoutAnnotation() {
108+
when(temporaryResourceCacheMock.isNewerThenKnownResource(any(), any())).thenReturn(true);
109109
informerEventSource.onUpdate(testDeployment(), testDeployment());
110110

111111
verify(eventHandlerMock, times(1)).handleEvent(any());
112112
}
113113

114114
@Test
115115
void processEventPropagationWithIncorrectAnnotation() {
116+
when(temporaryResourceCacheMock.isNewerThenKnownResource(any(), any())).thenReturn(true);
116117
informerEventSource.onAdd(
117118
new DeploymentBuilder(testDeployment())
118119
.editMetadata()
@@ -127,8 +128,7 @@ void processEventPropagationWithIncorrectAnnotation() {
127128
void propagateEventAndRemoveResourceFromTempCacheIfResourceVersionMismatch() {
128129
Deployment cachedDeployment = testDeployment();
129130
cachedDeployment.getMetadata().setResourceVersion(PREV_RESOURCE_VERSION);
130-
when(temporaryResourceCacheMock.getResourceFromCache(any()))
131-
.thenReturn(Optional.of(cachedDeployment));
131+
when(temporaryResourceCacheMock.isNewerThenKnownResource(any(), any())).thenReturn(true);
132132

133133
informerEventSource.onUpdate(cachedDeployment, testDeployment());
134134

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/TemporaryPrimaryResourceCacheTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void updateAddsTheResourceIntoCacheIfTheInformerHasThePreviousResourceVersion()
6666
void updateNotAddsTheResourceIntoCacheIfTheInformerHasOtherVersion() {
6767
var testResource = testResource();
6868
var informerCachedResource = testResource();
69-
informerCachedResource.getMetadata().setResourceVersion("x");
69+
informerCachedResource.getMetadata().setResourceVersion("2");
7070
when(informerEventSource.get(any())).thenReturn(Optional.of(informerCachedResource));
7171

7272
temporaryResourceCache.putResource(testResource, "0");

0 commit comments

Comments
 (0)