new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAddCluster.java
@BeforeAll
  public static void initAll(@Namespaces(2) List<String> namespaces) {
    logger = getLogger();
    // create standard, reusable retry/backoff policy
    withStandardRetryPolicy = with().pollDelay(2, SECONDS)
        .and().with().pollInterval(10, SECONDS)
        .atMost(5, MINUTES).await();

    // get a new unique opNamespace
    logger.info("Creating unique namespace for Operator");
    assertNotNull(namespaces.get(0), "Namespace list is null");
    opNamespace = namespaces.get(0);

    logger.info("Creating unique namespace for Domain");
    assertNotNull(namespaces.get(1), "Namespace list is null");
    domainNamespace = namespaces.get(1);

    // Create a service account for the unique opNamespace
    logger.info("Creating service account");
    String serviceAccountName = opNamespace + "-sa";
    assertDoesNotThrow(() -> createServiceAccount(new V1ServiceAccount()
        .metadata(
            new V1ObjectMeta()
                .namespace(opNamespace)
                .name(serviceAccountName))));
    logger.info("Created service account: {0}", serviceAccountName);

    // get Operator image name
    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);
    JsonObject dockerConfigJsonObject = createDockerConfigJson(
        REPO_USERNAME, REPO_PASSWORD, REPO_EMAIL, REPO_REGISTRY);
    dockerConfigJson = dockerConfigJsonObject.toString();

    // Create the V1Secret configuration
    logger.info("Creating repo secret {0}", REPO_SECRET_NAME);
    V1Secret repoSecret = new V1Secret()
        .metadata(new V1ObjectMeta()
            .name(REPO_SECRET_NAME)
            .namespace(opNamespace))
        .type("kubernetes.io/dockerconfigjson")
        .putDataItem(".dockerconfigjson", dockerConfigJson.getBytes());

    boolean secretCreated = assertDoesNotThrow(() -> createSecret(repoSecret),
        String.format("createSecret failed for %s", REPO_SECRET_NAME));
    assertTrue(secretCreated, String.format("createSecret failed while creating secret %s in namespace",
                  REPO_SECRET_NAME, opNamespace));

    // map with secret
    secretNameMap = new HashMap<String, Object>();
    secretNameMap.put("name", REPO_SECRET_NAME);
    // helm install parameters
    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(serviceAccountName);

    // install Operator
    logger.info("Installing Operator in namespace {0}", opNamespace);
    assertTrue(installOperator(opParams),
        String.format("Operator install failed 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);

    // check operator is running
    logger.info("Check Operator pod is running 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(operatorIsReady(opNamespace));

    // Create the repo secret to pull the image
    assertDoesNotThrow(() -> createRepoSecret(domainNamespace),
            String.format("createSecret failed for %s", REPO_SECRET_NAME));

    // create secret for admin credentials
    logger.info("Create secret for admin credentials");
    String adminSecretName = "weblogic-credentials";
    assertDoesNotThrow(() -> createDomainSecret(adminSecretName,"weblogic",
            "welcome1", domainNamespace),
            String.format("createSecret failed for %s", adminSecretName));

    // create encryption secret
    logger.info("Create encryption secret");
    String encryptionSecretName = "encryptionsecret";
    assertDoesNotThrow(() -> createDomainSecret(encryptionSecretName, "weblogicenc",
            "weblogicenc", domainNamespace),
             String.format("createSecret failed for %s", encryptionSecretName));
    // create the domain CR with no configmap
    createDomainResource(domainUid, domainNamespace, adminSecretName,
        REPO_SECRET_NAME, encryptionSecretName,
        replicaCount);

    // wait for the domain to exist
    logger.info("Check for domain custom resource in namespace {0}", domainNamespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for domain {0} to be created in namespace {1} "
                    + "(elapsed time {2}ms, remaining time {3}ms)",
                domainUid,
                domainNamespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(domainExists(domainUid, DOMAIN_VERSION, domainNamespace));
  }
/**
   * Install Operator.
   * Create domain resource defintion.
   * @param namespaces list of namespaces created by the IntegrationTestWatcher by the
   JUnit engine parameter resolution mechanism
   */
Install Operator.
Create domain resource defintion.
@param namespaces list of namespaces created by the IntegrationTestWatcher by the
JUnit engine parameter resolution mechanism
Install Operator . Create domain resource defintion . @param namespaces list of namespaces created by the IntegrationTestWatcher by the JUnit engine parameter resolution mechanism
@BeforeAll
  public static void initAll(@Namespaces(2) List<String> namespaces) {
    logger = getLogger();
    withStandardRetryPolicy = with().pollDelay(2, SECONDS)
        .and().with().pollInterval(10, SECONDS)
        .atMost(5, MINUTES).await();
    logger.info("Creating unique namespace for Operator");
    assertNotNull(namespaces.get(0), "Namespace list is null");
    opNamespace = namespaces.get(0);
    logger.info("Creating unique namespace for Domain");
    assertNotNull(namespaces.get(1), "Namespace list is null");
    domainNamespace = namespaces.get(1);
    logger.info("Creating service account");
    String serviceAccountName = opNamespace + "-sa";
    assertDoesNotThrow(() -> createServiceAccount(new V1ServiceAccount()
        .metadata(
            new V1ObjectMeta()
                .namespace(opNamespace)
                .name(serviceAccountName))));
    logger.info("Created service account: {0}", serviceAccountName);
    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);
    JsonObject dockerConfigJsonObject = createDockerConfigJson(
        REPO_USERNAME, REPO_PASSWORD, REPO_EMAIL, REPO_REGISTRY);
    dockerConfigJson = dockerConfigJsonObject.toString();
    logger.info("Creating repo secret {0}", REPO_SECRET_NAME);
    V1Secret repoSecret = new V1Secret()
        .metadata(new V1ObjectMeta()
            .name(REPO_SECRET_NAME)
            .namespace(opNamespace))
        .type("kubernetes.io/dockerconfigjson")
        .putDataItem(".dockerconfigjson", dockerConfigJson.getBytes());
    boolean secretCreated = assertDoesNotThrow(() -> createSecret(repoSecret),
        String.format("createSecret failed for %s", REPO_SECRET_NAME));
    assertTrue(secretCreated, String.format("createSecret failed while creating secret %s in namespace",
                  REPO_SECRET_NAME, opNamespace));
    secretNameMap = new HashMap<String, Object>();
    secretNameMap.put("name", REPO_SECRET_NAME);
    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(serviceAccountName);
    logger.info("Installing Operator in namespace {0}", opNamespace);
    assertTrue(installOperator(opParams),
        String.format("Operator install failed 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("Check Operator pod is running 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(operatorIsReady(opNamespace));
    assertDoesNotThrow(() -> createRepoSecret(domainNamespace),
            String.format("createSecret failed for %s", REPO_SECRET_NAME));
    logger.info("Create secret for admin credentials");
    String adminSecretName = "weblogic-credentials";
    assertDoesNotThrow(() -> createDomainSecret(adminSecretName,"weblogic",
            "welcome1", domainNamespace),
            String.format("createSecret failed for %s", adminSecretName));
    logger.info("Create encryption secret");
    String encryptionSecretName = "encryptionsecret";
    assertDoesNotThrow(() -> createDomainSecret(encryptionSecretName, "weblogicenc",
            "weblogicenc", domainNamespace),
             String.format("createSecret failed for %s", encryptionSecretName));
    createDomainResource(domainUid, domainNamespace, adminSecretName,
        REPO_SECRET_NAME, encryptionSecretName,
        replicaCount);
    logger.info("Check for domain custom resource in namespace {0}", domainNamespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for domain {0} to be created in namespace {1} "
                    + "(elapsed time {2}ms, remaining time {3}ms)",
                domainUid,
                domainNamespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(domainExists(domainUid, DOMAIN_VERSION, domainNamespace));
  }
@ BeforeAll public static void initAll ( @ Namespaces ( 2 ) List < String > namespaces ) { logger = getLogger ( ) ; withStandardRetryPolicy = with ( ) . pollDelay ( 2 , SECONDS ) . and ( ) . with ( ) . pollInterval ( 10 , SECONDS ) . atMost ( 5 , MINUTES ) . await ( ) ; logger . info ( "Creating unique namespace for Operator" ) ; assertNotNull ( namespaces . get ( 0 ) , "Namespace list is null" ) ; opNamespace = namespaces . get ( 0 ) ; logger . info ( "Creating unique namespace for Domain" ) ; assertNotNull ( namespaces . get ( 1 ) , "Namespace list is null" ) ; domainNamespace = namespaces . get ( 1 ) ; logger . info ( "Creating service account" ) ; String serviceAccountName = opNamespace + "-sa" ; assertDoesNotThrow ( ( ) -> createServiceAccount ( new V1ServiceAccount ( ) . metadata ( new V1ObjectMeta ( ) . namespace ( opNamespace ) . name ( serviceAccountName ) ) ) ) ; logger . info ( "Created service account: {0}" , serviceAccountName ) ; 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 ) ; JsonObject dockerConfigJsonObject = createDockerConfigJson ( REPO_USERNAME , REPO_PASSWORD , REPO_EMAIL , REPO_REGISTRY ) ; dockerConfigJson = dockerConfigJsonObject . toString ( ) ; logger . info ( "Creating repo secret {0}" , REPO_SECRET_NAME ) ; V1Secret repoSecret = new V1Secret ( ) . metadata ( new V1ObjectMeta ( ) . name ( REPO_SECRET_NAME ) . namespace ( opNamespace ) ) . type ( "kubernetes.io/dockerconfigjson" ) . putDataItem ( ".dockerconfigjson" , dockerConfigJson . getBytes ( ) ) ; boolean secretCreated = assertDoesNotThrow ( ( ) -> createSecret ( repoSecret ) , String . format ( "createSecret failed for %s" , REPO_SECRET_NAME ) ) ; assertTrue ( secretCreated , String . format ( "createSecret failed while creating secret %s in namespace" , REPO_SECRET_NAME , opNamespace ) ) ; secretNameMap = new HashMap < String , Object > ( ) ; secretNameMap . put ( "name" , REPO_SECRET_NAME ) ; 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 ( serviceAccountName ) ; logger . info ( "Installing Operator in namespace {0}" , opNamespace ) ; assertTrue ( installOperator ( opParams ) , String . format ( "Operator install failed 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 ( "Check Operator pod is running 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 ( operatorIsReady ( opNamespace ) ) ; assertDoesNotThrow ( ( ) -> createRepoSecret ( domainNamespace ) , String . format ( "createSecret failed for %s" , REPO_SECRET_NAME ) ) ; logger . info ( "Create secret for admin credentials" ) ; String adminSecretName = "weblogic-credentials" ; assertDoesNotThrow ( ( ) -> createDomainSecret ( adminSecretName , "weblogic" , "welcome1" , domainNamespace ) , String . format ( "createSecret failed for %s" , adminSecretName ) ) ; logger . info ( "Create encryption secret" ) ; String encryptionSecretName = "encryptionsecret" ; assertDoesNotThrow ( ( ) -> createDomainSecret ( encryptionSecretName , "weblogicenc" , "weblogicenc" , domainNamespace ) , String . format ( "createSecret failed for %s" , encryptionSecretName ) ) ; createDomainResource ( domainUid , domainNamespace , adminSecretName , REPO_SECRET_NAME , encryptionSecretName , replicaCount ) ; logger . info ( "Check for domain custom resource in namespace {0}" , domainNamespace ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for domain {0} to be created in namespace {1} " + "(elapsed time {2}ms, remaining time {3}ms)" , domainUid , domainNamespace , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( domainExists ( domainUid , DOMAIN_VERSION , domainNamespace ) ) ; }
Install Operator.
Install Operator .
// create standard, reusable retry/backoff policy // get a new unique opNamespace // 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 // Create the V1Secret configuration // map with secret // helm install parameters // Operator chart values to override // install Operator // list helm releases matching Operator release name in operator namespace // check operator is running // Create the repo secret to pull the image // create secret for admin credentials // create encryption secret // create the domain CR with no configmap // wait for the domain to exist