20
20
import java .util .Map ;
21
21
import java .util .Properties ;
22
22
23
+ import io .kubernetes .client .custom .Quantity ;
23
24
import io .kubernetes .client .custom .V1Patch ;
24
25
import io .kubernetes .client .openapi .ApiException ;
25
26
import io .kubernetes .client .openapi .models .V1Container ;
26
27
import io .kubernetes .client .openapi .models .V1EnvVar ;
27
28
import io .kubernetes .client .openapi .models .V1Ingress ;
28
29
import io .kubernetes .client .openapi .models .V1LocalObjectReference ;
29
30
import io .kubernetes .client .openapi .models .V1ObjectMeta ;
30
- import io .kubernetes .client .openapi .models .V1PersistentVolumeClaimVolumeSource ;
31
31
import io .kubernetes .client .openapi .models .V1Pod ;
32
32
import io .kubernetes .client .openapi .models .V1ServiceBackendPort ;
33
- import io .kubernetes .client .openapi .models .V1Volume ;
34
- import io .kubernetes .client .openapi .models .V1VolumeMount ;
35
33
import oracle .weblogic .domain .AdminServer ;
36
34
import oracle .weblogic .domain .AdminService ;
37
35
import oracle .weblogic .domain .Channel ;
38
36
import oracle .weblogic .domain .ClusterResource ;
39
37
import oracle .weblogic .domain .ClusterStatus ;
40
38
import oracle .weblogic .domain .Configuration ;
39
+ import oracle .weblogic .domain .CreateIfNotExists ;
40
+ import oracle .weblogic .domain .DomainCreationImage ;
41
+ import oracle .weblogic .domain .DomainOnPV ;
42
+ import oracle .weblogic .domain .DomainOnPVType ;
41
43
import oracle .weblogic .domain .DomainResource ;
42
44
import oracle .weblogic .domain .DomainSpec ;
43
45
import oracle .weblogic .domain .Model ;
46
48
import oracle .weblogic .kubernetes .actions .impl .Ingress ;
47
49
import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
48
50
import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
51
+ import oracle .weblogic .kubernetes .actions .impl .primitive .WitParams ;
49
52
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
50
53
import oracle .weblogic .kubernetes .annotations .Namespaces ;
51
54
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
65
68
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_PATCH ;
66
69
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
67
70
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_PATCH ;
71
+ import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO_SECRET_NAME ;
68
72
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
69
73
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_IMAGES_PREFIX ;
70
74
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_IMAGES_REPO ;
87
91
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
88
92
import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
89
93
import static oracle .weblogic .kubernetes .actions .ActionConstants .ITTESTS_DIR ;
94
+ import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
90
95
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
91
96
import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
92
97
import static oracle .weblogic .kubernetes .actions .TestActions .deleteSecret ;
107
112
import static oracle .weblogic .kubernetes .assertions .TestAssertions .podStateNotChanged ;
108
113
import static oracle .weblogic .kubernetes .assertions .TestAssertions .verifyRollingRestartOccurred ;
109
114
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .verifyAdminServerRESTAccess ;
115
+ import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createAndPushAuxiliaryImage ;
110
116
import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterAndVerify ;
111
117
import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterResource ;
112
118
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodsNotRolled ;
128
134
import static oracle .weblogic .kubernetes .utils .DomainUtils .checkDomainStatusConditionTypeExists ;
129
135
import static oracle .weblogic .kubernetes .utils .DomainUtils .checkDomainStatusConditionTypeHasExpectedStatus ;
130
136
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
137
+ import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainResourceOnPv ;
131
138
import static oracle .weblogic .kubernetes .utils .DomainUtils .verifyDomainStatusConditionTypeDoesNotExist ;
139
+ import static oracle .weblogic .kubernetes .utils .FmwUtils .getConfiguration ;
132
140
import static oracle .weblogic .kubernetes .utils .ImageUtils .createMiiImageAndVerify ;
133
141
import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
134
142
import static oracle .weblogic .kubernetes .utils .ImageUtils .imageRepoLoginAndPushImageToRegistry ;
141
149
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
142
150
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
143
151
import static oracle .weblogic .kubernetes .utils .PatchDomainUtils .patchDomainResource ;
144
- import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPV ;
145
- import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPVC ;
146
152
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
147
153
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodExists ;
148
154
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
151
157
import static oracle .weblogic .kubernetes .utils .PodUtils .getPodsWithTimeStamps ;
152
158
import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
153
159
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
154
- import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretsForImageRepos ;
155
160
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
156
161
import static oracle .weblogic .kubernetes .utils .WLSTUtils .executeWLSTScript ;
157
162
import static org .apache .commons .io .FileUtils .copyDirectory ;
@@ -202,6 +207,7 @@ class ItIntrospectVersion {
202
207
203
208
private static final String pvName = getUniqueName (domainUid + "-pv-" );
204
209
private static final String pvcName = getUniqueName (domainUid + "-pvc-" );
210
+ private static final String storageClassName = "weblogic-domain-storage-class" ;
205
211
206
212
private static final String wlSecretName = "weblogic-credentials" ;
207
213
private static String wlsUserName = ADMIN_USERNAME_DEFAULT ;
@@ -1136,98 +1142,59 @@ void testIntrospectorMakeright() {
1136
1142
}
1137
1143
1138
1144
private static void createDomain () {
1139
- String uniquePath = "/shared/" + introDomainNamespace + "/domains" ;
1145
+ String uniqueDomainHome = "/shared/" + introDomainNamespace + "/domains/ " ;
1140
1146
1141
1147
// create WebLogic domain credential secret
1142
1148
createSecretWithUsernamePassword (wlSecretName , introDomainNamespace ,
1143
1149
wlsUserName , wlsPassword );
1144
- createPV (pvName , domainUid , ItIntrospectVersion .class .getSimpleName ());
1145
- createPVC (pvName , pvcName , domainUid , introDomainNamespace );
1146
-
1147
- // create a temporary WebLogic domain property file
1148
- File domainPropertiesFile = assertDoesNotThrow (() ->
1149
- File .createTempFile ("domain" , ".properties" , new File (RESULTS_TEMPFILE )),
1150
- "Failed to create domain properties file" );
1151
- Properties p = new Properties ();
1152
- p .setProperty ("domain_path" , uniquePath );
1153
- p .setProperty ("domain_name" , domainUid );
1154
- p .setProperty ("cluster_name" , cluster1Name );
1155
- p .setProperty ("admin_server_name" , adminServerName );
1156
- p .setProperty ("managed_server_port" , Integer .toString (managedServerPort ));
1157
- p .setProperty ("admin_server_port" , "7001" );
1158
- p .setProperty ("admin_username" , wlsUserName );
1159
- p .setProperty ("admin_password" , wlsPassword );
1160
- p .setProperty ("admin_t3_public_address" , K8S_NODEPORT_HOST );
1161
- p .setProperty ("admin_t3_channel_port" , Integer .toString (t3ChannelPort ));
1162
- p .setProperty ("number_of_ms" , "2" ); // maximum number of servers in cluster
1163
- p .setProperty ("managed_server_name_base" , cluster1ManagedServerNameBase );
1164
- p .setProperty ("domain_logs" , uniquePath + "/logs/" + domainUid );
1165
- p .setProperty ("production_mode_enabled" , "true" );
1166
- assertDoesNotThrow (() ->
1167
- p .store (new FileOutputStream (domainPropertiesFile ), "domain properties file" ),
1168
- "Failed to write domain properties file" );
1169
-
1170
- // WLST script for creating domain
1171
- Path wlstScript = Paths .get (RESOURCE_DIR , "python-scripts" , "wlst-create-domain-onpv.py" );
1172
-
1173
- // create configmap and domain on persistent volume using the WLST script and property file
1174
- createDomainOnPVUsingWlst (wlstScript , domainPropertiesFile .toPath (),
1175
- pvName , pvcName , introDomainNamespace );
1176
-
1177
- // create cluster object
1178
- String clusterResName = domainUid + "-" + cluster1Name ;
1179
- ClusterResource cluster = createClusterResource (clusterResName ,
1180
- cluster1Name , introDomainNamespace , cluster1ReplicaCount );
1181
-
1182
- logger .info ("Creating cluster resource {0} in namespace {1}" ,clusterResName , introDomainNamespace );
1183
- createClusterAndVerify (cluster );
1184
-
1185
- // create a domain custom resource configuration object
1150
+ final String wlsModelFilePrefix = "model-dci-introspect" ;
1151
+ final String wlsModelFile = wlsModelFilePrefix + ".yaml" ;
1152
+ File wlsModelPropFile = createWdtPropertyFile (wlsModelFilePrefix , K8S_NODEPORT_HOST , t3ChannelPort );
1153
+
1154
+ // create domainCreationImage
1155
+ String domainCreationImageName = DOMAIN_IMAGES_PREFIX + "introspect-domain-on-pv-image" ;
1156
+ // create image with model and wdt installation files
1157
+ WitParams witParams
1158
+ = new WitParams ()
1159
+ .modelImageName (domainCreationImageName )
1160
+ .modelImageTag (MII_BASIC_IMAGE_TAG )
1161
+ .modelFiles (Collections .singletonList (MODEL_DIR + "/" + wlsModelFile ))
1162
+ .modelVariableFiles (Collections .singletonList (wlsModelPropFile .getAbsolutePath ()));
1163
+ createAndPushAuxiliaryImage (domainCreationImageName , MII_BASIC_IMAGE_TAG , witParams );
1164
+
1165
+ DomainCreationImage domainCreationImage
1166
+ = new DomainCreationImage ().image (domainCreationImageName + ":" + MII_BASIC_IMAGE_TAG );
1167
+
1168
+ // create a domain resource
1186
1169
logger .info ("Creating domain custom resource" );
1187
- DomainResource domain = new DomainResource ()
1188
- .apiVersion (DOMAIN_API_VERSION )
1189
- .kind ("Domain" )
1190
- .metadata (new V1ObjectMeta ()
1191
- .name (domainUid )
1192
- .namespace (introDomainNamespace ))
1193
- .spec (new DomainSpec ()
1194
- .domainUid (domainUid )
1195
- .domainHome (uniquePath + "/" + domainUid ) // point to domain home in pv
1196
- .domainHomeSourceType ("PersistentVolume" ) // set the domain home source type as pv
1197
- .image (WEBLOGIC_IMAGE_TO_USE_IN_SPEC )
1198
- .imagePullPolicy (IMAGE_PULL_POLICY )
1199
- .webLogicCredentialsSecret (new V1LocalObjectReference ()
1200
- .name (wlSecretName ))
1201
- .includeServerOutInPodLog (true )
1202
- .logHomeEnabled (Boolean .TRUE )
1203
- .logHome (uniquePath + "/logs/" + domainUid )
1204
- .dataHome ("" )
1205
- .serverStartPolicy ("IfNeeded" )
1206
- .serverPod (new ServerPod () //serverpod
1207
- .addEnvItem (new V1EnvVar ()
1208
- .name ("USER_MEM_ARGS" )
1209
- .value ("-Djava.security.egd=file:/dev/./urandom " ))
1210
- .addVolumesItem (new V1Volume ()
1211
- .name (pvName )
1212
- .persistentVolumeClaim (new V1PersistentVolumeClaimVolumeSource ()
1213
- .claimName (pvcName )))
1214
- .addVolumeMountsItem (new V1VolumeMount ()
1215
- .mountPath ("/shared" )
1216
- .name (pvName )))
1217
- .adminServer (new AdminServer () //admin server
1218
- .adminService (new AdminService ()
1219
- .addChannelsItem (new Channel ()
1220
- .channelName ("default" )
1221
- .nodePort (getNextFreePort ())))));
1222
-
1223
- // create secrets
1224
- List <V1LocalObjectReference > secrets = new ArrayList <>();
1225
- for (String secret : createSecretsForImageRepos (introDomainNamespace )) {
1226
- secrets .add (new V1LocalObjectReference ().name (secret ));
1170
+ Map <String , Quantity > pvCapacity = new HashMap <>();
1171
+ pvCapacity .put ("storage" , new Quantity ("2Gi" ));
1172
+
1173
+ Map <String , Quantity > pvcRequest = new HashMap <>();
1174
+ pvcRequest .put ("storage" , new Quantity ("2Gi" ));
1175
+ Configuration configuration = null ;
1176
+ if (OKE_CLUSTER ) {
1177
+ configuration = getConfiguration (pvcName , pvcRequest , "oci-fss" );
1178
+ } else {
1179
+ configuration = getConfiguration (pvName , pvcName , pvCapacity , pvcRequest , storageClassName ,
1180
+ ItIntrospectVersion .class .getSimpleName ());
1227
1181
}
1228
- domain .spec ().setImagePullSecrets (secrets );
1229
- // set cluster references
1230
- domain .getSpec ().withCluster (new V1LocalObjectReference ().name (clusterResName ));
1182
+ configuration .getInitializeDomainOnPV ().domain (new DomainOnPV ()
1183
+ .createMode (CreateIfNotExists .DOMAIN )
1184
+ .domainCreationImages (Collections .singletonList (domainCreationImage ))
1185
+ .domainType (DomainOnPVType .WLS ));
1186
+
1187
+ DomainResource domain = createDomainResourceOnPv (domainUid ,
1188
+ introDomainNamespace ,
1189
+ wlSecretName ,
1190
+ cluster1Name ,
1191
+ pvName ,
1192
+ pvcName ,
1193
+ new String []{BASE_IMAGES_REPO_SECRET_NAME },
1194
+ uniqueDomainHome ,
1195
+ cluster1ReplicaCount ,
1196
+ t3ChannelPort ,
1197
+ configuration );
1231
1198
1232
1199
setPodAntiAffinity (domain );
1233
1200
// verify the domain custom resource is created
@@ -1392,7 +1359,7 @@ private static void verifyMemberHealth(String adminServerPodName, List<String> m
1392
1359
headers = new HashMap <>();
1393
1360
headers .put ("host" , hostHeader );
1394
1361
}
1395
-
1362
+
1396
1363
String url = "http://" + hostAndPort
1397
1364
+ "/clusterview/ClusterViewServlet?user=" + user + "&password=" + code + "&ipv6=" + ipv6 ;
1398
1365
HttpResponse <String > response ;
@@ -1575,7 +1542,10 @@ private DomainResource createDomainResourceWithConfigMap(String domainUid, Strin
1575
1542
private void updateIngressBackendServicePort (int newAdminPort ) throws ApiException {
1576
1543
String ingressName = introDomainNamespace + "-" + domainUid + "-" + adminServerName + "-7001" ;
1577
1544
V1Ingress ingress = Ingress .getIngress (introDomainNamespace , ingressName ).orElse (null );
1578
- if (ingress != null && ingress .getSpec () != null && ingress .getSpec ().getRules () != null ) {
1545
+ if (ingress != null
1546
+ && ingress .getSpec () != null
1547
+ && ingress .getSpec ().getRules () != null
1548
+ && !ingress .getSpec ().getRules ().isEmpty ()) {
1579
1549
logger .info ("Updating ingress {0} with new admin port {1}" , ingressName , newAdminPort );
1580
1550
ingress .getSpec ().getRules ().getFirst ().getHttp ()
1581
1551
.getPaths ().getFirst ().getBackend ().getService ()
@@ -1586,4 +1556,25 @@ private void updateIngressBackendServicePort(int newAdminPort) throws ApiExcepti
1586
1556
}
1587
1557
}
1588
1558
1559
+ public static File createWdtPropertyFile (String wlsModelFilePrefix , String nodePortHost , int t3Port ) {
1560
+
1561
+ // create property file used with domain model file
1562
+ Properties p = new Properties ();
1563
+ p .setProperty ("WebLogicAdminUserName" , ADMIN_USERNAME_DEFAULT );
1564
+ p .setProperty ("WebLogicAdminPassword" , ADMIN_PASSWORD_DEFAULT );
1565
+ p .setProperty ("K8S_NODEPORT_HOST" , nodePortHost );
1566
+ p .setProperty ("T3_CHANNEL_PORT" , Integer .toString (t3Port ));
1567
+
1568
+ // create a model property file
1569
+ File domainPropertiesFile = assertDoesNotThrow (() ->
1570
+ File .createTempFile (wlsModelFilePrefix , ".properties" , new File (RESULTS_TEMPFILE )),
1571
+ "Failed to create WLS model properties file" );
1572
+
1573
+ // create the property file
1574
+ assertDoesNotThrow (() ->
1575
+ p .store (new FileOutputStream (domainPropertiesFile ), "WLS properties file" ),
1576
+ "Failed to write WLS properties file" );
1577
+
1578
+ return domainPropertiesFile ;
1579
+ }
1589
1580
}
0 commit comments