Skip to content

Commit 5c3c218

Browse files
committed
modified initialize for Operator
1 parent 63e6b2f commit 5c3c218

File tree

1 file changed

+4
-97
lines changed
  • integration-tests/src/test/java/oracle/kubernetes/operator/utils

1 file changed

+4
-97
lines changed

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

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import java.nio.file.Path;
99
import java.nio.file.Paths;
1010
import java.util.ArrayList;
11-
import java.util.HashMap;
12-
import java.util.List;
1311
import java.util.Map;
1412
import java.util.logging.Logger;
1513
import oracle.kubernetes.operator.BaseTest;
@@ -95,7 +93,7 @@ public Operator(
9593
RESTCertType restCertType)
9694
throws Exception {
9795
this.restCertType = restCertType;
98-
initializeCustom(inputMap, opNS, opSA, targetdomainNS);
96+
initialize(inputMap, opNS, opSA, targetdomainNS);
9997
generateInputYaml();
10098
}
10199
/**
@@ -107,7 +105,7 @@ public Operator(
107105
*/
108106
public Operator(Map<String, Object> inputMap, RESTCertType restCertType) throws Exception {
109107
this.restCertType = restCertType;
110-
initializeCustom(inputMap, true, true, true);
108+
initialize(inputMap, true, true, true);
111109
generateInputYaml();
112110
}
113111

@@ -390,101 +388,10 @@ private void runCommandInLoop(String command) throws Exception {
390388
}
391389

392390
private void initialize(String inputYaml) throws Exception {
393-
operatorMap = TestUtils.loadYaml(inputYaml);
394-
userProjectsDir = BaseTest.getUserProjectsDir();
395-
operatorNS = (String) operatorMap.getOrDefault("namespace", operatorNS);
396-
397-
if (operatorMap.get("releaseName") == null) {
398-
throw new RuntimeException("FAILURE: releaseName cann't be null");
399-
}
400-
// customize the inputs yaml file to generate a self-signed cert for the external Operator REST
401-
// https port
402-
externalRestEnabled =
403-
(boolean) operatorMap.getOrDefault("externalRestEnabled", externalRestEnabled);
404-
if (externalRestEnabled) {
405-
if (operatorMap.get("externalRestHttpsPort") != null) {
406-
try {
407-
externalRestHttpsPort = ((Integer) operatorMap.get("externalRestHttpsPort")).intValue();
408-
409-
} catch (NumberFormatException nfe) {
410-
throw new IllegalArgumentException(
411-
"FAILURE: Invalid value for " + "externalRestHttpsPort " + externalRestHttpsPort);
412-
}
413-
} else {
414-
operatorMap.put("externalRestHttpsPort", externalRestHttpsPort);
415-
}
416-
}
417-
418-
// customize the inputs yaml file to use our pre-built docker image
419-
// IMAGE_NAME_OPERATOR & IMAGE_TAG_OPERATOR variables are used for wercker
420-
if (System.getenv("IMAGE_NAME_OPERATOR") != null
421-
&& System.getenv("IMAGE_TAG_OPERATOR") != null) {
422-
operatorMap.put(
423-
"image",
424-
System.getenv("IMAGE_NAME_OPERATOR") + ":" + System.getenv("IMAGE_TAG_OPERATOR"));
425-
} else {
426-
operatorMap.put(
427-
"image",
428-
"wlsldi-v2.docker.oraclecorp.com/weblogic-operator"
429-
+ ":test_"
430-
+ BaseTest.getBranchName().replaceAll("/", "_"));
431-
}
432-
433-
if (System.getenv("IMAGE_PULL_POLICY_OPERATOR") != null) {
434-
operatorMap.put("imagePullPolicy", System.getenv("IMAGE_PULL_POLICY_OPERATOR"));
435-
}
436-
437-
ExecCommand.exec("kubectl delete namespace " + operatorNS);
438-
439-
// create opeartor namespace
440-
ExecCommand.exec("kubectl create namespace " + operatorNS);
441-
442-
// create operator service account
443-
String serviceAccount = (String) operatorMap.get("serviceAccount");
444-
if (serviceAccount != null && !serviceAccount.equals("default")) {
445-
ExecResult result =
446-
ExecCommand.exec("kubectl create serviceaccount " + serviceAccount + " -n " + operatorNS);
447-
if (result.exitValue() != 0) {
448-
throw new RuntimeException(
449-
"FAILURE: Couldn't create serviceaccount "
450-
+ serviceAccount
451-
+ ". Cmd returned "
452-
+ result.stdout()
453-
+ "\n"
454-
+ result.stderr());
455-
}
456-
}
457-
458-
// create domain namespaces
459-
460-
ArrayList<String> domainNamespaces = (ArrayList<String>) operatorMap.get("domainNamespaces");
461-
for (int i = 0; i < domainNamespaces.size(); i++) {
462-
String domainNS = domainNamespaces.get(i);
463-
logger.info("domainNamespace " + domainNS);
464-
if (!domainNS.equals("default")) {
465-
logger.info("Creating domain namespace " + domainNS);
466-
ExecCommand.exec("kubectl create namespace " + domainNS);
467-
}
468-
}
469-
470-
if (System.getenv("IMAGE_PULL_SECRET_OPERATOR") != null) {
471-
Map<String, String> m = new HashMap<>();
472-
m.put("name", System.getenv("IMAGE_PULL_SECRET_OPERATOR"));
473-
List<Map<String, String>> l = new ArrayList<>();
474-
l.add(m);
475-
operatorMap.put("imagePullSecrets", l);
476-
// create docker registry secrets
477-
TestUtils.createDockerRegistrySecret(
478-
System.getenv("IMAGE_PULL_SECRET_OPERATOR"),
479-
System.getenv("REPO_SERVER"),
480-
System.getenv("REPO_USERNAME"),
481-
System.getenv("REPO_PASSWORD"),
482-
System.getenv("REPO_EMAIL"),
483-
operatorNS);
484-
}
391+
initialize(TestUtils.loadYaml(inputYaml), true, true, true);
485392
}
486393

487-
private void initializeCustom(
394+
private void initialize(
488395
Map<String, Object> inputMap, boolean opNS, boolean opSA, boolean targetdomainNS)
489396
throws Exception {
490397
operatorMap = inputMap;

0 commit comments

Comments
 (0)