Skip to content

Commit

Permalink
Switch from drush and wp-cli to cv
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Feb 23, 2022
1 parent 8617011 commit 0108d7d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 39 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ be used for testing upgrade-logic.
### Scope

To facilitate testing of many databases, the current script uses the
command-line based upgrade system (drush) and never uses the web-based UI
(civicrm/upgrade). Therefore, it is appropriate for testing the database
command-line-based upgrader (`cv upgrade:db`) and never uses the web-based UI
(`civicrm/upgrade`). Therefore, it is appropriate for testing the database
manipulations. It does not currently test for:

* Issues in the upgrader web UI (such as browser compatibility)
* Issues with different CMS's (Joomla, WordPress, Drupal 6)
* Issues in the web UI (such as browser compatibility or CMS page-loading)
* Issues in the civicrm.settings.php
* Issues with setup or compatibility of PHP, MySQL, etc

### Pre-Requisites

* Have a Unix-like environment (bash)
* Install CiviCRM and either Drupal+Drush or WordPress+WP CLI.
* Install CiviCRM and cv
* Configure the username/password for a MySQL administrator in ~/.my.cnf

### Setup
Expand Down
39 changes: 12 additions & 27 deletions civicrm-upgrade-test
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ function drop_civicrm_sql {
function check_error {
OUTPUT="$1"
LOG="$2"
## Checkout OUTPUT
if head -n1 "$OUTPUT" | grep '^Upgrade output' > /dev/null ; then
## Check log
if grep '\[info\] $backTrace' "$LOG" > /dev/null ; then
echo 1
fi
## Checkout OUTPUT and LOG
if grep '\[\(error\|warning\)\]' "$LOG" > /dev/null ; then
echo 1
return
fi
if tail -n1 "$OUTPUT" | grep '^Have a nice day' > /dev/null ; then
echo
else
echo 1
fi
Expand Down Expand Up @@ -163,27 +164,15 @@ fi

#####################################################################
## Run upgrades
if [ -n "$DRUPAL_SITE" ]; then
DRUSH="drush -l $DRUPAL_SITE"
else
DRUSH="drush"
fi

set -e
LOGPAT=$( cv --cwd="$WEB_ROOT" path -c 'configAndLogDir/CiviCRM.*.log' )
set +e

for SQLBZ2 in $DATABASE_FILES ; do
NAME=$(basename $SQLBZ2)
OUTPUT="${OUTPUT_DIR}/${NAME}.out"
LOG="${OUTPUT_DIR}/${NAME}.log"
if grep backdrop "$WEB_ROOT/index.php" ; then
LOGPAT="$WEB_ROOT/files/civicrm/ConfigAndLog/CiviCRM.*.log"
elif [ -f "$WEB_ROOT/wp-config.php" ] ; then
LOGPAT="$WEB_ROOT/wp-content/uploads/civicrm/ConfigAndLog/CiviCRM.*.log"
else
if [ -z "$DRUPAL_SITE" ]; then
LOGPAT="$WEB_ROOT/sites/default/files/civicrm/ConfigAndLog/CiviCRM.*.log"
else
LOGPAT="$WEB_ROOT/sites/$DRUPAL_SITE/files/civicrm/ConfigAndLog/CiviCRM.*.log"
fi
fi

echo ""
echo "------------------------------------------------------"
Expand All @@ -205,11 +194,7 @@ for SQLBZ2 in $DATABASE_FILES ; do
pushd "$WEB_ROOT" > /dev/null
rm -f $LOGPAT
echo; echo "Upgrading database $TEST_DATABASE"
if [ -f "$WEB_ROOT/wp-config.php" ] ; then
wp civicrm upgrade-db > "$OUTPUT" 2>&1
else
$DRUSH civicrm-upgrade-db > "$OUTPUT" 2>&1
fi
cv upgrade:db -vv --no-interaction > "$OUTPUT" 2>&1
echo "LOGPAT: $LOGPAT" > $LOG
cat $LOGPAT >> $LOG
popd > /dev/null
Expand Down
7 changes: 0 additions & 7 deletions civicrm-upgrade-test.settings.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
## The base directory of the Drupal-Civi test installation.
WEB_ROOT=/Applications/MAMP/htdocs

## (For Drupal multisite) Specify the name of the Drupal site.
##
## If the configuration files live under $WEB_ROOT/sites/default,
## then leave this alone. If the configuration files live under
## $WEB_ROOT/sites/test.localhost, then set:
# DRUPAL_SITE=test.localhost

## The MySQL database used by your pre-existing CiviCRM install.
##
## The database should already be configured for use with
Expand Down

0 comments on commit 0108d7d

Please sign in to comment.