Getting Started - LivePersonInc/ephemerals GitHub Wiki

Ephemerals are short-lived cluster endpoints, designed to setup complex test environments on the fly, be integrated with cluster management systems and enable testing at a large scale.

Ephemerals can be deployed on various cloud providers for creating use-and-throw instances of browsers, web services, databases or anything else than can expose a connection endpoint.

The main motivation behind Ephemerals is that whole test environment is launched and destroyed during test lifecycle.

Ephemeral library is based on two major components:

  • Providers: Handle the deployment and launching of Ephemeral instances on the cluster.
  • Modules: Define Ephemeral's objects configuration such as container image, connection endpoints, etc...

Ephemerals currently support Kuberenetes as a deployment provider. More providers will be added soon.

Adding Binaries

You can use Ephemeral core API by adding following dependency to your Maven project:

<dependency>
        <groupId>com.liveperson</groupId>
        <artifactId>ephemerals-core</artifactId>
        <version>$VERSION</version>
</dependency>

Ephemeral core API is a good start-point for learning project's components and for implementing your own new modules or providers.

Since Ephemeral is based on modules and providers, you will need to add at least one module and one provider for actually creating Ephemeral instances.

For example, if your tests will deploy Selenium browsers in a Kubernetes Cluster, you need to add following dependencies:

Kuberenetes Provider:

<dependency>
        <groupId>com.liveperson.ephemerals</groupId>
        <artifactId>ephemerals-provider-kubernetes</artifactId>
        <version>$VERSION</version>
</dependency>

Selenium Module:

<dependency>
        <groupId>com.liveperson.ephemerals</groupId>
        <artifactId>ephemerals-module-selenium</artifactId>
        <version>$VERSION</version>
</dependency>

Configuring Deployment Context

Each deployment is executed using a DeploymentHandler.

Once a Deployment Provider is used, we need to define its DeploymentHandler and DeploymentConfiguration objects. Both objects define our DeploymentContext.

Following previous example, we initialize a KubernetesDeploymentHandler to perform all Ephemerals' deployments using a Kubernetes-managed cluster.

KubernetesDeploymentHandler kubernetesDeploymentHandler  = new KubernetesDeploymentHandler.Builder(
             getKubernetesService())
             .build()))

Example of KubernetesDeploymentConfiguration instance initialization:

DeploymentConfiguration deploymentConfiguration = new KubernetesDeploymentConfiguration.Builder()
        .withReplicas(1)
        .build();

Deploying an Ephemeral

After we set the deployment configuration, we can start deploying Ephemeral instances. Each Deployable Ephemeral will require both Deployer and DeploymentConfiguration objects for initalization.

Following our example above, following snippet will deploy a SeleniumEphemeral into Kubernetes Cluster and return connection endpoint in the form of a RemoteWebDriver instance:

Initialize Selenium Ephemeral:

SeleniumEphemeral seleniumEphemeral = new SeleniumEphemeral.Builder(new KubernetesDeploymentContext(
                    new KubernetesDeploymentHandler.Builder(
                            getKubernetesService())
                            .build()))
                    .build());

Deploy and fetch endpoint:

RemoteWebDriver remoteWebDriver = seleniumEphemeral.get();
remoteWebDriver.get("http://yahoo.com");
⚠️ **GitHub.com Fallback** ⚠️