Testing services

Learn how services can be tested before they are published and deployed

The Architect CLI has the ability to spin up and deploy an entire microservice stack on a user's local machine. In doing so, developers are empowered to write code for a stack that works the same way locally as it does in other cloud-based environments.

Prerequisites

Service debug commands

While remote deployments via Architect's platform leverage the default CMD in the Dockerfile to start a service, the CLI optionally reads from an alternative command specified in a service configuration when running a service locally. This command is great for running hot-reloading or other debugging tools on a local stack to increase productivity.

{
  "name": "architect/payments",
  "debug": "nodemon"
}

To override the command used to run a service locally, simply provide a debug key in your service config that includes the command to run. This can be any command that will resolve an execute in your container like "nodemon" as shown above, npm start, etc.

Running local services

Since any given service can't be aware of where it exists on the file system, the way local file paths are resolved and deployed is by reference in an environment config. More often than not you'll only want to test a single service with the rest running as local containers using default commands, but developers can also test multiple services in tandem by refering to their relative file paths in an environment config:

{
  "services": {
    "architect/frontend:latest": {
      "debug": {
        "path": "."
      }
    },
    "architect/payments:latest": {
      "debug": {
        "path": "../payments-service"
      }
    },
    "architect/auth": {
      "debug": {
        "path": "../auth-service"
      }
    }
  }
}

The snippet above represents an environment config that will deploy three services using their respective debug commands from the local filesystem. Any implicit dependencies of the services will also be run locally, but will instead be pulled down from the Architect registry and run using their default Docker commands. The command below would be run from the folder containing the architect/frontend service code and assumes that the payments and auth services are in sibling folders named payments-service and auth-service respectively.

architect deploy --local local-environment.json