Skip to content

Commit df88235

Browse files
authored
wip (#3658)
1 parent adcc6e3 commit df88235

File tree

4 files changed

+221
-12
lines changed

4 files changed

+221
-12
lines changed

integration-tests/src/test/java/oracle/weblogic/domain/Configuration.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class Configuration {
1919
@ApiModelProperty("Configuration for OPSS security.")
2020
private Opss opss;
2121

22+
@ApiModelProperty("Istio service mesh integration")
23+
private Istio istio;
24+
2225
@ApiModelProperty(
2326
"A list of names of the secrets for WebLogic configuration overrides or model.")
2427
private List<String> secrets;
@@ -167,6 +170,23 @@ public void setOverridesConfigMap(String overridesConfigMap) {
167170
this.overridesConfigMap = overridesConfigMap;
168171
}
169172

173+
public Configuration istio(Istio istio) {
174+
this.istio = istio;
175+
return this;
176+
}
177+
178+
public Istio istio() {
179+
return istio;
180+
}
181+
182+
public Istio getIstio() {
183+
return istio;
184+
}
185+
186+
public void setIstio(Istio istio) {
187+
this.istio = istio;
188+
}
189+
170190
public Configuration introspectorJobActiveDeadlineSeconds(
171191
Long introspectorJobActiveDeadlineSeconds) {
172192
this.introspectorJobActiveDeadlineSeconds = introspectorJobActiveDeadlineSeconds;

ItOpenshiftIstioMiiDomain.java renamed to integration-tests/src/test/java/oracle/weblogic/kubernetes/ItOpenshiftIstioMiiDomain.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
import io.kubernetes.client.openapi.models.V1EnvVar;
1515
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
1616
import io.kubernetes.client.openapi.models.V1ObjectMeta;
17-
import io.kubernetes.client.openapi.models.V1SecretReference;
1817
import io.kubernetes.client.util.Yaml;
19-
import oracle.weblogic.domain.Cluster;
2018
import oracle.weblogic.domain.Configuration;
21-
import oracle.weblogic.domain.Domain;
19+
import oracle.weblogic.domain.DomainResource;
2220
import oracle.weblogic.domain.DomainSpec;
2321
import oracle.weblogic.domain.Istio;
2422
import oracle.weblogic.domain.Model;
@@ -49,6 +47,7 @@
4947
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
5048
import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR;
5149
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppUsingHostHeader;
50+
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResourceAndAddReferenceToDomain;
5251
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
5352
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapAndVerify;
5453
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
@@ -194,7 +193,7 @@ void testIstioModelInImageDomain() {
194193
// create WDT config map without any files
195194
createConfigMapAndVerify(configMapName, domainUid, domainNamespace, Collections.emptyList());
196195
// create the domain object
197-
Domain domain = createDomainResource(domainUid,
196+
DomainResource domain = createDomainResource(domainUid,
198197
domainNamespace,
199198
adminSecretName,
200199
TEST_IMAGES_REPO_SECRET_NAME,
@@ -204,6 +203,9 @@ void testIstioModelInImageDomain() {
204203
configMapName);
205204
logger.info(Yaml.dump(domain));
206205

206+
domain = createClusterResourceAndAddReferenceToDomain(
207+
domainUid + "-" + clusterName, clusterName, domainNamespace, domain, replicaCount);
208+
207209
// create model in image domain
208210
createDomainAndVerify(domain, domainNamespace);
209211

@@ -270,13 +272,13 @@ void testIstioModelInImageDomain() {
270272
assertTrue(checkApp, "Failed to access WebLogic application");
271273
}
272274

273-
private Domain createDomainResource(String domainUid, String domNamespace,
275+
private DomainResource createDomainResource(String domainUid, String domNamespace,
274276
String adminSecretName, String repoSecretName,
275277
String encryptionSecretName, int replicaCount,
276278
String miiImage, String configmapName) {
277279

278280
// create the domain CR
279-
Domain domain = new Domain()
281+
DomainResource domain = new DomainResource()
280282
.apiVersion(DOMAIN_API_VERSION)
281283
.kind("Domain")
282284
.metadata(new V1ObjectMeta()
@@ -289,9 +291,8 @@ private Domain createDomainResource(String domainUid, String domNamespace,
289291
.imagePullPolicy("IfNotPresent")
290292
.addImagePullSecretsItem(new V1LocalObjectReference()
291293
.name(repoSecretName))
292-
.webLogicCredentialsSecret(new V1SecretReference()
293-
.name(adminSecretName)
294-
.namespace(domNamespace))
294+
.webLogicCredentialsSecret(new V1LocalObjectReference()
295+
.name(adminSecretName))
295296
.includeServerOutInPodLog(true)
296297
.serverStartPolicy("IF_NEEDED")
297298
.serverPod(new ServerPod()
@@ -303,9 +304,6 @@ private Domain createDomainResource(String domainUid, String domNamespace,
303304
.name("USER_MEM_ARGS")
304305
.value("-Djava.security.egd=file:/dev/./urandom ")))
305306
.adminServer(createAdminServer())
306-
.addClustersItem(new Cluster()
307-
.clusterName(clusterName)
308-
.replicas(replicaCount))
309307
.configuration(new Configuration()
310308
.istio(new Istio()
311309
.localhostBindingsEnabled(Boolean.FALSE))

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/OperatorParams.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class OperatorParams {
3232
private static final String DOMAIN_NS_LABEL_SELECTOR = "domainNamespaceLabelSelector";
3333
private static final String DOMAIN_NS_REG_EXP = "domainNamespaceRegExp";
3434
private static final String ENABLE_CLUSTER_ROLE_BINDING = "enableClusterRoleBinding";
35+
private static final String DOMAIN_PRESENCE_FAILURE_RETRY_MAX_COUNT = "domainPresenceFailureRetryMaxCount";
3536
private static final String FEATURE_GATES = "featureGates";
3637
private static final String KUBERNETES_PLATFORM = "kubernetesPlatform";
3738
private static final String CREATE_LOGSTASH_CONFIGMAP = "createLogStashConfigMap";
@@ -56,10 +57,13 @@ public class OperatorParams {
5657
private String domainNamespaceSelectionStrategy;
5758
private String domainNamespaceLabelSelector;
5859
private String domainNamespaceRegExp;
60+
private int domainPresenceFailureRetryMaxCount = 5;
61+
private int domainPresenceFailureRetrySeconds = 10;
5962
private String featureGates;
6063
private String kubernetesPlatform;
6164
private boolean createLogStashConfigMap = true;
6265
private boolean webhookOnly;
66+
private boolean openshiftIstioInjection;
6367

6468
public OperatorParams domainNamespaces(List<String> domainNamespaces) {
6569
this.domainNamespaces = domainNamespaces;
@@ -151,6 +155,21 @@ public OperatorParams logStashImage(String logStashImage) {
151155
return this;
152156
}
153157

158+
public OperatorParams domainPresenceFailureRetryMaxCount(int domainPresenceFailureRetryMaxCount) {
159+
this.domainPresenceFailureRetryMaxCount = domainPresenceFailureRetryMaxCount;
160+
return this;
161+
}
162+
163+
public OperatorParams domainPresenceFailureRetrySeconds(int domainPresenceFailureRetrySeconds) {
164+
this.domainPresenceFailureRetrySeconds = domainPresenceFailureRetrySeconds;
165+
return this;
166+
}
167+
168+
public OperatorParams openShiftIstioInjection(boolean openshiftIstioInjection) {
169+
this.openshiftIstioInjection = openshiftIstioInjection;
170+
return this;
171+
}
172+
154173
public OperatorParams featureGates(String featureGates) {
155174
this.featureGates = featureGates;
156175
return this;

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/OperatorUtils.java

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,177 @@ public static OperatorParams installAndVerifyOperator(String opReleaseName, Stri
547547
domainNamespaceSelectionStrategy, domainNamespaceSelector, enableClusterRoleBinding, domainNamespace);
548548
}
549549

550+
/**
551+
* Install WebLogic operator and wait up to five minutes until the operator pod is ready.
552+
*
553+
* @param opNamespace the operator namespace in which the operator will be installed
554+
* @param opServiceAccount the service account name for operator
555+
* @param withRestAPI whether to use REST API
556+
* @param externalRestHttpsPort the node port allocated for the external operator REST HTTPS interface
557+
* @param opHelmParams the Helm parameters to install operator
558+
* @param elkIntegrationEnabled true to enable ELK Stack, false otherwise
559+
* @param domainNamespaceSelectionStrategy SelectLabel, RegExp or List, value to tell the operator
560+
* how to select the set of namespaces that it will manage
561+
* @param domainNamespaceSelector the label or expression value to manage namespaces
562+
* @param enableClusterRoleBinding operator cluster role binding
563+
* @param loggingLevel logging level of operator
564+
* @param domainPresenceFailureRetryMaxCount the number of introspector job retries for a Domain
565+
* @param domainPresenceFailureRetrySeconds the interval in seconds between these retries
566+
* @param openshiftIstioInjection openshift istio enabled
567+
* @param domainNamespace the list of the domain namespaces which will be managed by the operator
568+
* @return the operator Helm installation parameters
569+
*/
570+
public static OperatorParams installAndVerifyOperator(String opNamespace,
571+
String opServiceAccount,
572+
boolean withRestAPI,
573+
int externalRestHttpsPort,
574+
HelmParams opHelmParams,
575+
boolean elkIntegrationEnabled,
576+
String domainNamespaceSelectionStrategy,
577+
String domainNamespaceSelector,
578+
boolean enableClusterRoleBinding,
579+
String loggingLevel,
580+
int domainPresenceFailureRetryMaxCount,
581+
int domainPresenceFailureRetrySeconds,
582+
boolean openshiftIstioInjection,
583+
String... domainNamespace) {
584+
LoggingFacade logger = getLogger();
585+
586+
// Create a service account for the unique opNamespace
587+
logger.info("Creating service account");
588+
assertDoesNotThrow(() -> createServiceAccount(new V1ServiceAccount()
589+
.metadata(new V1ObjectMeta()
590+
.namespace(opNamespace)
591+
.name(opServiceAccount))));
592+
logger.info("Created service account: {0}", opServiceAccount);
593+
594+
595+
// get operator image name
596+
String operatorImage = getOperatorImageName();
597+
assertFalse(operatorImage.isEmpty(), "operator image name can not be empty");
598+
logger.info("operator image name {0}", operatorImage);
599+
600+
// Create Docker registry secret in the operator namespace to pull the image from repository
601+
// this secret is used only for non-kind cluster
602+
logger.info("Creating Docker registry secret in namespace {0}", opNamespace);
603+
createTestRepoSecret(opNamespace);
604+
605+
// map with secret
606+
Map<String, Object> secretNameMap = new HashMap<>();
607+
secretNameMap.put("name", TEST_IMAGES_REPO_SECRET_NAME);
608+
609+
// operator chart values to override
610+
OperatorParams opParams = new OperatorParams()
611+
.helmParams(opHelmParams)
612+
.imagePullSecrets(secretNameMap)
613+
.domainNamespaces(Arrays.asList(domainNamespace))
614+
.javaLoggingLevel(loggingLevel)
615+
.serviceAccount(opServiceAccount);
616+
617+
if (domainNamespaceSelectionStrategy != null) {
618+
opParams.domainNamespaceSelectionStrategy(domainNamespaceSelectionStrategy);
619+
}
620+
621+
// use default image in chart when repoUrl is set, otherwise use latest/current branch operator image
622+
if (opHelmParams.getRepoUrl() == null) {
623+
opParams.image(operatorImage);
624+
}
625+
626+
// enable ELK Stack
627+
if (elkIntegrationEnabled) {
628+
opParams
629+
.elkIntegrationEnabled(elkIntegrationEnabled);
630+
opParams
631+
.elasticSearchHost(ELASTICSEARCH_HOST);
632+
opParams
633+
.elasticSearchPort(ELASTICSEARCH_HTTP_PORT);
634+
opParams
635+
.javaLoggingLevel(JAVA_LOGGING_LEVEL_VALUE);
636+
opParams
637+
.logStashImage(LOGSTASH_IMAGE);
638+
}
639+
640+
if (withRestAPI) {
641+
// create externalRestIdentitySecret
642+
assertTrue(createExternalRestIdentitySecret(opNamespace, DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME),
643+
"failed to create external REST identity secret");
644+
opParams
645+
.externalRestEnabled(true)
646+
.externalRestHttpsPort(externalRestHttpsPort)
647+
.externalRestIdentitySecret(DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME);
648+
}
649+
// operator chart values to override
650+
if (enableClusterRoleBinding) {
651+
opParams.enableClusterRoleBinding(enableClusterRoleBinding);
652+
}
653+
if (domainNamespaceSelectionStrategy != null) {
654+
opParams.domainNamespaceSelectionStrategy(domainNamespaceSelectionStrategy);
655+
if (domainNamespaceSelectionStrategy.equalsIgnoreCase("LabelSelector")) {
656+
opParams.domainNamespaceLabelSelector(domainNamespaceSelector);
657+
} else if (domainNamespaceSelectionStrategy.equalsIgnoreCase("RegExp")) {
658+
opParams.domainNamespaceRegExp(domainNamespaceSelector);
659+
}
660+
}
661+
662+
// domainPresenceFailureRetryMaxCount and domainPresenceFailureRetrySeconds
663+
if (domainPresenceFailureRetryMaxCount >= 0) {
664+
opParams.domainPresenceFailureRetryMaxCount(domainPresenceFailureRetryMaxCount);
665+
}
666+
if (domainPresenceFailureRetrySeconds > 0) {
667+
opParams.domainPresenceFailureRetrySeconds(domainPresenceFailureRetrySeconds);
668+
}
669+
670+
// If running on OKD cluster, we need to specify the target
671+
if (OKD) {
672+
opParams.kubernetesPlatform("OpenShift");
673+
}
674+
675+
if (openshiftIstioInjection) {
676+
opParams.openShiftIstioInjection(openshiftIstioInjection);
677+
}
678+
679+
// install operator
680+
logger.info("Installing operator in namespace {0}", opNamespace);
681+
assertTrue(installOperator(opParams),
682+
String.format("Failed to install operator in namespace %s", opNamespace));
683+
logger.info("Operator installed in namespace {0}", opNamespace);
684+
685+
// list Helm releases matching operator release name in operator namespace
686+
logger.info("Checking operator release {0} status in namespace {1}",
687+
OPERATOR_RELEASE_NAME, opNamespace);
688+
assertTrue(isHelmReleaseDeployed(OPERATOR_RELEASE_NAME, opNamespace),
689+
String.format("Operator release %s is not in deployed status in namespace %s",
690+
OPERATOR_RELEASE_NAME, opNamespace));
691+
logger.info("Operator release {0} status is deployed in namespace {1}",
692+
OPERATOR_RELEASE_NAME, opNamespace);
693+
694+
// wait for the operator to be ready
695+
logger.info("Wait for the operator pod is ready in namespace {0}", opNamespace);
696+
CommonTestUtils.withStandardRetryPolicy
697+
.conditionEvaluationListener(
698+
condition -> logger.info("Waiting for operator to be running in namespace {0} "
699+
+ "(elapsed time {1}ms, remaining time {2}ms)",
700+
opNamespace,
701+
condition.getElapsedTimeInMS(),
702+
condition.getRemainingTimeInMS()))
703+
.until(assertDoesNotThrow(() -> operatorIsReady(opNamespace),
704+
"operatorIsReady failed with ApiException"));
705+
706+
if (withRestAPI) {
707+
logger.info("Wait for the operator external service in namespace {0}", opNamespace);
708+
CommonTestUtils.withStandardRetryPolicy
709+
.conditionEvaluationListener(
710+
condition -> logger.info("Waiting for operator external service in namespace {0} "
711+
+ "(elapsed time {1}ms, remaining time {2}ms)",
712+
opNamespace,
713+
condition.getElapsedTimeInMS(),
714+
condition.getRemainingTimeInMS()))
715+
.until(assertDoesNotThrow(() -> operatorRestServiceRunning(opNamespace),
716+
"operator external service is not running"));
717+
}
718+
return opParams;
719+
}
720+
550721
/**
551722
* Upgrade WebLogic operator to manage the given domain namespaces.
552723
*
@@ -636,4 +807,5 @@ public static void restartOperator(String opNamespace) {
636807
logger.info("Operator pod is restarted in namespace {0}", opNamespace);
637808

638809
}
810+
639811
}

0 commit comments

Comments
 (0)