4
4
5
5
package oracle .kubernetes .operator ;
6
6
7
+ import java .nio .file .Files ;
8
+ import java .nio .file .Paths ;
7
9
import java .util .Map ;
8
10
import oracle .kubernetes .operator .utils .Domain ;
9
11
import oracle .kubernetes .operator .utils .Operator ;
@@ -26,6 +28,7 @@ public class ITPodsRestart extends BaseTest {
26
28
27
29
private static Domain domain = null ;
28
30
private static Operator operator1 ;
31
+ private static String domainUid = "" ;
29
32
30
33
/**
31
34
* This method gets called only once before any of the test methods are executed. It does the
@@ -84,10 +87,10 @@ public void testServerPodsRestartByChangingEnvProperty() throws Exception {
84
87
logTestBegin (testMethodName );
85
88
86
89
logger .info (
87
- "About to testDomainServerPodRestart for Domain: "
90
+ "About to verifyDomainServerPodRestart for Domain: "
88
91
+ domain .getDomainUid ()
89
92
+ " env property: StdoutDebugEnabled=false to StdoutDebugEnabled=true" );
90
- domain .testDomainServerPodRestart (
93
+ domain .verifyDomainServerPodRestart (
91
94
"\" -Dweblogic.StdoutDebugEnabled=false\" " , "\" -Dweblogic.StdoutDebugEnabled=true\" " );
92
95
93
96
logger .info ("SUCCESS - " + testMethodName );
@@ -107,10 +110,10 @@ public void testServerPodsRestartByChangingLogHomeEnabled() throws Exception {
107
110
logTestBegin (testMethodName );
108
111
109
112
logger .info (
110
- "About to testDomainServerPodRestart for Domain: "
113
+ "About to verifyDomainServerPodRestart for Domain: "
111
114
+ domain .getDomainUid ()
112
115
+ " logHomeEnabled: true --> logHomeEnabled: false" );
113
- domain .testDomainServerPodRestart ("logHomeEnabled: true" , "logHomeEnabled: false" );
116
+ domain .verifyDomainServerPodRestart ("logHomeEnabled: true" , "logHomeEnabled: false" );
114
117
115
118
logger .info ("SUCCESS - " + testMethodName );
116
119
}
@@ -129,10 +132,10 @@ public void testServerPodsRestartByChangingImagePullPolicy() throws Exception {
129
132
logTestBegin (testMethodName );
130
133
131
134
logger .info (
132
- "About to testDomainServerPodRestart for Domain: "
135
+ "About to verifyDomainServerPodRestart for Domain: "
133
136
+ domain .getDomainUid ()
134
137
+ " imagePullPolicy: IfNotPresent --> imagePullPolicy: Never " );
135
- domain .testDomainServerPodRestart (
138
+ domain .verifyDomainServerPodRestart (
136
139
"imagePullPolicy: \" IfNotPresent\" " , "imagePullPolicy: \" Never\" " );
137
140
138
141
logger .info ("SUCCESS - " + testMethodName );
@@ -152,10 +155,10 @@ public void testServerPodsRestartByChangingIncludeServerOutInPodLog() throws Exc
152
155
logTestBegin (testMethodName );
153
156
154
157
logger .info (
155
- "About to testDomainServerPodRestart for Domain: "
158
+ "About to verifyDomainServerPodRestart for Domain: "
156
159
+ domain .getDomainUid ()
157
160
+ " includeServerOutInPodLog: true --> includeServerOutInPodLog: false" );
158
- domain .testDomainServerPodRestart (
161
+ domain .verifyDomainServerPodRestart (
159
162
"includeServerOutInPodLog: true" , "includeServerOutInPodLog: false" );
160
163
161
164
logger .info ("SUCCESS - " + testMethodName );
@@ -176,12 +179,12 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
176
179
177
180
try {
178
181
logger .info (
179
- "About to testDomainServerPodRestart for Domain: "
182
+ "About to verifyDomainServerPodRestart for Domain: "
180
183
+ domain .getDomainUid ()
181
184
+ " Image property: store/oracle/weblogic:12.2.1.3 to store/oracle/weblogic:duplicate" );
182
185
183
186
TestUtils .exec ("docker tag store/oracle/weblogic:12.2.1.3 store/oracle/weblogic:duplicate" );
184
- domain .testDomainServerPodRestart (
187
+ domain .verifyDomainServerPodRestart (
185
188
"\" store/oracle/weblogic:12.2.1.3\" " , "\" store/oracle/weblogic:duplicate\" " );
186
189
} finally {
187
190
TestUtils .exec ("docker rmi -f store/oracle/weblogic:duplicate" );
@@ -190,13 +193,127 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
190
193
logger .info ("SUCCESS - " + testMethodName );
191
194
}
192
195
196
+ /**
197
+ * Modify/Add the containerSecurityContext section at ServerPod Level using kubectl apply -f
198
+ * cont.security.context.domain.yaml. Verify all the pods re-started. The property tested is:
199
+ * serverPod: containerSecurityContext: runAsUser: 1000 fsGroup: 1000.
200
+ *
201
+ * @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
202
+ * are not restarted or after restart the server yaml file doesn't include the new added
203
+ * property
204
+ */
205
+ @ Test
206
+ public void testServerPodsRestartByChangingContSecurityContext () throws Exception {
207
+ Assume .assumeFalse (QUICKTEST );
208
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
209
+ logTestBegin (testMethodName );
210
+
211
+ // firstly ensure that original domain.yaml doesn't include the property-to-be-added
212
+ String domainFileName =
213
+ BaseTest .getUserProjectsDir () + "/weblogic-domains/" + domainUid + "/domain.yaml" ;
214
+ boolean result =
215
+ (new String (Files .readAllBytes (Paths .get (domainFileName )))).contains ("fsGroup: 1000" );
216
+ Assert .assertFalse (result );
217
+
218
+ // domainYaml: the yaml file name with changed property under resources dir
219
+ String domainYaml = "cont.security.context.domain.yaml" ;
220
+ logger .info (
221
+ "About to verifyDomainServerPodRestart for Domain: "
222
+ + domain .getDomainUid ()
223
+ + " change container securityContext:\n "
224
+ + " runAsUser: 1000\n "
225
+ + " fsGroup: 1000 " );
226
+ domain .verifyDomainServerPodRestart (domainYaml );
227
+ domain .findServerPropertyChange ("securityContext" , "admin-server" );
228
+ domain .findServerPropertyChange ("securityContext" , "managed-server1" );
229
+
230
+ logger .info ("SUCCESS - " + testMethodName );
231
+ }
232
+
233
+ /**
234
+ * Modify/Add the podSecurityContext section at ServerPod level using kubectl apply -f
235
+ * pod.security.context.domain.yaml. Verify all the pods re-started. The property tested is:
236
+ * podSecurityContext: runAsUser: 1000 fsGroup: 2000.
237
+ *
238
+ * @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
239
+ * are not restarted or after restart the server yaml file doesn't include the new added
240
+ * property
241
+ */
242
+ @ Test
243
+ public void testServerPodsRestartByChangingPodSecurityContext () throws Exception {
244
+ Assume .assumeFalse (QUICKTEST );
245
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
246
+ logTestBegin (testMethodName );
247
+
248
+ // firstly ensure that original domain.yaml doesn't include the property-to-be-added
249
+ String domainFileName =
250
+ BaseTest .getUserProjectsDir () + "/weblogic-domains/" + domainUid + "/domain.yaml" ;
251
+ boolean result =
252
+ (new String (Files .readAllBytes (Paths .get (domainFileName )))).contains ("fsGroup: 2000" );
253
+ Assert .assertFalse (result );
254
+
255
+ // domainYaml: the yaml file name with changed property under resources dir
256
+ String domainYaml = "pod.security.context.domain.yaml" ;
257
+
258
+ logger .info (
259
+ "About to verifyDomainServerPodRestart for Domain: "
260
+ + domain .getDomainUid ()
261
+ + " change securityContext:\n "
262
+ + " runAsUser: 1000\n "
263
+ + " fsGroup: 2000 " );
264
+ domain .verifyDomainServerPodRestart (domainYaml );
265
+ domain .findServerPropertyChange ("fsGroup: 2000" , "admin-server" );
266
+ domain .findServerPropertyChange ("fsGroup: 2000" , "managed-server1" );
267
+
268
+ logger .info ("SUCCESS - " + testMethodName );
269
+ }
270
+
271
+ /**
272
+ * Modify/Add resources at ServerPod level using kubectl apply -f domain.yaml. Verify all pods
273
+ * re-started. The property tested is: resources: limits: cpu: "1" requests: cpu: "0.5" args: -
274
+ * -cpus - "2".
275
+ *
276
+ * @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
277
+ * are not restarted or after restart the server yaml file doesn't include the new added
278
+ * property
279
+ */
280
+ @ Test
281
+ public void testServerPodsRestartByChangingResource () throws Exception {
282
+ Assume .assumeFalse (QUICKTEST );
283
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
284
+ logTestBegin (testMethodName );
285
+
286
+ // firstly ensure that original domain.yaml doesn't include the property-to-be-addeded
287
+ String domainFileName =
288
+ BaseTest .getUserProjectsDir () + "/weblogic-domains/" + domainUid + "/domain.yaml" ;
289
+ boolean result =
290
+ (new String (Files .readAllBytes (Paths .get (domainFileName )))).contains ("cpu: 500m" );
291
+ Assert .assertFalse (result );
292
+
293
+ // domainYaml: the yaml file name with changed property under resources dir
294
+ String domainYaml = "resource.domain.yaml" ;
295
+
296
+ logger .info (
297
+ "About to verifyDomainServerPodRestart for Domain: "
298
+ + domain .getDomainUid ()
299
+ + " change resource:\n "
300
+ + " cpu: 500m" );
301
+ domain .verifyDomainServerPodRestart (domainYaml );
302
+ domain .findServerPropertyChange ("cpu: 500m" , "admin-server" );
303
+ domain .findServerPropertyChange ("cpu: 500m" , "managed-server1" );
304
+
305
+ logger .info ("SUCCESS - " + testMethodName );
306
+ }
307
+
193
308
private static Domain createPodsRestartdomain () throws Exception {
194
309
195
310
Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
196
311
domainMap .put ("domainUID" , "domainpodsrestart" );
197
312
domainMap .put ("initialManagedServerReplicas" , new Integer ("1" ));
198
313
199
- logger .info ("Creating Domain domain& verifing the domain creation" );
314
+ domainUid = (String ) domainMap .get ("domainUID" );
315
+ logger .info ("Creating and verifying the domain creation with domainUid: " + domainUid );
316
+
200
317
domain = TestUtils .createDomain (domainMap );
201
318
domain .verifyDomainCreated ();
202
319
0 commit comments