integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java
public void testClusterScaling(Operator operator, Domain domain, boolean verifyLoadBalancing)
      throws Exception {
    LoggerHelper.getLocal().log(Level.INFO, "Inside testClusterScaling");
    TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
    Map<String, Object> domainMap = domain.getDomainMap();
    String domainUid = domain.getDomainUid();
    final String domainNS = domainMap.get("namespace").toString();
    String managedServerNameBase = domainMap.get("managedServerNameBase").toString();
    int replicas = 3;
    String podName = domain.getDomainUid() + "-" + managedServerNameBase + replicas;
    final String clusterName = domainMap.get("clusterName").toString();

    LoggerHelper.getLocal().log(Level.INFO,
        "Scale domain " + domain.getDomainUid() + " Up to " + replicas + " managed servers");
    operator.scale(domainUid, domainMap.get("clusterName").toString(), replicas);

    LoggerHelper.getLocal().log(Level.INFO, "Checking if managed pod(" + podName + ") is Running");
    TestUtils.checkPodCreated(podName, domainNS);

    LoggerHelper.getLocal().log(Level.INFO,
        "Checking if managed server (" + podName + ") is Running");
    TestUtils.checkPodReady(podName, domainNS);

    LoggerHelper.getLocal().log(Level.INFO,
        "Checking if managed service(" + podName + ") is created");
    TestUtils.checkServiceCreated(podName, domainNS);

    int replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
    if (replicaCnt != replicas) {
      throw new RuntimeException(
          "FAILURE: Cluster replica doesn't match with scaled up size "
              + replicaCnt
              + "/"
              + replicas);
    }
    if (verifyLoadBalancing) {
      domain.verifyWebAppLoadBalancing(TESTWEBAPP);
    }

    replicas = 2;
    podName = domainUid + "-" + managedServerNameBase + (replicas + 1);
    LoggerHelper.getLocal().log(Level.INFO, "Scale down to " + replicas + " managed servers");
    operator.scale(domainUid, clusterName, replicas);

    LoggerHelper.getLocal().log(Level.INFO, "Checking if managed pod(" + podName + ") is deleted");
    TestUtils.checkPodDeleted(podName, domainNS);

    replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
    if (replicaCnt != replicas) {
      throw new RuntimeException(
          "FAILURE: Cluster replica doesn't match with scaled down size "
              + replicaCnt
              + "/"
              + replicas);
    }
    if (verifyLoadBalancing) {
      domain.verifyWebAppLoadBalancing(TESTWEBAPP);
    }

    LoggerHelper.getLocal().log(Level.INFO, "Done - testClusterScaling");
  }
/**
   * Scale the cluster up/down using Operator REST endpoint, load balancing should adjust
   * accordingly.
   *
   * @throws Exception exception
   */
Scale the cluster up/down using Operator REST endpoint, load balancing should adjust
accordingly.

@throws Exception exception
Scale the cluster up / down using Operator REST endpoint load balancing should adjust accordingly . @throws Exception exception
public void testClusterScaling(Operator operator, Domain domain, boolean verifyLoadBalancing)
      throws Exception {
    LoggerHelper.getLocal().log(Level.INFO, "Inside testClusterScaling");
    TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
    Map<String, Object> domainMap = domain.getDomainMap();
    String domainUid = domain.getDomainUid();
    final String domainNS = domainMap.get("namespace").toString();
    String managedServerNameBase = domainMap.get("managedServerNameBase").toString();
    int replicas = 3;
    String podName = domain.getDomainUid() + "-" + managedServerNameBase + replicas;
    final String clusterName = domainMap.get("clusterName").toString();
    LoggerHelper.getLocal().log(Level.INFO,
        "Scale domain " + domain.getDomainUid() + " Up to " + replicas + " managed servers");
    operator.scale(domainUid, domainMap.get("clusterName").toString(), replicas);
    LoggerHelper.getLocal().log(Level.INFO, "Checking if managed pod(" + podName + ") is Running");
    TestUtils.checkPodCreated(podName, domainNS);
    LoggerHelper.getLocal().log(Level.INFO,
        "Checking if managed server (" + podName + ") is Running");
    TestUtils.checkPodReady(podName, domainNS);
    LoggerHelper.getLocal().log(Level.INFO,
        "Checking if managed service(" + podName + ") is created");
    TestUtils.checkServiceCreated(podName, domainNS);
    int replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
    if (replicaCnt != replicas) {
      throw new RuntimeException(
          "FAILURE: Cluster replica doesn't match with scaled up size "
              + replicaCnt
              + "/"
              + replicas);
    }
    if (verifyLoadBalancing) {
      domain.verifyWebAppLoadBalancing(TESTWEBAPP);
    }
    replicas = 2;
    podName = domainUid + "-" + managedServerNameBase + (replicas + 1);
    LoggerHelper.getLocal().log(Level.INFO, "Scale down to " + replicas + " managed servers");
    operator.scale(domainUid, clusterName, replicas);
    LoggerHelper.getLocal().log(Level.INFO, "Checking if managed pod(" + podName + ") is deleted");
    TestUtils.checkPodDeleted(podName, domainNS);
    replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
    if (replicaCnt != replicas) {
      throw new RuntimeException(
          "FAILURE: Cluster replica doesn't match with scaled down size "
              + replicaCnt
              + "/"
              + replicas);
    }
    if (verifyLoadBalancing) {
      domain.verifyWebAppLoadBalancing(TESTWEBAPP);
    }
    LoggerHelper.getLocal().log(Level.INFO, "Done - testClusterScaling");
  }
public void testClusterScaling ( Operator operator , Domain domain , boolean verifyLoadBalancing ) throws Exception { LoggerHelper . getLocal ( ) . log ( Level . INFO , "Inside testClusterScaling" ) ; TestUtils . renewK8sClusterLease ( getProjectRoot ( ) , getLeaseId ( ) ) ; Map < String , Object > domainMap = domain . getDomainMap ( ) ; String domainUid = domain . getDomainUid ( ) ; final String domainNS = domainMap . get ( "namespace" ) . toString ( ) ; String managedServerNameBase = domainMap . get ( "managedServerNameBase" ) . toString ( ) ; int replicas = 3 ; String podName = domain . getDomainUid ( ) + "-" + managedServerNameBase + replicas ; final String clusterName = domainMap . get ( "clusterName" ) . toString ( ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Scale domain " + domain . getDomainUid ( ) + " Up to " + replicas + " managed servers" ) ; operator . scale ( domainUid , domainMap . get ( "clusterName" ) . toString ( ) , replicas ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Checking if managed pod(" + podName + ") is Running" ) ; TestUtils . checkPodCreated ( podName , domainNS ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Checking if managed server (" + podName + ") is Running" ) ; TestUtils . checkPodReady ( podName , domainNS ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Checking if managed service(" + podName + ") is created" ) ; TestUtils . checkServiceCreated ( podName , domainNS ) ; int replicaCnt = TestUtils . getClusterReplicas ( domainUid , clusterName , domainNS ) ; if ( replicaCnt != replicas ) { throw new RuntimeException ( "FAILURE: Cluster replica doesn't match with scaled up size " + replicaCnt + "/" + replicas ) ; } if ( verifyLoadBalancing ) { domain . verifyWebAppLoadBalancing ( TESTWEBAPP ) ; } replicas = 2 ; podName = domainUid + "-" + managedServerNameBase + ( replicas + 1 ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Scale down to " + replicas + " managed servers" ) ; operator . scale ( domainUid , clusterName , replicas ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Checking if managed pod(" + podName + ") is deleted" ) ; TestUtils . checkPodDeleted ( podName , domainNS ) ; replicaCnt = TestUtils . getClusterReplicas ( domainUid , clusterName , domainNS ) ; if ( replicaCnt != replicas ) { throw new RuntimeException ( "FAILURE: Cluster replica doesn't match with scaled down size " + replicaCnt + "/" + replicas ) ; } if ( verifyLoadBalancing ) { domain . verifyWebAppLoadBalancing ( TESTWEBAPP ) ; } LoggerHelper . getLocal ( ) . log ( Level . INFO , "Done - testClusterScaling" ) ; }
Scale the cluster up/down using Operator REST endpoint, load balancing should adjust
 accordingly.
Scale the cluster up / down using Operator REST endpoint load balancing should adjust accordingly .