Use cases
Use cases for sessions, from a single developer to a team that tests its changes together on one environment.
Last updated
On this page
- Description and operation
- General
- Start on a project in minutes
- Change the front end and the back end together
- Debug a failing request with real traffic
- Test two changes against each other
- Reproduce a bug without disturbing the team
- Review a pull request in a real environment
- Run integration tests against the services
- Stop everything with one call
- Tasks
- Work against a copy of an environment
- Collaborate on a shared environment
- Troubleshooting
Description and operation
General
Each use case below uses only sessions, their workspaces, the environment connection and intercepts. The examples use a team acme with an environment shop that runs web, api, worker and db.
| Use case | Who | What you get |
|---|---|---|
| Start on a project in minutes | A new developer | A working set-up against the real services, with nothing installed locally |
| Change the front end and the back end together | One developer | Two components that you change and run side by side |
| Debug a failing request with real traffic | One developer | Your code answers the real calls of the environment |
| Test two changes against each other | Two developers | A request that passes through both changes before either is merged |
| Reproduce a bug without disturbing the team | One developer | A private copy of the environment to break and fix |
| Review a pull request in a real environment | A reviewer | The change running against the services, not only the diff |
| Run integration tests against the services | A developer or a pipeline | A test run that reaches every service by name |
| Stop everything with one call | Anyone | All workspaces of a piece of work stopped, kept, and started again together |
Start on a project in minutes
Situation. A developer joins the team. The application needs a database, a queue and three services to run.
Set-up. The developer creates a session in acme, connects it to shop, and creates a workspace in the session with the repository and its packages.
Result. The code in the workspace reaches db, api and the other services by name. There is nothing to install, seed or configure on the laptop. See Create a session and Create a workspace in a session.
Change the front end and the back end together
Situation. A feature needs a change to web and to api.
Set-up. One session holds two workspaces, frontend and backend. The developer intercepts web with frontend and api with backend.
Result. A request to web reaches the front-end change, which calls api and reaches the back-end change. Both run against the real db and worker.
Debug a failing request with real traffic
Situation. Some requests to api fail, and only with the data and the callers of the environment.
Set-up. The developer intercepts api with a workspace that runs the service under a debugger.
Result. The failing request arrives in the workspace. The developer adds logs or breakpoints and saves; the next request runs the new code. When the bug is fixed, the developer removes the intercept and api takes its traffic back. See Intercept a service.
Test two changes against each other
Situation. Two developers change web and api for the same feature, in separate branches.
Set-up. Each developer connects their own session to shop. One intercepts web, the other intercepts api.
Result. A request passes through both workspaces. The two changes are tested together before either is merged. See task 002.
An intercept affects every developer on the environment. Agree who intercepts which service before you start.
Reproduce a bug without disturbing the team
Situation. A bug needs changes to the data or to a service that other developers use.
Set-up. The developer clones shop, connects their session to the copy, and intercepts there.
Result. The developer changes data and services freely. Nobody else on shop is affected. The copy is deleted at the end. See task 001.
Review a pull request in a real environment
Situation. A reviewer wants to see a change run, not only read it.
Set-up. The reviewer creates a workspace in their own session and checks out the branch of the pull request. The reviewer then intercepts the service that the change touches. In a shared environment, the reviewer uses a copy.
Result. The reviewer calls the service and sees the change answer with real data. The workspace is deleted after the review.
Run integration tests against the services
Situation. A test suite needs the real services, not mocks.
Set-up. A sandbox is created through the session, with the test command.
Result. The tests reach every service of the environment by name, and the sandbox ends when the run ends. Pipelines use the same model for their jobs. See Sandboxes.
Stop everything with one call
Situation. A piece of work uses several workspaces, and the developer stops for the day.
Set-up. The developer stops the session.
Result. All workspaces of the session stop together, and their homes are kept. Starting the session starts them again. Without any call, an unused session stops by itself after 30 minutes. See Stop a session.
Tasks
Work against a copy of an environment
Reason for the task: Test a change, or intercept a service, without affecting the other sessions on a shared environment.
Job set-up
- Access: you.
- References: Clone an environment, Connect an environment.
Procedure
Clone the shared environment. The copy has the same services and data, and belongs to the same team.
kl.environments.clone(environment="acme/shop", to="shop-dev")await kl.environments.clone({ environment: "acme/shop", to: "shop-dev" });if _, err := kl.Environments.Clone(kloudlite.CloneEnvironment{Environment: "acme/shop", To: "shop-dev"}); err != nil { log.Fatal(err)}kl.environments.clone(environment: "acme/shop", to: "shop-dev")kl.environments().clone(new Kloudlite.CloneEnvironment().environment("acme/shop").to("shop-dev"));kloudlite environments clone acme/shop --to shop-devConnect your session to the copy. The workspaces of the session now reach the services of the copy.
kl.sessions.connect(session="acme/dev", environment="shop-dev")await kl.sessions.connect({ session: "acme/dev", environment: "shop-dev" });env := "shop-dev"if _, err := kl.Sessions.Connect("acme/dev", &env); err != nil { log.Fatal(err)}kl.sessions.connect(session: "acme/dev", environment: "shop-dev")kl.sessions().connect("acme/dev", "shop-dev");kloudlite sessions connect-env shop-dev --session acme/devIf you test a change against real traffic, intercept a service of the copy. See Intercept a service.
Close-out
- When you are done, connect the session to the shared environment again, and delete the copy.
Collaborate on a shared environment
Reason for the task: Let several developers test their changes against each other, each in their own session.
Job set-up
- Access: each developer, in their own session of the same team.
- Conditions: the team has an environment, for example
acme/shopwith the serviceswebandapi. - References: Connect an environment, Intercept a service.
An intercept affects every developer on the environment. Agree who intercepts which service before you start.
Procedure
- Connect your own session to the environment, as each developer does in theirs (Connect an environment).
- Send the traffic of the service that you change to a workspace of your session, for example
api. Another developer intercepts another service, for exampleweb(Intercept a service). - Send a request to
webto test end to end. It reaches the other developer's workspace, which callsapiand reaches yours.
Close-out
- Remove your intercept, and make sure that the other developers remove theirs (Remove an intercept). The services take their traffic back.
Troubleshooting
| Symptom | Possible cause | Corrective action |
|---|---|---|
409 with session dev (karthik) already intercepts this service | Another developer holds the intercept on the shared environment. | Ask the holder to release it, or work in a copy. |
| Other developers see your change answer their requests | Your intercept is in force on a shared environment. | Remove the intercept, or move your work to a copy. |
| The copy of the environment counts against your quota | A clone is a full environment. | Delete the copy when you are done. |