17
17
import java .util .Properties ;
18
18
import java .util .concurrent .TimeUnit ;
19
19
20
- import com .gargoylesoftware .htmlunit .WebClient ;
21
- import com .gargoylesoftware .htmlunit .html .HtmlElement ;
22
- import com .gargoylesoftware .htmlunit .html .HtmlForm ;
23
- import com .gargoylesoftware .htmlunit .html .HtmlPage ;
24
20
import io .kubernetes .client .custom .Quantity ;
25
21
import io .kubernetes .client .openapi .models .V1ConfigMapVolumeSource ;
26
22
import io .kubernetes .client .openapi .models .V1Container ;
50
46
import oracle .weblogic .domain .DomainSpec ;
51
47
import oracle .weblogic .domain .ServerPod ;
52
48
import oracle .weblogic .kubernetes .TestConstants ;
53
- import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
54
- import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
55
49
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
56
50
57
51
import static java .nio .file .Files .copy ;
73
67
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
74
68
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
75
69
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
76
- import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_SLIM ;
77
70
import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
78
71
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
79
72
import static oracle .weblogic .kubernetes .actions .TestActions .getPodLog ;
@@ -445,14 +438,13 @@ private static DomainResource createDomainCustomResource(String domainUid,
445
438
*/
446
439
private static boolean adminNodePortAccessible (int nodePort )
447
440
throws IOException {
448
- if (WEBLOGIC_SLIM ) {
449
- getLogger ().info ("Check REST Console for WebLogic slim image" );
450
- StringBuffer curlCmd = new StringBuffer ("status=$(curl -g --user " );
451
- String host = K8S_NODEPORT_HOST ;
452
- if (host .contains (":" )) {
453
- host = "[" + host + "]" ;
454
- }
455
- curlCmd .append (ADMIN_USERNAME_DEFAULT )
441
+ getLogger ().info ("Check REST Console for WebLogic Image" );
442
+ StringBuffer curlCmd = new StringBuffer ("status=$(curl -g --user " );
443
+ String host = K8S_NODEPORT_HOST ;
444
+ if (host .contains (":" )) {
445
+ host = "[" + host + "]" ;
446
+ }
447
+ curlCmd .append (ADMIN_USERNAME_DEFAULT )
456
448
.append (":" )
457
449
.append (ADMIN_PASSWORD_DEFAULT )
458
450
.append (" http://" )
@@ -461,72 +453,36 @@ private static boolean adminNodePortAccessible(int nodePort)
461
453
.append (nodePort )
462
454
.append ("/management/tenant-monitoring/servers/ --silent --show-error -o /dev/null -w %{http_code}); " )
463
455
.append ("echo ${status}" );
464
- getLogger ().info ("checkRestConsole : curl command {0}" , new String (curlCmd ));
465
- try {
466
- ExecResult result = ExecCommand .exec (new String (curlCmd ), true );
467
- String response = result .stdout ().trim ();
468
- getLogger ().info ("exitCode: {0}, \n stdout: {1}, \n stderr: {2}" ,
456
+ getLogger ().info ("checkRestConsole : curl command {0}" , new String (curlCmd ));
457
+ try {
458
+ ExecResult result = ExecCommand .exec (new String (curlCmd ), true );
459
+ String response = result .stdout ().trim ();
460
+ getLogger ().info ("exitCode: {0}, \n stdout: {1}, \n stderr: {2}" ,
469
461
result .exitValue (), response , result .stderr ());
470
- return response .contains ("200" );
471
- } catch (IOException | InterruptedException ex ) {
472
- getLogger ().info ("Exception in checkRestConsole {0}" , ex );
473
- return false ;
474
- }
475
- } else {
476
- // generic/dev Image
477
- String host = K8S_NODEPORT_HOST ;
478
- if (host .contains (":" )) {
479
- host = "[" + host + "]" ;
480
- }
481
- getLogger ().info ("Check administration Console for generic/dev image" );
482
- String consoleUrl = new StringBuffer ()
483
- .append ("http://" )
484
- .append (host )
485
- .append (":" )
486
- .append (nodePort )
487
- .append ("/console/login/LoginForm.jsp" ).toString ();
488
-
489
- boolean adminAccessible = false ;
490
- for (int i = 1 ; i <= 10 ; i ++) {
491
- getLogger ().info ("Iteration {0} out of 10: Accessing WebLogic console with url {1}" , i , consoleUrl );
492
- final WebClient webClient = new WebClient ();
493
- webClient .getOptions ().setThrowExceptionOnFailingStatusCode (false );
494
- final HtmlPage loginPage = assertDoesNotThrow (() -> webClient .getPage (consoleUrl ),
495
- "connection to the WebLogic admin console failed" );
496
- HtmlForm form = loginPage .getFormByName ("loginData" );
497
- form .getInputByName ("j_username" ).type (ADMIN_USERNAME_DEFAULT );
498
- form .getInputByName ("j_password" ).type (ADMIN_PASSWORD_DEFAULT );
499
- HtmlElement submit = form .getOneHtmlElementByAttribute ("input" , "type" , "submit" );
500
- getLogger ().info ("Clicking login button" );
501
- HtmlPage home = submit .click ();
502
- if (home .asNormalizedText ().contains ("Persistent Stores" )) {
503
- getLogger ().info ("Console login passed" );
504
- adminAccessible = true ;
505
- break ;
506
- }
507
- }
508
- return adminAccessible ;
462
+ return response .contains ("200" );
463
+ } catch (IOException | InterruptedException ex ) {
464
+ getLogger ().info ("Exception in checkRestConsole {0}" , ex );
465
+ return false ;
509
466
}
510
467
}
511
468
512
469
/**
513
- * Verify admin console is accessible by login to WebLogic console .
470
+ * Verify REST console is accessible by login to WebLogic Server .
514
471
*
515
472
* @param adminServerPodName admin server pod
516
473
* @param adminPort admin port
517
474
* @param namespace admin server pod namespace
518
475
* @param userName WebLogic administration server user name
519
476
* @param password WebLogic administration server password
520
- * @return true if login to WebLogic administration console is successful
477
+ * @return true if login to WebLogic REST console is successful
521
478
* @throws IOException when connection to console fails
522
479
*/
523
480
public static boolean adminLoginPageAccessible (String adminServerPodName , String adminPort , String namespace ,
524
481
String userName , String password )
525
482
throws IOException {
526
483
LoggingFacade logger = getLogger ();
527
- if (WEBLOGIC_SLIM ) {
528
- logger .info ("Check REST Console for WebLogic slim image" );
529
- StringBuffer curlCmd = new StringBuffer (KUBERNETES_CLI + " exec -n "
484
+ logger .info ("Check REST Console for WebLogic Image" );
485
+ StringBuffer curlCmd = new StringBuffer (KUBERNETES_CLI + " exec -n "
530
486
+ namespace + " " + adminServerPodName )
531
487
.append (" -- /bin/bash -c \" " )
532
488
.append ("curl -g --user " )
@@ -535,48 +491,17 @@ public static boolean adminLoginPageAccessible(String adminServerPodName, String
535
491
.append (password )
536
492
.append (" http://" + adminServerPodName + ":" + adminPort )
537
493
.append ("/management/tenant-monitoring/servers/ --silent --show-error -o /dev/null -w %{http_code} && " )
538
- .append ("echo ${status}" );
539
- logger .info ("checkRestConsole : curl command {0}" , new String (curlCmd ));
540
- try {
541
- ExecResult result = ExecCommand .exec (new String (curlCmd ), true );
542
- String response = result .stdout ().trim ();
543
- logger .info ("exitCode: {0}, \n stdout: {1}, \n stderr: {2}" ,
494
+ .append ("echo ${status}\" " );
495
+ logger .info ("checkRestConsole : k8s exec command {0}" , new String (curlCmd ));
496
+ try {
497
+ ExecResult result = ExecCommand .exec (new String (curlCmd ), true );
498
+ String response = result .stdout ().trim ();
499
+ logger .info ("exitCode: {0}, \n stdout: {1}, \n stderr: {2}" ,
544
500
result .exitValue (), response , result .stderr ());
545
- return response .contains ("200" );
546
- } catch (IOException | InterruptedException ex ) {
547
- logger .info ("Exception in checkRestConsole {0}" , ex );
548
- return false ;
549
- }
550
- } else {
551
- // generic/dev Image
552
- logger .info ("Check administration Console for generic/dev image" );
553
- String curlCmd = new StringBuffer (KUBERNETES_CLI + " exec -n "
554
- + namespace + " " + adminServerPodName )
555
- .append (" -- /bin/bash -c \" " )
556
- .append ("curl --user " )
557
- .append (userName )
558
- .append (":" )
559
- .append (password )
560
- .append (" http://" + adminServerPodName + ":" + adminPort )
561
- .append ("/console/login/LoginForm.jsp" )
562
- .append ("\" " ).toString ();
563
-
564
- boolean adminAccessible = false ;
565
- String expectedValue = "Oracle WebLogic Server Administration Console" ;
566
- for (int i = 1 ; i <= 10 ; i ++) {
567
- logger .info ("Iteration {0} out of 10: Accessing WebLogic console " , i );
568
- logger .info ("check administration console: curl command {0} expectedValue {1}" , curlCmd , expectedValue );
569
- adminAccessible = Command
570
- .withParams (new CommandParams ()
571
- .command (curlCmd ))
572
- .executeAndVerify (expectedValue );
573
-
574
- if (adminAccessible ) {
575
- getLogger ().info ("Console login passed" );
576
- break ;
577
- }
578
- }
579
- return adminAccessible ;
501
+ return response .contains ("200" );
502
+ } catch (IOException | InterruptedException ex ) {
503
+ logger .info ("Exception in checkRestConsole {0}" , ex );
504
+ return false ;
580
505
}
581
506
}
582
507
@@ -923,7 +848,7 @@ public static void verifyAdminServerAccess(boolean isTLS,
923
848
consoleUrl .append (pathLocation );
924
849
}
925
850
926
- consoleUrl .append ("/console/login/LoginForm.jsp " );
851
+ consoleUrl .append ("/weblogic/ready " );
927
852
String curlCmd ;
928
853
if (isHostRouting ) {
929
854
curlCmd = String .format ("curl -g -ks --show-error --noproxy '*' -H 'host: %s' %s" ,
0 commit comments