Class AbstractOperatorExtension

java.lang.Object
io.javaoperatorsdk.operator.junit.AbstractOperatorExtension
All Implemented Interfaces:
HasKubernetesClient, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension
Direct Known Subclasses:
ClusterDeployedOperatorExtension, LocallyRunOperatorExtension

public abstract class AbstractOperatorExtension extends Object implements HasKubernetesClient, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback
  • Field Details

    • MAX_NAMESPACE_NAME_LENGTH

      public static final int MAX_NAMESPACE_NAME_LENGTH
      See Also:
    • CRD_READY_WAIT

      public static final int CRD_READY_WAIT
      See Also:
    • DEFAULT_NAMESPACE_DELETE_TIMEOUT

      public static final int DEFAULT_NAMESPACE_DELETE_TIMEOUT
      See Also:
    • infrastructure

      protected final List<io.fabric8.kubernetes.api.model.HasMetadata> infrastructure
    • infrastructureTimeout

      protected Duration infrastructureTimeout
    • oneNamespacePerClass

      protected final boolean oneNamespacePerClass
    • preserveNamespaceOnError

      protected final boolean preserveNamespaceOnError
    • skipNamespaceDeletion

      protected final boolean skipNamespaceDeletion
    • waitForNamespaceDeletion

      protected final boolean waitForNamespaceDeletion
    • namespaceDeleteTimeout

      protected final int namespaceDeleteTimeout
      See Also:
    • namespaceNameSupplier

      protected final Function<org.junit.jupiter.api.extension.ExtensionContext,String> namespaceNameSupplier
    • perClassNamespaceNameSupplier

      protected final Function<org.junit.jupiter.api.extension.ExtensionContext,String> perClassNamespaceNameSupplier
    • namespace

      protected String namespace
  • Constructor Details

    • AbstractOperatorExtension

      protected AbstractOperatorExtension(List<io.fabric8.kubernetes.api.model.HasMetadata> infrastructure, Duration infrastructureTimeout, boolean oneNamespacePerClass, boolean preserveNamespaceOnError, boolean skipNamespaceDeletion, boolean waitForNamespaceDeletion, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, io.fabric8.kubernetes.client.KubernetesClient infrastructureKubernetesClient, Function<org.junit.jupiter.api.extension.ExtensionContext,String> namespaceNameSupplier, Function<org.junit.jupiter.api.extension.ExtensionContext,String> perClassNamespaceNameSupplier)
  • Method Details

    • beforeAll

      public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
    • getKubernetesClient

      public io.fabric8.kubernetes.client.KubernetesClient getKubernetesClient()
      Description copied from interface: HasKubernetesClient
      Returns the main Kubernetes client that is used to deploy the operator to the cluster.
      Specified by:
      getKubernetesClient in interface HasKubernetesClient
      Returns:
      the main Kubernetes client
    • getInfrastructureKubernetesClient

      public io.fabric8.kubernetes.client.KubernetesClient getInfrastructureKubernetesClient()
      Description copied from interface: HasKubernetesClient
      Returns the Kubernetes client that is used to deploy infrastructure resources to the cluster such as clusterroles, clusterrolebindings, etc. This client can be different from the main client in case you need to test the operator with a different restrictions more closely resembling the real restrictions it will have in production.
      Specified by:
      getInfrastructureKubernetesClient in interface HasKubernetesClient
      Returns:
      the infrastructure Kubernetes client
    • getNamespace

      public String getNamespace()
    • resources

      public <T extends io.fabric8.kubernetes.api.model.HasMetadata> io.fabric8.kubernetes.client.dsl.NonNamespaceOperation<T,io.fabric8.kubernetes.api.model.KubernetesResourceList<T>,io.fabric8.kubernetes.client.dsl.Resource<T>> resources(Class<T> type)
    • get

      public <T extends io.fabric8.kubernetes.api.model.HasMetadata> T get(Class<T> type, String name)
    • create

      public <T extends io.fabric8.kubernetes.api.model.HasMetadata> T create(T resource)
    • serverSideApply

      public <T extends io.fabric8.kubernetes.api.model.HasMetadata> T serverSideApply(T resource)
    • update

      public <T extends io.fabric8.kubernetes.api.model.HasMetadata> T update(T resource)
    • replace

      public <T extends io.fabric8.kubernetes.api.model.HasMetadata> T replace(T resource)
    • delete

      public <T extends io.fabric8.kubernetes.api.model.HasMetadata> boolean delete(T resource)
    • beforeAllImpl

      protected void beforeAllImpl(org.junit.jupiter.api.extension.ExtensionContext context)
    • beforeEachImpl

      protected void beforeEachImpl(org.junit.jupiter.api.extension.ExtensionContext context)
    • before

      protected void before(org.junit.jupiter.api.extension.ExtensionContext context)
    • afterAllImpl

      protected void afterAllImpl(org.junit.jupiter.api.extension.ExtensionContext context)
    • afterEachImpl

      protected void afterEachImpl(org.junit.jupiter.api.extension.ExtensionContext context)
    • after

      protected void after(org.junit.jupiter.api.extension.ExtensionContext context)
    • deleteOperator

      protected void deleteOperator()