17
17
18
18
class PatchResourceAndStatusNoSSAIT {
19
19
@ RegisterExtension
20
- LocallyRunOperatorExtension operator =
20
+ LocallyRunOperatorExtension extension =
21
21
LocallyRunOperatorExtension .builder ()
22
22
.withConfigurationService (o -> o .withUseSSAToPatchPrimaryResource (false ))
23
23
.withReconciler (PatchResourceAndStatusNoSSAReconciler .class )
24
24
.build ();
25
25
26
26
@ Test
27
27
void updatesSubResourceStatus () {
28
+ extension
29
+ .getReconcilerOfType (PatchResourceAndStatusNoSSAReconciler .class )
30
+ .setRemoveAnnotation (false );
28
31
PatchResourceAndStatusNoSSACustomResource resource = createTestCustomResource ("1" );
29
- operator .create (resource );
32
+ extension .create (resource );
30
33
31
34
awaitStatusUpdated (resource .getMetadata ().getName ());
32
35
// wait for sure, there are no more events
33
36
TestUtils .waitXms (300 );
34
37
35
38
PatchResourceAndStatusNoSSACustomResource customResource =
36
- operator .get (
39
+ extension .get (
37
40
PatchResourceAndStatusNoSSACustomResource .class , resource .getMetadata ().getName ());
38
41
39
- assertThat (TestUtils .getNumberOfExecutions (operator )).isEqualTo (1 );
42
+ assertThat (TestUtils .getNumberOfExecutions (extension )).isEqualTo (1 );
40
43
assertThat (customResource .getStatus ().getState ())
41
44
.isEqualTo (PatchResourceAndStatusNoSSAStatus .State .SUCCESS );
42
45
assertThat (customResource .getMetadata ().getAnnotations ().get (TEST_ANNOTATION )).isNotNull ();
43
46
}
44
47
48
+ @ Test
49
+ void removeAnnotationCorrectlyUpdatesStatus () {
50
+ extension
51
+ .getReconcilerOfType (PatchResourceAndStatusNoSSAReconciler .class )
52
+ .setRemoveAnnotation (true );
53
+ PatchResourceAndStatusNoSSACustomResource resource = createTestCustomResource ("1" );
54
+ resource .getMetadata ().setAnnotations (Map .of (TEST_ANNOTATION , TEST_ANNOTATION_VALUE ));
55
+ extension .create (resource );
56
+
57
+ awaitStatusUpdated (resource .getMetadata ().getName ());
58
+ // wait for sure, there are no more events
59
+ TestUtils .waitXms (300 );
60
+
61
+ PatchResourceAndStatusNoSSACustomResource customResource =
62
+ extension .get (
63
+ PatchResourceAndStatusNoSSACustomResource .class , resource .getMetadata ().getName ());
64
+
65
+ assertThat (TestUtils .getNumberOfExecutions (extension )).isEqualTo (1 );
66
+ assertThat (customResource .getStatus ().getState ())
67
+ .isEqualTo (PatchResourceAndStatusNoSSAStatus .State .SUCCESS );
68
+ assertThat (customResource .getMetadata ().getAnnotations ().get (TEST_ANNOTATION )).isNull ();
69
+ }
70
+
45
71
void awaitStatusUpdated (String name ) {
46
72
await ("cr status updated" )
47
73
.atMost (5 , TimeUnit .SECONDS )
48
74
.untilAsserted (
49
75
() -> {
50
76
PatchResourceAndStatusNoSSACustomResource cr =
51
- operator .get (PatchResourceAndStatusNoSSACustomResource .class , name );
77
+ extension .get (PatchResourceAndStatusNoSSACustomResource .class , name );
52
78
assertThat (cr ).isNotNull ();
53
79
assertThat (cr .getStatus ()).isNotNull ();
54
80
assertThat (cr .getStatus ().getState ())
@@ -60,7 +86,6 @@ public PatchResourceAndStatusNoSSACustomResource createTestCustomResource(String
60
86
PatchResourceAndStatusNoSSACustomResource resource =
61
87
new PatchResourceAndStatusNoSSACustomResource ();
62
88
resource .setMetadata (new ObjectMetaBuilder ().withName ("doubleupdateresource-" + id ).build ());
63
- resource .getMetadata ().setAnnotations (Map .of (TEST_ANNOTATION , TEST_ANNOTATION_VALUE ));
64
89
resource .setSpec (new PatchResourceAndStatusNoSSASpec ());
65
90
resource .getSpec ().setValue (id );
66
91
return resource ;
0 commit comments