Browse code

python-psycopg2 : fix make check errors.

Change-Id: Id8b1064e6ea7b3957f23f8ab8708c44c399895f3
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3474
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Chang Lee <changlee@vmware.com>

xiaolin-vmware authored on 2017/08/10 23:31:42
Showing 1 changed files
... ...
@@ -4,7 +4,7 @@
4 4
 Summary:        Python-PostgreSQL Database Adapter
5 5
 Name:           python-psycopg2
6 6
 Version:        2.7.1
7
-Release:        2%{?dist}
7
+Release:        3%{?dist}
8 8
 Url:            https://pypi.python.org/pypi/psycopg2
9 9
 License:        LGPL with exceptions or ZPL
10 10
 Group:          Development/Languages/Python
... ...
@@ -60,10 +60,30 @@ python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
60 60
 popd
61 61
 
62 62
 %check
63
-python2 setup.py test
63
+chmod 700 /etc/sudoers
64
+echo 'Defaults env_keep += "PYTHONPATH"' >> /etc/sudoers
65
+#start postgresql server and create a database named psycopg2_test
66
+useradd -m postgres &>/dev/null
67
+groupadd postgres &>/dev/null
68
+rm -r /home/postgres/data &>/dev/null ||:
69
+mkdir -p /home/postgres/data
70
+chown postgres:postgres /home/postgres/data
71
+chmod 700 /home/postgres/data
72
+su - postgres -c 'initdb -D /home/postgres/data'
73
+echo "client_encoding = 'UTF8'" >> /home/postgres/data/postgresql.conf
74
+echo "unix_socket_directories = '/run/postgresql'" >> /home/postgres/data/postgresql.conf
75
+mkdir -p /run/postgresql
76
+chown -R postgres:postgres /run/postgresql
77
+su - postgres -c 'pg_ctl -D /home/postgres/data -l logfile start'
78
+sleep 3
79
+su - postgres -c 'createdb psycopg2_test'
80
+PYTHONPATH=%{buildroot}%{python2_sitelib} PATH=$PATH:%{buildroot}%{_bindir} sudo -u postgres python2 -c "from psycopg2 import tests; tests.unittest.main(defaultTest='tests.test_suite')" --verbose
81
+
64 82
 pushd ../p3dir
65
-python3 setup.py test
83
+PYTHONPATH=%{buildroot}%{python3_sitelib} PATH=$PATH:%{buildroot}%{_bindir} sudo -u postgres python3 -c "from psycopg2 import tests; tests.unittest.main(defaultTest='tests.test_suite')" --verbose
66 84
 popd
85
+su - postgres -c 'pg_ctl -D /home/postgres/data stop'
86
+rm -r /home/postgres/data &>/dev/null ||:
67 87
 
68 88
 %files
69 89
 %defattr(-,root,root)
... ...
@@ -74,6 +94,8 @@ popd
74 74
 %{python3_sitelib}/*
75 75
 
76 76
 %changelog
77
+*   Wed Aug 09 2017 Xiaolin Li <xiaolinl@vmware.com> 2.7.1-3
78
+-   Fixed make check errors
77 79
 *   Thu Jul 6 2017 Divya Thaluru <dthaluru@vmware.com> 2.7.1-2
78 80
 -   Added build requires on postgresql-devel
79 81
 *   Wed Apr 26 2017 Xialin Li <xiaolinl@vmware.com> 2.7.1-1