Skip to content

Commit 0908cdc

Browse files
committed
Merge branch 'develop' into owls-70659
2 parents e575e4e + 546b4a1 commit 0908cdc

File tree

109 files changed

+2280
-1069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2280
-1069
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The [User guide](site/user-guide.md) provides detailed information about all asp
5252

5353
# Samples
5454

55-
**TODO** put a list of samples here with a summary and links
55+
Please refer to our [samples](kubernetes/samples/README.md) for information about the available sample code we provide.
5656

5757
# Developer guide
5858

integration-tests/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@
5959
<dependency>
6060
<groupId>com.google.guava</groupId>
6161
<artifactId>guava</artifactId>
62-
<version>25.1-jre</version>
62+
<version>${guava-version}</version>
6363
</dependency>
6464
<dependency>
6565
<groupId>org.yaml</groupId>
6666
<artifactId>snakeyaml</artifactId>
67-
<version>1.21</version>
67+
<version>${snakeyaml-version}</version>
6868
</dependency>
6969
<dependency>
7070
<groupId>io.kubernetes</groupId>

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

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
package oracle.kubernetes.operator;
66

7+
import java.io.File;
8+
import java.nio.file.Files;
9+
import java.nio.file.StandardCopyOption;
710
import oracle.kubernetes.operator.utils.Domain;
811
import oracle.kubernetes.operator.utils.ExecCommand;
912
import oracle.kubernetes.operator.utils.ExecResult;
@@ -46,6 +49,7 @@ public class ITOperator extends BaseTest {
4649
private static String domain9YamlFile = "domain9.yaml";
4750
private static String domain10YamlFile = "domain10.yaml";
4851
private static String domain11YamlFile = "domain11.yaml";
52+
private static String domain12YamlFile = "domain12.yaml";
4953

5054
// property file used to configure constants for integration tests
5155
private static String appPropsFile = "OperatorIT.properties";
@@ -138,8 +142,7 @@ public void test1CreateFirstOperatorAndDomain() throws Exception {
138142
if (!SMOKETEST) domain1.testWlsLivenessProbe();
139143
testCompletedSuccessfully = true;
140144
} finally {
141-
142-
if (domain1 != null && (JENKINS || testCompletedSuccessfully))
145+
if (domain1 != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully))
143146
domain1.shutdownUsingServerStartPolicy();
144147
}
145148

@@ -251,7 +254,7 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
251254
logger.info("Verify no impact on domain5");
252255
domain5.verifyDomainCreated();
253256
testCompletedSuccessfully = true;
254-
logger.info("SUCCESS - test5CreateConfiguredDomainInTest2NS");
257+
255258
} finally {
256259
if (domain4 != null && (JENKINS || testCompletedSuccessfully)) {
257260
domain4.destroy();
@@ -260,6 +263,7 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
260263
domain5.destroy();
261264
}
262265
}
266+
logger.info("SUCCESS - test5CreateConfiguredDomainInTest2NS");
263267
}
264268

265269
@Test
@@ -459,7 +463,7 @@ public void testDeleteTwoDomains() throws Exception {
459463
logger.info("SUCCESS - testDeleteTwoDomains");
460464
}
461465

462-
// @Test
466+
@Test
463467
public void testAutoSitConfigOverrides() throws Exception {
464468
Assume.assumeFalse(QUICKTEST);
465469
logTestBegin("testAutoSitConfigOverrides");
@@ -469,32 +473,78 @@ public void testAutoSitConfigOverrides() throws Exception {
469473
}
470474
Domain domain11 = null;
471475
boolean testCompletedSuccessfully = false;
476+
String createDomainScriptDir =
477+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv";
472478
try {
479+
473480
// cp py
474-
copyCreateDomainScript();
481+
Files.copy(
482+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
483+
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
484+
StandardCopyOption.REPLACE_EXISTING);
485+
Files.copy(
486+
new File(createDomainScriptDir + "/create-domain-auto-sit-config.py").toPath(),
487+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
488+
StandardCopyOption.REPLACE_EXISTING);
489+
475490
domain11 = testDomainCreation(domain11YamlFile);
476491
domain11.verifyDomainCreated();
477492
testBasicUseCases(domain11);
493+
// testAdvancedUseCasesForADomain(operator1, domain11);
478494
testCompletedSuccessfully = true;
479495
logger.info("SUCCESS - testAutoSitConfigOverrides");
480496
} finally {
481-
482-
StringBuffer cmd = new StringBuffer("cd ");
483-
cmd.append(BaseTest.getProjectRoot())
484-
.append(
485-
"/integration-tests/src/test/resources/domain-home-on-pv && cp create-domain.py.bak create-domain.py");
486-
logger.info("Running " + cmd);
487-
ExecResult result = ExecCommand.exec(cmd.toString());
488-
if (result.exitValue() != 0) {
489-
throw new RuntimeException(cmd + " failed");
490-
}
491-
497+
Files.copy(
498+
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
499+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
500+
StandardCopyOption.REPLACE_EXISTING);
492501
if (domain11 != null && (JENKINS || testCompletedSuccessfully)) {
493502
domain11.destroy();
494503
}
495504
}
496505
}
497506

507+
// @Test
508+
public void testCustomSitConfigOverrides() throws Exception {
509+
Assume.assumeFalse(QUICKTEST);
510+
logTestBegin("testCustomSitConfigOverrides");
511+
512+
if (operator1 == null) {
513+
operator1 = TestUtils.createOperator(op1YamlFile);
514+
}
515+
Domain domain12 = null;
516+
boolean testCompletedSuccessfully = false;
517+
String createDomainScriptDir =
518+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv";
519+
try {
520+
521+
// cp py
522+
Files.copy(
523+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
524+
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
525+
StandardCopyOption.REPLACE_EXISTING);
526+
Files.copy(
527+
new File(createDomainScriptDir + "/create-domain-custom-sit-config.py").toPath(),
528+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
529+
StandardCopyOption.REPLACE_EXISTING);
530+
531+
domain12 = testDomainCreation(domain12YamlFile);
532+
domain12.verifyDomainCreated();
533+
testBasicUseCases(domain12);
534+
// testAdvancedUseCasesForADomain(operator1, domain11);
535+
testCompletedSuccessfully = true;
536+
logger.info("SUCCESS - testCustomSitConfigOverrides");
537+
} finally {
538+
Files.copy(
539+
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
540+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
541+
StandardCopyOption.REPLACE_EXISTING);
542+
if (domain12 != null && (JENKINS || testCompletedSuccessfully)) {
543+
domain12.destroy();
544+
}
545+
}
546+
}
547+
498548
private Domain testAdvancedUseCasesForADomain(Operator operator, Domain domain) throws Exception {
499549
if (!SMOKETEST) {
500550
testClusterScaling(operator, domain);
@@ -512,27 +562,4 @@ private void testBasicUseCases(Domain domain) throws Exception {
512562
testAdminT3Channel(domain);
513563
testAdminServerExternalService(domain);
514564
}
515-
516-
private void copyCreateDomainScript() throws Exception {
517-
String createDomainScriptPath =
518-
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv";
519-
520-
StringBuffer cmd = new StringBuffer("cd ");
521-
cmd.append(createDomainScriptPath).append(" && cp create-domain.py create-domain.py.bak");
522-
logger.info("Running " + cmd);
523-
524-
ExecResult result = ExecCommand.exec(cmd.toString());
525-
if (result.exitValue() != 0) {
526-
throw new RuntimeException(cmd + " failed");
527-
}
528-
529-
cmd = new StringBuffer("cd ");
530-
cmd.append(createDomainScriptPath)
531-
.append(" && cp create-domain-auto-sit-config.py create-domain.py");
532-
logger.info("Running " + cmd);
533-
result = ExecCommand.exec(cmd.toString());
534-
if (result.exitValue() != 0) {
535-
throw new RuntimeException(cmd + " failed");
536-
}
537-
}
538565
}

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

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.nio.file.Files;
1111
import java.nio.file.Path;
1212
import java.nio.file.Paths;
13+
import java.nio.file.StandardOpenOption;
1314
import java.util.HashMap;
1415
import java.util.Map;
1516
import java.util.Objects;
@@ -668,11 +669,14 @@ private void generateInputYaml() throws Exception {
668669

669670
private void callCreateDomainScript(String outputDir) throws Exception {
670671
StringBuffer cmd = new StringBuffer(BaseTest.getProjectRoot());
672+
671673
cmd.append(
672674
"/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh -i ")
673-
.append(generatedInputYamlFile)
674-
.append(" -e -v -o ")
675-
.append(outputDir);
675+
.append(generatedInputYamlFile);
676+
if (!domainMap.containsKey("configOverrides")) {
677+
cmd.append(" -e ");
678+
}
679+
cmd.append(" -v -o ").append(outputDir);
676680
logger.info("Running " + cmd);
677681
ExecResult result = ExecCommand.exec(cmd.toString(), true);
678682
if (result.exitValue() != 0) {
@@ -686,6 +690,37 @@ private void callCreateDomainScript(String outputDir) throws Exception {
686690
}
687691
String outputStr = result.stdout().trim();
688692
logger.info("Command returned " + outputStr);
693+
694+
// write configOverride and configOverrideSecrets to domain.yaml
695+
if (domainMap.containsKey("configOverrides")) {
696+
String contentToAppend =
697+
" configOverrides: "
698+
+ domainUid
699+
+ "-"
700+
+ domainMap.get("configOverrides")
701+
+ "\n"
702+
+ " configOverrideSecrets: [ \""
703+
+ domainUid
704+
+ "-t3publicaddress\" ]"
705+
+ "\n";
706+
707+
String domainYaml =
708+
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/domain.yaml";
709+
Files.write(Paths.get(domainYaml), contentToAppend.getBytes(), StandardOpenOption.APPEND);
710+
711+
String command = "kubectl create -f " + domainYaml;
712+
result = ExecCommand.exec(command);
713+
if (result.exitValue() != 0) {
714+
throw new RuntimeException(
715+
"FAILURE: command "
716+
+ cmd
717+
+ " failed, returned "
718+
+ result.stdout()
719+
+ "\n"
720+
+ result.stderr());
721+
}
722+
logger.info("Command returned " + result.stdout().trim());
723+
}
689724
}
690725

691726
private void createLoadBalancer() throws Exception {
@@ -790,7 +825,12 @@ private void callWebAppAndCheckForServerNameInResponse(
790825
ExecResult result = ExecCommand.exec(curlCmd.toString());
791826
if (result.exitValue() != 0) {
792827
throw new RuntimeException(
793-
"FAILURE: command " + curlCmd + " failed, returned " + result.stderr());
828+
"FAILURE: command "
829+
+ curlCmd
830+
+ " failed, returned "
831+
+ result.stderr()
832+
+ " \n "
833+
+ result.stdout());
794834
} else {
795835
logger.info("webapp invoked successfully");
796836
}
@@ -863,9 +903,9 @@ private void initialize(String inputYaml) throws Exception {
863903
}
864904

865905
domainMap.put("domainHome", "/shared/domains/" + domainUid);
866-
/* domainMap.put(
867-
"createDomainFilesDir",
868-
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv"); */
906+
domainMap.put(
907+
"createDomainFilesDir",
908+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv");
869909
String imageName = "store/oracle/weblogic";
870910
if (System.getenv("IMAGE_NAME_WEBLOGIC") != null) {
871911
imageName = System.getenv("IMAGE_NAME_WEBLOGIC");
@@ -889,6 +929,56 @@ private void initialize(String inputYaml) throws Exception {
889929
}
890930
// remove null values if any attributes
891931
domainMap.values().removeIf(Objects::isNull);
932+
933+
// create config map and secret for custom sit config
934+
if (domainMap.get("configOverrides") != null) {
935+
// write hostname in config file for public address
936+
937+
String cmd =
938+
"kubectl -n "
939+
+ domainNS
940+
+ " create cm "
941+
+ domainUid
942+
+ "-"
943+
+ domainMap.get("configOverrides")
944+
+ " --from-file "
945+
+ BaseTest.getProjectRoot()
946+
+ "/integration-tests/src/test/resources/domain-home-on-pv/customsitconfig";
947+
ExecResult result = ExecCommand.exec(cmd);
948+
if (result.exitValue() != 0) {
949+
throw new RuntimeException(
950+
"FAILURE: command " + cmd + " failed, returned " + result.stderr());
951+
}
952+
cmd =
953+
"kubectl -n "
954+
+ domainNS
955+
+ " label cm "
956+
+ domainUid
957+
+ "-"
958+
+ domainMap.get("configOverrides")
959+
+ " weblogic.domainUID="
960+
+ domainUid;
961+
result = ExecCommand.exec(cmd);
962+
if (result.exitValue() != 0) {
963+
throw new RuntimeException(
964+
"FAILURE: command " + cmd + " failed, returned " + result.stderr());
965+
}
966+
// create secret for custom sit config t3 public address
967+
cmd =
968+
"kubectl -n "
969+
+ domainNS
970+
+ " create secret generic "
971+
+ domainUid
972+
+ "-"
973+
+ "t3publicaddress "
974+
+ " --from-literal=hostname="
975+
+ TestUtils.getHostName();
976+
result = ExecCommand.exec(cmd);
977+
if (result.exitValue() != 0) {
978+
throw new RuntimeException(
979+
"FAILURE: command " + cmd + " failed, returned " + result.stderr());
980+
}
981+
}
892982
}
893983

894984
private String getNodeHost() throws Exception {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private void generateInputYaml() throws Exception {
230230
// write certificates
231231
ExecCommand.exec(
232232
BaseTest.getProjectRoot()
233-
+ "/kubernetes/samples/scripts/generate-external-rest-identity.sh "
233+
+ "/kubernetes/samples/scripts/rest/generate-external-rest-identity.sh "
234234
+ "DNS:"
235235
+ TestUtils.getHostName()
236236
+ " >> "

0 commit comments

Comments
 (0)