~roadmr/canonical-identity-provider/fix-deprecation-warnings-1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /bin/bash
# How the tests are run in Jenkins by Tarmac
#
# ./run-tests -- run unit/acceptance tests for an environment.
#
# Usage: ./run-tests [dev|staging|production]


set -e

TARGET=$1
BOOTSTRAP=${2:-yes}

if [ "$TARGET" = "production" ]; then
    SST_BASE_URL="https://login.ubuntu.com"
elif [ "$TARGET" = "staging" ]; then
    SST_BASE_URL="https://login.staging.ubuntu.com"
fi

# Some Jenkins jobs copy workspace.tar.gz from successful build.
if [ -r "workspace.tar.gz" ]; then
    tar zxf workspace.tar.gz -C .
fi

# clean old results
rm -rf results/*
# make sure that dependencies are up to date
if [ $BOOTSTRAP = "yes" ]; then
    echo "Bootstrapping..."
    make clean && make bootstrap
fi

PG_TARMAC_DB="/dev/shm/pg_sso"
CURRENT_DIR="`pwd`"
# Set up the correct Django configuration.
LOCAL_SETTINGS_PATH="$CURRENT_DIR/../local_config/settings.py"
# back up user's config, if any
cp "$LOCAL_SETTINGS_PATH" "$LOCAL_SETTINGS_PATH.backup" || touch "$LOCAL_SETTINGS_PATH.backup"

function clean_up {
    set +e
    make stop-db
    mv "$LOCAL_SETTINGS_PATH.backup" "$LOCAL_SETTINGS_PATH" 2>&1 >/dev/null || true
    rm -rf $PG_TARMAC_DB
    exit
}

# handle exit cleanly (mainly Ctrl-C)
trap clean_up EXIT SIGHUP SIGINT SIGTERM

make start-db

# run tests
if [[ -z ${TARGET} ]]; then
    echo "Updating translation messages"
    make makemessages
    echo "Running canonical-identity-provider tests in tarmac"
    make test ARGS="--noinput --failfast"
else
    # Ensure static assets are collected and put in proper place to be served during testing.
    make collectstatic
    # run acceptance tests if TARGET given
    if [ ${TARGET} = "dev" ]; then
        echo "from django_project.settings_acceptance_dev import *  # noqa" > "$LOCAL_SETTINGS_PATH"
        ./scripts/acceptance-dev.sh
    else
        echo "from django_project.settings_acceptance import *  # noqa" > "$LOCAL_SETTINGS_PATH"
        SST_BASE_URL="$SST_BASE_URL" make run-acceptance
    fi
fi