Discover how environment as a service (EaaS) technology can enhance developer productivity, reduce costs, and improve product quality.
Environment as a service (EaaS) describes a method of provisioning full hosted application environments, including the application code, dependencies, runtime binaries, and configuration files. Development teams use EaaS to rapidly create ephemeral environments for individual feature branches that mimic their production environments. Developers use such ephemeral environments to test software under realistic conditions and remove the environments after testing.
This article covers the features and benefits of EaaS, explains its use cases, and offers tips and recommendations for adopting it. It concludes with a discussion of best practices, including a series of instructions, code snippets, and examples to help you implement EaaS effectively and obtain the best possible outcome.
Here are the key ideas presented in this article
Let us look at some common challenges faced by software teams that EaaS solves.
Traditional test, staging, or production environments are persistent and shared by the full development and quality assurance (QA) teams. Developers and test engineers must wait their turn to test code in centralized and permanent environments, which slows development velocity and hinders innovation. These environments remain idle at night and during times when testing is not required, wasting resources and money.
EaaS solves this suboptimal usage of resources by providing an on-demand environment for every feature branch that requires testing and then removing it automatically when the code merges with the main branch.
Offering sandboxes might be a complex feature for developers to implement because it typically involves problems related to scaling, load balancing, and maintaining different code versions in multiple sandboxes. With EaaS, creating sandboxes becomes as easy as creating a new branch within version control.
Product managers often use webinars or screencasts for software demonstrations as part of user acceptance testing. With EaaS, you can also easily create and share live preview environments with your audience.
Developers engage in debugging activities such as pair programming and work by sharing screens. Preview environments help developers avoid screen sharing by interacting directly with an environment created for any branch relevant to their work.
There are many compelling reasons to consider using EaaS to manage your test environments.
You can save time, money, and effort by letting a service provision and remove on-demand test environments. Ephemeral environments avoid idle infrastructure overnight when developers sleep and during the time in a development sprint when testing is not required.
Developers should focus on writing test cases and finding and fixing bugs, not configuring test environments. By delegating infrastructure provisioning to an EaaS provider, developers can work on their code rather than dealing with the complexities of configuring compute, storage, networking, DNS, and database resources.
Developers often wait in line to test their code changes in shared environments. EaaS helps developers work independently by providing a dedicated environment for every feature branch.
Code reviews don’t always reveal all of the design problems or software bugs. Preview environments let code reviewers experience the code in action, speeding up the quality assurance process. They also help keep the main branch clean as developers fix issues in a feature branch before merging the changes.
Large application refactoring projects are scary and often create resistance, forcing developers to patch code instead of making fundamental changes. The smooth process provided by EaaS boosts confidence to the level needed to undertake large refactoring projects by viewing and testing incremental changes throughout the project.
Here are some of the most common environments hosted on EaaS platforms.
Most development teams separate their development environments from their testing environments. Ephemeral environments hosted on EaaS platforms make it easier to operate many platforms simultaneously.
It’s a best practice to test data migrations and architectural migrations in a temporary environment before implementing the changes in production. EaaS platforms can help create parallel environments with varying configurations to test code before and after a migration.
Upgrading the version of middleware components (like the message bus and databases) can require proper testing facilitated by ephemeral environments.
Product management teams often demo the most recent features to customers who requested the enhancements before their general release. Ephemeral environments can help facilitate customer demos.
Research and development teams can use ephemeral environments to start on a current software release’s foundation and apply changes to showcase new design ideas for management approval.
Here are some of the core features that an effective EaaS should offer:
Some additional helpful features that EaaS platforms can offer include the following:
To most effectively add EaaS into your development cycle, follow these best practices.
EaaS uses containerization to set up and tear down ephemeral environments quickly. Package your application code along with dependencies such as libraries, configuration files, and binaries into self-contained containers that can run on popular runtime engines like Docker, Cri-o, or containerd.
After defining your container in a configuration file, you can build container images and upload them to a registry such as DockerHub or Amazon Elastic Container Registry. By giving access, EaaS can pull these images whenever it creates an environment. Follow this documentation to get a deeper understanding of containerization and the process of storing container images in a registry.
Storing code on a Git-based version control system (VCS) is a common practice, but it’s still worth mentioning, especially since VCS platforms increasingly support built-in continuous integration functionality. CI workflows use webhooks to monitor events occurring in your code repository and can trigger EaaS to set up and tear down ephemeral environments. For example, the GitHub Actions workflow offers triggers that can integrate with EaaS platforms such as Uffizzi. Here is an example of a workflow that listens for the pull_request event. It executes the workflow whenever a pull request is raised against the main branch in the repository.
To start with Docker Compose, refer to Docker’s getting started guide.
Secrets include passwords, keys to third-party APIs, encryption keys, database credentials, and authentication certificates. Don’t store this sensitive information in your code: Put it in a secret manager and let EaaS inject the necessary secrets into the codebase at runtime as needed.
Here is a section of a Docker Compose file that uses variable substitution to fill in secrets at runtime:
These values can be accessed from within the server application. Here is an example:
You can configure CI workflows so that the EaaS service is triggered by Git events like pushing commits to a branch or raising pull requests. Once triggered by an event, EaaS can provision a preview environment and make the environment accessible through a URL.The most important steps involved in such a workflow are to build a container image of your application and push the image to a container registry such as GitHub container registry. EaaS should then be able to put together your docker-compose file, the images in the container registry, and secrets in the secret manager to create the environment. You can refer to this documentation to learn more about integrating Uffizzi with CI workflows.
Seeding databases with initial data makes preview environments more comprehensive and easier to test. Pick a data loading method that works best for your database. For example, a MySQL database can load data from an SQL dump file stored in Amazon S3.
The official MySQL image published on Docker Hub includes facilities for populating the database at startup. These containers will automatically execute *.sql, *sql.gz, and *.sh files stored in the /docker-entrypoint-initdb.d directory. Here is an example of a shell script to download a SQL dump file from your S3 bucket and load it into the database.
Different EaaS providers support different seeding methods; learn more about the seeding methods supported by Uffizzi.
Mocking refers to using simulation services that mimic the behavior of real services. This allows developers to test their code without actually calling the service. You can mock third-party services and external API adapters in your code to avoid maintaining multiple test accounts of these services for use in your preview environments.
Here is a sample implementation in which Stripe-based payment functionality is mocked in a preview environment.
Here are some more ideas to keep in mind that may help ensure a good outcome when adopting EaaS:
Environment-as-a-service platforms set up and tear down a complete ephemeral application stack for every feature branch allowing each developer or test engineer to run tests in isolation before merging their code with the main branch.
EaaS platforms should integrate with CI/CD platforms like GitHub Actions, container provisioning technologies like Docker compose, and provide their own secret manager and functionality to seed a database.
Be sure to assess any potential EaaS provider before making a commitment to ensure that it meets your needs. Quality providers should offer a live, interactive demo and a free trial.