1717import java .util .Properties ;
1818import java .util .concurrent .TimeUnit ;
1919
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 ;
2420import io .kubernetes .client .custom .Quantity ;
2521import io .kubernetes .client .openapi .models .V1ConfigMapVolumeSource ;
2622import io .kubernetes .client .openapi .models .V1Container ;
5046import oracle .weblogic .domain .DomainSpec ;
5147import oracle .weblogic .domain .ServerPod ;
5248import oracle .weblogic .kubernetes .TestConstants ;
53- import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
54- import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
5549import oracle .weblogic .kubernetes .logging .LoggingFacade ;
5650
5751import static java .nio .file .Files .copy ;
7367import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
7468import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
7569import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
76- import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_SLIM ;
7770import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
7871import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
7972import static oracle .weblogic .kubernetes .actions .TestActions .getPodLog ;
@@ -445,14 +438,13 @@ private static DomainResource createDomainCustomResource(String domainUid,
445438 */
446439 private static boolean adminNodePortAccessible (int nodePort )
447440 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 )
456448 .append (":" )
457449 .append (ADMIN_PASSWORD_DEFAULT )
458450 .append (" http://" )
@@ -461,72 +453,36 @@ private static boolean adminNodePortAccessible(int nodePort)
461453 .append (nodePort )
462454 .append ("/management/tenant-monitoring/servers/ --silent --show-error -o /dev/null -w %{http_code}); " )
463455 .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}" ,
469461 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 ;
509466 }
510467 }
511468
512469 /**
513- * Verify admin console is accessible by login to WebLogic console .
470+ * Verify REST console is accessible by login to WebLogic Server .
514471 *
515472 * @param adminServerPodName admin server pod
516473 * @param adminPort admin port
517474 * @param namespace admin server pod namespace
518475 * @param userName WebLogic administration server user name
519476 * @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
521478 * @throws IOException when connection to console fails
522479 */
523480 public static boolean adminLoginPageAccessible (String adminServerPodName , String adminPort , String namespace ,
524481 String userName , String password )
525482 throws IOException {
526483 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 "
530486 + namespace + " " + adminServerPodName )
531487 .append (" -- /bin/bash -c \" " )
532488 .append ("curl -g --user " )
@@ -535,48 +491,17 @@ public static boolean adminLoginPageAccessible(String adminServerPodName, String
535491 .append (password )
536492 .append (" http://" + adminServerPodName + ":" + adminPort )
537493 .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}" ,
544500 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 ;
580505 }
581506 }
582507
@@ -923,7 +848,7 @@ public static void verifyAdminServerAccess(boolean isTLS,
923848 consoleUrl .append (pathLocation );
924849 }
925850
926- consoleUrl .append ("/console/login/LoginForm.jsp " );
851+ consoleUrl .append ("/weblogic/ready " );
927852 String curlCmd ;
928853 if (isHostRouting ) {
929854 curlCmd = String .format ("curl -g -ks --show-error --noproxy '*' -H 'host: %s' %s" ,
0 commit comments