4
4
5
5
package oracle .kubernetes .operator ;
6
6
7
+ import static org .junit .Assert .assertTrue ;
8
+
7
9
import java .nio .file .Files ;
8
10
import java .nio .file .Paths ;
9
11
import java .nio .file .StandardCopyOption ;
10
12
import java .nio .file .StandardOpenOption ;
11
13
import java .util .Map ;
12
14
import oracle .kubernetes .operator .utils .Domain ;
15
+ import oracle .kubernetes .operator .utils .K8sTestUtils ;
13
16
import oracle .kubernetes .operator .utils .Operator ;
14
17
import oracle .kubernetes .operator .utils .Operator .RESTCertType ;
15
18
import oracle .kubernetes .operator .utils .TestUtils ;
@@ -33,8 +36,9 @@ public class ITMultipleClusters extends BaseTest {
33
36
34
37
private static Operator operatorForBackwardCompatibility ;
35
38
private static Operator operatorForRESTCertChain ;
36
-
39
+
37
40
private static String TWO_CONFIGURED_CLUSTER_SCRIPT = "create-domain-two-configured-cluster.py" ;
41
+ private static String domainUid = "" ;
38
42
39
43
/**
40
44
* This method gets called only once before any of the test methods are executed. It does the
@@ -82,7 +86,8 @@ public static void staticUnPrepare() throws Exception {
82
86
public void testCreateDomainTwoConfiguredCluster () throws Exception {
83
87
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
84
88
logTestBegin (testMethodName );
85
- String template = getResultDir () +"/samples/scripts/common/domain-template.yaml" ;
89
+ String template =
90
+ BaseTest .getProjectRoot () + "/kubernetes/samples/scripts/common/domain-template.yaml" ;
86
91
logger .info ("Creating Operator & waiting for the script to complete execution" );
87
92
// create operator1
88
93
if (operator1 == null ) {
@@ -91,35 +96,51 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
91
96
Domain domain = null ;
92
97
boolean testCompletedSuccessfully = false ;
93
98
try {
94
- Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
99
+ Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
95
100
domainMap .put ("domainUID" , "customsitdomain" );
96
101
domainMap .put (
97
102
"createDomainPyScript" ,
98
- "integration-tests/src/test/resources/domain-home-on-pv/" + TWO_CONFIGURED_CLUSTER_SCRIPT );
99
-
100
- String add = " - clusterName: %CLUSTER_NAME%-2 \n " +
101
- " serverStartState: \" RUNNING \" \n " +
102
- " replicas : %INITIAL_MANAGED_SERVER_REPLICAS% \n " +
103
- "~" ;
104
- Files . copy ( Paths . get ( template ), Paths . get ( template + ".org" ),
105
- StandardCopyOption . REPLACE_EXISTING );
106
-
107
- Files .write (
108
- Paths . get ( template ),
109
- add . getBytes (),
110
- StandardOpenOption .APPEND );
111
-
112
- domain = TestUtils .createDomain (DOMAINONPV_WLST_YAML );
103
+ "integration-tests/src/test/resources/domain-home-on-pv/"
104
+ + TWO_CONFIGURED_CLUSTER_SCRIPT );
105
+
106
+ String add =
107
+ " - clusterName : %CLUSTER_NAME%-2 \n "
108
+ + " serverStartState: \" RUNNING \" \n "
109
+ + " replicas: %INITIAL_MANAGED_SERVER_REPLICAS% \n " ;
110
+ logger . info ( "Making a backup of the domain template file:" + template );
111
+ if (! Files . exists ( Paths . get ( template + ".org" ))) {
112
+ Files .copy ( Paths . get ( template ), Paths . get ( template + ".org" ));
113
+ }
114
+ logger . info ( "Appended the domain template file" );
115
+ Files . write ( Paths . get ( template ), add . getBytes (), StandardOpenOption .APPEND );
116
+ logger . info ( "Appended the domain template file" );
117
+ domain = TestUtils .createDomain (domainMap );
113
118
domain .verifyDomainCreated ();
119
+ K8sTestUtils testUtil = new K8sTestUtils ();
120
+ String domain1LabelSelector = String .format ("weblogic.domainUID in (%s)" , domainUid );
121
+ String namespace = domain .getDomainNS ();
122
+ String pods [] = {
123
+ domainUid + "-" + domain .getAdminServerName (),
124
+ domainUid + "-managed-server1" ,
125
+ domainUid + "-managed-server2" ,
126
+ domainUid + "new-managed-server1" ,
127
+ domainUid + "new-managed-server2" ,
128
+ };
129
+ for (String pod : pods ) {
130
+ assertTrue (
131
+ pod + " Pod not running" , testUtil .isPodRunning (namespace , domain1LabelSelector , pod ));
132
+ }
133
+
114
134
testBasicUseCases (domain );
115
135
if (!SMOKETEST ) domain .testWlsLivenessProbe ();
116
136
testCompletedSuccessfully = true ;
117
137
} finally {
118
- if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully ))
119
- Files .copy (Paths .get (template +".org" ),Paths .get (template ),
120
- StandardCopyOption .REPLACE_EXISTING );
121
- domain .shutdownUsingServerStartPolicy ();
122
-
138
+ if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully )) {
139
+ Files .copy (
140
+ Paths .get (template + ".org" ), Paths .get (template ), StandardCopyOption .REPLACE_EXISTING );
141
+ Files .delete (Paths .get (template + ".org" ));
142
+ }
143
+ domain .shutdownUsingServerStartPolicy ();
123
144
}
124
145
logger .info ("SUCCESS - " + testMethodName );
125
146
}
0 commit comments