9
9
import java .util .regex .Matcher ;
10
10
import java .util .regex .Pattern ;
11
11
import oracle .kubernetes .operator .utils .Domain ;
12
- import oracle .kubernetes .operator .utils .ExecCommand ;
13
12
import oracle .kubernetes .operator .utils .ExecResult ;
14
13
import oracle .kubernetes .operator .utils .Operator ;
15
14
import oracle .kubernetes .operator .utils .TestUtils ;
30
29
public class ITSessionMigration extends BaseTest {
31
30
private static final String testAppName = "httpsessionreptestapp" ;
32
31
private static final String scriptName = "buildDeployAppInPod.sh" ;
33
-
34
32
private static Map <String , String > httpAttrMap ;
35
-
36
33
private static String httpHeaderFile ;
37
-
38
34
private static Operator operator ;
39
35
private static Domain domain ;
40
36
@@ -70,7 +66,6 @@ public static void staticPrepare() throws Exception {
70
66
}
71
67
72
68
httpHeaderFile = BaseTest .getResultDir () + "/headers" ;
73
-
74
69
httpAttrMap = new HashMap <String , String >();
75
70
httpAttrMap .put ("sessioncreatetime" , "(.*)sessioncreatetime>(.*)</sessioncreatetime(.*)" );
76
71
httpAttrMap .put ("sessionid" , "(.*)sessionid>(.*)</sessionid(.*)" );
@@ -133,7 +128,7 @@ public void testRepickPrimary() throws Exception {
133
128
String sessCreateTime1 = getHttpResponseAttribute (result .stdout (), sessCreateTime );
134
129
135
130
// Stop primary server
136
- stopPrimaryServer (primaryServName1 );
131
+ domain . shutdownManagedServerUsingServerStartPolicy (primaryServName1 );
137
132
138
133
// Send the second HTTP request using HTTP header/sessionID info save before
139
134
result = getHTTPResponse (testAppPath , " -b " );
@@ -151,6 +146,7 @@ public void testRepickPrimary() throws Exception {
151
146
primaryServName1 .trim ().equals (primaryServName2 .trim ()));
152
147
153
148
// Restore test env
149
+ domain .restartManagedServerUsingServerStartPolicy (primaryServName1 );
154
150
TestUtils .checkPodReady (domainUid + "-" + primaryServName1 , domainNS );
155
151
156
152
logger .info (
@@ -189,7 +185,7 @@ public void testHttpSessionMigr() throws Exception {
189
185
String countattribute1 = getHttpResponseAttribute (result .stdout (), count );
190
186
191
187
// Stop primary server
192
- stopPrimaryServer (primaryServName1 );
188
+ domain . shutdownManagedServerUsingServerStartPolicy (primaryServName1 );
193
189
194
190
// Send the second HTTP request using HTTP header/sessionID info save before
195
191
result = getHTTPResponse (webServiceGetUrl , " -b " );
@@ -209,6 +205,7 @@ public void testHttpSessionMigr() throws Exception {
209
205
"HTTP session state is NOT migrated!" , countattribute1 .equals (countattribute2 ));
210
206
211
207
// Restore test env
208
+ domain .restartManagedServerUsingServerStartPolicy (primaryServName1 );
212
209
TestUtils .checkPodReady (domainUid + "-" + primaryServName1 , domainNS );
213
210
214
211
logger .info ("SUCCESS - " + testMethodName + ". HTTP session state is migrated!" );
@@ -226,45 +223,11 @@ private ExecResult getHTTPResponse(String webServiceURL, String headerOption) th
226
223
String curlCmd = buildWebServiceUrl (webServiceURL , headerOption + httpHeaderFile );
227
224
logger .info ("Send a HTTP request: " + curlCmd );
228
225
229
- ExecResult result = ExecCommand .exec (curlCmd );
230
-
231
- if (result .exitValue () != 0 ) {
232
- throw new Exception (
233
- "FAILURE: command "
234
- + curlCmd
235
- + " failed, returned "
236
- + result .stderr ()
237
- + "\n "
238
- + result .stdout ());
239
- }
226
+ ExecResult result = TestUtils .exec (curlCmd );
240
227
241
228
return result ;
242
229
}
243
230
244
- /**
245
- * Stop the primary server
246
- *
247
- * @param primaryServerName - weblogic primary server name
248
- * @throws Exception
249
- */
250
- private void stopPrimaryServer (String primaryServerName ) throws Exception {
251
- Map <String , Object > domainMap = domain .getDomainMap ();
252
- String domainNS = domainMap .get ("namespace" ).toString ();
253
- String domainUid = domain .getDomainUid ();
254
-
255
- // stop primary server
256
- String msPodName = domainUid + "-" + primaryServerName ;
257
- String cmd = "kubectl delete po/" + msPodName + " -n " + domainNS ;
258
- logger .info ("Stop managed server <" + msPodName + "> using command:\n " + cmd );
259
-
260
- ExecResult result = ExecCommand .exec (cmd );
261
- if (result .exitValue () != 0 ) {
262
- throw new Exception ("FAILURE: command " + cmd + " failed, returned " + result .stderr ());
263
- }
264
-
265
- logger .info (result .stdout ());
266
- }
267
-
268
231
/**
269
232
* Get the value of a HTTP attribute
270
233
*
@@ -274,11 +237,8 @@ private void stopPrimaryServer(String primaryServerName) throws Exception {
274
237
*/
275
238
private String getHttpResponseAttribute (String httpResponseString , String attribute )
276
239
throws Exception {
277
-
278
240
String attrPatn = httpAttrMap .get (attribute );
279
-
280
241
Assume .assumeNotNull (attrPatn );
281
-
282
242
String httpAttribute = null ;
283
243
284
244
Pattern pattern = Pattern .compile (attrPatn );
@@ -316,28 +276,4 @@ private String buildWebServiceUrl(String curlURLPath, String paramToAppend) thro
316
276
317
277
return webServiceUrl .toString ();
318
278
}
319
-
320
- /**
321
- * Execute a given curl command and verify the results
322
- *
323
- * @param curlCmd - a curl command to execute
324
- * @throws Exception
325
- */
326
- private ExecResult execCurlCmd (String curlCmd ) throws Exception {
327
- logger .info ("curl command to exec is:\n " + curlCmd );
328
-
329
- ExecResult result = ExecCommand .exec (curlCmd );
330
-
331
- if (result .exitValue () != 0 ) {
332
- throw new Exception (
333
- "FAILURE: command "
334
- + curlCmd
335
- + " failed, returned "
336
- + result .stderr ()
337
- + "\n "
338
- + result .stdout ());
339
- }
340
-
341
- return result ;
342
- }
343
279
}
0 commit comments