new-integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonTestUtils.java
public static HelmParams installAndVerifyOperator(String opNamespace,
                                                    String opServiceAccount,
                                                    boolean withRestAPI,
                                                    int externalRestHttpsPort,
                                                    String... domainNamespace) {
    LoggingFacade logger = getLogger();
    // Create a service account for the unique opNamespace
    logger.info("Creating service account");
    assertDoesNotThrow(() -> createServiceAccount(new V1ServiceAccount()
        .metadata(new V1ObjectMeta()
            .namespace(opNamespace)
            .name(opServiceAccount))));
    logger.info("Created service account: {0}", opServiceAccount);

    // get operator image name
    String operatorImage = getOperatorImageName();
    assertFalse(operatorImage.isEmpty(), "operator image name can not be empty");
    logger.info("operator image name {0}", operatorImage);

    // Create Docker registry secret in the operator namespace to pull the image from repository
    logger.info("Creating Docker registry secret in namespace {0}", opNamespace);
    createDockerRegistrySecret(opNamespace);

    // map with secret
    Map<String, Object> secretNameMap = new HashMap<>();
    secretNameMap.put("name", REPO_SECRET_NAME);

    // Helm install parameters
    HelmParams opHelmParams = new HelmParams()
        .releaseName(OPERATOR_RELEASE_NAME)
        .namespace(opNamespace)
        .chartDir(OPERATOR_CHART_DIR);

    // operator chart values to override
    OperatorParams opParams = new OperatorParams()
        .helmParams(opHelmParams)
        .image(operatorImage)
        .imagePullSecrets(secretNameMap)
        .domainNamespaces(Arrays.asList(domainNamespace))
        .serviceAccount(opServiceAccount);

    if (withRestAPI) {
      // create externalRestIdentitySecret
      assertTrue(createExternalRestIdentitySecret(opNamespace, DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME),
          "failed to create external REST identity secret");
      opParams
          .externalRestEnabled(true)
          .externalRestHttpsPort(externalRestHttpsPort)
          .externalRestIdentitySecret(DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME);
    }

    // install operator
    logger.info("Installing operator in namespace {0}", opNamespace);
    assertTrue(installOperator(opParams),
        String.format("Failed to install operator in namespace %s", opNamespace));
    logger.info("Operator installed in namespace {0}", opNamespace);

    // list Helm releases matching operator release name in operator namespace
    logger.info("Checking operator release {0} status in namespace {1}",
        OPERATOR_RELEASE_NAME, opNamespace);
    assertTrue(isHelmReleaseDeployed(OPERATOR_RELEASE_NAME, opNamespace),
        String.format("Operator release %s is not in deployed status in namespace %s",
            OPERATOR_RELEASE_NAME, opNamespace));
    logger.info("Operator release {0} status is deployed in namespace {1}",
        OPERATOR_RELEASE_NAME, opNamespace);

    // wait for the operator to be ready
    logger.info("Wait for the operator pod is ready in namespace {0}", opNamespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for operator to be running in namespace {0} "
                    + "(elapsed time {1}ms, remaining time {2}ms)",
                opNamespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(assertDoesNotThrow(() -> operatorIsReady(opNamespace),
            "operatorIsReady failed with ApiException"));

    return opHelmParams;
  }
/**
   * Install WebLogic operator and wait up to five minutes until the operator pod is ready.
   *
   * @param opNamespace the operator namespace in which the operator will be installed
   * @param opServiceAccount the service account name for operator
   * @param withRestAPI whether to use REST API
   * @param externalRestHttpsPort the node port allocated for the external operator REST HTTPS interface
   * @param domainNamespace the list of the domain namespaces which will be managed by the operator
   * @return the operator Helm installation parameters
   */
Install WebLogic operator and wait up to five minutes until the operator pod is ready.
Install WebLogic operator and wait up to five minutes until the operator pod is ready .
public static HelmParams installAndVerifyOperator(String opNamespace,
                                                    String opServiceAccount,
                                                    boolean withRestAPI,
                                                    int externalRestHttpsPort,
                                                    String... domainNamespace) {
    LoggingFacade logger = getLogger();
    logger.info("Creating service account");
    assertDoesNotThrow(() -> createServiceAccount(new V1ServiceAccount()
        .metadata(new V1ObjectMeta()
            .namespace(opNamespace)
            .name(opServiceAccount))));
    logger.info("Created service account: {0}", opServiceAccount);
    String operatorImage = getOperatorImageName();
    assertFalse(operatorImage.isEmpty(), "operator image name can not be empty");
    logger.info("operator image name {0}", operatorImage);
    logger.info("Creating Docker registry secret in namespace {0}", opNamespace);
    createDockerRegistrySecret(opNamespace);
    Map<String, Object> secretNameMap = new HashMap<>();
    secretNameMap.put("name", REPO_SECRET_NAME);
    HelmParams opHelmParams = new HelmParams()
        .releaseName(OPERATOR_RELEASE_NAME)
        .namespace(opNamespace)
        .chartDir(OPERATOR_CHART_DIR);
    OperatorParams opParams = new OperatorParams()
        .helmParams(opHelmParams)
        .image(operatorImage)
        .imagePullSecrets(secretNameMap)
        .domainNamespaces(Arrays.asList(domainNamespace))
        .serviceAccount(opServiceAccount);
    if (withRestAPI) {
      assertTrue(createExternalRestIdentitySecret(opNamespace, DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME),
          "failed to create external REST identity secret");
      opParams
          .externalRestEnabled(true)
          .externalRestHttpsPort(externalRestHttpsPort)
          .externalRestIdentitySecret(DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME);
    }
    logger.info("Installing operator in namespace {0}", opNamespace);
    assertTrue(installOperator(opParams),
        String.format("Failed to install operator in namespace %s", opNamespace));
    logger.info("Operator installed in namespace {0}", opNamespace);
    logger.info("Checking operator release {0} status in namespace {1}",
        OPERATOR_RELEASE_NAME, opNamespace);
    assertTrue(isHelmReleaseDeployed(OPERATOR_RELEASE_NAME, opNamespace),
        String.format("Operator release %s is not in deployed status in namespace %s",
            OPERATOR_RELEASE_NAME, opNamespace));
    logger.info("Operator release {0} status is deployed in namespace {1}",
        OPERATOR_RELEASE_NAME, opNamespace);
    logger.info("Wait for the operator pod is ready in namespace {0}", opNamespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for operator to be running in namespace {0} "
                    + "(elapsed time {1}ms, remaining time {2}ms)",
                opNamespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(assertDoesNotThrow(() -> operatorIsReady(opNamespace),
            "operatorIsReady failed with ApiException"));
    return opHelmParams;
  }
public static HelmParams installAndVerifyOperator ( String opNamespace , String opServiceAccount , boolean withRestAPI , int externalRestHttpsPort , String ... domainNamespace ) { LoggingFacade logger = getLogger ( ) ; logger . info ( "Creating service account" ) ; assertDoesNotThrow ( ( ) -> createServiceAccount ( new V1ServiceAccount ( ) . metadata ( new V1ObjectMeta ( ) . namespace ( opNamespace ) . name ( opServiceAccount ) ) ) ) ; logger . info ( "Created service account: {0}" , opServiceAccount ) ; String operatorImage = getOperatorImageName ( ) ; assertFalse ( operatorImage . isEmpty ( ) , "operator image name can not be empty" ) ; logger . info ( "operator image name {0}" , operatorImage ) ; logger . info ( "Creating Docker registry secret in namespace {0}" , opNamespace ) ; createDockerRegistrySecret ( opNamespace ) ; Map < String , Object > secretNameMap = new HashMap < > ( ) ; secretNameMap . put ( "name" , REPO_SECRET_NAME ) ; HelmParams opHelmParams = new HelmParams ( ) . releaseName ( OPERATOR_RELEASE_NAME ) . namespace ( opNamespace ) . chartDir ( OPERATOR_CHART_DIR ) ; OperatorParams opParams = new OperatorParams ( ) . helmParams ( opHelmParams ) . image ( operatorImage ) . imagePullSecrets ( secretNameMap ) . domainNamespaces ( Arrays . asList ( domainNamespace ) ) . serviceAccount ( opServiceAccount ) ; if ( withRestAPI ) { assertTrue ( createExternalRestIdentitySecret ( opNamespace , DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME ) , "failed to create external REST identity secret" ) ; opParams . externalRestEnabled ( true ) . externalRestHttpsPort ( externalRestHttpsPort ) . externalRestIdentitySecret ( DEFAULT_EXTERNAL_REST_IDENTITY_SECRET_NAME ) ; } logger . info ( "Installing operator in namespace {0}" , opNamespace ) ; assertTrue ( installOperator ( opParams ) , String . format ( "Failed to install operator in namespace %s" , opNamespace ) ) ; logger . info ( "Operator installed in namespace {0}" , opNamespace ) ; logger . info ( "Checking operator release {0} status in namespace {1}" , OPERATOR_RELEASE_NAME , opNamespace ) ; assertTrue ( isHelmReleaseDeployed ( OPERATOR_RELEASE_NAME , opNamespace ) , String . format ( "Operator release %s is not in deployed status in namespace %s" , OPERATOR_RELEASE_NAME , opNamespace ) ) ; logger . info ( "Operator release {0} status is deployed in namespace {1}" , OPERATOR_RELEASE_NAME , opNamespace ) ; logger . info ( "Wait for the operator pod is ready in namespace {0}" , opNamespace ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for operator to be running in namespace {0} " + "(elapsed time {1}ms, remaining time {2}ms)" , opNamespace , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( assertDoesNotThrow ( ( ) -> operatorIsReady ( opNamespace ) , "operatorIsReady failed with ApiException" ) ) ; return opHelmParams ; }
Install WebLogic operator and wait up to five minutes until the operator pod is ready.
Install WebLogic operator and wait up to five minutes until the operator pod is ready .
// Create a service account for the unique opNamespace // get operator image name // Create Docker registry secret in the operator namespace to pull the image from repository // map with secret // Helm install parameters // operator chart values to override // create externalRestIdentitySecret // install operator // list Helm releases matching operator release name in operator namespace // wait for the operator to be ready