Skip to content
Snippets Groups Projects
Select Git revision
  • f17ca174697eb74e189a735c1e895e20d9ee7d4f
  • noblogs default
  • noblogs-5.7.1
  • upstream
  • noblogs-5.7
  • noblogs-5.6new
  • upstream5.5.1
  • noblogs28dic
  • upstream28dic
  • noblogs-5.5.1
  • noblogs-5.4.2
  • noblogs-5.4_seconda
  • noblogs-5.4
  • noblogs-7c
  • wp5.2.3p3
  • mergedbconf
  • noblogs-5.7.1
  • noblogs.5.7.0p1
  • noblogs-5.7.0
  • noblogs-5.6p3
  • noblogs5.6p2
  • noblogs-5.6p1
  • noblogs-5.6
  • noblogs-5.4.2p1
  • noblogs-5.4.2
  • noblogs-5.4.1
  • noblogs-5.4
  • noblogs-p5.4
  • noblogs-5.3.2p2
  • noblogs-5.3.2p1
  • noblogs-5.3.2
  • noblogs-5.3
  • noblogs-5.2.3p4
  • noblogs-5.2.3p3
  • noblogs-5.2.3p2
  • noblogs-5.2.3p1
36 results

class-wp-error.php

Blame
  • test-driver 2.54 KiB
    #!/bin/sh
    
    # Find the absolute path to this script's directory
    # (so that we can find the 'float' root dir).
    bin_dir=$(dirname "$0")
    bin_dir=${bin_dir:-.}
    bin_dir=$(cd "${bin_dir}" && pwd)
    float_dir="${bin_dir}"
    
    log() {
        echo " ***" >&2
        echo " *** $*" >&2
        echo " ***" >&2
    }
    
    die() {
        echo "ERROR: $*" >&2
        exit 1
    }
    
    start_vagrant() {
        log Starting VMs
        vagrant box update
        vagrant up ${VAGRANT_PROVIDER:+--provider ${VAGRANT_PROVIDER}}
        return $?
    }
    
    stop_vagrant() {
        log Stopping VMs
        vagrant destroy --force --parallel
    }
    
    wait_for_vms() {
        log Waiting for VMs to become available
    
        # Wait at most 30 seconds for the vms to become reachable.
        local i=0
        local ok=1
        while [ $i -lt 10 ]; do
            sleep 3
            if ansible -v -i config.yml all -m ping; then
                ok=0
                break
            fi
            i=$(($i + 1))
        done
        return $ok
    }
    
    save_logs() {
        local out_dir="$1"
    
        ANSIBLE_STDOUT_CALLBACK=unixy \
        ${float_dir}/float run --extra-vars "out_dir=$out_dir" \
            ${float_dir}/test/save-logs.yml
    }
    
    run_init() {
        start_vagrant \
            || die "could not start VMs"
    
        wait_for_vms \
            || die "could not reach the VMs with Ansible"
    
        log Running init-credentials playbook
        ${float_dir}/float run init-credentials.yml \
            || die "failed to run the init-credentials playbook"
    
        log Running main playbook
        ${float_dir}/float run -vv site.yml \
            || die "failed to run the main playbook"
    }
    
    run_cleanup() {
        stop_vagrant
    }
    
    usage() {
        cat <<EOF
    Usage: test-driver [COMMAND] [DIR]
    Commands:
    
      init       Initialize the test environment (turn up VMs, set up
                 credentials, run the main float playbook)
    
      cleanup    Cleanup the test environment (turn down VMs, etc)
    
      run        Run the test suite, using the playbooks specified by
                 the remaining command-line arguments
    
    If DIR is specified, chdir there before running anything.
    
    EOF
        exit 2
    }
    
    cmd="$1"
    shift
    
    if [ $# -gt 0 ]; then
        cd "$1"
        shift
    fi
    
    case "$cmd" in
        init)
            run_init
            ;;
    
        cleanup)
            save_logs logs
            run_cleanup
            ;;
    
        run)
            # The 'yaml' output format has slightly more legible errors.
            export ANSIBLE_STDOUT_CALLBACK=yaml
    
            for playbook in "${float_dir}/test/integration-test-docker.yml" "$@"; do
                log Running test playbook ${playbook}
                ${float_dir}/float run ${playbook} \
                    || die "test playbook failed"
            done
            ;;
    
        *)
            usage
            ;;
    esac
    
    exit 0