4
4
import io .apicurio .registry .operator .api .v1 .ApicurioRegistry3 ;
5
5
import io .fabric8 .kubernetes .api .model .HasMetadata ;
6
6
import io .fabric8 .kubernetes .api .model .NamespaceBuilder ;
7
+ import io .fabric8 .kubernetes .api .model .Pod ;
7
8
import io .fabric8 .kubernetes .api .model .apps .Deployment ;
8
9
import io .fabric8 .kubernetes .client .Config ;
9
10
import io .fabric8 .kubernetes .client .ConfigBuilder ;
12
13
import io .fabric8 .kubernetes .client .utils .Serialization ;
13
14
import io .javaoperatorsdk .operator .Operator ;
14
15
import io .javaoperatorsdk .operator .api .reconciler .Reconciler ;
16
+ import io .javaoperatorsdk .operator .processing .event .ResourceID ;
15
17
import io .quarkiverse .operatorsdk .runtime .QuarkusConfigurationService ;
16
18
import jakarta .enterprise .inject .Instance ;
17
19
import jakarta .enterprise .inject .spi .CDI ;
22
24
import org .slf4j .Logger ;
23
25
import org .slf4j .LoggerFactory ;
24
26
25
- import java .io .FileInputStream ;
26
- import java .io .IOException ;
27
+ import java .io .*;
27
28
import java .nio .file .Files ;
28
29
import java .nio .file .Path ;
29
30
import java .time .Duration ;
31
+ import java .util .ArrayList ;
30
32
import java .util .List ;
33
+ import java .util .Map ;
31
34
import java .util .UUID ;
32
35
33
36
import static org .assertj .core .api .Assertions .assertThat ;
@@ -54,6 +57,7 @@ public enum OperatorDeployment {
54
57
protected static Instance <Reconciler <? extends HasMetadata >> reconcilers ;
55
58
protected static QuarkusConfigurationService configuration ;
56
59
protected static KubernetesClient client ;
60
+ protected static PodLogManager podLogManager ;
57
61
protected static PortForwardManager portForwardManager ;
58
62
protected static IngressManager ingressManager ;
59
63
protected static String deploymentTarget ;
@@ -79,9 +83,11 @@ public static void before() throws Exception {
79
83
80
84
portForwardManager = new PortForwardManager (client , namespace );
81
85
ingressManager = new IngressManager (client , namespace );
86
+ podLogManager = new PodLogManager (client );
82
87
83
88
if (operatorDeployment == OperatorDeployment .remote ) {
84
89
createTestResources ();
90
+ startOperatorLogs ();
85
91
} else {
86
92
createOperator ();
87
93
registerReconcilers ();
@@ -176,6 +182,21 @@ private static void createTestResources() throws Exception {
176
182
});
177
183
}
178
184
185
+ private static void startOperatorLogs () {
186
+ List <Pod > operatorPods = new ArrayList <>();
187
+ await ().ignoreExceptions ().untilAsserted (() -> {
188
+ operatorPods .clear ();
189
+ operatorPods .addAll (client .pods ()
190
+ .withLabels (Map .of (
191
+ "app.kubernetes.io/name" , "apicurio-registry-operator" ,
192
+ "app.kubernetes.io/component" , "operator" ,
193
+ "app.kubernetes.io/part-of" , "apicurio-registry" ))
194
+ .list ().getItems ());
195
+ assertThat (operatorPods ).hasSize (1 );
196
+ });
197
+ podLogManager .startPodLog (ResourceID .fromResource (operatorPods .get (0 )));
198
+ }
199
+
179
200
private static void cleanTestResources () throws Exception {
180
201
if (cleanup ) {
181
202
log .info ("Deleting generated resources from Namespace {}" , namespace );
@@ -258,7 +279,7 @@ public static void after() throws Exception {
258
279
} else {
259
280
cleanTestResources ();
260
281
}
261
-
282
+ podLogManager . stopAndWait ();
262
283
if (cleanup ) {
263
284
log .info ("Deleting namespace : {}" , namespace );
264
285
assertThat (client .namespaces ().withName (namespace ).delete ()).isNotNull ();
0 commit comments