Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
 
set -Eeuo pipefail
IFS=$'\n\t'
 
TEST_NAME=""
JOBS=4
 
usage() {
    cat <<EOF
Usage:
  ./build_script.sh
  ./build_script.sh --test_name=dbms_tns
  ./build_script.sh --test_name dbms_tns
  ./build_script.sh --test_name="dbms_tns another_test" -j 4
 
Options:
  --test_name NAME     Optional regression test name or list of tests
  -j, --jobs N         Parallel jobs for make, default: 4
  -h, --help           Show this help
EOF
}
 
log() {
    echo
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
 
fail() {
    echo "ERROR: $*" >&2
    exit 1
}
 
while [[ $# -gt 0 ]]; do
    case "$1" in
        --test_name=*)
            TEST_NAME="${1#*=}"
            ;;
        --test_name)
            ARG_NAME="$1"
            shift
            [[ $# -gt 0 ]] || fail "После $ARG_NAME нужно указать имя теста"
            TEST_NAME="$1"
            ;;
        -j|--jobs)
            ARG_NAME="$1"
            shift
            [[ $# -gt 0 ]] || fail "После $ARG_NAME нужно указать число потоков"
            JOBS="$1"
            ;;
        --jobs=*)
            JOBS="${1#*=}"
            ;;
        -h|--help)
            usage
            exit 0
            ;;
        *)
            fail "Неизвестный аргумент: $1"
            ;;
    esac
    shift
done
 
[[ "$JOBS" =~ ^[0-9]+$ ]] || fail "jobs должен быть числом: $JOBS"
 
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
. "$SCRIPT_DIR/config/rudb_version.conf" || exit 1
INSTALL_PATH="${RUDB_INSTALL_PATH:-/opt/rudb-${RUDB_PG_MAJOR}}"
 
[[ -f "./full_build.sh" ]] || fail "Не найден ./full_build.sh. Запусти скрипт из корня репозитория или положи его туда."
[[ -f "./db_cr_all.sh" ]] || fail "Не найден ./db_cr_all.sh"
[[ -d "./src/test/regress" ]] || fail "Не найдена директория ./src/test/regress"
 
log "Start build pipeline"
log "Current OS user: $(id -un)"
log "Repository dir: $SCRIPT_DIR"
log "Jobs: $JOBS"
 
if [[ -n "$TEST_NAME" ]]; then
    log "Test name: $TEST_NAME"
else
    log "Test name not specified: regression tests will be skipped"
fi
 
log "1/4 make clean"
if [[ -f "./GNUmakefile" && -f "./src/Makefile.global" ]]; then
    make clean
else
    log "Skipping make clean: build tree is not configured yet"
fi
 
log "2/4 bash ./full_build.sh --dev"
bash ./full_build.sh --dev
 
log "3/4 bash ./db_cr_all.sh"
bash ./db_cr_all.sh
 
log "4/4 checking psql connection"
"$INSTALL_PATH/bin/psql" -p "${PGPORT:-5432}" -d postgres -U postgres <<'SQL'
SELECT 1;
\q
SQL
 
if [[ -n "$TEST_NAME" ]]; then
    log "Running regression tests"
    make -C src/test/regress check-tests TESTS="$TEST_NAME" -j"$JOBS"
else
    log "Skipping regression tests because --test_name was not specified"
fi
 
log "Done"