@@ -547,6 +547,177 @@ public static OperatorParams installAndVerifyOperator(String opReleaseName, Stri
547
547
domainNamespaceSelectionStrategy , domainNamespaceSelector , enableClusterRoleBinding , domainNamespace );
548
548
}
549
549
550
+ /**
551
+ * Install WebLogic operator and wait up to five minutes until the operator pod is ready.
552
+ *
553
+ * @param opNamespace the operator namespace in which the operator will be installed
554
+ * @param opServiceAccount the service account name for operator
555
+ * @param withRestAPI whether to use REST API
556
+ * @param externalRestHttpsPort the node port allocated for the external operator REST HTTPS interface
557
+ * @param opHelmParams the Helm parameters to install operator
558
+ * @param elkIntegrationEnabled true to enable ELK Stack, false otherwise
559
+ * @param domainNamespaceSelectionStrategy SelectLabel, RegExp or List, value to tell the operator
560
+ * how to select the set of namespaces that it will manage
561
+ * @param domainNamespaceSelector the label or expression value to manage namespaces
562
+ * @param enableClusterRoleBinding operator cluster role binding
563
+ * @param loggingLevel logging level of operator
564
+ * @param domainPresenceFailureRetryMaxCount the number of introspector job retries for a Domain
565
+ * @param domainPresenceFailureRetrySeconds the interval in seconds between these retries
566
+ * @param openshiftIstioInjection openshift istio enabled
567
+ * @param domainNamespace the list of the domain namespaces which will be managed by the operator
568
+ * @return the operator Helm installation parameters
569
+ */
570
+ public static OperatorParams installAndVerifyOperator (String opNamespace ,
571
+ String opServiceAccount ,
572
+ boolean withRestAPI ,
573
+ int externalRestHttpsPort ,
574
+ HelmParams opHelmParams ,
575
+ boolean elkIntegrationEnabled ,
576
+ String domainNamespaceSelectionStrategy ,
577
+ String domainNamespaceSelector ,
578
+ boolean enableClusterRoleBinding ,
579
+ String loggingLevel ,
580
+ int domainPresenceFailureRetryMaxCount ,
581
+ int domainPresenceFailureRetrySeconds ,
582
+ boolean openshiftIstioInjection ,
583
+ String ... domainNamespace ) {
584
+ LoggingFacade logger = getLogger ();
585
+
586
+ // Create a service account for the unique opNamespace
587
+ logger .info ("Creating service account" );
588
+ assertDoesNotThrow (() -> createServiceAccount (new V1ServiceAccount ()
589
+ .metadata (new V1ObjectMeta ()
590
+ .namespace (opNamespace )
591
+ .name (opServiceAccount ))));
592
+ logger .info ("Created service account: {0}" , opServiceAccount );
593
+
594
+
595
+ // get operator image name
596
+ String operatorImage = getOperatorImageName ();
597
+ assertFalse (operatorImage .isEmpty (), "operator image name can not be empty" );
598
+ logger .info ("operator image name {0}" , operatorImage );
599
+
600
+ // Create Docker registry secret in the operator namespace to pull the image from repository
601
+ // this secret is used only for non-kind cluster
602
+ logger .info ("Creating Docker registry secret in namespace {0}" , opNamespace );
603
+ createTestRepoSecret (opNamespace );
604
+
605
+ // map with secret
606
+ Map <String , Object > secretNameMap = new HashMap <>();
607
+ secretNameMap .put ("name" , TEST_IMAGES_REPO_SECRET_NAME );
608
+
609
+ // operator chart values to override
610
+ OperatorParams opParams = new OperatorParams ()
611
+ .helmParams (opHelmParams )
612
+ .imagePullSecrets (secretNameMap )
613
+ .domainNamespaces (Arrays .asList (domainNamespace ))
614
+ .javaLoggingLevel (loggingLevel )
615
+ .serviceAccount (opServiceAccount );
616
+
617
+ if (domainNamespaceSelectionStrategy != null ) {
618
+ opParams .domainNamespaceSelectionStrategy (domainNamespaceSelectionStrategy );
619
+ }
620
+
621
+ // use default image in chart when repoUrl is set, otherwise use latest/current branch operator image
622
+ if (opHelmParams .getRepoUrl () == null ) {
623
+ opParams .image (operatorImage );
624
+ }
625
+
626
+ // enable ELK Stack
627
+ if (elkIntegrationEnabled ) {
628
+ opParams
629
+ .elkIntegrationEnabled (elkIntegrationEnabled );
630
+ opParams
631
+ .elasticSearchHost (ELASTICSEARCH_HOST );
632
+ opParams
633
+ .elasticSearchPort (ELASTICSEARCH_HTTP_PORT );
634
+ opParams
635
+ .javaLoggingLevel (JAVA_LOGGING_LEVEL_VALUE );
636
+ opParams
637
+ .logStashImage (LOGSTASH_IMAGE );
638
+ }
639
+
640
+ if (withRestAPI ) {
641
+ // create externalRestIdentitySecret
642
+ assertTrue (createExternalRestIdentitySecret (opNamespace , DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME ),
643
+ "failed to create external REST identity secret" );
644
+ opParams
645
+ .externalRestEnabled (true )
646
+ .externalRestHttpsPort (externalRestHttpsPort )
647
+ .externalRestIdentitySecret (DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME );
648
+ }
649
+ // operator chart values to override
650
+ if (enableClusterRoleBinding ) {
651
+ opParams .enableClusterRoleBinding (enableClusterRoleBinding );
652
+ }
653
+ if (domainNamespaceSelectionStrategy != null ) {
654
+ opParams .domainNamespaceSelectionStrategy (domainNamespaceSelectionStrategy );
655
+ if (domainNamespaceSelectionStrategy .equalsIgnoreCase ("LabelSelector" )) {
656
+ opParams .domainNamespaceLabelSelector (domainNamespaceSelector );
657
+ } else if (domainNamespaceSelectionStrategy .equalsIgnoreCase ("RegExp" )) {
658
+ opParams .domainNamespaceRegExp (domainNamespaceSelector );
659
+ }
660
+ }
661
+
662
+ // domainPresenceFailureRetryMaxCount and domainPresenceFailureRetrySeconds
663
+ if (domainPresenceFailureRetryMaxCount >= 0 ) {
664
+ opParams .domainPresenceFailureRetryMaxCount (domainPresenceFailureRetryMaxCount );
665
+ }
666
+ if (domainPresenceFailureRetrySeconds > 0 ) {
667
+ opParams .domainPresenceFailureRetrySeconds (domainPresenceFailureRetrySeconds );
668
+ }
669
+
670
+ // If running on OKD cluster, we need to specify the target
671
+ if (OKD ) {
672
+ opParams .kubernetesPlatform ("OpenShift" );
673
+ }
674
+
675
+ if (openshiftIstioInjection ) {
676
+ opParams .openShiftIstioInjection (openshiftIstioInjection );
677
+ }
678
+
679
+ // install operator
680
+ logger .info ("Installing operator in namespace {0}" , opNamespace );
681
+ assertTrue (installOperator (opParams ),
682
+ String .format ("Failed to install operator in namespace %s" , opNamespace ));
683
+ logger .info ("Operator installed in namespace {0}" , opNamespace );
684
+
685
+ // list Helm releases matching operator release name in operator namespace
686
+ logger .info ("Checking operator release {0} status in namespace {1}" ,
687
+ OPERATOR_RELEASE_NAME , opNamespace );
688
+ assertTrue (isHelmReleaseDeployed (OPERATOR_RELEASE_NAME , opNamespace ),
689
+ String .format ("Operator release %s is not in deployed status in namespace %s" ,
690
+ OPERATOR_RELEASE_NAME , opNamespace ));
691
+ logger .info ("Operator release {0} status is deployed in namespace {1}" ,
692
+ OPERATOR_RELEASE_NAME , opNamespace );
693
+
694
+ // wait for the operator to be ready
695
+ logger .info ("Wait for the operator pod is ready in namespace {0}" , opNamespace );
696
+ CommonTestUtils .withStandardRetryPolicy
697
+ .conditionEvaluationListener (
698
+ condition -> logger .info ("Waiting for operator to be running in namespace {0} "
699
+ + "(elapsed time {1}ms, remaining time {2}ms)" ,
700
+ opNamespace ,
701
+ condition .getElapsedTimeInMS (),
702
+ condition .getRemainingTimeInMS ()))
703
+ .until (assertDoesNotThrow (() -> operatorIsReady (opNamespace ),
704
+ "operatorIsReady failed with ApiException" ));
705
+
706
+ if (withRestAPI ) {
707
+ logger .info ("Wait for the operator external service in namespace {0}" , opNamespace );
708
+ CommonTestUtils .withStandardRetryPolicy
709
+ .conditionEvaluationListener (
710
+ condition -> logger .info ("Waiting for operator external service in namespace {0} "
711
+ + "(elapsed time {1}ms, remaining time {2}ms)" ,
712
+ opNamespace ,
713
+ condition .getElapsedTimeInMS (),
714
+ condition .getRemainingTimeInMS ()))
715
+ .until (assertDoesNotThrow (() -> operatorRestServiceRunning (opNamespace ),
716
+ "operator external service is not running" ));
717
+ }
718
+ return opParams ;
719
+ }
720
+
550
721
/**
551
722
* Upgrade WebLogic operator to manage the given domain namespaces.
552
723
*
@@ -636,4 +807,5 @@ public static void restartOperator(String opNamespace) {
636
807
logger .info ("Operator pod is restarted in namespace {0}" , opNamespace );
637
808
638
809
}
810
+
639
811
}
0 commit comments