绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
PostgreSQL开发入门(1)--编译、测试
2020-05-19 17:34:24

作为PostgreSQL开发人员,首先我们需要知道如何在Linux下进行编译、测试。这里将会介绍环境准备,代码下载、配置、编译,回归测试,如何获得代码覆盖率。

环境准备

操作系统:

[postgres@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[postgres@localhost ~]$ uname -a
Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

环境准备(很贴心的只保留了命令):

sudo yum install -y git gcc lcov flex bison zlib-devel readline-devel libxml2-devel libxslt-devel openssl-devel vim lcov
sudo yum install -y epel-release
sudo yum install -y centos-release-scl
sudo yum install -y llvm-toolset-7 llvm-toolset-7-llvm-devel llvm5.0-devel llvm-toolset-7-clang-analyzer llvm-toolset-7-clang-tools-extra gcc-c++
scl enable llvm-toolset-7 bash //enable clang
sudo ln -s /opt/rh/llvm-toolset-7/root/usr/bin/clang /usr/bin/clang

补充:这里安装LLVM是为了启用PostgreSQL的JIT功能,详细安装过程,请参看:developers.redhat.com/b

sudo yum install -y perl-core perl-IPC-Run

为了启用PostgreSQL的TAP测试套件,需要安装Perl相关组件。perl-core内容,请参看:perl.com/article/what-i。更多TAP内容,请参看:testanything.org/

源码下载

Git下载:

[postgres@localhost ~]$ git clone git://git.postgresql.org/git/postgresql.git pg13
Cloning into 'pg13'...
remote: Counting objects: 761424, done.
remote: Compressing objects:  (109491/109491), done.
remote: Total 761424 (delta 652269), reused 757277 (delta 649047)
Receiving objects:  (761424/761424), 229.17 MiB | 1.08 MiB/s, done.
Resolving deltas:  (652269/652269), done.
[postgres@localhost ~]$ cd pg13/
[postgres@localhost pg13]$ ls
aclocal.m4  configure     contrib    doc             HISTORY   README      src
config      configure.in  COPYRIGHT  GNUmakefile.in  Makefile  README.git

Git结构:

[postgres@localhost pg13]$ git tag | grep REL_12
REL_12_0
REL_12_1
REL_12_BETA1
REL_12_BETA2
REL_12_BETA3
REL_12_BETA4
REL_12_RC1
[postgres@localhost pg13]$ git branch -r | grep REL_12
  origin/REL_12_STABLE

tag是PostgreSQL各个版本,branch是代码分支。

编译、测试:

[postgres@localhost pg13]$ ./configure --prefix=/home/postgres/pgdb13 --enable-debug --enable-coverage --enable-tap-tests --with-openssl --with-llvm LLVM_CONFIG=/usr/lib64/llvm5.0/bin/llvm-config --with-libxml --with-libxslt --enable-thread-safety
[postgres@localhost pg13]$ make world; make install-world; make check-world
[postgres@localhost pg13]$ make coverage-html

make coverage-html会代码覆盖率报告,如下:

详细过程请参看:postgresql.org/docs/cur

当准备开发PostgreSQL时,我们首先要对整个数据库进行回归测试,确认没有问题后,再进行开发。当完成功能开发后,同时要增加自己的测试用例,还需要再次进行回归测试。同时要进行代码覆盖率测试,确保开发代码覆盖率足够高。

分享好友

分享这个小栈给你的朋友们,一起进步吧。

华山论剑
创建时间:2019-02-22 18:53:00
没了烟火气,人生就是一段孤独的旅程·····于是,在ITPUB,我们以武论英雄!
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

栈主、嘉宾

查看更多
  • 栈栈
    栈主
  • ?
    嘉宾

小栈成员

查看更多
  • u_9a3ed7a37f8e4a
  • daisyplay
  • boss_ch
  • Jack2k
戳我,来吐槽~