integration-tests/src/test/java/oracle/kubernetes/operator/ItUsabilityOperatorHelmChart.java
@Test
  public void testNotPreexistedOpServiceAccountCreateOperatorNegativeInstall() throws Exception {
    Assumptions.assumeTrue(FULLTEST);
    String testMethodName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    logTestBegin(testMethodName);
    Operator operator = null;
    operator =
        new Operator(
            (createOperatorMap(getNewSuffixCount(),false, "usab")),
            true,
            false,
            true,
            RestCertType.SELF_SIGNED);
    String oprelease = (String)(operator.getOperatorMap()).get("releaseName");
    String opnamespace = (String)(operator.getOperatorMap()).get("namespace");
    try {
      operator.callHelmInstall();
      throw new Exception(
          "FAILURE: Helm installs operator with not preexisted service account ");

    } catch (Exception ex) {
      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: failed helm is not showed in the failed list ");
      }
      // create operator service account
      String serviceAccount = (String) operator.getOperatorMap().get("serviceAccount");
      String operatorNS = (String) operator.getOperatorMap().get("namespace");
      if (serviceAccount != null && !serviceAccount.equals("default")) {
        result =
            ExecCommand.exec(
                "kubectl create serviceaccount " + serviceAccount + " -n " + operatorNS);
        if (result.exitValue() != 0) {
          throw new Exception(
              "FAILURE: Couldn't create serviceaccount "
                  + serviceAccount
                  + ". Cmd returned "
                  + result.stdout()
                  + "\n"
                  + result.stderr());
        }
      }
      // after service account created the operator should be started
      Thread.sleep(BaseTest.getWaitTimePod() * 2000);
      operator.verifyOperatorReady();
    } finally {
      if (operator != null) {
        operator.destroy();
      }
    }
    LoggerHelper.getLocal().log(Level.INFO, "SUCCESS - " + testMethodName);
  }
/**
   * Install the operator with non existing operator service account.
   * Operator installation should fail.
   * Create the service account.
   * Make sure operator pod is in ready state.
   *
   * @throws Exception when operator pod is not ready after the service account is created 
   */
Install the operator with non existing operator service account.
Operator installation should fail.
Create the service account.
Make sure operator pod is in ready state.

@throws Exception when operator pod is not ready after the service account is created
Install the operator with non existing operator service account . Operator installation should fail . Create the service account . Make sure operator pod is in ready state . @throws Exception when operator pod is not ready after the service account is created
@Test
  public void testNotPreexistedOpServiceAccountCreateOperatorNegativeInstall() throws Exception {
    Assumptions.assumeTrue(FULLTEST);
    String testMethodName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    logTestBegin(testMethodName);
    Operator operator = null;
    operator =
        new Operator(
            (createOperatorMap(getNewSuffixCount(),false, "usab")),
            true,
            false,
            true,
            RestCertType.SELF_SIGNED);
    String oprelease = (String)(operator.getOperatorMap()).get("releaseName");
    String opnamespace = (String)(operator.getOperatorMap()).get("namespace");
    try {
      operator.callHelmInstall();
      throw new Exception(
          "FAILURE: Helm installs operator with not preexisted service account ");
    } catch (Exception ex) {
      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: failed helm is not showed in the failed list ");
      }
      String serviceAccount = (String) operator.getOperatorMap().get("serviceAccount");
      String operatorNS = (String) operator.getOperatorMap().get("namespace");
      if (serviceAccount != null && !serviceAccount.equals("default")) {
        result =
            ExecCommand.exec(
                "kubectl create serviceaccount " + serviceAccount + " -n " + operatorNS);
        if (result.exitValue() != 0) {
          throw new Exception(
              "FAILURE: Couldn't create serviceaccount "
                  + serviceAccount
                  + ". Cmd returned "
                  + result.stdout()
                  + "\n"
                  + result.stderr());
        }
      }
      Thread.sleep(BaseTest.getWaitTimePod() * 2000);
      operator.verifyOperatorReady();
    } finally {
      if (operator != null) {
        operator.destroy();
      }
    }
    LoggerHelper.getLocal().log(Level.INFO, "SUCCESS - " + testMethodName);
  }
@ Test public void testNotPreexistedOpServiceAccountCreateOperatorNegativeInstall ( ) throws Exception { Assumptions . assumeTrue ( FULLTEST ) ; String testMethodName = new Object ( ) { } . getClass ( ) . getEnclosingMethod ( ) . getName ( ) ; logTestBegin ( testMethodName ) ; Operator operator = null ; operator = new Operator ( ( createOperatorMap ( getNewSuffixCount ( ) , false , "usab" ) ) , true , false , true , RestCertType . SELF_SIGNED ) ; String oprelease = ( String ) ( operator . getOperatorMap ( ) ) . get ( "releaseName" ) ; String opnamespace = ( String ) ( operator . getOperatorMap ( ) ) . get ( "namespace" ) ; try { operator . callHelmInstall ( ) ; throw new Exception ( "FAILURE: Helm installs operator with not preexisted service account " ) ; } catch ( Exception ex ) { 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: failed helm is not showed in the failed list " ) ; } String serviceAccount = ( String ) operator . getOperatorMap ( ) . get ( "serviceAccount" ) ; String operatorNS = ( String ) operator . getOperatorMap ( ) . get ( "namespace" ) ; if ( serviceAccount != null && ! serviceAccount . equals ( "default" ) ) { result = ExecCommand . exec ( "kubectl create serviceaccount " + serviceAccount + " -n " + operatorNS ) ; if ( result . exitValue ( ) != 0 ) { throw new Exception ( "FAILURE: Couldn't create serviceaccount " + serviceAccount + ". Cmd returned " + result . stdout ( ) + "\n" + result . stderr ( ) ) ; } } Thread . sleep ( BaseTest . getWaitTimePod ( ) * 2000 ) ; operator . verifyOperatorReady ( ) ; } finally { if ( operator != null ) { operator . destroy ( ) ; } } LoggerHelper . getLocal ( ) . log ( Level . INFO , "SUCCESS - " + testMethodName ) ; }
Install the operator with non existing operator service account.
Install the operator with non existing operator service account .
// create operator service account // after service account created the operator should be started