Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better logging of env vars and odh constants #59

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target/
!**/src/main/**/target/
!**/src/test/**/target/
src/main/resources/install-files
pom.xml.versionsBackup*

### IntelliJ IDEA ###
.idea/
Expand Down
243 changes: 0 additions & 243 deletions pom.xml.versionsBackup

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/io/odh/test/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private Environment() {

static {
String debugFormat = "{}: {}";
LoggerUtils.logSeparator("-", 30);
LOGGER.info("Used environment variables:");
VALUES.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
Expand All @@ -107,6 +108,7 @@ private Environment() {
LOGGER.info(debugFormat, entry.getKey(), entry.getValue());
}
});
LoggerUtils.logSeparator("-", 30);
}

public static void print() {
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/io/odh/test/LoggerUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Skodjob 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.Collections;

public class LoggerUtils {

private static final Logger LOGGER = LoggerFactory.getLogger(LoggerUtils.class);
static final String SEPARATOR_CHAR = "#";

public static void logSeparator() {
logSeparator(SEPARATOR_CHAR, 76);
}

public static void logSeparator(String delimiterChar, int length) {
LOGGER.info(String.join("", Collections.nCopies(length, delimiterChar)));
}
}
2 changes: 2 additions & 0 deletions src/main/java/io/odh/test/OdhConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private static <T> T getOdhOrRhoai(String var, T odhValue, T rhoaiValue) {

static {
String debugFormat = "{}: {}";
LoggerUtils.logSeparator("-", 30);
LOGGER.info("Used OdhConstants:");
VALUES.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
Expand All @@ -93,5 +94,6 @@ private static <T> T getOdhOrRhoai(String var, T odhValue, T rhoaiValue) {
LOGGER.info(debugFormat, entry.getKey(), entry.getValue());
}
});
LoggerUtils.logSeparator("-", 30);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@
package io.odh.test.framework.listeners;

import io.odh.test.framework.ExtensionContextParameterResolver;
import io.odh.test.LoggerUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;

@ExtendWith(ExtensionContextParameterResolver.class)
public interface TestVisualSeparator {
Logger LOGGER = LoggerFactory.getLogger(TestVisualSeparator.class);
String SEPARATOR_CHAR = "#";

@BeforeEach
default void beforeEachTest(ExtensionContext testContext) {
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
LoggerUtils.logSeparator();
LOGGER.info(String.format("%s.%s-STARTED", testContext.getRequiredTestClass().getName(),
testContext.getDisplayName().replace("()", "")));
}
Expand All @@ -30,6 +28,6 @@ default void beforeEachTest(ExtensionContext testContext) {
default void afterEachTest(ExtensionContext testContext) {
LOGGER.info(String.format("%s.%s-FINISHED", testContext.getRequiredTestClass().getName(),
testContext.getDisplayName().replace("()", "")));
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
LoggerUtils.logSeparator();
}
}
Loading