mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Add tests for actions
, containers
and services
actions
Tests should run fine now with macOS
This commit is contained in:
parent
c54255381b
commit
ead44c5ed5
@ -5,10 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
- Add tests for `actions`, `containers` and `services` actions
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Downgrade Docker Compose from [1.29.2](https://github.com/docker/compose/releases/tag/1.29.2) to [1.28.0](https://github.com/docker/compose/releases/tag/1.28.0) for Alpine image, to get faster builds 🚀
|
- Downgrade Docker Compose from [1.29.2](https://github.com/docker/compose/releases/tag/1.29.2) to [1.28.0](https://github.com/docker/compose/releases/tag/1.28.0) for Alpine image, to get faster builds 🚀
|
||||||
- Reduce Docker images size based on Alpine, again
|
- Reduce Docker images size based on Alpine, again
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Tests should run fine now with macOS
|
||||||
|
|
||||||
## [1.2.0-beta.1] - 2021-09-03
|
## [1.2.0-beta.1] - 2021-09-03
|
||||||
### Added
|
### Added
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
# cd psu/
|
# cd psu/
|
||||||
# cp tests/dockerfiles/.env.local tests/dockerfiles/.env
|
# cp tests/dockerfiles/.env.local tests/dockerfiles/.env
|
||||||
# source tests/dockerfiles/.env
|
# source tests/dockerfiles/.env
|
||||||
# docker build --no-cache -t $PSU_IMAGE:$PSU_TAG -f Dockerfile .
|
# docker build --no-cache -t ${PSU_IMAGE}:${PSU_TAG} -f Dockerfile .
|
||||||
# docker build --no-cache -t $PSU_IMAGE:core-$PSU_TAG -f Dockerfile.core .
|
# docker build --no-cache -t ${PSU_IMAGE}:core-${PSU_TAG} -f Dockerfile.core .
|
||||||
# docker build --no-cache -t $PSU_IMAGE:debian-$PSU_TAG -f Dockerfile.debian .
|
# docker build --no-cache -t ${PSU_IMAGE}:debian-${PSU_TAG} -f Dockerfile.debian .
|
||||||
# docker build --no-cache -t $PSU_IMAGE:debaian-core-$PSU_TAG -f Dockerfile.debian-core .
|
# docker build --no-cache -t ${PSU_IMAGE}:debian-core-${PSU_TAG} -f Dockerfile.debian-core .
|
||||||
#
|
#
|
||||||
# Build Docker images from https://gitlab.com/psuapp/hub locally:
|
# Build Docker images from https://gitlab.com/psuapp/hub locally:
|
||||||
# cd ..
|
# cd ..
|
||||||
@ -49,9 +49,12 @@ PORTAINER_IMAGE="portainer/portainer-ce"
|
|||||||
#PORTAINER_IMAGE="portainer/portainer"
|
#PORTAINER_IMAGE="portainer/portainer"
|
||||||
PORTAINER_VERSION=latest
|
PORTAINER_VERSION=latest
|
||||||
#PORTAINER_VERSION="2.6.3"
|
#PORTAINER_VERSION="2.6.3"
|
||||||
#PORTAINER_VERSION="1.24.1"
|
#PORTAINER_VERSION="1.24.2"
|
||||||
PORTAINER_COMMAND_OPTIONS=""
|
PORTAINER_COMMAND_OPTIONS=""
|
||||||
#PORTAINER_COMMAND_OPTIONS=" --no-analytics"
|
#PORTAINER_COMMAND_OPTIONS=" --no-analytics"
|
||||||
|
#PORTAINER_DEPLOY_EXTRA_ARGS="--debug --verbose"
|
||||||
|
|
||||||
SWARM_NODE_NAME=localhost
|
SWARM_NODE_NAME=localhost
|
||||||
SWARM_NODE_IP=$(hostname -I | awk '{ print $1 }')
|
SWARM_NODE_IP=$(hostname -I | awk '{ print $1 }')
|
||||||
|
# For macOS
|
||||||
|
#SWARM_NODE_IP=$(ipconfig getifaddr en0)
|
||||||
|
@ -46,5 +46,6 @@ networks:
|
|||||||
secrets:
|
secrets:
|
||||||
psu-portainer-password:
|
psu-portainer-password:
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
psu-portainer:
|
psu-portainer:
|
||||||
|
@ -66,6 +66,7 @@ services:
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
psu-traefik-net:
|
psu-traefik-net:
|
||||||
|
driver: overlay
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
33
tests/run.sh
33
tests/run.sh
@ -68,16 +68,19 @@ function version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Leave Docker Swarm, if already set
|
# Leave Docker Swarm, if already set
|
||||||
docker swarm leave --force && sleep 3 | true
|
(docker swarm leave --force && sleep 3) || true
|
||||||
|
|
||||||
# Remove admin password from Docker secrets, if already set
|
# Remove admin password from Docker secrets, if already set
|
||||||
docker secret rm psu-portainer-password | true
|
docker secret rm psu-portainer-password || true
|
||||||
|
|
||||||
|
# Delete all stopped containers
|
||||||
|
docker rm -f $(docker ps -a -q) || true
|
||||||
|
|
||||||
# Remove portainer data, if already set
|
# Remove portainer data, if already set
|
||||||
docker volume rm --force portainer_psu-portainer && sleep 2 | true
|
(docker volume rm --force portainer_psu-portainer && sleep 2) || true
|
||||||
|
|
||||||
# Remove web-app data, if already set
|
# Remove web-app data, if already set
|
||||||
docker volume rm --force web-app_psu-php-runner && sleep 2 | true
|
(docker volume rm --force web-app_psu-php-runner && sleep 2) || true
|
||||||
|
|
||||||
# Init Docker Swarm
|
# Init Docker Swarm
|
||||||
docker swarm init
|
docker swarm init
|
||||||
@ -103,11 +106,12 @@ psu_wrapper --version | grep -E 'version v?[0-9]+\.[0-9]+\.[0-9]+'
|
|||||||
|
|
||||||
# psu help test
|
# psu help test
|
||||||
# Check if 4 terms present in the help message are visible when running the command
|
# Check if 4 terms present in the help message are visible when running the command
|
||||||
[ "$(psu_wrapper --help | grep -E 'Usage|Arguments|Options|Available actions' | wc -l)" == "4" ]
|
[ "$(psu_wrapper --help | grep -E 'Usage|Arguments|Options|Available actions' | wc -l | tr -d ' ')" == "4" ]
|
||||||
|
|
||||||
# TODO: test 'actions' action
|
# psu 'actions' action test
|
||||||
# TODO: test 'services' action
|
# Check if some of the available actions of psu
|
||||||
# TODO: test 'containers' action
|
# are visible when running the 'actions' command
|
||||||
|
[ "$(psu_wrapper actions | grep -E ' deploy | rm | ls | status | services | tasks | actions ' | wc -l | tr -d ' ')" == "7" ]
|
||||||
|
|
||||||
# Portainer login test
|
# Portainer login test
|
||||||
PSU_AUTH_TOKEN=$(psu_wrapper login --user $PSU_USER --password $PSU_PASSWORD --url $PSU_URL --insecure)
|
PSU_AUTH_TOKEN=$(psu_wrapper login --user $PSU_USER --password $PSU_PASSWORD --url $PSU_URL --insecure)
|
||||||
@ -159,6 +163,19 @@ stack_envvars="$(echo -n "$stack_info" | jq ".Env" -jc)"
|
|||||||
stack_list="$(psu_wrapper ls --user $PSU_USER --password $PSU_PASSWORD --url $PSU_URL --insecure --debug false --verbose false --quiet)"
|
stack_list="$(psu_wrapper ls --user $PSU_USER --password $PSU_PASSWORD --url $PSU_URL --insecure --debug false --verbose false --quiet)"
|
||||||
[ "$stack_list" == "$PSU_STACK_NAME" ]
|
[ "$stack_list" == "$PSU_STACK_NAME" ]
|
||||||
|
|
||||||
|
# psu 'services' action test
|
||||||
|
# The current stack should have 3 services:
|
||||||
|
# 'web-app_app', 'web-app_job' and 'web-app_web'
|
||||||
|
[ "$(psu_wrapper services --user=$PSU_USER --password=$PSU_PASSWORD --url=$PSU_URL --name=$PSU_STACK_NAME --insecure --debug false --verbose false --quiet | wc -l | tr -d ' ')" == "3" ]
|
||||||
|
|
||||||
|
# psu 'tasks:healthy' action test
|
||||||
|
# The current stack should have 3 healthy tasks:
|
||||||
|
[ "$(psu_wrapper tasks:healthy --user=$PSU_USER --password=$PSU_PASSWORD --url=$PSU_URL --name=$PSU_STACK_NAME --insecure --debug false --verbose false --quiet | wc -l | tr -d ' ')" == "3" ]
|
||||||
|
|
||||||
|
# psu 'containers' action test
|
||||||
|
# The current stack should have 2 running containers:
|
||||||
|
[ "$(psu_wrapper containers --user=$PSU_USER --password=$PSU_PASSWORD --url=$PSU_URL --name=$PSU_STACK_NAME --insecure --debug false --verbose false --quiet | wc -l | tr -d ' ')" == "2" ]
|
||||||
|
|
||||||
# Convert env file in a base64 encoded string,
|
# Convert env file in a base64 encoded string,
|
||||||
# due to some limitations with Docker in Docker and volumes
|
# due to some limitations with Docker in Docker and volumes
|
||||||
# see: https://stackoverflow.com/a/55481515
|
# see: https://stackoverflow.com/a/55481515
|
||||||
|
Loading…
Reference in New Issue
Block a user