24
24
import jakarta .enterprise .util .TypeLiteral ;
25
25
import org .awaitility .Awaitility ;
26
26
import org .eclipse .microprofile .config .ConfigProvider ;
27
- import org .junit .jupiter .api .*;
27
+ import org .junit .jupiter .api .AfterAll ;
28
+ import org .junit .jupiter .api .AfterEach ;
29
+ import org .junit .jupiter .api .BeforeAll ;
30
+ import org .junit .jupiter .api .BeforeEach ;
31
+ import org .junit .jupiter .api .TestInfo ;
28
32
import org .slf4j .Logger ;
29
33
import org .slf4j .LoggerFactory ;
30
34
40
44
import java .util .Map ;
41
45
import java .util .UUID ;
42
46
47
+ import static java .time .Duration .ofSeconds ;
43
48
import static org .assertj .core .api .Assertions .assertThat ;
44
49
import static org .awaitility .Awaitility .await ;
45
50
@@ -56,6 +61,13 @@ public abstract class ITBase {
56
61
public static final String CRD_FILE = "../model/target/classes/META-INF/fabric8/apicurioregistries3.registry.apicur.io-v1.yml" ;
57
62
public static final String REMOTE_TESTS_INSTALL_FILE = "test.operator.install-file" ;
58
63
64
+ public static final Duration POLL_INTERVAL_DURATION = ofSeconds (5 );
65
+ public static final Duration SHORT_DURATION = ofSeconds (30 );
66
+ // NOTE: When running remote tests, some extra time might be needed to pull an image before the pod can be run.
67
+ // TODO: Consider changing the duration based on test type or the situation.
68
+ public static final Duration MEDIUM_DURATION = ofSeconds (60 );
69
+ public static final Duration LONG_DURATION = ofSeconds (5 * 60 );
70
+
59
71
public enum OperatorDeployment {
60
72
local , remote
61
73
}
@@ -123,46 +135,46 @@ public void beforeEach(TestInfo testInfo) {
123
135
}
124
136
125
137
protected static void checkDeploymentExists (ApicurioRegistry3 primary , String component , int replicas ) {
126
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
138
+ await ().atMost (MEDIUM_DURATION ).ignoreExceptions ().untilAsserted (() -> {
127
139
assertThat (client .apps ().deployments ()
128
140
.withName (primary .getMetadata ().getName () + "-" + component + "-deployment" ).get ()
129
141
.getStatus ().getReadyReplicas ()).isEqualTo (replicas );
130
142
});
131
143
}
132
144
133
145
protected static void checkDeploymentDoesNotExist (ApicurioRegistry3 primary , String component ) {
134
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
146
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
135
147
assertThat (client .apps ().deployments ()
136
148
.withName (primary .getMetadata ().getName () + "-" + component + "-deployment" ).get ())
137
149
.isNull ();
138
150
});
139
151
}
140
152
141
153
protected static void checkServiceExists (ApicurioRegistry3 primary , String component ) {
142
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
154
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
143
155
assertThat (client .services ()
144
156
.withName (primary .getMetadata ().getName () + "-" + component + "-service" ).get ())
145
157
.isNotNull ();
146
158
});
147
159
}
148
160
149
161
protected static void checkServiceDoesNotExist (ApicurioRegistry3 primary , String component ) {
150
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
162
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
151
163
assertThat (client .services ()
152
164
.withName (primary .getMetadata ().getName () + "-" + component + "-service" ).get ()).isNull ();
153
165
});
154
166
}
155
167
156
168
protected static void checkIngressExists (ApicurioRegistry3 primary , String component ) {
157
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
169
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
158
170
assertThat (client .network ().v1 ().ingresses ()
159
171
.withName (primary .getMetadata ().getName () + "-" + component + "-ingress" ).get ())
160
172
.isNotNull ();
161
173
});
162
174
}
163
175
164
176
protected static void checkIngressDoesNotExist (ApicurioRegistry3 primary , String component ) {
165
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
177
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
166
178
assertThat (client .network ().v1 ().ingresses ()
167
179
.withName (primary .getMetadata ().getName () + "-" + component + "-ingress" ).get ()).isNull ();
168
180
});
@@ -172,7 +184,7 @@ protected static PodDisruptionBudget checkPodDisruptionBudgetExists(ApicurioRegi
172
184
String component ) {
173
185
final ValueOrNull <PodDisruptionBudget > rval = new ValueOrNull <>();
174
186
175
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
187
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
176
188
PodDisruptionBudget pdb = client .policy ().v1 ().podDisruptionBudget ()
177
189
.withName (primary .getMetadata ().getName () + "-" + component + "-poddisruptionbudget" )
178
190
.get ();
@@ -186,7 +198,7 @@ protected static PodDisruptionBudget checkPodDisruptionBudgetExists(ApicurioRegi
186
198
protected static NetworkPolicy checkNetworkPolicyExists (ApicurioRegistry3 primary , String component ) {
187
199
final ValueOrNull <NetworkPolicy > rval = new ValueOrNull <>();
188
200
189
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
201
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
190
202
NetworkPolicy networkPolicy = client .network ().v1 ().networkPolicies ()
191
203
.withName (primary .getMetadata ().getName () + "-" + component + "-networkpolicy" ).get ();
192
204
assertThat (networkPolicy ).isNotNull ();
@@ -225,7 +237,7 @@ private static void createTestResources() throws Exception {
225
237
226
238
private static void startOperatorLogs () {
227
239
List <Pod > operatorPods = new ArrayList <>();
228
- await ().atMost (Duration . ofSeconds ( 30 ) ).ignoreExceptions ().untilAsserted (() -> {
240
+ await ().atMost (SHORT_DURATION ).ignoreExceptions ().untilAsserted (() -> {
229
241
operatorPods .clear ();
230
242
operatorPods .addAll (client .pods ()
231
243
.withLabels (Map .of (
@@ -312,8 +324,8 @@ static String calculateNamespace() {
312
324
}
313
325
314
326
static void setDefaultAwaitilityTimings () {
315
- Awaitility .setDefaultPollInterval (Duration . ofSeconds ( 5 ) );
316
- Awaitility .setDefaultTimeout (Duration . ofSeconds ( 5 * 60 ) );
327
+ Awaitility .setDefaultPollInterval (POLL_INTERVAL_DURATION );
328
+ Awaitility .setDefaultTimeout (LONG_DURATION );
317
329
}
318
330
319
331
static void createResources (List <HasMetadata > resources , String resourceType ) {
0 commit comments