test_gpdb.py 3.2 KB
Newer Older
1 2 3
#!/usr/bin/python2

import optparse
4 5 6
import os
import shutil
import stat
7 8
import subprocess
import sys
9

10
from builds.GpBuild import GpBuild
11

12

13 14 15 16 17
def install_gpdb(dependency_name):
    status = subprocess.call("mkdir -p /usr/local/gpdb", shell=True)
    if status:
        return status
    status = subprocess.call(
18 19
        "tar -xzf " + dependency_name + "/*.tar.gz -C /usr/local/gpdb",
        shell=True)
20 21
    return status

22

23 24
def create_gpadmin_user():
    status = subprocess.call("gpdb_src/concourse/scripts/setup_gpadmin_user.bash")
25
    os.chmod('/bin/ping', os.stat('/bin/ping').st_mode | stat.S_ISUID)
26 27 28 29
    if status:
        return status


30
def copy_output():
31 32 33 34 35 36 37 38 39 40
    for dirpath, dirs, diff_files in os.walk('gpdb_src/'):
        if 'regression.diffs' in diff_files:
            diff_file = dirpath + '/' + 'regression.diffs'
            print(  "======================================================================\n" +
                    "DIFF FILE: " + diff_file+"\n" +
                    "----------------------------------------------------------------------")
            with open(diff_file, 'r') as fin:
                print fin.read()
    shutil.copyfile("gpdb_src/src/test/regress/regression.diffs", "icg_output/regression.diffs")
    shutil.copyfile("gpdb_src/src/test/regress/regression.out", "icg_output/regression.out")
41

M
Michael Roth 已提交
42 43 44 45 46 47 48 49 50

def configure():
    p_env = os.environ.copy()
    p_env['LD_LIBRARY_PATH'] = '/usr/local/gpdb/lib'
    p_env['CFLAGS'] = '-I/usr/local/gpdb/include'
    p_env['CPPFLAGS'] = '-I/usr/local/gpdb/include'
    p_env['LDFLAGS'] = '-L/usr/local/gpdb/lib'
    return subprocess.call(["./configure",
                            "--enable-mapreduce",
51
                            "--enable-orafce",
M
Michael Roth 已提交
52 53 54 55
                            "--with-gssapi",
                            "--with-perl",
                            "--with-libxml",
                            "--with-python",
T
Taylor Vesely 已提交
56 57
                            # TODO: remove this flag after zstd is vendored in the installer for ubuntu
                            "--without-zstd",
L
Larry Hamel 已提交
58 59
                            "--with-libs=/usr/local/gpdb/lib",
                            "--with-includes=/usr/local/gpdb/include",
60
                            "--prefix=/usr/local/gpdb"], env=p_env, cwd="gpdb_src")
M
Michael Roth 已提交
61

62

63 64 65
def main():
    parser = optparse.OptionParser()
    parser.add_option("--build_type", dest="build_type", default="RELEASE")
66
    parser.add_option("--mode",  choices=['orca', 'planner'])
67 68 69 70 71
    parser.add_option("--compiler", dest="compiler")
    parser.add_option("--cxxflags", dest="cxxflags")
    parser.add_option("--output_dir", dest="output_dir", default="install")
    parser.add_option("--gpdb_name", dest="gpdb_name")
    (options, args) = parser.parse_args()
72
    gp_build = GpBuild(options.mode)
73

74 75 76
    status = install_gpdb(options.gpdb_name)
    if status:
        return status
M
Michael Roth 已提交
77
    status = configure()
78 79 80
    if status:
        return status
    status = create_gpadmin_user()
81 82 83 84
    if status:
        return status
    status = gp_build.unit_test()

85 86
    if status:
        return status
G
Goutam Tadi 已提交
87
    if os.getenv("TEST_SUITE", "icg") == 'icw':
88
      status = gp_build.install_check('world')
G
Goutam Tadi 已提交
89
    else:
90
      status = gp_build.install_check()
91 92
    if status:
        copy_output()
93 94
    return status

95

96 97
if __name__ == "__main__":
    sys.exit(main())