Class OpenShiftAssistant

java.lang.Object
org.arquillian.cube.kubernetes.impl.KubernetesAssistant
org.arquillian.cube.openshift.impl.client.OpenShiftAssistant

public class OpenShiftAssistant extends KubernetesAssistant
Class that allows you to deploy undeploy and wait for resources programmatically in a test.
  • Method Details

    • deployApplication

      public void deployApplication(String applicationName) throws IOException
      Deploys application finding resources in default location in classpath. That is: openshift.(y[a]ml|json), kubernetes.(y[a]ml|json), META-INF/fabric8/openshift.(y[a]ml|json), META-INF/fabric8/kubernetes.(y[a]ml|json) In this method yo specify the application name.
      Overrides:
      deployApplication in class KubernetesAssistant
      Parameters:
      applicationName - to configure in cluster
      Throws:
      IOException
    • deploy

      public void deploy(InputStream inputStream) throws IOException
      Deploys application reading resources from specified InputStream.
      Overrides:
      deploy in class KubernetesAssistant
      Parameters:
      inputStream - where resources are read
      Throws:
      IOException
    • getRoute

      public Optional<URL> getRoute(String routeName)
      Gets the URL of the route with given name.
      Parameters:
      routeName - to return its URL
      Returns:
      URL backed by the route with given name.
    • getRoute

      public Optional<URL> getRoute()
      Returns the URL of the first route.
      Returns:
      URL backed by the first route.
    • awaitUrl

      public void awaitUrl(URL routeUrl, int... statusCodes)
      Waits until the url responds with correct status code
      Parameters:
      routeUrl - URL to check (usually a route one)
      statusCodes - list of status code that might return that service is up and running. It is used as OR, so if one returns true, then the route is considered valid. If not set, then only 200 status code is used.
    • scale

      public void scale(int replicas)
      Scaling the last deployed application to given replicas
      Overrides:
      scale in class KubernetesAssistant
      Parameters:
      replicas - to scale the application
    • scale

      public void scale(String applicationName, int replicas)
      Scaling the application to given replicas
      Overrides:
      scale in class KubernetesAssistant
      Parameters:
      applicationName - name of the application to scale
      replicas - to scale the application
    • awaitApplicationReadinessOrFail

      public void awaitApplicationReadinessOrFail()
      Awaits at most 5 minutes until all pods of the last deployed application are running.
      Overrides:
      awaitApplicationReadinessOrFail in class KubernetesAssistant
    • awaitApplicationReadinessOrFail

      public void awaitApplicationReadinessOrFail(String applicationName)
      Awaits at most 5 minutes until all pods of the application are running.
      Overrides:
      awaitApplicationReadinessOrFail in class KubernetesAssistant
      Parameters:
      applicationName - name of the application to wait for pods readiness
    • deploymentConfig

      public io.fabric8.openshift.api.model.DeploymentConfig deploymentConfig()
      Method that returns the current deployment configuration object
      Returns:
      Current deployment config object.
    • usingTemplate

      public OpenShiftAssistantTemplate usingTemplate(URL templateURL)
      Gets template URL used for deploying application.
      Parameters:
      templateURL - url path to the template
      Returns:
      OpenShiftAssistantTemplate object.
    • usingTemplate

      public OpenShiftAssistantTemplate usingTemplate(String templateURL) throws MalformedURLException
      Gets template URL string used for deploying application.
      Parameters:
      templateURL - path to the template
      Returns:
      OpenShiftAssistantTemplate object.
      Throws:
      MalformedURLException
    • listProjects

      public List<io.fabric8.openshift.api.model.Project> listProjects()
      Gets the list of all the OpenShift Projects.
      Returns:
      list of OpenShift Projects.
    • getCurrentProjectName

      public String getCurrentProjectName()
      Gets the current OpenShift project used for deploying application.
      Returns:
      current namespace.
    • projectExists

      public boolean projectExists(String name) throws IllegalArgumentException
      Checks if the given project exists or not.
      Parameters:
      name - project name
      Returns:
      true/false
      Throws:
      IllegalArgumentException
    • findProject

      public Optional<io.fabric8.openshift.api.model.Project> findProject(String name) throws IllegalArgumentException
      Finds for the given project.
      Parameters:
      name - project name
      Returns:
      given project or an empty Optional if project does not exist
      Throws:
      IllegalArgumentException
    • getClient

      public io.fabric8.openshift.client.OpenShiftClient getClient()