13
13
import java .nio .file .StandardCopyOption ;
14
14
import java .time .OffsetDateTime ;
15
15
import java .util .ArrayList ;
16
- import java .util .Arrays ;
16
+ import java .util .Collections ;
17
17
import java .util .HashMap ;
18
18
import java .util .LinkedHashMap ;
19
19
import java .util .List ;
22
22
import java .util .concurrent .Callable ;
23
23
import java .util .concurrent .TimeUnit ;
24
24
25
+ import io .kubernetes .client .custom .Quantity ;
25
26
import io .kubernetes .client .custom .V1Patch ;
26
27
import io .kubernetes .client .openapi .ApiException ;
27
28
import io .kubernetes .client .openapi .models .V1Container ;
28
29
import io .kubernetes .client .openapi .models .V1EnvVar ;
29
- import io .kubernetes .client .openapi .models .V1LocalObjectReference ;
30
30
import io .kubernetes .client .openapi .models .V1ObjectMeta ;
31
- import io .kubernetes .client .openapi .models .V1PersistentVolumeClaimVolumeSource ;
32
31
import io .kubernetes .client .openapi .models .V1Pod ;
33
32
import io .kubernetes .client .openapi .models .V1Secret ;
34
33
import io .kubernetes .client .openapi .models .V1Service ;
35
- import io .kubernetes .client .openapi .models .V1Volume ;
36
- import io .kubernetes .client .openapi .models .V1VolumeMount ;
37
- import oracle .weblogic .domain .AdminServer ;
38
- import oracle .weblogic .domain .AdminService ;
39
- import oracle .weblogic .domain .Channel ;
40
- import oracle .weblogic .domain .ClusterResource ;
34
+ import io .kubernetes .client .util .Yaml ;
41
35
import oracle .weblogic .domain .Configuration ;
36
+ import oracle .weblogic .domain .CreateIfNotExists ;
37
+ import oracle .weblogic .domain .DomainCreationImage ;
38
+ import oracle .weblogic .domain .DomainOnPV ;
39
+ import oracle .weblogic .domain .DomainOnPVType ;
42
40
import oracle .weblogic .domain .DomainResource ;
43
- import oracle .weblogic .domain .DomainSpec ;
44
- import oracle .weblogic .domain .ServerPod ;
45
41
import oracle .weblogic .kubernetes .actions .impl .NginxParams ;
46
42
import oracle .weblogic .kubernetes .actions .impl .Service ;
47
43
import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
44
+ import oracle .weblogic .kubernetes .actions .impl .primitive .WitParams ;
48
45
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
49
46
import oracle .weblogic .kubernetes .annotations .Namespaces ;
50
47
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
64
61
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
65
62
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
66
63
import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO_SECRET_NAME ;
67
- import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
68
- import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
64
+ import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_IMAGES_PREFIX ;
69
65
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
70
66
import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
67
+ import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
68
+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
71
69
import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER_PRIVATEIP ;
72
70
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_TEMPFILE ;
73
71
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
74
72
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_12213 ;
75
73
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
76
74
import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
75
+ import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
77
76
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
78
77
import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
79
78
import static oracle .weblogic .kubernetes .actions .TestActions .createSecret ;
89
88
import static oracle .weblogic .kubernetes .actions .impl .Domain .patchDomainCustomResource ;
90
89
import static oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes .listConfigMaps ;
91
90
import static oracle .weblogic .kubernetes .assertions .TestAssertions .podStateNotChanged ;
91
+ import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createAndPushAuxiliaryImage ;
92
92
import static oracle .weblogic .kubernetes .utils .BuildApplication .buildApplication ;
93
- import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterAndVerify ;
94
- import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterResource ;
95
93
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
96
94
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
97
95
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
104
102
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapFromFiles ;
105
103
import static oracle .weblogic .kubernetes .utils .DeployUtil .deployUsingWlst ;
106
104
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
105
+ import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainResourceOnPv ;
107
106
import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
108
107
import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
108
+ import static oracle .weblogic .kubernetes .utils .FmwUtils .getConfiguration ;
109
109
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
110
110
import static oracle .weblogic .kubernetes .utils .JobUtils .createDomainJob ;
111
111
import static oracle .weblogic .kubernetes .utils .JobUtils .getIntrospectJobName ;
114
114
import static oracle .weblogic .kubernetes .utils .MySQLDBUtils .createMySQLDB ;
115
115
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
116
116
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
117
- import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPV ;
118
- import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPVC ;
119
117
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
120
118
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodExists ;
121
119
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
122
120
import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
123
121
import static oracle .weblogic .kubernetes .utils .PodUtils .getPodCreationTime ;
124
- import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
125
122
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
126
123
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
127
124
import static oracle .weblogic .kubernetes .utils .WLSTUtils .executeWLSTScript ;
@@ -155,8 +152,7 @@ class ItConfigDistributionStrategy {
155
152
final String adminServerName = "admin-server" ;
156
153
final int adminPort = 7001 ;
157
154
final String adminServerPodName = domainUid + "-" + adminServerName ;
158
- final String managedServerNameBase = "ms-" ;
159
- final int managedServerPort = 8001 ;
155
+ final String managedServerNameBase = "managed-server" ;
160
156
int t3ChannelPort ;
161
157
final String pvName = getUniqueName (domainUid + "-pv-" );
162
158
final String pvcName = getUniqueName (domainUid + "-pvc-" );
@@ -169,12 +165,8 @@ class ItConfigDistributionStrategy {
169
165
String overridecm = "configoverride-cm" ;
170
166
LinkedHashMap <String , OffsetDateTime > podTimestamps ;
171
167
172
- static int mysqlDBPort1 ;
173
- static int mysqlDBPort2 ;
174
168
static String dsUrl1 ;
175
169
static String dsUrl2 ;
176
- static String mysql1SvcEndpoint = null ;
177
- static String mysql2SvcEndpoint = null ;
178
170
private static String ingressIP = null ;
179
171
180
172
String dsName0 = "JdbcTestDataSource-0" ;
@@ -983,104 +975,67 @@ private void verifyIntrospectorRuns() {
983
975
984
976
//create a standard WebLogic domain.
985
977
private void createDomain () {
986
-
987
- String uniquePath = "/shared/" + domainNamespace + "/domains" ;
978
+ String uniqueDomainHome = "/shared/" + domainNamespace + "/domains" ;
988
979
989
980
// create WebLogic domain credential secret
990
981
createSecretWithUsernamePassword (wlSecretName , domainNamespace ,
991
982
ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
992
-
993
- createPV (pvName , domainUid , this .getClass ().getSimpleName ());
994
- createPVC (pvName , pvcName , domainUid , domainNamespace );
995
-
983
+ final String wlsModelFilePrefix = "model-dci-introspect" ;
984
+ final String wlsModelFile = wlsModelFilePrefix + ".yaml" ;
996
985
t3ChannelPort = getNextFreePort ();
997
-
998
- // create a temporary WebLogic domain property file
999
- File domainPropertiesFile = assertDoesNotThrow (()
1000
- -> File .createTempFile ("domain" , ".properties" , new File (RESULTS_TEMPFILE )),
1001
- "Failed to create domain properties file" );
1002
- Properties p = new Properties ();
1003
- p .setProperty ("domain_path" , uniquePath );
1004
- p .setProperty ("domain_name" , domainUid );
1005
- p .setProperty ("cluster_name" , clusterName );
1006
- p .setProperty ("admin_server_name" , adminServerName );
1007
- p .setProperty ("managed_server_port" , Integer .toString (managedServerPort ));
1008
- p .setProperty ("admin_server_port" , "7001" );
1009
- p .setProperty ("admin_username" , ADMIN_USERNAME_DEFAULT );
1010
- p .setProperty ("admin_password" , ADMIN_PASSWORD_DEFAULT );
1011
- p .setProperty ("admin_t3_public_address" , ingressIP );
1012
- p .setProperty ("admin_t3_channel_port" , Integer .toString (t3ChannelPort ));
1013
- p .setProperty ("number_of_ms" , "2" );
1014
- p .setProperty ("managed_server_name_base" , managedServerNameBase );
1015
- p .setProperty ("domain_logs" , uniquePath + "/logs" );
1016
- p .setProperty ("production_mode_enabled" , "true" );
1017
- assertDoesNotThrow (()
1018
- -> p .store (new FileOutputStream (domainPropertiesFile ), "domain properties file" ),
1019
- "Failed to write domain properties file" );
1020
-
1021
- // WLST script for creating domain
1022
- Path wlstScript = Paths .get (RESOURCE_DIR , "python-scripts" , "wlst-create-domain-onpv.py" );
1023
-
1024
- // create configmap and domain on persistent volume using the WLST script and property file
1025
- createDomainOnPVUsingWlst (wlstScript , domainPropertiesFile .toPath (),
1026
- pvName , pvcName , domainNamespace );
1027
-
1028
- // create a domain custom resource configuration object
986
+ File wlsModelPropFile = ItIntrospectVersion .createWdtPropertyFile (wlsModelFilePrefix ,
987
+ K8S_NODEPORT_HOST , t3ChannelPort );
988
+ // create domainCreationImage
989
+ String domainCreationImageName = DOMAIN_IMAGES_PREFIX + "configdist-domain-on-pv-image" ;
990
+ // create image with model and wdt installation files
991
+ WitParams witParams
992
+ = new WitParams ()
993
+ .modelImageName (domainCreationImageName )
994
+ .modelImageTag (MII_BASIC_IMAGE_TAG )
995
+ .modelFiles (Collections .singletonList (MODEL_DIR + "/" + wlsModelFile ))
996
+ .modelVariableFiles (Collections .singletonList (wlsModelPropFile .getAbsolutePath ()));
997
+ createAndPushAuxiliaryImage (domainCreationImageName , MII_BASIC_IMAGE_TAG , witParams );
998
+
999
+ DomainCreationImage domainCreationImage
1000
+ = new DomainCreationImage ().image (domainCreationImageName + ":" + MII_BASIC_IMAGE_TAG );
1001
+
1002
+ // create a domain resource
1029
1003
logger .info ("Creating domain custom resource" );
1030
- DomainResource domain = new DomainResource ()
1031
- .apiVersion (DOMAIN_API_VERSION )
1032
- .kind ("Domain" )
1033
- .metadata (new V1ObjectMeta ()
1034
- .name (domainUid )
1035
- .namespace (domainNamespace ))
1036
- .spec (new DomainSpec ()
1037
- .configuration (new Configuration ()
1038
- .overrideDistributionStrategy ("Dynamic" )
1039
- .introspectorJobActiveDeadlineSeconds (300L ))
1040
- .domainUid (domainUid )
1041
- .domainHome (uniquePath + "/" + domainUid ) // point to domain home in pv
1042
- .domainHomeSourceType ("PersistentVolume" ) // set the domain home source type as pv
1043
- .image (WEBLOGIC_IMAGE_TO_USE_IN_SPEC )
1044
- .imagePullPolicy (IMAGE_PULL_POLICY )
1045
- .imagePullSecrets (Arrays .asList (
1046
- new V1LocalObjectReference ()
1047
- .name (BASE_IMAGES_REPO_SECRET_NAME ))) // this secret is used only in non-kind cluster
1048
- .webLogicCredentialsSecret (new V1LocalObjectReference ()
1049
- .name (wlSecretName ))
1050
- .includeServerOutInPodLog (true )
1051
- .logHomeEnabled (Boolean .TRUE )
1052
- .logHome (uniquePath + "/logs/" + domainUid )
1053
- .dataHome ("" )
1054
- .serverStartPolicy ("IfNeeded" )
1055
- .serverPod (new ServerPod () //serverpod
1056
- .addEnvItem (new V1EnvVar ()
1057
- .name ("JAVA_OPTIONS" )
1058
- .value ("-Dweblogic.debug.DebugSituationalConfig=true "
1059
- + "-Dweblogic.debug.DebugSituationalConfigDumpXml=true " ))
1060
- .addEnvItem (new V1EnvVar ()
1061
- .name ("USER_MEM_ARGS" )
1062
- .value ("-Djava.security.egd=file:/dev/./urandom " ))
1063
- .addVolumesItem (new V1Volume ()
1064
- .name (pvName )
1065
- .persistentVolumeClaim (new V1PersistentVolumeClaimVolumeSource ()
1066
- .claimName (pvcName )))
1067
- .addVolumeMountsItem (new V1VolumeMount ()
1068
- .mountPath ("/shared" )
1069
- .name (pvName )))
1070
- .adminServer (new AdminServer () //admin server
1071
- .adminService (new AdminService ()
1072
- .addChannelsItem (new Channel ()
1073
- .channelName ("default" )
1074
- .nodePort (0 )))));
1075
- setPodAntiAffinity (domain );
1076
-
1077
- // create cluster object
1078
- ClusterResource cluster = createClusterResource (clusterResName ,
1079
- clusterName , domainNamespace , replicaCount );
1080
- logger .info ("Creating cluster resource {0} in namespace {1}" , clusterResName , domainNamespace );
1081
- createClusterAndVerify (cluster );
1082
- // set cluster references
1083
- domain .getSpec ().withCluster (new V1LocalObjectReference ().name (clusterResName ));
1004
+ Map <String , Quantity > pvCapacity = new HashMap <>();
1005
+ pvCapacity .put ("storage" , new Quantity ("2Gi" ));
1006
+
1007
+ Map <String , Quantity > pvcRequest = new HashMap <>();
1008
+ pvcRequest .put ("storage" , new Quantity ("2Gi" ));
1009
+ Configuration configuration = null ;
1010
+ final String storageClassName = "weblogic-domain-storage-class" ;
1011
+ if (OKE_CLUSTER ) {
1012
+ configuration = getConfiguration (pvcName , pvcRequest , "oci-fss" );
1013
+ } else {
1014
+ configuration = getConfiguration (pvName , pvcName , pvCapacity , pvcRequest , storageClassName ,
1015
+ ItIntrospectVersion .class .getName ());
1016
+ }
1017
+ configuration .getInitializeDomainOnPV ().domain (new DomainOnPV ()
1018
+ .createMode (CreateIfNotExists .DOMAIN )
1019
+ .domainCreationImages (Collections .singletonList (domainCreationImage ))
1020
+ .domainType (DomainOnPVType .WLS ));
1021
+ configuration .overrideDistributionStrategy ("Dynamic" );
1022
+
1023
+ DomainResource domain = createDomainResourceOnPv (domainUid ,
1024
+ domainNamespace ,
1025
+ wlSecretName ,
1026
+ clusterName ,
1027
+ pvName ,
1028
+ pvcName ,
1029
+ new String []{BASE_IMAGES_REPO_SECRET_NAME },
1030
+ uniqueDomainHome ,
1031
+ 2 ,
1032
+ t3ChannelPort ,
1033
+ configuration );
1034
+ domain .spec ().serverPod ().addEnvItem (new V1EnvVar ()
1035
+ .name ("JAVA_OPTIONS" )
1036
+ .value ("-Dweblogic.debug.DebugSituationalConfig=true "
1037
+ + "-Dweblogic.debug.DebugSituationalConfigDumpXml=true " ));
1038
+ logger .info (Yaml .dump (domain ));
1084
1039
1085
1040
// verify the domain custom resource is created
1086
1041
createDomainAndVerify (domain , domainNamespace );
0 commit comments