Skip to content

Commit 9c77c80

Browse files
authored
Moved patchDomainResourceWithNewIntrospectVersion method from Domain.java to DomainUtil.java (#3831)
* [v9cluster] move patchDomainResourceWithNewIntrospectVersion method from Domain.java to DomainUtil.java
1 parent 2e2d304 commit 9c77c80

File tree

3 files changed

+51
-51
lines changed

3 files changed

+51
-51
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.actions;
@@ -78,6 +78,7 @@
7878
import oracle.weblogic.kubernetes.extensions.InitializationTasks;
7979
import oracle.weblogic.kubernetes.logging.LoggingFacade;
8080
import oracle.weblogic.kubernetes.utils.ClusterUtils;
81+
import oracle.weblogic.kubernetes.utils.DomainUtils;
8182
import oracle.weblogic.kubernetes.utils.ExecResult;
8283

8384
import static oracle.weblogic.kubernetes.TestConstants.CLUSTER_VERSION;
@@ -303,7 +304,7 @@ public static String patchDomainCustomResourceReturnResponse(String domainUid, S
303304
*/
304305
public static String patchDomainResourceWithNewIntrospectVersion(
305306
String domainUid, String namespace) {
306-
return Domain.patchDomainResourceWithNewIntrospectVersion(domainUid, namespace);
307+
return DomainUtils.patchDomainResourceWithNewIntrospectVersion(domainUid, namespace);
307308
}
308309

309310
/**

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

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.actions.impl;
@@ -204,53 +204,6 @@ public static String patchDomainCustomResourceReturnResponse(String domainUid, S
204204
return Kubernetes.patchDomainCustomResourceReturnResponse(domainUid, namespace, patch, patchFormat);
205205
}
206206

207-
/**
208-
* Patch a running domain with introspectVersion.
209-
* If the introspectVersion doesn't exist it will add the value as 2,
210-
* otherwise the value is updated by 1.
211-
*
212-
* @param domainUid UID of the domain to patch with introspectVersion
213-
* @param namespace namespace in which the domain resource exists
214-
* @return introspectVersion new introspectVersion of the domain resource
215-
*/
216-
public static String patchDomainResourceWithNewIntrospectVersion(
217-
String domainUid, String namespace) {
218-
LoggingFacade logger = getLogger();
219-
StringBuffer patchStr;
220-
DomainResource res = assertDoesNotThrow(
221-
() -> getDomainCustomResource(domainUid, namespace),
222-
String.format("Failed to get the introspectVersion of %s in namespace %s", domainUid, namespace));
223-
int introspectVersion = 2;
224-
// construct the patch string
225-
if (res.getSpec().getIntrospectVersion() == null) {
226-
patchStr = new StringBuffer("[{")
227-
.append("\"op\": \"add\", ")
228-
.append("\"path\": \"/spec/introspectVersion\", ")
229-
.append("\"value\": \"")
230-
.append(introspectVersion)
231-
.append("\"}]");
232-
} else {
233-
introspectVersion = Integer.parseInt(res.getSpec().getIntrospectVersion()) + 1;
234-
patchStr = new StringBuffer("[{")
235-
.append("\"op\": \"replace\", ")
236-
.append("\"path\": \"/spec/introspectVersion\", ")
237-
.append("\"value\": \"")
238-
.append(introspectVersion)
239-
.append("\"}]");
240-
}
241-
242-
logger.info("Patch String \n{0}", patchStr);
243-
logger.info("Adding/updating introspectVersion in domain {0} in namespace {1} using patch string: {2}",
244-
domainUid, namespace, patchStr.toString());
245-
246-
// patch the domain
247-
V1Patch patch = new V1Patch(new String(patchStr));
248-
boolean ivPatched = patchDomainCustomResource(domainUid, namespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH);
249-
assertTrue(ivPatched, "patchDomainCustomResource(introspectVersion) failed");
250-
251-
return String.valueOf(introspectVersion);
252-
}
253-
254207
/**
255208
* Patch the domain resource with a new restartVersion.
256209
*

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

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.utils;
@@ -505,6 +505,52 @@ public static void patchDomainWithAuxiliaryImageAndVerify(String oldImageName, S
505505
}
506506
}
507507

508+
/**
509+
* Patch a running domain with introspectVersion.
510+
* If the introspectVersion doesn't exist it will add the value as 2,
511+
* otherwise the value is updated by 1.
512+
*
513+
* @param domainUid UID of the domain to patch with introspectVersion
514+
* @param namespace namespace in which the domain resource exists
515+
* @return introspectVersion new introspectVersion of the domain resource
516+
*/
517+
public static String patchDomainResourceWithNewIntrospectVersion(String domainUid, String namespace) {
518+
LoggingFacade logger = getLogger();
519+
StringBuffer patchStr;
520+
DomainResource res = assertDoesNotThrow(
521+
() -> getDomainCustomResource(domainUid, namespace),
522+
String.format("Failed to get the introspectVersion of %s in namespace %s", domainUid, namespace));
523+
int introspectVersion = 2;
524+
// construct the patch string
525+
if (res.getSpec().getIntrospectVersion() == null) {
526+
patchStr = new StringBuffer("[{")
527+
.append("\"op\": \"add\", ")
528+
.append("\"path\": \"/spec/introspectVersion\", ")
529+
.append("\"value\": \"")
530+
.append(introspectVersion)
531+
.append("\"}]");
532+
} else {
533+
introspectVersion = Integer.parseInt(res.getSpec().getIntrospectVersion()) + 1;
534+
patchStr = new StringBuffer("[{")
535+
.append("\"op\": \"replace\", ")
536+
.append("\"path\": \"/spec/introspectVersion\", ")
537+
.append("\"value\": \"")
538+
.append(introspectVersion)
539+
.append("\"}]");
540+
}
541+
542+
logger.info("Patch String \n{0}", patchStr);
543+
logger.info("Adding/updating introspectVersion in domain {0} in namespace {1} using patch string: {2}",
544+
domainUid, namespace, patchStr.toString());
545+
546+
// patch the domain
547+
V1Patch patch = new V1Patch(new String(patchStr));
548+
boolean ivPatched = patchDomainCustomResource(domainUid, namespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH);
549+
assertTrue(ivPatched, "patchDomainCustomResource(introspectVersion) failed");
550+
551+
return String.valueOf(introspectVersion);
552+
}
553+
508554
/**
509555
* Create a domain in PV using WDT.
510556
*

0 commit comments

Comments
 (0)