55
66import java .io .File ;
77import java .io .FileOutputStream ;
8+ import java .net .http .HttpResponse ;
89import java .nio .file .Path ;
910import java .nio .file .Paths ;
1011import java .util .List ;
1516import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
1617import oracle .weblogic .kubernetes .annotations .Namespaces ;
1718import oracle .weblogic .kubernetes .logging .LoggingFacade ;
19+ import oracle .weblogic .kubernetes .utils .OracleHttpClient ;
1820import org .junit .jupiter .api .BeforeAll ;
1921import org .junit .jupiter .api .DisplayName ;
2022import org .junit .jupiter .api .Tag ;
2123import org .junit .jupiter .api .Test ;
2224
2325import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
2426import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
27+ import static oracle .weblogic .kubernetes .TestConstants .OKD ;
2528import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
29+ import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
2630import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
2731import static oracle .weblogic .kubernetes .actions .TestActions .getNextIntrospectVersion ;
2832import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
2933import static oracle .weblogic .kubernetes .actions .TestActions .getServicePort ;
3034import static oracle .weblogic .kubernetes .actions .impl .Domain .patchDomainCustomResource ;
31- import static oracle .weblogic .kubernetes .assertions .TestAssertions .adminNodePortAccessible ;
35+ import static oracle .weblogic .kubernetes .utils .ApplicationUtils .verifyAdminServerRESTAccess ;
36+ import static oracle .weblogic .kubernetes .utils .ApplicationUtils .verifyAdminServerRESTAccessInAdminPod ;
3237import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
33- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .isAppInServerPodReady ;
38+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
3439import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
3540import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainOnPvUsingWdt ;
3641import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
@@ -56,14 +61,17 @@ class ItAddNewDynamicClusterUsingWlst {
5661
5762 // domain constants
5863 private static final String domainUid = "dynasconfigcluster-domain-1" ;
59- private static final String adminServerPodName = domainUid + "-admin-server" ;
64+ private static final String adminServerName = "admin-server" ;
65+ private static final String adminServerPodName = domainUid + "-" + adminServerName ;
66+ private static final int adminPort = 7001 ;
6067 private static final String newManagedServerPrefix = "new-managed-server" ;
6168 private static final String newManagedServerPodPrefix = domainUid + "-" + newManagedServerPrefix ;
6269 private static final String clusterName = "cluster-1" ;
6370 private static final String newClusterName = "cluster-2" ;
6471 private static final int replicaCount = 2 ;
6572 private static final String wlSecretName = "weblogic-credentials" ;
6673 private static String domainNamespace = null ;
74+ private static String hostHeader ;
6775
6876 private static LoggingFacade logger = null ;
6977
@@ -104,6 +112,13 @@ void testDynamicClusterNotAsConfigCluster() {
104112 DomainResource domain = createDomainOnPvUsingWdt (domainUid , domainNamespace , wlSecretName ,
105113 clusterName , replicaCount , ItAddNewDynamicClusterUsingWlst .class .getSimpleName ());
106114 assertDomainNotNull (domain );
115+
116+ if (TestConstants .KIND_CLUSTER
117+ && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
118+ hostHeader = createIngressHostRouting (domainNamespace , domainUid , adminServerName , adminPort );
119+ assertDoesNotThrow (() -> verifyAdminServerRESTAccess ("localhost" ,
120+ TRAEFIK_INGRESS_HTTP_HOSTPORT , false , hostHeader ));
121+ }
107122
108123 // get admin service node port
109124 logger .info ("Getting node port for default channel" );
@@ -116,15 +131,16 @@ void testDynamicClusterNotAsConfigCluster() {
116131
117132 logger .info ("Validating WebLogic admin server access by login to console" );
118133 if (OKE_CLUSTER ) {
119- testUntil (isAppInServerPodReady (domainNamespace ,
120- adminServerPodName , 7001 , "/console/login/LoginForm.jsp" , "Copyright" ),
121- logger , "Validating WebLogic admin server access by login to console" );
122- } else {
123- testUntil (
124- assertDoesNotThrow (() -> {
125- return adminNodePortAccessible (serviceNodePort ,
126- ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT , routeHost );
127- }, "Access to admin server node port failed" ), logger , "Console login validation" );
134+ testUntil (() -> verifyAdminServerRESTAccessInAdminPod (adminServerPodName , "7001" ,
135+ domainNamespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ),
136+ logger , "Validating WebLogic admin server access using REST api" );
137+ } else if (OKD ) {
138+ testUntil (() -> {
139+ String url = "http://" + routeHost + ":" + serviceNodePort + "/management/tenant-monitoring/servers/" ;
140+ HttpResponse <String > response ;
141+ response = OracleHttpClient .get (url , null , true );
142+ return response .body ().contains ("RUNNING" );
143+ }, logger , "Access to admin server failed" );
128144 }
129145
130146 // create a new dynamic cluster using an online WLST script
@@ -143,7 +159,7 @@ private void createNewDynamicCluster() {
143159 // get port for default channel
144160 logger .info ("Getting port for default channel" );
145161 int defaultChannelPort = assertDoesNotThrow (()
146- -> getServicePort (domainNamespace , getExternalServicePodName ( adminServerPodName ) , "default" ),
162+ -> getServicePort (domainNamespace , adminServerPodName , "default" ),
147163 "Getting admin server default port failed" );
148164 assertNotEquals (-1 , defaultChannelPort , "Couldn't get valid port for default channel" );
149165 logger .info ("default channel port: {0}" , defaultChannelPort );
0 commit comments