<commit_before>#!/bin/bash

set -x

function stop {
    if [ ! ${SF_SKIP_BOOTSTRAP} ]; then
        cd lxc
        ./bootstrap-lxc.sh clean
        cd ..
    fi
}

echo -n > /tmp/debug
export SF_ROOT=$(pwd)
export SF_PREFIX=${SF_PREFIX:-tests}
export SKIP_CLEAN_ROLES="y"
export EDEPLOY_ROLES=/var/lib/sf/roles/

(cd lxc; ./bootstrap-lxc.sh clean)
sudo ./build_roles.sh

if [ ! ${SF_SKIP_BOOTSTRAP} ]; then
    cd lxc
    ./bootstrap-lxc.sh
    cd ..
fi

# Start serverspec test to detect failure early
cp build/serverspec/hosts.yaml serverspec/
cd serverspec/
rake spec
RET=$?
[ "$RET" != "0" ] && {
    cd ..
    stop
    exit $RET
}
cd ..

nosetests -v ./tests
RET=$?
# This delay is used to wait a bit before fetching log file from hosts<commit_msg>Retry serverspec tests if failing<commit_after>#!/bin/bash

set -x

function stop {
    if [ ! ${SF_SKIP_BOOTSTRAP} ]; then
        cd lxc
        ./bootstrap-lxc.sh clean
        cd ..
    fi
}

echo -n > /tmp/debug
export SF_ROOT=$(pwd)
export SF_PREFIX=${SF_PREFIX:-tests}
export SKIP_CLEAN_ROLES="y"
export EDEPLOY_ROLES=/var/lib/sf/roles/

(cd lxc; ./bootstrap-lxc.sh clean)
sudo ./build_roles.sh

if [ ! ${SF_SKIP_BOOTSTRAP} ]; then
    cd lxc
    ./bootstrap-lxc.sh
    cd ..
fi

# Start serverspec test to detect failure early
cp build/serverspec/hosts.yaml serverspec/
cd serverspec/
retries=0
while true; do
    rake spec
    RET=$?

    [ "$RET" == "0" ] && break

        let retries=retries+1
        if [ "$retries" == "9" ]; then
            exit $RET
        fi
    sleep 30
done
cd ..


nosetests -v ./tests
RET=$?
# This delay is used to wait a bit before fetching log file from hosts
{'fraction_non_alphanumeric': 0.13051359516616315, 'fraction_numerical': 0.004229607250755287, 'mean_word_length': 2.5309168443496803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7284775', 'n_tokens_mistral': 633, 'n_tokens_neox': 621, 'n_words': 174}