Skip to content

Commit c60672e

Browse files
jshum2479rjeberhard
authored andcommitted
fix unit test
1 parent 81bb1c1 commit c60672e

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

operator/src/test/java/oracle/kubernetes/operator/helpers/DomainIntrospectorJobTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
import static oracle.kubernetes.operator.helpers.StepContextConstants.OPSS_WALLETFILE_VOLUME;
138138
import static oracle.kubernetes.operator.helpers.StepContextConstants.SECRETS_VOLUME;
139139
import static oracle.kubernetes.operator.helpers.StepContextConstants.WDTCONFIGMAP_MOUNT_PATH;
140+
import static oracle.kubernetes.operator.helpers.StepContextConstants.WDT_MODEL_ENCRYPTION_PASSPHRASE_MOUNT_PATH;
141+
import static oracle.kubernetes.operator.helpers.StepContextConstants.WDT_MODEL_ENCRYPTION_PASSPHRASE_VOLUME;
140142
import static oracle.kubernetes.operator.tuning.TuningParameters.DOMAIN_PRESENCE_RECHECK_INTERVAL_SECONDS;
141143
import static oracle.kubernetes.weblogic.domain.model.AuxiliaryImage.AUXILIARY_IMAGE_DEFAULT_SOURCE_WDT_INSTALL_HOME;
142144
import static oracle.kubernetes.weblogic.domain.model.AuxiliaryImage.AUXILIARY_IMAGE_INTERNAL_VOLUME_NAME;
@@ -497,6 +499,24 @@ void whenJobCreatedWithInitializeDomainOnPVDefined_hasSecretsVolumeAndMounts() {
497499
.mountPath(OPSS_KEY_MOUNT_PATH).readOnly(true)));
498500
}
499501

502+
@Test
503+
void whenJobCreatedWithInitDomainOnPVWithModelEncryption_hasSecretsVolumeAndMounts() {
504+
getConfigurator().withInitializeDomainOnPVModelEncryptionSecret("encryptedSecret");
505+
testSupport.defineResources(createSecret("encryptedSecret"));
506+
507+
List<V1Job> jobs = runStepsAndGetJobs();
508+
V1Job job = jobs.get(0);
509+
510+
assertThat(getJobPodSpec(job).getVolumes(),
511+
hasItem(new V1Volume().name(WDT_MODEL_ENCRYPTION_PASSPHRASE_VOLUME).secret(
512+
new V1SecretVolumeSource().secretName("encryptedSecret").optional(true).defaultMode(420))));
513+
assertThat(getCreatedPodSpecContainers(jobs).get(0).getVolumeMounts(),
514+
hasItem(new V1VolumeMount().name(WDT_MODEL_ENCRYPTION_PASSPHRASE_VOLUME)
515+
.mountPath(WDT_MODEL_ENCRYPTION_PASSPHRASE_MOUNT_PATH).readOnly(true)));
516+
517+
}
518+
519+
500520
private V1Secret createSecret(String name) {
501521
return new V1Secret().metadata(new V1ObjectMeta().name(name).namespace(NS));
502522
}

operator/src/test/java/oracle/kubernetes/weblogic/domain/DomainConfigurator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,5 +725,14 @@ public abstract DomainConfigurator withConfigurationForInitializeDomainOnPV(
725725
*/
726726
public abstract DomainConfigurator withDomainCreationConfigMap(String cm);
727727

728+
/**
729+
* Add model encryption secret for the domain resource's initializeDomainOnPV.
730+
*
731+
* @param secret the model encryption file secret
732+
* @return this object
733+
*/
734+
public abstract DomainConfigurator withInitializeDomainOnPVModelEncryptionSecret(String secret);
735+
736+
728737
public abstract DomainConfigurator withModel(Model model);
729738
}

operator/src/test/java/oracle/kubernetes/weblogic/domain/model/DomainCommonConfigurator.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,12 @@ public DomainConfigurator withInitializeDomainOnPVOpssWalletFileSecret(String se
476476
return this;
477477
}
478478

479+
@Override
480+
public DomainConfigurator withInitializeDomainOnPVModelEncryptionSecret(String secret) {
481+
getOrCreateInitializeDomainOnPVModelSecret(secret);
482+
return this;
483+
}
484+
479485
@Override
480486
public DomainConfigurator withInitializeDomainOnPVType(String type) {
481487
getOrCreateInitializeDomainOnPVDomain().domainType(type);
@@ -570,6 +576,13 @@ private Opss getOrCreateInitializeDomainOnPVOpss() {
570576
return domain.getOpss();
571577
}
572578

579+
private void getOrCreateInitializeDomainOnPVModelSecret(String secretName) {
580+
InitializeDomainOnPV initializeDomainOnPV = getOrCreateInitializeDomainOnPV();
581+
if (initializeDomainOnPV.getWdtModelEncryptionPassphraseSecret() == null) {
582+
initializeDomainOnPV.wdtModelEncryptionPassphraseSecret(secretName);
583+
}
584+
}
585+
573586
@Override
574587
public void setShuttingDown(boolean shuttingDown) {
575588
configureAdminServer().withServerStartPolicy(shuttingDown ? ServerStartPolicy.NEVER : ServerStartPolicy.ALWAYS);

0 commit comments

Comments
 (0)