-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add execution listeners and ability to connect to kube based on token (…
…#10)
- Loading branch information
Showing
11 changed files
with
177 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,35 @@ | |
<artifactId>odh-e2e</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<name>OpenDataHub e2e</name> | ||
<url>https://github.com/ExcelentProject/odh-e2e</url> | ||
<description>Test suite for testing opendatahub</description> | ||
|
||
<licenses> | ||
<license> | ||
<name>Apache License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<id>kornys</id> | ||
<name>David Kornel</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
<developer> | ||
<id>Frawless</id> | ||
<name>Jakub Stejskal</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<url>https://github.com/ExcelentProject/odh-e2e</url> | ||
</scm> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Tealc authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.odh.test; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Class which holds environment variables for system tests. | ||
*/ | ||
public class Environment { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(Environment.class); | ||
private static final Map<String, String> VALUES = new HashMap<>(); | ||
|
||
private static final String USERNAME_ENV = "KUBE_USERNAME"; | ||
private static final String PASSWORD_ENV = "KUBE_PASSWORD"; | ||
private static final String TOKEN_ENV = "KUBE_TOKEN"; | ||
private static final String URL_ENV = "KUBE_URL"; | ||
|
||
/** | ||
* Set values | ||
*/ | ||
public static final String RUN_USER = getOrDefault("USER", null); | ||
public static final String KUBE_USERNAME = getOrDefault(USERNAME_ENV, null); | ||
public static final String KUBE_PASSWORD = getOrDefault(PASSWORD_ENV, null); | ||
public static final String KUBE_TOKEN = getOrDefault(TOKEN_ENV, null); | ||
public static final String KUBE_URL = getOrDefault(URL_ENV, null); | ||
|
||
private Environment() { } | ||
|
||
static { | ||
String debugFormat = "{}: {}"; | ||
LOGGER.info("Used environment variables:"); | ||
VALUES.entrySet().stream() | ||
.sorted(Map.Entry.comparingByKey()) | ||
.forEach(entry -> LOGGER.info(debugFormat, entry.getKey(), entry.getValue())); | ||
} | ||
|
||
public static void print() { } | ||
|
||
private static String getOrDefault(String varName, String defaultValue) { | ||
return getOrDefault(varName, String::toString, defaultValue); | ||
} | ||
|
||
private static <T> T getOrDefault(String var, Function<String, T> converter, T defaultValue) { | ||
String value = System.getenv(var); | ||
T returnValue = defaultValue; | ||
if (value != null) { | ||
returnValue = converter.apply(value); | ||
} | ||
VALUES.put(var, String.valueOf(returnValue)); | ||
return returnValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/io/odh/test/framework/ExecutionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Tealc authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.odh.test.framework; | ||
|
||
import io.odh.test.Environment; | ||
import org.junit.platform.launcher.TestExecutionListener; | ||
import org.junit.platform.launcher.TestPlan; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class ExecutionListener implements TestExecutionListener { | ||
Logger LOGGER = LoggerFactory.getLogger(TestSeparator.class); | ||
|
||
public void testPlanExecutionStarted(TestPlan testPlan) { | ||
LOGGER.info("======================================================================="); | ||
LOGGER.info("======================================================================="); | ||
LOGGER.info(" Test run started"); | ||
LOGGER.info("======================================================================="); | ||
LOGGER.info("======================================================================="); | ||
Environment.print(); | ||
} | ||
|
||
public void testPlanExecutionFinished(TestPlan testPlan) { | ||
LOGGER.info("======================================================================="); | ||
LOGGER.info("======================================================================="); | ||
LOGGER.info(" Test run finished"); | ||
LOGGER.info("======================================================================="); | ||
LOGGER.info("======================================================================="); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/test/java/io/odh/test/e2e/deployed/DataScienceClusterIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.odh.test.framework.ExecutionListener |