Ephemeral Environments: 7 Questions to Ask Before You Pick an Approach
Full copies, shared-cluster routing or service virtualization? Seven questions on tests, data, cost and routing to ask before you choose one.
If your team uses ephemeral environments, each pull request can get its own temporary environment. Kubernetes reports the pods as running, and the deploy job reports a passing status. Often, that status only confirms the manifests applied. At best, it shows pods became ready. But what if the database was never seeded and no test request ever reached the service? A broken change might still land in review looking healthy.
Ephemeral environments, also called preview environments, are usually deleted on merge or close. Creating them is well automated. Testing inside them is harder, because you need test cases, realistic data and stand-ins for services you can’t copy, such as a payment provider.
3 broad approaches#

Full copies: Each pull request gets its own instance of every service and usually its own database. Tests hit real code and schemas with little shared state, but every open pull request needs the whole stack deployed.
Shared-cluster routing: Only the changed services run, in a shared cluster or on a developer or CI machine. Requests carrying a routing header reach the changed versions, and other traffic reaches the stable baseline. It is light, but data is shared by default.
Service virtualization: Dependencies you can’t or don’t want to run are replaced with stand-ins built from stubs, specs or contracts, or recorded from real traffic. Tests get more repeatable and cheaper, but stand-ins know only captured or written behavior. It can stand alone or sit on top of either approach above.
7 questions to ask#
1. Who writes and maintains the tests?#
An environment gives you a running application, not tests. Your team usually writes and maintains them. Some traffic-recording tools generate test cases, though recordings need refreshing after intended changes. Look for coverage that grows faster than the test-writing work.
2. What happens to the APIs you can’t clone?#
A payment or email provider can’t be copied per pull request. Full copies and routing leave this to you, so teams usually share a test sandbox or run their own stand-in. Service virtualization supplies the tooling, though responses still have to be written, recorded or spec-generated, and inbound webhooks need separate handling. Look for stand-ins that behave like the real API.
3. Where does test data come from, and who else is touching it?#
Full copies usually start with an empty database unless someone seeds it or restores a snapshot, which is a privacy risk if it holds unmasked production data. Routing shares one database unless each sandbox gets its own, so tests can change each other’s data. Recorded stand-ins carry realistic responses, but only for calls like those captured, and production captures need masking. Look for realistic, isolated data that still exercises your real schema.
4. What does it cost to test each change?#

With full copies, twenty services across fifteen open pull requests can mean three hundred running services, busy or idle, unless idle environments are put to sleep. Routing adds only the changed services but needs an always-on baseline. Service virtualization skips running stubbed dependencies, though recording needs a live environment somewhere. Look for cost that grows with the changes you test, not with your architecture.
5. Will your test requests reach the changed code?#

In routing setups, every service in the request path must propagate the routing header. If a hop before your changed service drops it, the request lands on the stable version and the check can pass without touching your change. Full copies avoid this unless they share a queue or broker. With virtualization alone, test requests reach the new code, but calls to stubbed dependencies must hit stand-ins, and a miss fails, gets a fallback or passes through, depending on settings. Look for proof that test traffic reached the new code.
6. What happens when an upstream service changes?#
Real internal services in full copies and routing reflect whichever versions are deployed, but stand-ins answer as they did when last updated. Contract or spec checks can flag drift in hand-written stand-ins. Re-recording refreshes recorded ones but can quietly accept a breaking change. Look for a way to detect upstream changes, not just refresh after them.
7. What does a green check prove?#
Checks against stand-ins are usually more repeatable once noisy fields are handled, but they cover only recorded or written behavior, so a changed dependency or an unseen schema change can slip through. Real services answer unrecorded calls and use real schemas, though shared data or live dependencies can make results flakier. Look for a clear statement of what a pass covers and what it leaves out.
Choosing an approach#

Choose full copies when changes often touch schemas, migrations or several services at once, and you can afford the full stack per pull request. For example, splitting one table into two needs the migration to run against a real database before merge.
Choose shared-cluster routing when you run many services on Kubernetes, most pull requests change only one or two, and your services already propagate trace context. For example, most pull requests across forty services touch only checkout.
Choose service virtualization when the hard part is dependencies you can’t run per pull request, or when you want fast, repeatable regression checks in CI. For example, an order service whose tests need the payment provider to approve, decline and time out on demand.
Conclusion#
These approaches often work best together: full copies or routing for end-to-end realism, and service virtualization for third-party APIs and fast regression checks. Creating an environment per pull request is already well automated. The next step is making every green check answer one question honestly: was this change tested?
Originally published at https://www.devopsdigest.com on October 26, 2026.
Written by Dhananjay Aggarwal

