Categorygithub.com/tshak/testdummy
repositorypackage
0.3.6
Repository: https://github.com/tshak/testdummy.git
Documentation: pkg.go.dev

# README

Introduction

TestDummy is a rudimentary utility service to assist in testing platform schedulers such as Kubernetes and Nomad. It can be used as a simple "hello world" service or it can be used to test a couple of common failure modes (a humble "chaos monkey" in a way).

Usage

docker run -it --rm -p 8000:8000 ghcr.io/tshak/testdummy:latest

Docker images are hosted on GitHub.

Environment variables

The following environment variables can be used to configure the service.

NameDefaultDescription
TESTDUMMY_BIND_ADDRESS:8000The address to bind the service to
TESTDUMMY_ENABLE_ENVfalseEnable the /env endpoint which dumps env vars. :warning: This can be a security risk so enable with caution
TESTDUMMY_ENABLE_REQUEST_LOGGINGfalseLogs all requests to stdout
TESTDUMMY_HEALTHYtrueBoolean. When true /health returns an HTTP 200 response. When false /health returns an empty HTTP 500 response.
TESTDUMMY_HEALTHY_AFTER_SECONDSWhen set, sets the health status to false (regardless of TESTDUMMY_HEALTHY) until the specified number of seconds. This is useful for testing post deployment "warmup" scenarios.
TESTDUMMY_HEALTHCHECK_PG_DSNWhen set, adds a healthcheck for the specified Postgres DSN (e.g. postgres://test:[email protected]:5432/test?sslmode=disable)
TESTDUMMY_PANIC_SECONDSWhen set, specifies the number of seconds to wait before panicking. This is useful for testing crash recovery scenarios.
TESTDUMMY_ROOT_PATH/The root path for all routes
TESTDUMMY_STRESS_CPU_DURATION0sPing endpoints will perform a naive CPU stress test on all cores for the supplied duration

API

PathDescription
/ or /pingReturns pong
/echoReturns request body
/envReturns all environment variables in the format NAME=VALUE, one per line.
/exit?code={exitCode}Causes the process to exit with a default exit code of 1. Use the code parameter to customize the exit code.
/health?healthy={true|false}Returns an empty HTTP 200 if healthy, otherwise an empty HTTP 500. The healthy status can be changed using the optional healthy query parameter. This status persists for the lifetime of the process. See the Environment Variables section for related options.
/healthcheckRuns specific healthchecks as configured via the TESTDUMMY_HEALTHCHECK_* environment variables.
/status?status={statusCode}Returns the supplied HTTP status code
/versionReturns the testdummy version