Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public void setRuntimeEncryptionSecret(String runtimeEncryptionSecret) {
this.runtimeEncryptionSecret = runtimeEncryptionSecret;
}

String getModelHome() {
public String getModelHome() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see anything in this PR that requires these visibility options to change. Why did you promote these methods to public?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was debugging the wdt logs folder creation issue I noticed that dumping the domain cr didn't print the modelHome configuration and found these methods without public identifier. After changing the access modifiers I was able to see it in the debug logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other get/set methods that need to be similarly adjusted? How were you doing the dump?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.info(Yaml.dump(domainCR));

I didn't see any other method that needs change.

return modelHome;
}

void setModelHome(String modelHome) {
public void setModelHome(String modelHome) {
this.modelHome = modelHome;
}

Expand All @@ -99,11 +99,11 @@ public Model withModelHome(String modelHome) {
return this;
}

String getWdtInstallHome() {
public String getWdtInstallHome() {
return wdtInstallHome;
}

void setWdtInstallHome(String wdtInstallHome) {
public void setWdtInstallHome(String wdtInstallHome) {
this.wdtInstallHome = wdtInstallHome;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
* Tests related to overrideDistributionStrategy attribute.
Expand Down Expand Up @@ -555,8 +556,18 @@ void testOnRestartOverride() {
Path dstDsOverrideFile = Paths.get(WORK_DIR, "jdbc-JdbcTestDataSource-1.xml");
String tempString = assertDoesNotThrow(()
-> Files.readString(srcDsOverrideFile).replaceAll("JDBC_URL", dsUrl2));
assertDoesNotThrow(()
-> Files.write(dstDsOverrideFile, tempString.getBytes(StandardCharsets.UTF_8)));
logger.info("Before override \n{0}", tempString);
if (WEBLOGIC_IMAGE_TO_USE_IN_SPEC.contains("12.2.1.3")) {
logger.info("Using 12.2.1.3 image, driver is com.mysql.jdbc.Driver");
tempString = tempString.replaceAll("com.mysql.cj.jdbc.Driver", "com.mysql.jdbc.Driver");
}
logger.info("After override \n{0}", tempString);
try {
Files.write(dstDsOverrideFile, tempString.getBytes(StandardCharsets.UTF_8));
} catch (IOException ioe) {
logger.severe(ioe.getMessage());
fail("Couldn't write override file");
}

List<Path> overrideFiles = new ArrayList<>();
overrideFiles.add(dstDsOverrideFile);
Expand Down Expand Up @@ -1076,7 +1087,13 @@ private void createJdbcDataSource(String dsName, String user, String password,
p.setProperty("admin_password", ADMIN_PASSWORD_DEFAULT);
p.setProperty("dsName", dsName);
p.setProperty("dsUrl", jdbcDsUrl);
p.setProperty("dsDriver", "com.mysql.cj.jdbc.Driver");
if (WEBLOGIC_IMAGE_TO_USE_IN_SPEC.contains("12.2.1.3")) {
logger.info("Using 12.2.1.3 image, driver is com.mysql.jdbc.Driver");
p.setProperty("dsDriver", "com.mysql.jdbc.Driver");
} else {
logger.info("Using 12.2.1.4 and later image, driver is com.mysql.cj.jdbc.Driver");
p.setProperty("dsDriver", "com.mysql.cj.jdbc.Driver");
}
p.setProperty("dsUser", user);
p.setProperty("dsPassword", password);
p.setProperty("dsTarget", clusterName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static oracle.weblogic.kubernetes.TestConstants.MII_DYNAMIC_UPDATE_EXPECTED_ERROR_MSG;
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_VERSION;
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR;
import static oracle.weblogic.kubernetes.actions.TestActions.getDomainCustomResource;
Expand Down Expand Up @@ -260,7 +259,7 @@ void testOperatorLogIntrospectorMsg() {
logger.info("operator pod log: {0}", operatorPodLog);
assertTrue(operatorPodLog.contains("Introspector Job Log"));
if (!WEBLOGIC_SLIM) {
assertTrue(operatorPodLog.contains("WebLogic version='" + WEBLOGIC_VERSION + "'"));
assertTrue(operatorPodLog.contains("Version check passed"));
}
assertTrue(operatorPodLog.contains("Job " + domainUid + "-introspector has failed"));
assertTrue(operatorPodLog.contains(MII_DYNAMIC_UPDATE_EXPECTED_ERROR_MSG));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.models.V1ObjectReference;
Expand All @@ -20,6 +21,7 @@
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.listServiceAccounts;
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.readSecretByReference;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

public class Secret {

Expand Down Expand Up @@ -110,34 +112,38 @@ public static String getSecretOfServiceAccount(String namespace, String serviceA
* @return the encoded token of the secret
*/
public static String getSecretEncodedToken(String namespace, String secretName) {
LoggingFacade logger = getLogger();
for (int i = 0; i < 10; i++) {
String token = getToken(namespace, secretName);
if (token != null) {
logger.info("Got the token {0}", token);
return token;
}
logger.info("Token is null, retrying after 5 seconds");
assertDoesNotThrow(() -> TimeUnit.SECONDS.sleep(5));
}
logger.warning("Secret token is null");
return null;
}

private static String getToken(String namespace, String secretName) {
String token = null;
List<V1Secret> v1Secrets = new ArrayList<>();

V1SecretList secretList = listSecrets(namespace);
if (secretList != null) {
v1Secrets = secretList.getItems();
}

for (V1Secret v1Secret : v1Secrets) {
if (v1Secret.getMetadata() != null && v1Secret.getMetadata().getName() != null) {
if (v1Secret.getMetadata().getName().equals(secretName)) {
if (v1Secret.getData() != null) {
if (v1Secret.getData() != null && v1Secret.getData().get("token") != null) {
byte[] encodedToken = v1Secret.getData().get("token");
getLogger().info(new String(encodedToken));
Base64.Encoder encoder = Base64.getEncoder();
if (encoder != null) {
String encodeToString = encoder.encodeToString(encodedToken);
getLogger().info(encodeToString);
} else {
getLogger().info("encoder is null");
}
return Base64.getEncoder().encodeToString(encodedToken);
token = Base64.getEncoder().encodeToString(encodedToken);
}
}
}
}

return "";
return token;
}

/**
Expand Down