5
5
6
6
import java .io .File ;
7
7
import java .io .FileOutputStream ;
8
+ import java .net .http .HttpResponse ;
8
9
import java .nio .file .Path ;
9
10
import java .nio .file .Paths ;
10
11
import java .util .List ;
15
16
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
16
17
import oracle .weblogic .kubernetes .annotations .Namespaces ;
17
18
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
19
+ import oracle .weblogic .kubernetes .utils .OracleHttpClient ;
18
20
import org .junit .jupiter .api .BeforeAll ;
19
21
import org .junit .jupiter .api .DisplayName ;
20
22
import org .junit .jupiter .api .Tag ;
21
23
import org .junit .jupiter .api .Test ;
22
24
23
25
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
24
26
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
27
+ import static oracle .weblogic .kubernetes .TestConstants .OKD ;
25
28
import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
29
+ import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
26
30
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
27
31
import static oracle .weblogic .kubernetes .actions .TestActions .getNextIntrospectVersion ;
28
32
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
29
33
import static oracle .weblogic .kubernetes .actions .TestActions .getServicePort ;
30
34
import 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 ;
32
37
import 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 ;
34
39
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
35
40
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainOnPvUsingWdt ;
36
41
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
@@ -56,14 +61,17 @@ class ItAddNewDynamicClusterUsingWlst {
56
61
57
62
// domain constants
58
63
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 ;
60
67
private static final String newManagedServerPrefix = "new-managed-server" ;
61
68
private static final String newManagedServerPodPrefix = domainUid + "-" + newManagedServerPrefix ;
62
69
private static final String clusterName = "cluster-1" ;
63
70
private static final String newClusterName = "cluster-2" ;
64
71
private static final int replicaCount = 2 ;
65
72
private static final String wlSecretName = "weblogic-credentials" ;
66
73
private static String domainNamespace = null ;
74
+ private static String hostHeader ;
67
75
68
76
private static LoggingFacade logger = null ;
69
77
@@ -104,6 +112,13 @@ void testDynamicClusterNotAsConfigCluster() {
104
112
DomainResource domain = createDomainOnPvUsingWdt (domainUid , domainNamespace , wlSecretName ,
105
113
clusterName , replicaCount , ItAddNewDynamicClusterUsingWlst .class .getSimpleName ());
106
114
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
+ }
107
122
108
123
// get admin service node port
109
124
logger .info ("Getting node port for default channel" );
@@ -116,15 +131,16 @@ void testDynamicClusterNotAsConfigCluster() {
116
131
117
132
logger .info ("Validating WebLogic admin server access by login to console" );
118
133
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" );
128
144
}
129
145
130
146
// create a new dynamic cluster using an online WLST script
@@ -143,7 +159,7 @@ private void createNewDynamicCluster() {
143
159
// get port for default channel
144
160
logger .info ("Getting port for default channel" );
145
161
int defaultChannelPort = assertDoesNotThrow (()
146
- -> getServicePort (domainNamespace , getExternalServicePodName ( adminServerPodName ) , "default" ),
162
+ -> getServicePort (domainNamespace , adminServerPodName , "default" ),
147
163
"Getting admin server default port failed" );
148
164
assertNotEquals (-1 , defaultChannelPort , "Couldn't get valid port for default channel" );
149
165
logger .info ("default channel port: {0}" , defaultChannelPort );
0 commit comments