Bladeren bron

Fixes tests

clean-build-dependencies
Ales Komarek 6 jaren geleden
bovenliggende
commit
fce26dbe25
3 gewijzigde bestanden met toevoegingen van 43 en 16 verwijderingen
  1. +10
    -1
      Makefile
  2. +3
    -0
      tests/pillar/server.sls
  3. +30
    -15
      tests/run_tests.sh

+ 10
- 1
Makefile Bestand weergeven

@@ -27,12 +27,14 @@ KITCHEN_OPTS_TEST?=""

all:
@echo "make install - Install into DESTDIR"
@echo "make lint - Run lint tests"
@echo "make test - Run tests"
@echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
@echo "make clean - Cleanup after tests run"
@echo "make release-major - Generate new major release"
@echo "make release-minor - Generate new minor release"
@echo "make changelog - Show changes since last release"
@echo "make test-model-validate - Run salt jsonschema validation"

install:
# Formula
@@ -45,9 +47,16 @@ install:
[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)

lint:
[ ! -d tests ] || (cd tests; ./run_tests.sh lint)

test:
[ ! -d tests ] || (cd tests; ./run_tests.sh)

test-model-validate:
# TODO make it actually fail
[ ! -d $(FORMULANAME)/schemas/ ] || (cd tests; ./run_tests.sh model-validate)

release-major: check-changes
@echo "Current version is $(VERSION), new version is $(NEW_MAJOR_VERSION)"
@[ $(VERSION_MAJOR) != $(NEW_MAJOR_VERSION) ] || (echo "Major version $(NEW_MAJOR_VERSION) already released, nothing to do. Do you want release-minor?" && exit 1)
@@ -65,7 +74,7 @@ release-minor: check-changes
[ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
(git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)")
git tag -s -m $(NEW_MAJOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)
git tag -s -m $(VERSION_MAJOR).$(NEW_MINOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)

check-changes:
@git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1)

+ 3
- 0
tests/pillar/server.sls Bestand weergeven

@@ -1,3 +1,6 @@
home_assistant:
server:
enabled: true
bind:
address: 0.0.0.0
port: 8123

+ 30
- 15
tests/run_tests.sh Bestand weergeven

@@ -2,7 +2,8 @@

###
# Script requirments:
# apt-get install -y python-yaml virtualenv git
#apt-get install -y python-yaml virtualenv git

set -e
[ -n "$DEBUG" ] && set -x

@@ -42,9 +43,11 @@ log_err() {

setup_virtualenv() {
log_info "Setting up Python virtualenv"
dependency_check virtualenv
virtualenv $VENV_DIR
source ${VENV_DIR}/bin/activate
pip install salt${PIP_SALT_VERSION}
pip install jsonschema
if [[ -f ${CURDIR}/pip_requirements.txt ]]; then
pip install -r ${CURDIR}/pip_requirements.txt
fi
@@ -108,6 +111,7 @@ fetch_dependency() {
dep_root="${DEPSDIR}/$(basename $dep_source .git)"
dep_metadata="${dep_root}/metadata.yml"

dependency_check git
[ -d $dep_root ] && { log_info "Dependency $dep_name already fetched"; return 0; }

log_info "Fetching dependency $dep_name"
@@ -200,19 +204,30 @@ real_run() {
}

run_model_validate(){
[[ -d ${SCHEMARDIR} ]] || { log_err "${SCHEMARDIR} not found!"; return 1; }
# model validator require py modules
fetch_dependency "salt:https://github.com/salt-formulas/salt-formula-salt"
link_modules
# Rendered Example:
# salt-call --local -c /test1/maas/tests/build/salt --id=maas_cluster modelschema.model_validate maas cluster
for role in ${SCHEMARDIR}/*.yaml; do
state_name=$(basename "${role%*.yaml}")
minion_id="${state_name}"
# in case debug-reruns, usefull to make cleanup
[ -n "$DEBUG" ] && { salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all; }
salt_run -m ${DEPSDIR}/salt-formula-salt --id=${minion_id} modelschema.model_validate ${FORMULA_NAME} ${state_name} || { log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1 ; }
done
if [ -d ${SCHEMARDIR} ]; then
# model validator require py modules
fetch_dependency "salt:https://github.com/salt-formulas/salt-formula-salt"
link_modules
# Rendered Example:
# salt-call --local -c /test1/maas/tests/build/salt --id=maas_cluster modelschema.model_validate maas cluster
for role in ${SCHEMARDIR}/*.yaml; do
state_name=$(basename "${role%*.yaml}")
minion_id="${state_name}"
# in case debug-reruns, usefull to make cleanup
[ -n "$DEBUG" ] && { salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all; }
salt_run -m ${DEPSDIR}/salt-formula-salt --id=${minion_id} modelschema.model_validate ${FORMULA_NAME} ${state_name} || { log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1 ; }
done
else
log_err "${SCHEMARDIR} not found!";
fi
}

dependency_check() {
local DEPENDENCY_COMMANDS=$*

for DEPENDENCY_COMMAND in $DEPENDENCY_COMMANDS; do
which $DEPENDENCY_COMMAND > /dev/null || ( log_err "Command \"$DEPENDENCY_COMMAND\" can not be found in default path."; exit 1; )
done
}

_atexit() {
@@ -256,4 +271,4 @@ case $1 in
run
run_model_validate
;;
esac
esac

Laden…
Annuleren
Opslaan