Skip to content
Jing Wang edited this page Mar 31, 2017 · 13 revisions

Dev notes

Remove dev from setup.cfg's tag_build

python setup.py sdist
gpg --detach-sign --armor *.tar.gz
twine upload PyHive*

Local testing

Start with http://releases.ubuntu.com/12.04/

echo Etc/UTC | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata
sudo reboot
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y git oracle-java8-installer python-dev g++ libsasl2-dev openssh-server
sudo pip install virtualenv wheel

git clone https://github.com/dropbox/PyHive.git
cd PyHive
CDH=cdh5 PRESTO=0.147 scripts/travis-install.sh

virtualenv --no-site-packages ~/env
source ~/env/bin/activate
pip install -e .
pip install -r dev_requirements.txt
py.test -v

If rebooting: Rerun travis-install.sh and sudo chmod -R 777 /tmp/hive

Authentication

https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-Authentication/SecurityConfiguration

LDAP

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-a-basic-ldap-server-on-an-ubuntu-12-04-vps

sudo apt-get install sldap ldap-utils phpldapadmin

Edit /etc/hive/conf/hive-site.xml

<property>
  <name>hive.server2.authentication</name>
  <value>LDAP</value>
</property>
<property>
  <name>hive.server2.authentication.ldap.url</name>
  <value>ldap://localhost:389</value>
</property>

Restart HiveServer2:

sudo service hive-server2 restart

Test:

from pyhive.hive import *
from thrift.transport.TTransport import *

c = connect('localhost', username='cn=admin,dc=test,dc=com', password='a')
cur = c.cursor()
cur.execute('show tables')
print(cur.fetchall())

# should fail
try:
    connect('localhost', username='cn=admin,dc=test,dc=com', password='ab')
    assert False
except TTransportException as e:
    assert 'Error validating the login' in e.message
    print(e)
Clone this wiki locally