add shellspec golden harness for the legacy make engine

- spec/golden/cases.txt: 69 black-box cases (CLI wrapper mode and make
  include mode) run in a hermetic sandbox with a mocked docker
- spec/golden/expected/*.txt recorded from this engine (baseline)
- make test / test-golden / golden-record / lint dev targets
This commit is contained in:
Yann Autissier
2026-09-03 14:35:58 +02:00
parent e2e34d813e
commit 1d44a2ff32
102 changed files with 632 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
--require spec_helper
--shell bash
--default-path spec/unit:spec/golden
--pattern "*_spec.sh"
+22
View File
@@ -1 +1,23 @@
DEV_TARGETS := test test-unit test-golden test-integration lint golden-record
ifneq ($(filter $(DEV_TARGETS),$(MAKECMDGOALS)),)
SHELLSPEC ?= shellspec
SHELLCHECK ?= shellcheck
.PHONY: $(DEV_TARGETS)
test: ## Run unit + golden tests
$(SHELLSPEC)
test-unit: ## Run unit tests only
$(SHELLSPEC) spec/unit
test-golden: ## Run golden tests only (MYOS_ENGINE=legacy|cli)
$(SHELLSPEC) spec/golden
test-integration: ## Run tests needing a real docker daemon
$(SHELLSPEC) --tag integration
golden-record: ## Re-record golden expectations from the legacy engine
spec/golden/record.sh $(CASES)
lint: ## shellcheck all shell sources
$(SHELLCHECK) -s bash myos spec/golden/record.sh spec/support/run.sh spec/support/bin/* $(wildcard bin/* lib/*.sh lib/cmd/*.sh install.sh)
else
include make/include.mk
endif
+2
View File
@@ -0,0 +1,2 @@
APP_SERVICE_8080_TAGS=urlprefix-app.${DOMAIN}/*
POSTGRES_PASSWORD=changeme
+2
View File
@@ -0,0 +1,2 @@
MYOS ?= /usr/local/lib/myos
-include $(MYOS)/make/include.mk
+4
View File
@@ -0,0 +1,4 @@
services:
app:
environment:
DEBUG: "true"
+13
View File
@@ -0,0 +1,13 @@
services:
app:
image: alpine:3.20
command: sleep infinity
environment:
APP_DOMAIN: ${APP_DOMAIN}
DOMAIN: ${DOMAIN}
labels:
- SERVICE_8080_NAME=${COMPOSE_SERVICE_NAME}-app-8080
- SERVICE_8080_TAGS=${APP_SERVICE_8080_TAGS:-urlprefix-app.localhost/*}
networks:
- default
- private
+5
View File
@@ -0,0 +1,5 @@
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
+3
View File
@@ -0,0 +1,3 @@
services:
web:
image: nginx:alpine
@@ -0,0 +1,6 @@
services:
myos:
image: ${USER_DOCKER_IMAGE:-myos:latest}
container_name: ${USER_COMPOSE_PROJECT_NAME:-user}
volumes:
- ${USER_DOCKER_VOLUME:-user}:/tmp/ssh-agent
+1
View File
@@ -0,0 +1 @@
default ?= postgres redis
@@ -0,0 +1,3 @@
services:
drone:
image: drone/drone:1.6
@@ -0,0 +1,2 @@
DRONE_SERVER_HOST ?= drone.$(DOMAIN)
ENV_VARS += DRONE_SERVER_HOST
@@ -0,0 +1,7 @@
services:
drone:
image: drone/drone:${DRONE_VERSION:-latest}
environment:
DRONE_SERVER_HOST: ${DRONE_SERVER_HOST:-drone.localhost}
networks:
- private
@@ -0,0 +1,4 @@
services:
nginx:
volumes:
- dns:/dns
@@ -0,0 +1,4 @@
services:
nginx:
volumes:
- www:/var/www
@@ -0,0 +1,6 @@
services:
nginx:
image: nginx:alpine
container_name: ${HOST_COMPOSE_PROJECT_NAME:-localhost}-nginx
ports:
- "8080:80"
@@ -0,0 +1,3 @@
services:
postgres:
image: postgres:9.6
@@ -0,0 +1,4 @@
services:
postgres:
ports:
- "5432:5432"
@@ -0,0 +1,13 @@
services:
postgres:
image: postgres:${POSTGRES_VERSION:-latest}
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
labels:
- SERVICE_5432_NAME=${COMPOSE_SERVICE_NAME}-postgres-5432
networks:
- private
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
@@ -0,0 +1,5 @@
services:
redis:
image: redis:alpine
networks:
- private
+1
View File
@@ -0,0 +1 @@
testing ?= drone/drone redis
+12
View File
@@ -0,0 +1,12 @@
services:
consul:
image: hashicorp/consul:1.15
container_name: ${HOST_COMPOSE_PROJECT_NAME:-localhost}-consul
network_mode: host
restart: always
environment:
CONSUL_HTTP_TOKEN: ${HOST_CONSUL_HTTP_TOKEN}
volumes:
- consul:/consul/data
volumes:
consul:
+13
View File
@@ -0,0 +1,13 @@
services:
fabio:
image: fabiolb/fabio:1.6.3
container_name: ${HOST_COMPOSE_PROJECT_NAME:-localhost}-fabio
depends_on: [consul]
ports:
- "80:80"
- "443:443"
environment:
FABIO_REGISTRY_CONSUL_ADDR: ${DOCKER_HOST_INET4:-127.0.0.1}:8500
FABIO_LOG_ACCESS_TARGET: ${HOST_FABIO_LOG_ACCESS:-}
networks:
- public
+10
View File
@@ -0,0 +1,10 @@
# Stack host: consul + fabio (80/443) + registrator, one instance per host.
host ?= host/consul host/fabio host/registrator
.PHONY: host
host:
$(call make,up STACK="$(host)")
.PHONY: host-down
host-down:
$(call make,down STACK="$(host)")
+9
View File
@@ -0,0 +1,9 @@
services:
registrator:
image: gliderlabs/registrator:master
container_name: ${HOST_COMPOSE_PROJECT_NAME:-localhost}-registrator
network_mode: host
depends_on: [consul]
command: -internal=false -useIpFromLabel SERVICE_ADDRESS consul://127.0.0.1:8500
volumes:
- ${DOCKER_SOCKET_LOCATION:-/var/run/docker.sock}:/tmp/docker.sock
+8
View File
@@ -0,0 +1,8 @@
# Intentional differences between the legacy make engine and the bash CLI
Golden expectations in `expected/` are recorded from the legacy engine
(`git tag legacy-1.0-beta`). When the CLI intentionally behaves differently,
the case gets an override in `expected.cli/<case>.txt` and a line here.
| case | delta | why |
|---|---|---|
+70
View File
@@ -0,0 +1,70 @@
# name | fixture | args
host-print-project | host-project | print-COMPOSE_PROJECT_NAME STACK=host/consul
host-print-compose-file | host-project | print-COMPOSE_FILE STACK=host/consul
host-print-stack-dir | host-project | print-STACK_DIR STACK=host/consul
host-print-env-vars | host-project | print-ENV_VARS STACK=host/consul
host-print-suffix | host-project | print-COMPOSE_FILE_SUFFIX STACK=host/consul
host-print-network-default | host-project | print-DOCKER_NETWORK_DEFAULT STACK=host/consul
host-print-network-private | host-project | print-DOCKER_NETWORK_PRIVATE STACK=host/consul
host-print-network-public | host-project | print-DOCKER_NETWORK_PUBLIC STACK=host/consul
host-print-host-stack | host-project | print-HOST_STACK STACK=host/consul
host-print-app | host-project | print-APP STACK=host/consul
host-up-consul | host-project | up STACK=host/consul
host-up-two | host-project | up STACK="host/consul host/fabio"
host-up-group | host-project | up STACK=host
host-target | host-project | host
host-down-group | host-project | down STACK=host
host-config | host-project | config STACK=host/fabio
host-ps | host-project | ps STACK=host/consul
host-logs | host-project | logs STACK=host/consul
host-stack-host-config | host-project | stack-host-config
host-exec | host-project | exec STACK=host/consul SERVICE=consul ARGS='consul members'
host-env-master | host-project | print-COMPOSE_FILE STACK=host/consul ENV=master
host-print-project-env-master | host-project | print-COMPOSE_PROJECT_NAME STACK=host/consul ENV=master
app-print-project | app-git | print-COMPOSE_PROJECT_NAME
app-print-compose-file | app-git | print-COMPOSE_FILE
app-print-app | app-git | print-APP
app-print-stack | app-git | print-STACK
app-up | app-git | up
app-up-env-master | app-git | up ENV=master
app-config | app-git | config
app-down | app-git | down
app-run | app-git | run SERVICE=app ARGS='id'
app-scale | app-git | scale SERVICE=app NUM=2
app-print-service-name | app-git | print-COMPOSE_SERVICE_NAME
app-print-repository | app-git | print-DOCKER_REPOSITORY
nogit-print-project | app-nogit | print-COMPOSE_PROJECT_NAME
nogit-print-app | app-nogit | print-APP
nogit-up | app-nogit | up
cat-postgres-compose-file | app-nogit | print-COMPOSE_FILE STACK=postgres
cat-postgres-project | app-nogit | print-COMPOSE_PROJECT_NAME STACK=postgres
cat-postgres-up | app-nogit | up STACK=postgres
cat-postgres-version | app-nogit | print-COMPOSE_FILE STACK=postgres:9.6
cat-postgres-env-master | app-nogit | print-COMPOSE_FILE STACK=postgres ENV=master
cat-user-project | app-nogit | print-COMPOSE_PROJECT_NAME STACK=User/User
cat-user-compose-file | app-nogit | print-COMPOSE_FILE STACK=User/User
cat-user-network | app-nogit | print-DOCKER_NETWORK STACK=User/User
cat-group-testing | app-nogit | print-COMPOSE_FILE STACK=testing
cat-group-testing-up | app-nogit | up STACK=testing
cat-group-default-up | app-nogit | up STACK=default
cat-drone-version | app-nogit | print-COMPOSE_FILE STACK=drone/drone:1.6
cat-drone-env-vars | app-nogit | print-ENV_VARS STACK=drone/drone
cat-nginx-www | app-nogit | print-COMPOSE_FILE STACK=host/nginx COMPOSE_FILE_WWW=true
cat-nginx-www-dns | app-nogit | print-COMPOSE_FILE STACK=host/nginx COMPOSE_FILE_WWW=true COMPOSE_FILE_DNS=true
cat-nginx-project | app-nogit | print-COMPOSE_PROJECT_NAME STACK=host/nginx
cat-unknown-stack | app-nogit | print-COMPOSE_FILE STACK=doesnotexist
cat-unknown-target | app-nogit | doesnotexist
misc-help | app-nogit | help
inc-app-print-project | app-git | @make print-COMPOSE_PROJECT_NAME
inc-app-print-compose-file | app-git | @make print-COMPOSE_FILE
inc-app-print-app | app-git | @make print-APP
inc-app-up | app-git | @make up
inc-app-up-env-master | app-git | @make up ENV=master
inc-app-config | app-git | @make config
inc-app-down | app-git | @make down
inc-app-ps | app-git | @make ps
inc-app-print-service-name | app-git | @make print-COMPOSE_SERVICE_NAME
inc-app-print-env-vars | app-git | @make print-ENV_VARS
inc-app-print-network-default | app-git | @make print-DOCKER_NETWORK_DEFAULT
inc-app-stack-postgres-up | app-git | @make up STACK=postgres
inc-app-unknown-target | app-git | @make doesnotexist
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-config MAKE_OLDFILE=docker-stack-config ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-config STACK=myos APP_NAME=myos
docker --log-level=error compose --ansi=auto -f @MYOS@/stack/myos/networks.yml -p tester-myos-local config
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-down MAKE_OLDFILE=docker-stack-down ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-down STACK=myos APP_NAME=myos
docker --log-level=error compose --ansi=auto -f @MYOS@/stack/myos/networks.yml -p tester-myos-local down
[exit 0]
+2
View File
@@ -0,0 +1,2 @@
APP myos
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE @MYOS@/stack/myos/networks.yml
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME tester-myos-local
[exit 0]
@@ -0,0 +1,2 @@
DOCKER_REPOSITORY tester/myos/local
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_SERVICE_NAME tester-myos-local
[exit 0]
+2
View File
@@ -0,0 +1,2 @@
STACK myos
[exit 0]
+2
View File
@@ -0,0 +1,2 @@
docker --log-level=error compose --ansi=auto -f @MYOS@/stack/myos/networks.yml -p tester-myos-local run --rm app id
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-scale MAKE_OLDFILE=docker-stack-scale ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-scale STACK=myos APP_NAME=myos
docker --log-level=error compose --ansi=auto -f @MYOS@/stack/myos/networks.yml -p tester-myos-local up -d --scale app=2
[exit 0]
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=master DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=myos APP_NAME=myos
sh -c docker network create tester-master >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @MYOS@/stack/myos/networks.yml -p tester-myos-master up -d
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=myos APP_NAME=myos
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @MYOS@/stack/myos/networks.yml -p tester-myos-local up -d
[exit 0]
@@ -0,0 +1,2 @@
ENV_VARS DOCKER_NETWORK_DEFAULT DOCKER_NETWORK_PRIVATE DOCKER_NETWORK_PUBLIC DRONE_SERVER_HOST DRONE_VERSION
[exit 0]
@@ -0,0 +1,2 @@
make/apps/common.mk:54: *** multiple target patterns. Stop.
[exit 2]
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=default APP_NAME=default
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @HOME@/.local/share/myos/stack/postgres/postgres.yml -f @HOME@/.local/share/myos/stack/postgres/postgres.local.yml -f @HOME@/.local/share/myos/stack/redis/redis.yml -f @MYOS@/stack/myos/networks.yml -p tester-default-local up -d
[exit 0]
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=testing APP_NAME=testing
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @HOME@/.local/share/myos/stack/drone/drone.yml -f @HOME@/.local/share/myos/stack/redis/redis.yml -f @MYOS@/stack/myos/networks.yml -p tester-testing-local up -d
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE @HOME@/.local/share/myos/stack/drone/drone.yml @HOME@/.local/share/myos/stack/redis/redis.yml @MYOS@/stack/myos/networks.yml
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME testhost
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE @HOME@/.local/share/myos/stack/host/nginx.yml @HOME@/.local/share/myos/stack/host/nginx.www.yml @HOME@/.local/share/myos/stack/host/nginx.dns.yml @MYOS@/stack/myos/networks.yml @MYOS@/stack/myos/volumes.www.local.yml @MYOS@/stack/myos/volumes.dns.local.yml
[exit 0]
+2
View File
@@ -0,0 +1,2 @@
COMPOSE_FILE @HOME@/.local/share/myos/stack/host/nginx.yml @HOME@/.local/share/myos/stack/host/nginx.www.yml @MYOS@/stack/myos/networks.yml @MYOS@/stack/myos/volumes.www.local.yml
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE @HOME@/.local/share/myos/stack/postgres/postgres.yml @HOME@/.local/share/myos/stack/postgres/postgres.local.yml @MYOS@/stack/myos/networks.yml
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE @HOME@/.local/share/myos/stack/postgres/postgres.yml @MYOS@/stack/myos/networks.yml
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME tester-myos-local
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=postgres APP_NAME=postgres
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @HOME@/.local/share/myos/stack/postgres/postgres.yml -f @HOME@/.local/share/myos/stack/postgres/postgres.local.yml -f @MYOS@/stack/myos/networks.yml -p tester-postgres-local up -d
[exit 0]
@@ -0,0 +1,2 @@
make/apps/common.mk:54: *** multiple target patterns. Stop.
[exit 2]
@@ -0,0 +1,2 @@
COMPOSE_FILE @MYOS@/stack/myos/networks.yml
[exit 0]
@@ -0,0 +1,2 @@
WARNING: myos[0] doesnotexist-rule-exists: target doesnotexist unavailable in app myos
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE @HOME@/.local/share/myos/stack/User/User.yml @MYOS@/stack/myos/networks.yml
[exit 0]
@@ -0,0 +1,2 @@
DOCKER_NETWORK tester
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME tester-example-test
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-config MAKE_OLDFILE=docker-stack-config ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-config STACK=host/fabio APP_NAME=host
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/fabio.yml -f @MYOS@/stack/myos/networks.yml -p testhost config
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-down MAKE_OLDFILE=docker-stack-down ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-down STACK=host APP_NAME=host
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @WD@/stack/host/registrator.yml -f @MYOS@/stack/myos/networks.yml -p testhost down
[exit 0]
+2
View File
@@ -0,0 +1,2 @@
COMPOSE_FILE @WD@/stack/host/consul.yml @MYOS@/stack/myos/networks.yml
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @MYOS@/stack/myos/networks.yml -p testhost exec -T consul sh -c consul members
/bin/bash: -c: line 0: syntax error near unexpected token `||'
/bin/bash: -c: line 0: `|| true'
make: *** [exec] Error 2
[exit 2]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-logs MAKE_OLDFILE=docker-stack-logs ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-logs STACK=host/consul APP_NAME=host
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @MYOS@/stack/myos/networks.yml -p testhost logs --follow --tail=100
[exit 0]
+2
View File
@@ -0,0 +1,2 @@
APP myos
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE @WD@/stack/host/consul.yml @MYOS@/stack/myos/networks.yml
[exit 0]
@@ -0,0 +1,2 @@
ENV_VARS DOCKER_NETWORK_DEFAULT DOCKER_NETWORK_PRIVATE DOCKER_NETWORK_PUBLIC DRONE_SERVER_HOST HOST_COMPOSE_PROJECT_NAME HOST_CONSUL_HTTP_TOKEN
[exit 0]
@@ -0,0 +1,2 @@
HOST_STACK host
[exit 0]
@@ -0,0 +1,2 @@
DOCKER_NETWORK_DEFAULT _testhost
[exit 0]
@@ -0,0 +1,2 @@
DOCKER_NETWORK_PRIVATE tester-local
[exit 0]
@@ -0,0 +1,2 @@
DOCKER_NETWORK_PUBLIC testhost
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME testhost
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME testhost
[exit 0]
@@ -0,0 +1,2 @@
STACK_DIR @MYOS@/stack @HOME@/.local/share/myos/stack @WD@/stack
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE_SUFFIX app labels networks ssh volumes
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-ps MAKE_OLDFILE=docker-stack-ps ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-ps STACK=host/consul APP_NAME=host
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @MYOS@/stack/myos/networks.yml -p testhost ps
[exit 0]
@@ -0,0 +1,4 @@
make -o stack-host-config MAKE_OLDFILE=stack-host-config ENV=local DOCKER_COMPOSE=docker --log-level=error compose COMPOSE_IGNORE_ORPHANS=true host=host/consul host/fabio host/registrator config STACK=host
make -o stack-host-config MAKE_OLDFILE=stack-host-config ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-config STACK=host APP_NAME=host
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @WD@/stack/host/registrator.yml -f @MYOS@/stack/myos/networks.yml -p testhost config
[exit 0]
+14
View File
@@ -0,0 +1,14 @@
make -o host MAKE_OLDFILE=host ENV=local DOCKER_COMPOSE=docker --log-level=error compose up STACK=host/consul host/fabio host/registrator
make -o host MAKE_OLDFILE=host ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=host/consul APP_NAME=host
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @MYOS@/stack/myos/networks.yml -p testhost up -d
make -o host MAKE_OLDFILE=host ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=host/fabio APP_NAME=host
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/fabio.yml -f @MYOS@/stack/myos/networks.yml -p testhost up -d
make -o host MAKE_OLDFILE=host ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=host/registrator APP_NAME=host
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/registrator.yml -f @MYOS@/stack/myos/networks.yml -p testhost up -d
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=host/consul APP_NAME=host
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @MYOS@/stack/myos/networks.yml -p testhost up -d
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=host APP_NAME=host
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @WD@/stack/host/registrator.yml -f @MYOS@/stack/myos/networks.yml -p testhost up -d
[exit 0]
+9
View File
@@ -0,0 +1,9 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=host/consul APP_NAME=host
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @MYOS@/stack/myos/networks.yml -p testhost up -d
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=host/fabio APP_NAME=host
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @MYOS@/stack/myos/networks.yml -p testhost up -d
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-config MAKE_OLDFILE=docker-stack-config ENV=local DOCKER_COMPOSE=docker --log-level=error compose app-wd-config
docker --log-level=error compose --ansi=auto -f ././docker-compose.yml -f ././docker-compose.local.yml -f ./docker/docker-compose.yml -p tester-wd-local config
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-down MAKE_OLDFILE=docker-stack-down ENV=local DOCKER_COMPOSE=docker --log-level=error compose app-wd-down
docker --log-level=error compose --ansi=auto -f ././docker-compose.yml -f ././docker-compose.local.yml -f ./docker/docker-compose.yml -p tester-wd-local down
[exit 0]
@@ -0,0 +1,2 @@
APP wd
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_FILE ./docker-compose.yml ./docker-compose.local.yml docker/docker-compose.yml
[exit 0]
@@ -0,0 +1,2 @@
ENV_VARS DOCKER_NETWORK_DEFAULT DOCKER_NETWORK_PRIVATE DOCKER_NETWORK_PUBLIC DRONE_SERVER_HOST
[exit 0]
@@ -0,0 +1,2 @@
DOCKER_NETWORK_DEFAULT _tester-wd-local
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME tester-wd-local
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_SERVICE_NAME tester-wd-local
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-ps MAKE_OLDFILE=docker-stack-ps ENV=local DOCKER_COMPOSE=docker --log-level=error compose app-wd-ps
docker --log-level=error compose --ansi=auto -f ././docker-compose.yml -f ././docker-compose.local.yml -f ./docker/docker-compose.yml -p tester-wd-local ps
[exit 0]
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=postgres APP_NAME=postgres
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f ./docker-compose.yml -f ./docker-compose.local.yml -f docker/docker-compose.yml -p tester-postgres-local up -d
[exit 0]
@@ -0,0 +1,2 @@
WARNING: wd[0] doesnotexist-rule-exists: target doesnotexist unavailable in app wd
[exit 0]
@@ -0,0 +1,3 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=master DOCKER_COMPOSE=docker --log-level=error compose app-wd-up
docker --log-level=error compose --ansi=auto -f ././docker-compose.yml -f ./docker/docker-compose.yml -p tester-wd-master up -d
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose app-wd-up
docker --log-level=error compose --ansi=auto -f ././docker-compose.yml -f ././docker-compose.local.yml -f ./docker/docker-compose.yml -p tester-wd-local up -d
[exit 0]
+52
View File
@@ -0,0 +1,52 @@
Usage:
make [target]
Targets:
test Run unit + golden tests
test-unit Run unit tests only
test-golden Run golden tests only (MYOS_ENGINE=legacy|cli)
test-integration Run tests needing a real docker daemon
golden-record Re-record golden expectations from the legacy engine
lint shellcheck all shell sources
help This help
attach Attach to docker SERVICE
bootstrap Configure system
build Build application docker images
clean Clean application and docker stuffs
config View application docker compose file
connect Connect to docker SERVICE
deploy Deploy application dockers
down Remove application dockers
exec Exec command in docker SERVICE
install Install application
logs Display application dockers logs
rebuild Rebuild application dockers images
reinstall Reinstall application
release Create release VERSION
restart Restart application
run Run a command in a new docker
scale Scale SERVICE application to NUM dockers
shutdown Shutdown all dockers
start Start application dockers
stop Stop application dockers
tests Test application
up Create application dockers
update Update application files
upgrade Upgrade application
ssh Connect to first remote host
Context:
ENV local
ENV_PATH @WD@
DOCKER_MACHINE x86_64
DOCKER_SOCKET_LOCATION /var/run/docker.sock
DOCKER_SYSTEM Linux
DOMAIN example.test
APP myos
APPS c411 dsh myos wbr wbr.old
BRANCH lightning
VERSION legacy-1.0-beta
RELEASE
COMPOSE_FILE @MYOS@/stack/myos/networks.yml
DOCKER_REPOSITORY tester/myos/local
[exit 0]
+2
View File
@@ -0,0 +1,2 @@
APP myos
[exit 0]
@@ -0,0 +1,2 @@
COMPOSE_PROJECT_NAME tester-myos-local
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
make -o docker-stack-up MAKE_OLDFILE=docker-stack-up ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-up STACK=myos APP_NAME=myos
sh -c docker network create tester-local >/dev/null 2>&1
sh -c docker network create testhost >/dev/null 2>&1
docker --log-level=error compose --ansi=auto -f @MYOS@/stack/myos/networks.yml -p tester-myos-local up -d
[exit 0]
+32
View File
@@ -0,0 +1,32 @@
#shellcheck shell=sh
# Golden tests: every case of cases.txt must produce the recorded output.
# MYOS_ENGINE=legacy (default) runs the make engine, MYOS_ENGINE=cli runs bin/myos.
# For the cli engine, spec/golden/expected.cli/<case>.txt overrides the legacy
# expectation when a delta is intentional (documented in DELTAS.md).
Describe 'golden'
engine=${MYOS_ENGINE:-legacy}
expected_file() {
if [ "$engine" = cli ] && [ -f "$SHELLSPEC_PROJECT_ROOT/spec/golden/expected.cli/$1.txt" ]; then
printf '%s\n' "$SHELLSPEC_PROJECT_ROOT/spec/golden/expected.cli/$1.txt"
else
printf '%s\n' "$SHELLSPEC_PROJECT_ROOT/spec/golden/expected/$1.txt"
fi
}
run_case() {
sb=$(myos_sandbox "$2")
eval "set -- $3"
myos_run_engine "$engine" "$sb" "$@"
rm -rf "$sb"
}
Parameters:dynamic
while IFS='|' read -r name fixture args; do
name=$(echo "$name" | tr -d ' '); fixture=$(echo "$fixture" | tr -d ' ')
[ -z "$name" ] || [ "${name#\#}" != "$name" ] && continue
%data "$name" "$fixture" "$args"
done < "$SHELLSPEC_PROJECT_ROOT/spec/golden/cases.txt"
End
It "matches recorded output: $1 ($engine)"
When call run_case "$1" "$2" "$3"
The output should equal "$(cat "$(expected_file "$1")")"
End
End
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Record golden outputs of the LEGACY make engine into spec/golden/expected/.
# Usage: spec/golden/record.sh [case-name ...]
set -u
here=$(cd "$(dirname "$0")" && pwd)
. "$here/../support/run.sh"
MYOS_ROOT=${MYOS_ROOT:-$(cd "$here/../.." && pwd)}
only="$*"
grep -v '^#' "$here/cases.txt" | while IFS='|' read -r name fixture args; do
name=$(echo "$name" | tr -d ' '); fixture=$(echo "$fixture" | tr -d ' ')
[ -z "$name" ] && continue
if [ -n "$only" ]; then case " $only " in *" $name "*) ;; *) continue ;; esac; fi
sb=$(myos_sandbox "$fixture")
eval "set -- $args"
myos_run_engine legacy "$sb" "$@" > "$here/expected/$name.txt"
rm -rf "$sb"
printf 'recorded %s (%s lines)\n' "$name" "$(wc -l < "$here/expected/$name.txt" | tr -d ' ')"
done
+6
View File
@@ -0,0 +1,6 @@
#shellcheck shell=sh
# shellspec helper: loaded before every spec file.
MYOS_ROOT=${MYOS_ROOT:-$SHELLSPEC_PROJECT_ROOT}
SPEC_DIR=$MYOS_ROOT/spec
export MYOS_ROOT SPEC_DIR
. "$SPEC_DIR/support/run.sh"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Mock docker for myos tests: logs every call, answers a few read-only queries deterministically.
[ -n "${MYOS_DOCKER_LOG:-}" ] && printf 'docker %s\n' "$*" >> "$MYOS_DOCKER_LOG"
case "$1 $2" in
"compose version") echo "${MOCK_COMPOSE_VERSION:-2.29.0}" ;;
"compose config") echo "# mock compose config" ;;
"compose ps") : ;;
"compose "*) : ;;
"info --format") echo "${MOCK_SWARM_STATE:-inactive}" ;;
"run --rm") case "$*" in *"uname -m"*) echo x86_64 ;; *"uname -s"*) echo Linux ;; *) : ;; esac ;;
"images -q") : ;;
"ps -q") : ;;
"network ls") : ;;
"volume ls") : ;;
"version --format") echo 29.0.0 ;;
*) : ;;
esac
exit 0

Some files were not shown because too many files have changed in this diff Show More