Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.nio.file.Paths;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -59,10 +58,11 @@
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_PATCH;
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_PATCH;
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET;
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_REGISTRY;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_WEBLOGIC_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.OKD;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
Expand Down Expand Up @@ -95,7 +95,6 @@
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapForDomainCreation;
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployUsingRest;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createSecretForBaseImages;
import static oracle.weblogic.kubernetes.utils.ImageUtils.dockerLoginAndPushImageToRegistry;
import static oracle.weblogic.kubernetes.utils.JobUtils.createDomainJob;
import static oracle.weblogic.kubernetes.utils.JobUtils.getIntrospectJobName;
Expand All @@ -114,6 +113,7 @@
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodsWithTimeStamps;
import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretsForImageRepos;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static oracle.weblogic.kubernetes.utils.WLSTUtils.executeWLSTScript;
import static org.apache.commons.io.FileUtils.copyDirectory;
Expand Down Expand Up @@ -204,10 +204,6 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
// install operator and verify its running in ready state
installAndVerifyOperator(opNamespace, introDomainNamespace);

// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
// this secret is used only for non-kind cluster
createSecretForBaseImages(introDomainNamespace);

// build the clusterview application
Path targetDir = Paths.get(WORK_DIR,
ItIntrospectVersion.class.getName() + "/clusterviewapp");
Expand Down Expand Up @@ -710,7 +706,7 @@ void testUpdateImageName() {
String imageTag = CommonTestUtils.getDateAndTimeStamp();
String imageUpdate = KIND_REPO != null ? KIND_REPO
+ (WEBLOGIC_IMAGE_NAME + ":" + imageTag).substring(TestConstants.BASE_IMAGES_REPO.length() + 1)
: WEBLOGIC_IMAGE_NAME + ":" + imageTag;
: OCIR_REGISTRY + "/" + OCIR_WEBLOGIC_IMAGE_NAME + ":" + imageTag;
dockerTag(imageName, imageUpdate);
dockerLoginAndPushImageToRegistry(imageUpdate);

Expand Down Expand Up @@ -1024,9 +1020,6 @@ private static void createDomain() {
.domainHomeSourceType("PersistentVolume") // set the domain home source type as pv
.image(WEBLOGIC_IMAGE_TO_USE_IN_SPEC)
.imagePullPolicy("IfNotPresent")
.imagePullSecrets(Arrays.asList(
new V1LocalObjectReference()
.name(BASE_IMAGES_REPO_SECRET))) // this secret is used only in non-kind cluster
.webLogicCredentialsSecret(new V1SecretReference()
.name(wlSecretName)
.namespace(introDomainNamespace))
Expand Down Expand Up @@ -1069,6 +1062,14 @@ private static void createDomain() {
.clusterName(cluster1Name)
.replicas(cluster1ReplicaCount)
.serverStartState("RUNNING")));

// create secrets
List<V1LocalObjectReference> secrets = new ArrayList<>();
for (String secret : createSecretsForImageRepos(introDomainNamespace)) {
secrets.add(new V1LocalObjectReference().name(secret));
}
domain.spec().setImagePullSecrets(secrets);

setPodAntiAffinity(domain);
// verify the domain custom resource is created
createDomainAndVerify(domain, introDomainNamespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_WDT_MODEL_FILE;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_REGISTRY;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_WEBLOGIC_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
import static oracle.weblogic.kubernetes.TestConstants.WDT_TEST_VERSION;
Expand Down Expand Up @@ -100,6 +101,7 @@
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodCreationTime;
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodsWithTimeStamps;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretsForImageRepos;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.awaitility.Awaitility.with;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down Expand Up @@ -134,6 +136,7 @@ class ItMiiAuxiliaryImage {
private String adminSvcExtHost = null;
private String adminSecretName = "weblogic-credentials";
private String encryptionSecretName = "encryptionsecret";
private static String[] imageSecrets;

ConditionFactory withStandardRetryPolicy
= with().pollDelay(0, SECONDS)
Expand Down Expand Up @@ -187,10 +190,6 @@ void testCreateDomainUsingMultipleAuxiliaryImages() {
final String auxiliaryImageVolumeName = "auxiliaryImageVolume1";
final String auxiliaryImagePath = "/auxiliary";

// Create the repo secret to pull the image
// this secret is used only for non-kind cluster
createOcirRepoSecret(domainNamespace);

// create secret for admin credentials
logger.info("Create secret for admin credentials");
String adminSecretName = "weblogic-credentials";
Expand Down Expand Up @@ -284,7 +283,7 @@ void testCreateDomainUsingMultipleAuxiliaryImages() {
logger.info("Creating domain custom resource with domainUid {0} and auxiliary images {1} {2}",
domainUid, miiAuxiliaryImage1, miiAuxiliaryImage2);
Domain domainCR = createDomainResource(domainUid, domainNamespace,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, OCIR_SECRET_NAME,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(domainNamespace),
encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath,
auxiliaryImageVolumeName, miiAuxiliaryImage1, miiAuxiliaryImage2);

Expand Down Expand Up @@ -407,7 +406,7 @@ void testUpdateBaseImageName() {
String imageTag = getDateAndTimeStamp();
String imageUpdate = KIND_REPO != null ? KIND_REPO
+ (WEBLOGIC_IMAGE_NAME + ":" + imageTag).substring(TestConstants.BASE_IMAGES_REPO.length() + 1)
: WEBLOGIC_IMAGE_NAME + ":" + imageTag;
: OCIR_REGISTRY + "/" + OCIR_WEBLOGIC_IMAGE_NAME + ":" + imageTag;
dockerTag(imageName, imageUpdate);
dockerLoginAndPushImageToRegistry(imageUpdate);

Expand Down Expand Up @@ -608,7 +607,7 @@ void testErrorPathDomainMismatchMountPath() {
logger.info("Creating domain custom resource with domainUid {0} and auxiliary image {1}",
domainUid, errorPathAuxiliaryImage1);
Domain domainCR = createDomainResource(domainUid, errorpathDomainNamespace,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, OCIR_SECRET_NAME,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(errorpathDomainNamespace),
encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath,
auxiliaryImageVolumeName, errorPathAuxiliaryImage1);

Expand Down Expand Up @@ -691,7 +690,7 @@ void testErrorPathDomainMissingWDTBinary() {
logger.info("Creating domain custom resource with domainUid {0} and auxiliary image {1}",
domainUid, errorPathAuxiliaryImage2);
Domain domainCR = createDomainResource(domainUid, errorpathDomainNamespace,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, OCIR_SECRET_NAME,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(errorpathDomainNamespace),
encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath,
auxiliaryImageVolumeName, errorPathAuxiliaryImage2);

Expand Down Expand Up @@ -781,7 +780,7 @@ void testErrorPathDomainMissingDomainConfig() {
logger.info("Creating domain custom resource with domainUid {0} and auxiliary image {1}",
domainUid, errorPathAuxiliaryImage3);
Domain domainCR = createDomainResource(domainUid, errorpathDomainNamespace,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, OCIR_SECRET_NAME,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(errorpathDomainNamespace),
encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath,
auxiliaryImageVolumeName, errorPathAuxiliaryImage3);

Expand Down Expand Up @@ -890,7 +889,7 @@ void testErrorPathFilePermission() {
logger.info("Creating domain custom resource with domainUid {0} and auxiliary image {1}",
domainUid, errorPathAuxiliaryImage4);
Domain domainCR = createDomainResource(domainUid, errorpathDomainNamespace,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, OCIR_SECRET_NAME,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(errorpathDomainNamespace),
encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath,
auxiliaryImageVolumeName, errorPathAuxiliaryImage4);

Expand Down Expand Up @@ -1056,7 +1055,7 @@ void testUpdateWDTVersionUsingMultipleAuxiliaryImages() {
logger.info("Creating domain custom resource with domainUid {0} and auxiliary images {1} {2}",
domainUid, miiAuxiliaryImage4, miiAuxiliaryImage5);
Domain domainCR = createDomainResource(domainUid, wdtDomainNamespace,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, OCIR_SECRET_NAME,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(wdtDomainNamespace),
encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath,
auxiliaryImageVolumeName, miiAuxiliaryImage4, miiAuxiliaryImage5);

Expand Down Expand Up @@ -1252,10 +1251,6 @@ private void createAuxiliaryImage(String stageDirPath, String dockerFileLocation
}

private void createSecretsForDomain(String adminSecretName, String encryptionSecretName, String domainNamespace) {
if (!secretExists(OCIR_SECRET_NAME, domainNamespace)) {
createOcirRepoSecret(domainNamespace);
}

// create secret for admin credentials
logger.info("Create secret for admin credentials");
if (!secretExists(adminSecretName, domainNamespace)) {
Expand All @@ -1270,6 +1265,7 @@ private void createSecretsForDomain(String adminSecretName, String encryptionSec
}
}


private void checkConfiguredJMSresouce(String domainNamespace, String adminServerPodName) {
int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
Expand Down Expand Up @@ -1353,5 +1349,4 @@ private void verifyIntrospectorPodLogContainsExpectedErrorMsg(String domainUid,
.until(() ->
introspectorPodLogContainsExpectedErrorMsg(domainUid, namespace, expectedErrorMsg));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_IMAGES_REPO;
import static oracle.weblogic.kubernetes.TestConstants.MII_AUXILIARY_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME;
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
Expand All @@ -54,6 +53,7 @@
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
import static oracle.weblogic.kubernetes.utils.PodUtils.getExternalServicePodName;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretsForImageRepos;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.awaitility.Awaitility.with;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down Expand Up @@ -190,7 +190,7 @@ void testCreateDomainUsingAuxiliaryImagesWClusterConfig() {
logger.info("Creating domain custom resource with domainUid {0} and auxiliary images {1} {2}",
domainUid, auxiliaryImageDomainScopeNames.toString(), auxiliaryImageClusterScopeNames.toString());
Domain domainCR = createDomainResourceWithAuxiliaryImageClusterScope(domainUid, domainNamespace,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, OCIR_SECRET_NAME,
WEBLOGIC_IMAGE_TO_USE_IN_SPEC, adminSecretName, createSecretsForImageRepos(domainNamespace),
encryptionSecretName, replicaCount, clusterName,
Map.of(auxiliaryImagePath, List.of(auxiliaryImageVolumeName)),
auxiliaryImageDomainScopeNames, auxiliaryImageClusterScopeNames);
Expand Down Expand Up @@ -362,7 +362,7 @@ void testPatchDomainToAddModelsToClusterConfigIgnored() {

private void createAuxiliaryImage(String stageDirPath, String dockerFileLocation, String auxiliaryImage) {
//replace the BUSYBOX_IMAGE and BUSYBOX_TAG in Dockerfile
Path dockerDestFile = Paths.get(WORK_DIR, "auximages", "Dockerfile");
Path dockerDestFile = Paths.get(WORK_DIR, "auximagescluster", "Dockerfile");
assertDoesNotThrow(() -> {
Files.createDirectories(dockerDestFile.getParent());
Files.copy(Paths.get(dockerFileLocation),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_PASSWORD;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_REGISTRY;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME;
import static oracle.weblogic.kubernetes.TestConstants.OCIR_USERNAME;
import static oracle.weblogic.kubernetes.TestConstants.OKD;
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
Expand Down Expand Up @@ -83,6 +82,7 @@
import static oracle.weblogic.kubernetes.utils.PodUtils.execInPod;
import static oracle.weblogic.kubernetes.utils.PodUtils.getExternalServicePodName;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretsForImageRepos;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -254,7 +254,8 @@ void testMiiDomainWithModelAndApplicationInPV(Entry<String, String> params) {
logger.info("Creating domain custom resource with domainUid {0} and image {1}",
domainUid, image);
Domain domainCR = CommonMiiTestUtils.createDomainResource(domainUid, domainNamespace,
image, adminSecretName, OCIR_SECRET_NAME, encryptionSecretName, replicaCount, clusterName);
image, adminSecretName, createSecretsForImageRepos(domainNamespace),
encryptionSecretName, replicaCount, clusterName);
domainCR.spec().configuration().model().withModelHome(modelMountPath + "/model");
domainCR.spec().serverPod()
.addVolumesItem(new V1Volume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static Domain createMiiDomainAndVerify(
domainNamespace,
imageName,
adminSecretName,
OCIR_SECRET_NAME,
new String[]{OCIR_SECRET_NAME},
encryptionSecretName,
replicaCount,
"cluster-1");
Expand Down Expand Up @@ -223,11 +223,16 @@ public static Domain createDomainResource(
String domNamespace,
String imageName,
String adminSecretName,
String repoSecretName,
String[] repoSecretName,
String encryptionSecretName,
int replicaCount,
String clusterName) {

// create secrets
List<V1LocalObjectReference> secrets = new ArrayList<>();
for (String secret : repoSecretName) {
secrets.add(new V1LocalObjectReference().name(secret));
}
// create the domain CR
Domain domain = new Domain()
.apiVersion(DOMAIN_API_VERSION)
Expand All @@ -239,8 +244,6 @@ public static Domain createDomainResource(
.domainUid(domainResourceName)
.domainHomeSourceType("FromModel")
.image(imageName)
.addImagePullSecretsItem(new io.kubernetes.client.openapi.models.V1LocalObjectReference()
.name(repoSecretName))
.webLogicCredentialsSecret(new io.kubernetes.client.openapi.models.V1SecretReference()
.name(adminSecretName)
.namespace(domNamespace))
Expand Down Expand Up @@ -268,6 +271,7 @@ public static Domain createDomainResource(
.domainType("WLS")
.runtimeEncryptionSecret(encryptionSecretName))
.introspectorJobActiveDeadlineSeconds(300L)));
domain.spec().setImagePullSecrets(secrets);

setPodAntiAffinity(domain);
return domain;
Expand Down Expand Up @@ -296,7 +300,7 @@ public static Domain createDomainResource(
String domNamespace,
String baseImageName,
String adminSecretName,
String repoSecretName,
String[] repoSecretName,
String encryptionSecretName,
int replicaCount,
String clusterName,
Expand Down Expand Up @@ -343,7 +347,7 @@ public static Domain createDomainResourceWithAuxiliaryImage(
String domNamespace,
String baseImageName,
String adminSecretName,
String repoSecretName,
String[] repoSecretName,
String encryptionSecretName,
int replicaCount,
String clusterName,
Expand Down Expand Up @@ -394,7 +398,7 @@ public static Domain createDomainResourceWithAuxiliaryImageClusterScope(
String domNamespace,
String baseImageName,
String adminSecretName,
String repoSecretName,
String[] repoSecretName,
String encryptionSecretName,
int replicaCount,
String clusterName,
Expand Down
Loading