22
22
import oracle .weblogic .domain .DomainSpec ;
23
23
import oracle .weblogic .domain .Model ;
24
24
import oracle .weblogic .domain .ServerPod ;
25
+ import oracle .weblogic .kubernetes .actions .TestActions ;
25
26
import oracle .weblogic .kubernetes .actions .impl .OperatorParams ;
26
27
import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
27
28
import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
@@ -107,11 +108,15 @@ class ItUsabilityOperatorHelmChart {
107
108
private static String domain1Namespace = null ;
108
109
private static String domain2Namespace = null ;
109
110
private static String domain3Namespace = null ;
111
+ private static String domain4Namespace = null ;
110
112
111
113
// domain constants
112
114
private final String domain1Uid = "usabdomain1" ;
113
115
private final String domain2Uid = "usabdomain2" ;
114
116
private final String domain3Uid = "usabdomain3" ;
117
+ private final String domain4Uid = "usabdomain4" ;
118
+ private final String domain5Uid = "usabdomain5" ;
119
+
115
120
private final String clusterName = "cluster-1" ;
116
121
private final int managedServerPort = 8001 ;
117
122
private final int replicaCount = 2 ;
@@ -137,7 +142,7 @@ class ItUsabilityOperatorHelmChart {
137
142
* JUnit engine parameter resolution mechanism
138
143
*/
139
144
@ BeforeAll
140
- public static void initAll (@ Namespaces (5 ) List <String > namespaces ) {
145
+ public static void initAll (@ Namespaces (6 ) List <String > namespaces ) {
141
146
logger = getLogger ();
142
147
// get a unique operator namespace
143
148
logger .info ("Getting a unique namespace for operator" );
@@ -159,10 +164,15 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
159
164
assertNotNull (namespaces .get (3 ), "Namespace list is null" );
160
165
domain3Namespace = namespaces .get (3 );
161
166
167
+ // get a unique domain namespace
168
+ logger .info ("Getting a unique namespace for WebLogic domain 4" );
169
+ assertNotNull (namespaces .get (4 ), "Namespace list is null" );
170
+ domain4Namespace = namespaces .get (4 );
171
+
162
172
// get a unique operator 2 namespace
163
173
logger .info ("Getting a unique namespace for operator 2" );
164
- assertNotNull (namespaces .get (4 ), "Namespace list is null" );
165
- op2Namespace = namespaces .get (4 );
174
+ assertNotNull (namespaces .get (5 ), "Namespace list is null" );
175
+ op2Namespace = namespaces .get (5 );
166
176
}
167
177
168
178
@ AfterAll
@@ -740,6 +750,91 @@ public void testNotPreexistedOpServiceAccountCreateOperatorNegativeInstall() {
740
750
}
741
751
}
742
752
753
+
754
+ /**
755
+ * Install the Operator successfully.
756
+ * Create domain4, domain5 in the same namespace and verify the domains are started
757
+ * Verify both domains are managed by the operator by making a REST API call
758
+ * Verify domains scaling by calling scalingAction.sh script
759
+ */
760
+ @ Test
761
+ @ DisplayName ("Create domain4, domain5 in the same namespace managed by operator ,"
762
+ + " verify scaling via scalingAction.sh script and restAPI" )
763
+ public void testTwoDomainsInSameNameSpaceOnOperator () {
764
+
765
+ String opReleaseName = OPERATOR_RELEASE_NAME ;
766
+ HelmParams op1HelmParams = new HelmParams ().releaseName (opReleaseName )
767
+ .namespace (op2Namespace )
768
+ .chartDir (OPERATOR_CHART_DIR );
769
+ try {
770
+ // install operator
771
+ String opServiceAccount = op2Namespace + "-sa" ;
772
+ HelmParams opHelmParams = installAndVerifyOperator (op2Namespace , opServiceAccount , true ,
773
+ 0 , op1HelmParams , domain4Namespace ).getHelmParams ();
774
+ assertNotNull (opHelmParams , "Can't install operator" );
775
+ int externalRestHttpsPort = getServiceNodePort (op2Namespace , "external-weblogic-operator-svc" );
776
+ assertTrue (externalRestHttpsPort != -1 ,
777
+ "Could not get the Operator external service node port" );
778
+ logger .info ("externalRestHttpsPort {0}" , externalRestHttpsPort );
779
+
780
+ logger .info ("Installing and verifying domain4" );
781
+ assertTrue (createVerifyDomain (domain4Namespace , domain4Uid ),
782
+ "can't start or verify domain4 in namespace " + domain4Namespace );
783
+ logger .info ("Installing and verifying domain5" );
784
+ assertTrue (createVerifyDomain (domain4Namespace , domain5Uid ),
785
+ "can't start or verify domain5 in namespace " + domain4Namespace );
786
+
787
+ assertTrue (scaleClusterWithRestApi (domain4Uid , clusterName ,3 ,
788
+ externalRestHttpsPort ,op2Namespace , opServiceAccount ),
789
+ "Domain4 " + domain4Namespace + " scaling operation failed" );
790
+ String managedServerPodName1 = domain4Uid + managedServerPrefix + 3 ;
791
+ logger .info ("Checking that the managed server pod {0} exists in namespace {1}" ,
792
+ managedServerPodName1 , domain4Namespace );
793
+ assertDoesNotThrow (() ->
794
+ checkPodExists (managedServerPodName1 , domain4Uid , domain4Namespace ),
795
+ "operator failed to manage domain4, scaling was not succeeded" );
796
+ logger .info ("Domain4 scaled to 3 servers" );
797
+
798
+ assertTrue (scaleClusterWithRestApi (domain5Uid , clusterName ,3 ,
799
+ externalRestHttpsPort ,op2Namespace , opServiceAccount ),
800
+ "Domain2 " + domain4Namespace + " scaling operation failed" );
801
+ String managedServerPodName2 = domain5Uid + managedServerPrefix + 3 ;
802
+ logger .info ("Checking that the managed server pod {0} exists in namespace {1}" ,
803
+ managedServerPodName2 , domain4Namespace );
804
+ assertDoesNotThrow (() ->
805
+ checkPodExists (managedServerPodName2 , domain5Uid , domain4Namespace ),
806
+ "operator failed to manage domain2, scaling was not succeeded" );
807
+
808
+ logger .info ("Domain4 scaled to 3 servers" );
809
+
810
+ assertDoesNotThrow (() ->
811
+ TestActions .scaleClusterWithScalingActionScript (clusterName , domain4Uid , domain4Namespace ,
812
+ "/u01/domains/" + domain4Uid , "scaleDown" , 1 ,
813
+ op2Namespace ,opServiceAccount ),
814
+ "scaling was not succeeded" );
815
+ assertDoesNotThrow (() ->
816
+ checkPodDoesNotExist (managedServerPodName1 , domain4Uid , domain4Namespace ),
817
+ " scaling via scalingAction.sh script was not succeeded for domain4" );
818
+ logger .info ("Domain4 scaled to 2 servers" );
819
+ assertDoesNotThrow (() ->
820
+ TestActions .scaleClusterWithScalingActionScript (clusterName , domain5Uid , domain4Namespace ,
821
+ "/u01/domains/" + domain5Uid , "scaleDown" , 1 ,
822
+ op2Namespace ,opServiceAccount ),
823
+ " scaling via scalingAction.sh script was not succeeded for domain5" );
824
+
825
+ assertDoesNotThrow (() ->
826
+ checkPodDoesNotExist (managedServerPodName2 , domain5Uid , domain4Namespace ),
827
+ " scaling via scalingAction.sh script was not succeeded for domain5" );
828
+ logger .info ("Domain5 scaled to 2 servers" );
829
+ } finally {
830
+ uninstallOperator (op1HelmParams );
831
+ deleteSecret (OCIR_SECRET_NAME ,op2Namespace );
832
+ cleanUpSA (op2Namespace );
833
+ }
834
+ }
835
+
836
+
837
+
743
838
private boolean createVerifyDomain (String domainNamespace , String domainUid ) {
744
839
745
840
// create and verify the domain
@@ -767,12 +862,12 @@ private void createAndVerifyMiiDomain(String domainNamespace, String domainUid)
767
862
768
863
// create secret for admin credentials
769
864
logger .info ("Creating secret for admin credentials" );
770
- String adminSecretName = "weblogic-credentials" ;
865
+ String adminSecretName = "weblogic-credentials-" + domainUid ;
771
866
createSecretWithUsernamePassword (adminSecretName , domainNamespace , "weblogic" , "welcome1" );
772
867
773
868
// create encryption secret
774
869
logger .info ("Creating encryption secret" );
775
- String encryptionSecretName = "encryptionsecret" ;
870
+ String encryptionSecretName = "encryptionsecret" + domainUid ;
776
871
createSecretWithUsernamePassword (encryptionSecretName , domainNamespace , "weblogicenc" , "weblogicenc" );
777
872
778
873
// construct a list of oracle.weblogic.domain.Cluster objects to be used in the domain custom resource
0 commit comments