2222import oracle .weblogic .domain .DomainSpec ;
2323import oracle .weblogic .domain .Model ;
2424import oracle .weblogic .domain .ServerPod ;
25+ import oracle .weblogic .kubernetes .actions .TestActions ;
2526import oracle .weblogic .kubernetes .actions .impl .OperatorParams ;
2627import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
2728import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
@@ -107,11 +108,15 @@ class ItUsabilityOperatorHelmChart {
107108 private static String domain1Namespace = null ;
108109 private static String domain2Namespace = null ;
109110 private static String domain3Namespace = null ;
111+ private static String domain4Namespace = null ;
110112
111113 // domain constants
112114 private final String domain1Uid = "usabdomain1" ;
113115 private final String domain2Uid = "usabdomain2" ;
114116 private final String domain3Uid = "usabdomain3" ;
117+ private final String domain4Uid = "usabdomain4" ;
118+ private final String domain5Uid = "usabdomain5" ;
119+
115120 private final String clusterName = "cluster-1" ;
116121 private final int managedServerPort = 8001 ;
117122 private final int replicaCount = 2 ;
@@ -137,7 +142,7 @@ class ItUsabilityOperatorHelmChart {
137142 * JUnit engine parameter resolution mechanism
138143 */
139144 @ BeforeAll
140- public static void initAll (@ Namespaces (5 ) List <String > namespaces ) {
145+ public static void initAll (@ Namespaces (6 ) List <String > namespaces ) {
141146 logger = getLogger ();
142147 // get a unique operator namespace
143148 logger .info ("Getting a unique namespace for operator" );
@@ -159,10 +164,15 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
159164 assertNotNull (namespaces .get (3 ), "Namespace list is null" );
160165 domain3Namespace = namespaces .get (3 );
161166
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+
162172 // get a unique operator 2 namespace
163173 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 );
166176 }
167177
168178 @ AfterAll
@@ -740,6 +750,91 @@ public void testNotPreexistedOpServiceAccountCreateOperatorNegativeInstall() {
740750 }
741751 }
742752
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+
743838 private boolean createVerifyDomain (String domainNamespace , String domainUid ) {
744839
745840 // create and verify the domain
@@ -767,12 +862,12 @@ private void createAndVerifyMiiDomain(String domainNamespace, String domainUid)
767862
768863 // create secret for admin credentials
769864 logger .info ("Creating secret for admin credentials" );
770- String adminSecretName = "weblogic-credentials" ;
865+ String adminSecretName = "weblogic-credentials-" + domainUid ;
771866 createSecretWithUsernamePassword (adminSecretName , domainNamespace , "weblogic" , "welcome1" );
772867
773868 // create encryption secret
774869 logger .info ("Creating encryption secret" );
775- String encryptionSecretName = "encryptionsecret" ;
870+ String encryptionSecretName = "encryptionsecret" + domainUid ;
776871 createSecretWithUsernamePassword (encryptionSecretName , domainNamespace , "weblogicenc" , "weblogicenc" );
777872
778873 // construct a list of oracle.weblogic.domain.Cluster objects to be used in the domain custom resource
0 commit comments