Skip to content

Commit efc4f69

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop-feature-mock-wls
2 parents 8477ede + 2ed4e27 commit efc4f69

File tree

15 files changed

+453
-141
lines changed

15 files changed

+453
-141
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ public class ITOperator extends BaseTest {
5454
private static Operator operatorForDel1;
5555
private static Operator operatorForDel2;
5656

57+
private static boolean QUICKTEST;
58+
private static boolean SMOKETEST;
59+
60+
// Set QUICKTEST env var to true to run a small subset of tests.
61+
// Set SMOKETEST env var to true to run an even smaller subset
62+
// of tests, plus leave domain1 up and running when the test completes.
63+
static {
64+
QUICKTEST =
65+
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
66+
SMOKETEST =
67+
System.getenv("SMOKETEST") != null && System.getenv("SMOKETEST").equalsIgnoreCase("true");
68+
if (SMOKETEST) QUICKTEST = true;
69+
}
70+
5771
/**
5872
* This method gets called only once before any of the test methods are executed. It does the
5973
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -103,16 +117,15 @@ public void test1CreateFirstOperatorAndDomain() throws Exception {
103117
logTestBegin("test1CreateFirstOperatorAndDomain");
104118
testCreateOperatorManagingDefaultAndTest1NS();
105119
Domain domain1 = testAllUseCasesForADomain(operator1, domain1YamlFile);
106-
domain1.testWlsLivenessProbe();
107-
domain1.shutdownUsingServerStartPolicy();
120+
if (!SMOKETEST) domain1.testWlsLivenessProbe();
121+
if (!SMOKETEST) domain1.shutdownUsingServerStartPolicy();
108122

109123
logger.info("SUCCESS - test1CreateFirstOperatorAndDomain");
110124
}
111125

112126
@Test
113127
public void test2CreateAnotherDomainInDefaultNS() throws Exception {
114-
Assume.assumeFalse(
115-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
128+
Assume.assumeFalse(QUICKTEST);
116129

117130
logTestBegin("test2CreateAnotherDomainInDefaultNS");
118131
logger.info("Creating Domain domain2 & verifing the domain creation");
@@ -129,8 +142,7 @@ public void test2CreateAnotherDomainInDefaultNS() throws Exception {
129142

130143
@Test
131144
public void test3CreateDomainInTest1NS() throws Exception {
132-
Assume.assumeFalse(
133-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
145+
Assume.assumeFalse(QUICKTEST);
134146

135147
logTestBegin("test3CreateDomainInTest1NS");
136148
logger.info("Creating Domain domain3 & verifing the domain creation");
@@ -146,8 +158,7 @@ public void test3CreateDomainInTest1NS() throws Exception {
146158

147159
@Test
148160
public void test4CreateAnotherOperatorManagingTest2NS() throws Exception {
149-
Assume.assumeFalse(
150-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
161+
Assume.assumeFalse(QUICKTEST);
151162

152163
logTestBegin("test4CreateAnotherOperatorManagingTest2NS");
153164
logger.info("Creating Operator & waiting for the script to complete execution");
@@ -158,8 +169,7 @@ public void test4CreateAnotherOperatorManagingTest2NS() throws Exception {
158169

159170
@Test
160171
public void test5CreateConfiguredDomainInTest2NS() throws Exception {
161-
Assume.assumeFalse(
162-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
172+
Assume.assumeFalse(QUICKTEST);
163173

164174
logTestBegin("test5CreateConfiguredDomainInTest2NS");
165175
logger.info("Creating Domain domain4 & verifing the domain creation");
@@ -198,8 +208,7 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
198208

199209
@Test
200210
public void test6CreateDomainWithStartPolicyAdminOnly() throws Exception {
201-
Assume.assumeFalse(
202-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
211+
Assume.assumeFalse(QUICKTEST);
203212

204213
logTestBegin("test6CreateDomainWithStartPolicyAdminOnly");
205214
logger.info("Checking if operator1 is running, if not creating");
@@ -215,8 +224,7 @@ public void test6CreateDomainWithStartPolicyAdminOnly() throws Exception {
215224

216225
@Test
217226
public void test7CreateDomainPVReclaimPolicyRecycle() throws Exception {
218-
Assume.assumeFalse(
219-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
227+
Assume.assumeFalse(QUICKTEST);
220228

221229
logTestBegin("test7CreateDomainPVReclaimPolicyRecycle");
222230
logger.info("Checking if operator1 is running, if not creating");
@@ -233,8 +241,7 @@ public void test7CreateDomainPVReclaimPolicyRecycle() throws Exception {
233241

234242
@Test
235243
public void test8CreateDomainOnExistingDir() throws Exception {
236-
Assume.assumeFalse(
237-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
244+
Assume.assumeFalse(QUICKTEST);
238245

239246
logTestBegin("test8CreateDomainOnExistingDir");
240247
if (operator1 == null) {
@@ -251,8 +258,8 @@ public void test8CreateDomainOnExistingDir() throws Exception {
251258

252259
// @Test
253260
public void testACreateDomainApacheLB() throws Exception {
254-
Assume.assumeFalse(
255-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
261+
Assume.assumeFalse(QUICKTEST);
262+
256263
logTestBegin("testACreateDomainApacheLB");
257264
logger.info("Creating Domain domain9 & verifing the domain creation");
258265
if (operator1 == null) {
@@ -268,8 +275,8 @@ public void testACreateDomainApacheLB() throws Exception {
268275

269276
@Test
270277
public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception {
271-
Assume.assumeFalse(
272-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
278+
Assume.assumeFalse(QUICKTEST);
279+
273280
logTestBegin("testBCreateDomainWithDefaultValuesInSampleInputs");
274281
logger.info("Creating Domain domain10 & verifing the domain creation");
275282
if (operator1 == null) {
@@ -284,8 +291,7 @@ public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception
284291

285292
@Test
286293
public void testDeleteOneDomain() throws Exception {
287-
Assume.assumeFalse(
288-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
294+
Assume.assumeFalse(QUICKTEST);
289295
logTestBegin("Deleting one domain.");
290296

291297
if (operatorForDel1 == null) {
@@ -303,8 +309,7 @@ public void testDeleteOneDomain() throws Exception {
303309

304310
@Test
305311
public void testDeleteTwoDomains() throws Exception {
306-
Assume.assumeFalse(
307-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
312+
Assume.assumeFalse(QUICKTEST);
308313
logTestBegin("Deleting two domains.");
309314

310315
if (operatorForDel2 == null) {
@@ -337,9 +342,11 @@ private Domain testAllUseCasesForADomain(Operator operator, String domainYamlFil
337342
logger.info("Creating Domain & verifing the domain creation");
338343
// create domain1
339344
Domain domain = testDomainCreation(domainYamlFile);
340-
testClusterScaling(operator, domain);
341-
testDomainLifecyle(operator, domain);
342-
testOperatorLifecycle(operator, domain);
345+
if (!SMOKETEST) {
346+
testClusterScaling(operator, domain);
347+
testDomainLifecyle(operator, domain);
348+
testOperatorLifecycle(operator, domain);
349+
}
343350
return domain;
344351
}
345352

integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ public static void createRBACPoliciesForWLDFScaling() throws Exception {
728728
public static void deleteWeblogicDomainResources(String domainUid) throws Exception {
729729
StringBuilder cmd =
730730
new StringBuilder(BaseTest.getProjectRoot())
731-
.append("/kubernetes/delete-weblogic-domain-resources.sh ")
731+
.append("/kubernetes/samples/scripts/delete-weblogic-domain-resources.sh ")
732732
.append("-d ")
733733
.append(domainUid);
734734
logger.info("Running " + cmd);

kubernetes/delete-weblogic-domain-resources.sh renamed to kubernetes/samples/scripts/delete-weblogic-domain-resources.sh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ cat << EOF
2929
or all resources were deleted (default $default_maxwaitsecs seconds).
3030
3131
The domains can be specified as a comma-separated list of
32-
domain-uids (no spaces), or the keyword 'all'. The domains can be
33-
located in any kubernetes namespace.
32+
domain-uids (no spaces). The domains can be located in any
33+
kubernetes namespace.
3434
3535
Specify '-t' to run the script in a test mode which will
3636
show kubernetes commands but not actually perform them.
@@ -73,18 +73,14 @@ EOF
7373
#
7474
function getDomainResources {
7575
local domain_regex=''
76-
if [ "$1" = "all" ]; then
77-
LABEL_SELECTOR="weblogic.domainUID"
78-
else
79-
LABEL_SELECTOR="weblogic.domainUID in ($1)"
80-
IFS=',' read -ra UIDS <<< "$1"
81-
for i in "${!UIDS[@]}"; do
82-
if [ $i -gt 0 ]; then
83-
domain_regex="$domain_regex|"
84-
fi
85-
domain_regex="$domain_regex^Domain ${UIDS[$i]} "
86-
done
87-
fi
76+
LABEL_SELECTOR="weblogic.domainUID in ($1)"
77+
IFS=',' read -ra UIDS <<< "$1"
78+
for i in "${!UIDS[@]}"; do
79+
if [ $i -gt 0 ]; then
80+
domain_regex="$domain_regex|"
81+
fi
82+
domain_regex="$domain_regex^Domain ${UIDS[$i]} "
83+
done
8884

8985
# clean the output file
9086
if [ -e $2 ]; then
@@ -122,7 +118,6 @@ function getDomainResources {
122118
#
123119
# Usage:
124120
# deleteDomains domainA,domainB,... maxwaitsecs
125-
# deleteDomains all maxwaitsecs
126121
#
127122
# Internal helper function
128123
# This function first sets the serverStartPolicy of each Domain to NEVER
@@ -131,9 +126,7 @@ function getDomainResources {
131126
# any remaining k8s resources for domain $1 (including any remaining pods)
132127
# and retries these direct deletes up to $2 seconds.
133128
#
134-
# If $1 has special value "all", it deletes all domains in all namespaces.
135-
#
136-
# If global $test_mode is true, it shows candidate actions but doesn't
129+
# If global $test_mode is true, it shows candidate actions but doesn't
137130
# actually perform them
138131
#
139132
function deleteDomains {

operator/src/main/java/oracle/kubernetes/operator/DomainProcessorImpl.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import oracle.kubernetes.operator.work.Fiber;
5050
import oracle.kubernetes.operator.work.Fiber.CompletionCallback;
5151
import oracle.kubernetes.operator.work.FiberGate;
52+
import oracle.kubernetes.operator.work.FiberGateFactory;
5253
import oracle.kubernetes.operator.work.NextAction;
5354
import oracle.kubernetes.operator.work.Packet;
5455
import oracle.kubernetes.operator.work.Step;
@@ -62,7 +63,15 @@ public class DomainProcessorImpl implements DomainProcessor {
6263

6364
private static final LoggingFacade LOGGER = LoggingFactory.getLogger("Operator", "Operator");
6465

65-
private static final FiberGate FIBER_GATE = new FiberGate(Main.engine);
66+
private static final FiberGateFactory FACTORY =
67+
() -> {
68+
return new FiberGate(Main.engine);
69+
};
70+
private static final ConcurrentMap<String, FiberGate> fiberGates = new ConcurrentHashMap<>();
71+
72+
private static FiberGate getFiberGate(String ns) {
73+
return fiberGates.computeIfAbsent(ns, k -> FACTORY.get());
74+
}
6675

6776
// Map from namespace to map of domainUID to Domain
6877
private static final ConcurrentMap<String, ConcurrentMap<String, DomainPresenceInfo>> domains =
@@ -754,6 +763,7 @@ void runDomainPlan(
754763
Step.StepAndPacket plan,
755764
boolean isDeleting,
756765
boolean isWillInterrupt) {
766+
FiberGate gate = getFiberGate(ns);
757767
CompletionCallback cc =
758768
new CompletionCallback() {
759769
@Override
@@ -765,7 +775,7 @@ public void onCompletion(Packet packet) {
765775
public void onThrowable(Packet packet, Throwable throwable) {
766776
LOGGER.severe(MessageKeys.EXCEPTION, throwable);
767777

768-
FIBER_GATE.startFiberIfLastFiberMatches(
778+
gate.startFiberIfLastFiberMatches(
769779
domainUID,
770780
Fiber.getCurrentIfSet(),
771781
DomainStatusUpdater.createFailedStep(throwable, null),
@@ -782,8 +792,7 @@ public void onThrowable(Packet packet, Throwable throwable) {
782792
}
783793
});
784794

785-
FIBER_GATE
786-
.getExecutor()
795+
gate.getExecutor()
787796
.schedule(
788797
() -> {
789798
DomainPresenceInfo existing = getExisting(ns, domainUID);
@@ -798,9 +807,9 @@ public void onThrowable(Packet packet, Throwable throwable) {
798807
};
799808

800809
if (isWillInterrupt) {
801-
FIBER_GATE.startFiber(domainUID, plan.step, plan.packet, cc);
810+
gate.startFiber(domainUID, plan.step, plan.packet, cc);
802811
} else {
803-
FIBER_GATE.startFiberIfNoCurrentFiber(domainUID, plan.step, plan.packet, cc);
812+
gate.startFiberIfNoCurrentFiber(domainUID, plan.step, plan.packet, cc);
804813
}
805814
}
806815

operator/src/main/java/oracle/kubernetes/operator/helpers/JobHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ List<V1EnvVar> getEnvironmentVariables(TuningParameters tuningParameters) {
7575
addEnvVar(envVarList, "LOG_HOME", getEffectiveLogHome());
7676
addEnvVar(envVarList, "INTROSPECT_HOME", getIntrospectHome());
7777
addEnvVar(envVarList, "SERVER_OUT_IN_POD_LOG", getIncludeServerOutInPodLog());
78+
addEnvVar(envVarList, "ADMIN_SECRET_NAME", getAdminSecretName());
7879

7980
return envVarList;
8081
}

operator/src/main/java/oracle/kubernetes/operator/helpers/JobStepContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private String getDomainResourceName() {
6363

6464
abstract String getJobName();
6565

66-
private String getAdminSecretName() {
66+
String getAdminSecretName() {
6767
return getDomain().getAdminSecret().getName();
6868
}
6969

operator/src/main/java/oracle/kubernetes/operator/work/Fiber.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ private synchronized void addBreadCrumb(BreadCrumb bc) {
808808

809809
private synchronized void recordBreadCrumb() {
810810
if (breadCrumbs != null) {
811-
if (parent == null || parent.isDone()) {
811+
if (parent == null) {
812812
StringBuilder sb = new StringBuilder();
813813
writeBreadCrumb(sb);
814814

@@ -822,22 +822,20 @@ private synchronized void recordBreadCrumb() {
822822

823823
private synchronized void writeBreadCrumb(StringBuilder sb) {
824824
if (breadCrumbs != null) {
825-
if (parent == null || parent.isDone()) {
826-
sb.append('[');
827-
Iterator<BreadCrumb> it = breadCrumbs.iterator();
828-
BreadCrumb previous = null;
829-
while (it.hasNext()) {
830-
BreadCrumb bc = it.next();
831-
if (!bc.isMarker()) {
832-
if (previous != null) {
833-
sb.append(previous.isMarker() ? "][" : ",");
834-
}
835-
bc.writeTo(sb);
825+
sb.append('[');
826+
Iterator<BreadCrumb> it = breadCrumbs.iterator();
827+
BreadCrumb previous = null;
828+
while (it.hasNext()) {
829+
BreadCrumb bc = it.next();
830+
if (!bc.isMarker()) {
831+
if (previous != null) {
832+
sb.append(previous.isMarker() ? "][" : ",");
836833
}
837-
previous = bc;
834+
bc.writeTo(sb);
838835
}
839-
sb.append(']');
836+
previous = bc;
840837
}
838+
sb.append(']');
841839
}
842840
}
843841

@@ -887,7 +885,15 @@ public ChildFiberBreadCrumb(Fiber child) {
887885

888886
@Override
889887
public void writeTo(StringBuilder sb) {
890-
child.writeBreadCrumb(sb);
888+
sb.append("{child-");
889+
sb.append(child.id);
890+
sb.append(": ");
891+
if (child.status.get() == NOT_COMPLETE) {
892+
sb.append("not-complete");
893+
} else {
894+
child.writeBreadCrumb(sb);
895+
}
896+
sb.append("}");
891897
}
892898
}
893899

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at
3+
// http://oss.oracle.com/licenses/upl.
4+
5+
package oracle.kubernetes.operator.work;
6+
7+
import java.util.function.Supplier;
8+
9+
public interface FiberGateFactory extends Supplier<FiberGate> {}

0 commit comments

Comments
 (0)