Skip to content

Commit

Permalink
Merge pull request #17 from essentialkaos/develop
Browse files Browse the repository at this point in the history
bibop-massive 1.1.0
  • Loading branch information
andyone authored Aug 2, 2019
2 parents 4630f2e + e5df7e9 commit c3c3889
Showing 1 changed file with 68 additions and 8 deletions.
76 changes: 68 additions & 8 deletions bibop-massive
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ STATUS_SKIPPED=3
################################################################################

APP="bibop-massive"
VER="1.0.0"
VER="1.1.0"
DESC="Utility for mass package testing"

################################################################################
Expand Down Expand Up @@ -95,7 +95,10 @@ main() {
exit 0
fi

export LC_ALL=C

checkEnv
configureYUM
processRecipes "$@"
filterRecipes

Expand Down Expand Up @@ -144,6 +147,14 @@ checkEnv() {
fi
}

# Configure YUM to use cache
#
# Code: No
# Echo: No
configureYUM() {
sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf
}

# Process source recipes
#
# *: All given recipes
Expand Down Expand Up @@ -271,7 +282,7 @@ runTests() {
# Echo: No
runTest() {
local recipe="$1"
local require_install required_packages packages_installed start_ts end_ts grace_time
local require_install required_packages packages_installed start_ts end_ts grace_time skip_tests

required_packages=$(bibop --list-packages "$recipe")

Expand All @@ -284,6 +295,18 @@ runTest() {

printf " %${max_recipe_size}s: " "$cur_recipe"

if [[ -n "$require_install" ]] ; then
# shellcheck disable=SC2086
if ! checkPackagesAvailability $required_packages ; then
log "[ERROR] One or more required packages haven't found"

printStatusBullet $STATUS_SKIPPED

require_install=""
skip_tests=true
fi
fi

if [[ -n "$require_install" ]] ; then
# shellcheck disable=SC2086
installPackages $required_packages
Expand All @@ -302,8 +325,10 @@ runTest() {
printStatusBullet $STATUS_SKIPPED
printStatusBullet $STATUS_SKIPPED
else
execRecipe "$recipe"
printStatusBullet $?
if [[ -z "$skip_tests" ]] ; then
execRecipe "$recipe"
printStatusBullet $?
fi

if [[ -n "$require_install" ]] ; then
uninstallPackages
Expand Down Expand Up @@ -378,7 +403,7 @@ execRecipe() {
if [[ $? -eq 0 ]] ; then
log "Recipe successfully validated"
else
log "Error while recipe validation"
log "[ERROR] Error while recipe validation"
(( fail_count++ ))
return $STATUS_VALIDATION_ERROR
fi
Expand All @@ -393,12 +418,47 @@ execRecipe() {
(( pass_count++ ))
return $STATUS_OK
else
log "Error while executing tests"
log "[ERROR] Error while executing tests"
(( fail_count++ ))
return $STATUS_ERROR
fi
}

# Check required packages availability
#
# *: List of required packages
#
# Code: Yes
# Echo: No
checkPackagesAvailability() {
local opts pkg_list aval_list

log "Checking files availability…"

pkg_list=$(echo "$* " | sed 's: :\.* :g')

if [[ -n "$enablerepo" ]] ; then
opts="--enablerepo=$enablerepo"
fi

if [[ -n "$disablerepo" ]] ; then
opts="--disablerepo=$disablerepo"
fi

# shellcheck disable=SC2086
aval_list=$(yum -q $opts list availabile $pkg_list 2> /dev/null | grep -v 'Available Packages' | cut -f1 -d" " | sed 's:\..*::' | tr "\n" " " | sed 's/ $//')

if [[ -z "$aval_list" ]] ; then
return 1
fi

if ! comm -3 <(echo "$aval_list") <(echo "$*") &> /dev/null ; then
return 1
fi

return 0
}

# Install required packages
#
# *: List of required packages
Expand Down Expand Up @@ -428,7 +488,7 @@ installPackages() {
log "Packages successfully installed ($pkg_count installed)"
return 0
else
log "Error while package install"
log "[ERROR] Error while package install"
(( fail_count++ ))
return 1
fi
Expand All @@ -452,7 +512,7 @@ uninstallPackages() {
log "Packages successfully uninstalled ($pkg_count uninstalled)"
return $STATUS_OK
else
log "Error while package uninstall"
log "[ERROR] Error while package uninstall"
(( fail_count++ ))
return $STATUS_ERROR
fi
Expand Down

0 comments on commit c3c3889

Please sign in to comment.