Skip to content

Commit 6a21841

Browse files
authored
[ST] Update skodjob k8s test dependency + test fixes - timeouts (#2414)
* update skodjob * test utils update * javadoc --------- Signed-off-by: jkalinic <jkalinic@redhat.com>
1 parent d17bdd7 commit 6a21841

File tree

69 files changed

+644
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+644
-396
lines changed

systemtests/pom.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<!-- Playwright -->
2323
<playwright.version>1.58.0</playwright.version>
2424
<!-- Used for test-frame -->
25-
<test-frame.version>1.4.0</test-frame.version>
25+
<skodjob.kubetest4j.version>1.0.0</skodjob.kubetest4j.version>
2626
<!-- Allows skipping tests - unit, system or both types -->
2727
<skipTests>false</skipTests>
2828
<skipUTs>${skipTests}</skipUTs>
@@ -87,24 +87,24 @@
8787
</dependency>
8888
<!-- Test Frame used for handling k8s resources -->
8989
<dependency>
90-
<groupId>io.skodjob</groupId>
91-
<artifactId>test-frame-common</artifactId>
92-
<version>${test-frame.version}</version>
90+
<groupId>io.skodjob.kubetest4j</groupId>
91+
<artifactId>kubetest4j</artifactId>
92+
<version>${skodjob.kubetest4j.version}</version>
9393
</dependency>
9494
<dependency>
95-
<groupId>io.skodjob</groupId>
96-
<artifactId>test-frame-kubernetes</artifactId>
97-
<version>${test-frame.version}</version>
95+
<groupId>io.skodjob.kubetest4j</groupId>
96+
<artifactId>kubernetes-resources</artifactId>
97+
<version>${skodjob.kubetest4j.version}</version>
9898
</dependency>
9999
<dependency>
100-
<groupId>io.skodjob</groupId>
101-
<artifactId>test-frame-openshift</artifactId>
102-
<version>${test-frame.version}</version>
100+
<groupId>io.skodjob.kubetest4j</groupId>
101+
<artifactId>openshift-resources</artifactId>
102+
<version>${skodjob.kubetest4j.version}</version>
103103
</dependency>
104104
<dependency>
105-
<groupId>io.skodjob</groupId>
106-
<artifactId>test-frame-log-collector</artifactId>
107-
<version>${test-frame.version}</version>
105+
<groupId>io.skodjob.kubetest4j</groupId>
106+
<artifactId>log-collector</artifactId>
107+
<version>${skodjob.kubetest4j.version}</version>
108108
</dependency>
109109
<dependency>
110110
<groupId>io.fabric8</groupId>

systemtests/src/main/java/com/github/streamshub/systemtests/Environment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import com.github.streamshub.systemtests.exceptions.SetupException;
66
import com.github.streamshub.systemtests.utils.resourceutils.ClusterUtils;
77
import io.fabric8.kubernetes.api.model.Service;
8-
import io.skodjob.testframe.enums.InstallType;
9-
import io.skodjob.testframe.environment.TestEnvironmentVariables;
10-
import io.skodjob.testframe.resources.KubeResourceManager;
8+
import io.skodjob.kubetest4j.enums.InstallType;
9+
import io.skodjob.kubetest4j.environment.TestEnvironmentVariables;
10+
import io.skodjob.kubetest4j.resources.KubeResourceManager;
1111

1212
import java.io.IOException;
1313

14-
import static io.skodjob.testframe.TestFrameEnv.USER_PATH;
14+
import static io.skodjob.kubetest4j.KubeTestEnv.USER_PATH;
1515

1616
public class Environment {
1717
private static final TestEnvironmentVariables ENVS = new TestEnvironmentVariables();

systemtests/src/main/java/com/github/streamshub/systemtests/MessageStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import com.github.streamshub.systemtests.exceptions.SetupException;
66
import com.github.streamshub.systemtests.logs.LogWrapper;
7-
import io.skodjob.testframe.TestFrameEnv;
7+
import io.skodjob.kubetest4j.KubeTestEnv;
88
import org.apache.logging.log4j.Logger;
99

1010
import java.io.IOException;
@@ -33,7 +33,7 @@ public class MessageStore {
3333
private MessageStore() {}
3434

3535
private static JsonNode jsonResources;
36-
private static final Path MESSAGES_PATH = Path.of(TestFrameEnv.USER_PATH + "/../ui/messages/en.json");
36+
private static final Path MESSAGES_PATH = Path.of(KubeTestEnv.USER_PATH + "/../ui/messages/en.json");
3737

3838
static {
3939
try {

systemtests/src/main/java/com/github/streamshub/systemtests/TestCaseConfig.java

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.streamshub.systemtests;
22

33
import com.github.streamshub.systemtests.constants.Constants;
4+
import com.github.streamshub.systemtests.logs.LogWrapper;
45
import com.github.streamshub.systemtests.utils.Utils;
56
import com.github.streamshub.systemtests.utils.playwright.PwUtils;
67
import com.github.streamshub.systemtests.utils.resourceutils.kafka.KafkaNamingUtils;
@@ -12,19 +13,23 @@
1213
import com.microsoft.playwright.Tracing;
1314
import com.microsoft.playwright.options.ColorScheme;
1415
import com.microsoft.playwright.options.ViewportSize;
16+
import org.apache.logging.log4j.Logger;
1517
import org.junit.jupiter.api.extension.ExtensionContext;
1618

1719
import java.lang.reflect.Method;
1820
import java.util.Locale;
1921

2022
public class TestCaseConfig {
23+
24+
private static final Logger LOGGER = LogWrapper.getLogger(TestCaseConfig.class);
25+
2126
private static final ViewportSize FULL_HD = new ViewportSize(1920, 1080);
2227
private final String testName;
2328
private final String namespace;
24-
private final Playwright playwright;
25-
private final BrowserContext context;
26-
private final Browser browser;
27-
private final Page page;
29+
private Playwright playwright;
30+
private BrowserContext context;
31+
private Browser browser;
32+
private Page page;
2833
private final int defaultMessageCount;
2934

3035
// Default Kafka
@@ -53,19 +58,7 @@ public TestCaseConfig(ExtensionContext extensionContext) {
5358
.map(name -> name.toLowerCase(Locale.ENGLISH) + "-" + Utils.hashStub(testName))
5459
.orElse("nullClass");
5560

56-
this.playwright = Playwright.create();
57-
58-
// to keep browser context open it must exist within the TestCaseConfig context - can't be a local var
59-
browser = PwUtils.createBrowser(playwright);
60-
this.context = browser.newContext(new Browser.NewContextOptions()
61-
.setColorScheme(ColorScheme.DARK)
62-
.setViewportSize(FULL_HD)
63-
.setIgnoreHTTPSErrors(true));
64-
65-
// Allow tracing
66-
this.context.tracing().start(new Tracing.StartOptions().setScreenshots(true).setSnapshots(true).setSources(true));
67-
68-
this.page = context.newPage();
61+
this.initPlaywright();
6962

7063
this.kafkaName = KafkaNamingUtils.kafkaClusterName(namespace);
7164
this.connectName = KafkaNamingUtils.kafkaConnectName(namespace);
@@ -83,6 +76,38 @@ public TestCaseConfig(ExtensionContext extensionContext) {
8376
this.apicurioRegistry3Name = Constants.APICURIO_PREFIX + "-" + Utils.hashStub(namespace);
8477
}
8578

79+
private void initPlaywright() {
80+
this.playwright = Playwright.create();
81+
// to keep browser context open it must exist within the TestCaseConfig context - can't be a local var
82+
this.browser = PwUtils.createBrowser(playwright);
83+
84+
this.context = browser.newContext(new Browser.NewContextOptions()
85+
.setColorScheme(ColorScheme.DARK)
86+
.setViewportSize(FULL_HD)
87+
.setIgnoreHTTPSErrors(true));
88+
89+
// Allow tracing
90+
this.context.tracing().start(new Tracing.StartOptions()
91+
.setScreenshots(true)
92+
.setSnapshots(true)
93+
.setSources(true));
94+
95+
this.page = context.newPage();
96+
}
97+
98+
public void resetBrowserContext() {
99+
try {
100+
PwUtils.saveTracing(this.context);
101+
// closes the context and its page(s), browser stays alive
102+
this.context.close();
103+
this.browser.close();
104+
this.playwright.close();
105+
} catch (Exception ignored) {
106+
LOGGER.error("Cannot reset context");
107+
}
108+
initPlaywright();
109+
}
110+
86111
// ----------
87112
// Getters
88113
// ----------

systemtests/src/main/java/com/github/streamshub/systemtests/TestExecutionWatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.github.streamshub.systemtests.logs.LogWrapper;
55
import com.github.streamshub.systemtests.logs.TestLogCollector;
66
import com.github.streamshub.systemtests.utils.playwright.PwUtils;
7-
import io.skodjob.testframe.resources.KubeResourceManager;
7+
import io.skodjob.kubetest4j.resources.KubeResourceManager;
88
import org.apache.logging.log4j.Logger;
99
import org.junit.jupiter.api.extension.ExtensionContext;
1010
import org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler;

systemtests/src/main/java/com/github/streamshub/systemtests/constants/Constants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ private Constants() {}
1313
// --------------------------------
1414
// ------------ General -----------
1515
// --------------------------------
16-
public static final int MAX_ACTION_RETRIES = 10;
16+
public static final int DEFAULT_ACTION_RETRIES = 8;
1717
public static final int LOGOUT_RETRIES = 5;
18+
public static final int SELECTOR_RETRIES = 10;
1819

1920
/**
2021
* Commands
@@ -30,7 +31,6 @@ private Constants() {}
3031
/**
3132
* Test values
3233
*/
33-
public static final int SELECTOR_RETRIES = 10;
3434
public static final String VALUE_ATTRIBUTE = "value";
3535
public static final String CHECKED_ATTRIBUTE = "checked";
3636
public static final int DEFAULT_TOPICS_PER_PAGE = 20;

systemtests/src/main/java/com/github/streamshub/systemtests/constants/ResourceConditions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.github.streamshub.systemtests.enums.ConditionStatus;
44
import com.github.streamshub.systemtests.enums.ResourceStatus;
55
import io.fabric8.kubernetes.client.CustomResource;
6-
import io.skodjob.testframe.resources.ResourceCondition;
6+
import io.skodjob.kubetest4j.resources.ResourceCondition;
77
import io.strimzi.api.kafka.model.common.Spec;
88
import io.strimzi.api.kafka.model.kafka.Status;
99

systemtests/src/main/java/com/github/streamshub/systemtests/constants/TimeConstants.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.streamshub.systemtests.constants;
22

3-
import io.skodjob.testframe.TestFrameConstants;
3+
import io.skodjob.kubetest4j.KubeTestConstants;
44

55
import java.time.Duration;
66

@@ -26,9 +26,12 @@ private static long secondsInMilis(int seconds) {
2626
// HTML elements
2727
public static final long ELEMENT_VISIBILITY_TIMEOUT = minutesInMilis(1);
2828
public static final long UI_COMPONENT_REACTION_INTERVAL_SHORT = secondsInMilis(5);
29+
public static final long ACTION_WAIT_LONG = minutesInMilis(1);
30+
public static final long ACTION_WAIT_MEDIUM = secondsInMilis(20);
31+
public static final long ACTION_WAIT_SHORT = secondsInMilis(10);
2932

3033
// Time values depending on variable
3134
public static long timeoutForClientFinishJob(int messagesCount) {
32-
return messagesCount * (TestFrameConstants.POLL_INTERVAL_FOR_RESOURCE_READINESS + TestFrameConstants.GLOBAL_TIMEOUT_MEDIUM);
35+
return messagesCount * (KubeTestConstants.POLL_INTERVAL_FOR_RESOURCE_READINESS + KubeTestConstants.GLOBAL_TIMEOUT_MEDIUM);
3336
}
3437
}

systemtests/src/main/java/com/github/streamshub/systemtests/exceptions/ClusterUnreachableException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.streamshub.systemtests.exceptions;
22

3-
import io.skodjob.testframe.clients.KubeClusterException;
4-
import io.skodjob.testframe.executor.ExecResult;
3+
import io.skodjob.kubetest4j.clients.KubeClusterException;
4+
import io.skodjob.kubetest4j.executor.ExecResult;
55

66
public class ClusterUnreachableException extends KubeClusterException {
77
public ClusterUnreachableException(ExecResult result) {

systemtests/src/main/java/com/github/streamshub/systemtests/interfaces/TestBucketExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.github.streamshub.systemtests.annotations.TestBucket;
66
import com.github.streamshub.systemtests.exceptions.SetupException;
77
import com.github.streamshub.systemtests.logs.LogWrapper;
8-
import io.skodjob.testframe.resources.KubeResourceManager;
8+
import io.skodjob.kubetest4j.resources.KubeResourceManager;
99
import org.apache.logging.log4j.Logger;
1010
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
1111
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;

0 commit comments

Comments
 (0)