integration-tests/src/test/java/oracle/kubernetes/operator/ItUsabilityOperatorHelmChart.java
@Test
  public void testSecondOpSharingSameExternalRestPortNegativeInstall() throws Exception {
    Assumptions.assumeTrue(FULLTEST);
    String testMethodName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    logTestBegin(testMethodName);
    int httpsRestPort = 0;

    Operator operator1 = new Operator(createOperatorMap(getNewSuffixCount(),
        true, "usab"),
        RestCertType.SELF_SIGNED);
    operator1.callHelmInstall();

    httpsRestPort = new Integer(operator1.getOperatorMap().get("externalRestHttpsPort").toString()).intValue();
    LoggerHelper.getLocal().log(Level.INFO, "Creating second operator with externalRestHttpPort " + httpsRestPort);
    Map<String, Object> operatorMap = createOperatorMap(getNewSuffixCount(), true, "usab");
    operatorMap.replace("externalRestHttpsPort", httpsRestPort);
    String oprelease = (String)operatorMap.get("releaseName");
    String opnamespace = (String)operatorMap.get("namespace");
    Operator operator2 = new Operator(operatorMap, RestCertType.SELF_SIGNED);
    try {
      operator2.callHelmInstall();
      throw new Exception(
          "FAILURE: Helm install operator with duplicate rest port number ");
    } catch (Exception ex) {
      LoggerHelper.getLocal().log(Level.INFO, "Error message " + ex.getMessage());
      if (!ex.getMessage()
          .contains(
              "Service \"external-weblogic-operator-svc\" is invalid: spec.ports[0].nodePort: Invalid value:")) {
        throw new Exception(
            "FAILURE: Helm install operator with duplicate rest port number does not report the expected message "
                + ex.getMessage());
      }
      String cmdLb = "";
      cmdLb = "helm list --failed --namespace " + opnamespace + " | grep " + oprelease;
      LoggerHelper.getLocal().log(Level.INFO, "Executing cmd " + cmdLb);
      ExecResult result = ExecCommand.exec(cmdLb);
      if (result.exitValue() != 0) {
        throw new Exception(
            "FAILURE: Helm install operator with duplicate Rest Port number ");
      }
    } finally {
      if (operator1 != null) {
        operator1.destroy();
      }
      if (operator2 != null) {
        operator2.destroy();
      }
    }
    LoggerHelper.getLocal().log(Level.INFO, "SUCCESS - " + testMethodName);
  }
/**
   * Intitialize two operators op1 and op2 with same ExternalRestHttpPort.
   * Install operator op1.
   * Install operator op2.
   * Installation of second operator should fail.
   *
   * @throws Exception when second operator installation does not fail
   */
Intitialize two operators op1 and op2 with same ExternalRestHttpPort.
Install operator op1.
Install operator op2.
Installation of second operator should fail.

@throws Exception when second operator installation does not fail
Intitialize two operators op1 and op2 with same ExternalRestHttpPort . Install operator op1 . Install operator op2 . Installation of second operator should fail . @throws Exception when second operator installation does not fail
@Test
  public void testSecondOpSharingSameExternalRestPortNegativeInstall() throws Exception {
    Assumptions.assumeTrue(FULLTEST);
    String testMethodName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    logTestBegin(testMethodName);
    int httpsRestPort = 0;
    Operator operator1 = new Operator(createOperatorMap(getNewSuffixCount(),
        true, "usab"),
        RestCertType.SELF_SIGNED);
    operator1.callHelmInstall();
    httpsRestPort = new Integer(operator1.getOperatorMap().get("externalRestHttpsPort").toString()).intValue();
    LoggerHelper.getLocal().log(Level.INFO, "Creating second operator with externalRestHttpPort " + httpsRestPort);
    Map<String, Object> operatorMap = createOperatorMap(getNewSuffixCount(), true, "usab");
    operatorMap.replace("externalRestHttpsPort", httpsRestPort);
    String oprelease = (String)operatorMap.get("releaseName");
    String opnamespace = (String)operatorMap.get("namespace");
    Operator operator2 = new Operator(operatorMap, RestCertType.SELF_SIGNED);
    try {
      operator2.callHelmInstall();
      throw new Exception(
          "FAILURE: Helm install operator with duplicate rest port number ");
    } catch (Exception ex) {
      LoggerHelper.getLocal().log(Level.INFO, "Error message " + ex.getMessage());
      if (!ex.getMessage()
          .contains(
              "Service \"external-weblogic-operator-svc\" is invalid: spec.ports[0].nodePort: Invalid value:")) {
        throw new Exception(
            "FAILURE: Helm install operator with duplicate rest port number does not report the expected message "
                + ex.getMessage());
      }
      String cmdLb = "";
      cmdLb = "helm list --failed --namespace " + opnamespace + " | grep " + oprelease;
      LoggerHelper.getLocal().log(Level.INFO, "Executing cmd " + cmdLb);
      ExecResult result = ExecCommand.exec(cmdLb);
      if (result.exitValue() != 0) {
        throw new Exception(
            "FAILURE: Helm install operator with duplicate Rest Port number ");
      }
    } finally {
      if (operator1 != null) {
        operator1.destroy();
      }
      if (operator2 != null) {
        operator2.destroy();
      }
    }
    LoggerHelper.getLocal().log(Level.INFO, "SUCCESS - " + testMethodName);
  }
@ Test public void testSecondOpSharingSameExternalRestPortNegativeInstall ( ) throws Exception { Assumptions . assumeTrue ( FULLTEST ) ; String testMethodName = new Object ( ) { } . getClass ( ) . getEnclosingMethod ( ) . getName ( ) ; logTestBegin ( testMethodName ) ; int httpsRestPort = 0 ; Operator operator1 = new Operator ( createOperatorMap ( getNewSuffixCount ( ) , true , "usab" ) , RestCertType . SELF_SIGNED ) ; operator1 . callHelmInstall ( ) ; httpsRestPort = new Integer ( operator1 . getOperatorMap ( ) . get ( "externalRestHttpsPort" ) . toString ( ) ) . intValue ( ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Creating second operator with externalRestHttpPort " + httpsRestPort ) ; Map < String , Object > operatorMap = createOperatorMap ( getNewSuffixCount ( ) , true , "usab" ) ; operatorMap . replace ( "externalRestHttpsPort" , httpsRestPort ) ; String oprelease = ( String ) operatorMap . get ( "releaseName" ) ; String opnamespace = ( String ) operatorMap . get ( "namespace" ) ; Operator operator2 = new Operator ( operatorMap , RestCertType . SELF_SIGNED ) ; try { operator2 . callHelmInstall ( ) ; throw new Exception ( "FAILURE: Helm install operator with duplicate rest port number " ) ; } catch ( Exception ex ) { LoggerHelper . getLocal ( ) . log ( Level . INFO , "Error message " + ex . getMessage ( ) ) ; if ( ! ex . getMessage ( ) . contains ( "Service \"external-weblogic-operator-svc\" is invalid: spec.ports[0].nodePort: Invalid value:" ) ) { throw new Exception ( "FAILURE: Helm install operator with duplicate rest port number does not report the expected message " + ex . getMessage ( ) ) ; } String cmdLb = "" ; cmdLb = "helm list --failed --namespace " + opnamespace + " | grep " + oprelease ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Executing cmd " + cmdLb ) ; ExecResult result = ExecCommand . exec ( cmdLb ) ; if ( result . exitValue ( ) != 0 ) { throw new Exception ( "FAILURE: Helm install operator with duplicate Rest Port number " ) ; } } finally { if ( operator1 != null ) { operator1 . destroy ( ) ; } if ( operator2 != null ) { operator2 . destroy ( ) ; } } LoggerHelper . getLocal ( ) . log ( Level . INFO , "SUCCESS - " + testMethodName ) ; }
Intitialize two operators op1 and op2 with same ExternalRestHttpPort.
Intitialize two operators op1 and op2 with same ExternalRestHttpPort .