Skip to content

Commit d93ccbf

Browse files
committed
chore(operator): adjust test timeouts
1 parent 8d08668 commit d93ccbf

File tree

1 file changed

+24
-12
lines changed
  • operator/controller/src/test/java/io/apicurio/registry/operator/it

1 file changed

+24
-12
lines changed

operator/controller/src/test/java/io/apicurio/registry/operator/it/ITBase.java

+24-12
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
import jakarta.enterprise.util.TypeLiteral;
2525
import org.awaitility.Awaitility;
2626
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;
2832
import org.slf4j.Logger;
2933
import org.slf4j.LoggerFactory;
3034

@@ -40,6 +44,7 @@
4044
import java.util.Map;
4145
import java.util.UUID;
4246

47+
import static java.time.Duration.ofSeconds;
4348
import static org.assertj.core.api.Assertions.assertThat;
4449
import static org.awaitility.Awaitility.await;
4550

@@ -56,6 +61,13 @@ public abstract class ITBase {
5661
public static final String CRD_FILE = "../model/target/classes/META-INF/fabric8/apicurioregistries3.registry.apicur.io-v1.yml";
5762
public static final String REMOTE_TESTS_INSTALL_FILE = "test.operator.install-file";
5863

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+
5971
public enum OperatorDeployment {
6072
local, remote
6173
}
@@ -123,46 +135,46 @@ public void beforeEach(TestInfo testInfo) {
123135
}
124136

125137
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(() -> {
127139
assertThat(client.apps().deployments()
128140
.withName(primary.getMetadata().getName() + "-" + component + "-deployment").get()
129141
.getStatus().getReadyReplicas()).isEqualTo(replicas);
130142
});
131143
}
132144

133145
protected static void checkDeploymentDoesNotExist(ApicurioRegistry3 primary, String component) {
134-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
146+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
135147
assertThat(client.apps().deployments()
136148
.withName(primary.getMetadata().getName() + "-" + component + "-deployment").get())
137149
.isNull();
138150
});
139151
}
140152

141153
protected static void checkServiceExists(ApicurioRegistry3 primary, String component) {
142-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
154+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
143155
assertThat(client.services()
144156
.withName(primary.getMetadata().getName() + "-" + component + "-service").get())
145157
.isNotNull();
146158
});
147159
}
148160

149161
protected static void checkServiceDoesNotExist(ApicurioRegistry3 primary, String component) {
150-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
162+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
151163
assertThat(client.services()
152164
.withName(primary.getMetadata().getName() + "-" + component + "-service").get()).isNull();
153165
});
154166
}
155167

156168
protected static void checkIngressExists(ApicurioRegistry3 primary, String component) {
157-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
169+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
158170
assertThat(client.network().v1().ingresses()
159171
.withName(primary.getMetadata().getName() + "-" + component + "-ingress").get())
160172
.isNotNull();
161173
});
162174
}
163175

164176
protected static void checkIngressDoesNotExist(ApicurioRegistry3 primary, String component) {
165-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
177+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
166178
assertThat(client.network().v1().ingresses()
167179
.withName(primary.getMetadata().getName() + "-" + component + "-ingress").get()).isNull();
168180
});
@@ -172,7 +184,7 @@ protected static PodDisruptionBudget checkPodDisruptionBudgetExists(ApicurioRegi
172184
String component) {
173185
final ValueOrNull<PodDisruptionBudget> rval = new ValueOrNull<>();
174186

175-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
187+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
176188
PodDisruptionBudget pdb = client.policy().v1().podDisruptionBudget()
177189
.withName(primary.getMetadata().getName() + "-" + component + "-poddisruptionbudget")
178190
.get();
@@ -186,7 +198,7 @@ protected static PodDisruptionBudget checkPodDisruptionBudgetExists(ApicurioRegi
186198
protected static NetworkPolicy checkNetworkPolicyExists(ApicurioRegistry3 primary, String component) {
187199
final ValueOrNull<NetworkPolicy> rval = new ValueOrNull<>();
188200

189-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
201+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
190202
NetworkPolicy networkPolicy = client.network().v1().networkPolicies()
191203
.withName(primary.getMetadata().getName() + "-" + component + "-networkpolicy").get();
192204
assertThat(networkPolicy).isNotNull();
@@ -225,7 +237,7 @@ private static void createTestResources() throws Exception {
225237

226238
private static void startOperatorLogs() {
227239
List<Pod> operatorPods = new ArrayList<>();
228-
await().atMost(Duration.ofSeconds(30)).ignoreExceptions().untilAsserted(() -> {
240+
await().atMost(SHORT_DURATION).ignoreExceptions().untilAsserted(() -> {
229241
operatorPods.clear();
230242
operatorPods.addAll(client.pods()
231243
.withLabels(Map.of(
@@ -312,8 +324,8 @@ static String calculateNamespace() {
312324
}
313325

314326
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);
317329
}
318330

319331
static void createResources(List<HasMetadata> resources, String resourceType) {

0 commit comments

Comments
 (0)