Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d527055
Implementing timeseries types and code
Oct 19, 2015
a75843b
Table object, timeseries ops do not use timeout
Oct 19, 2015
3de1e7f
Merge branch 'master' into features/lrb/rts-367
Oct 22, 2015
b40078b
Add setup code for Timeseries, begin to add integration tests
Oct 22, 2015
9de23fd
Refactor tests to allow running individuall. Still have to implement …
Oct 24, 2015
a8227e1
Refactored unit tests to allow running explicit test suites. Moved se…
Oct 25, 2015
454ba86
Add code to query TS data and encode / decode from PB messages. Tests…
Oct 27, 2015
4551e14
Ensure that RiakClient objects created during tests are closed
Oct 27, 2015
a4ab50c
Test fixes, decoding TS data fixes, ensure that resources are cleaned up
Oct 27, 2015
867ff63
Remove two TODOs
Oct 27, 2015
c268e6a
Add TsGetReq / TsGetResp support and tests
Oct 27, 2015
aece9f3
Add TsDelReq / TsDelResp support and tests
Oct 27, 2015
429b5fd
Remove support for sets and maps in TS data
Oct 27, 2015
b2b15e7
Small fix for test when security is disabled
Oct 28, 2015
9cba451
- Rename all SKIP_ variables to RUN_ to be consistent
Oct 28, 2015
2c59f20
Move contributions to README like other clients.
Oct 28, 2015
bac106c
Ensure format strings work correctly and make the linter happy
Oct 29, 2015
2549944
Changes after renaming data types and fields in the PB messages
Oct 30, 2015
d46c940
TS integration tests are complete
Nov 5, 2015
5f738c5
TS rpb renaming binary -> varchar, fix up tests and add some
Nov 10, 2015
0bcebd7
Fix tests. Timestamp is now returned in timestamp_value field
Nov 23, 2015
7330d75
PEP8
Dec 2, 2015
a48cb91
Add ListKeys encoding unit test
Dec 9, 2015
33862c1
TS streaming list keys done and with integration test
Dec 9, 2015
e226683
Tweak support for Python 3 by removing ability to have binary varchars
Dec 10, 2015
19454a2
Python 2.6 changes
Dec 10, 2015
a48020d
Update supported Python versions
Dec 11, 2015
6ae0494
Update supported Python versions
Dec 11, 2015
fdec441
Revert to 2.7+ version since 2.6 has been retired
Dec 11, 2015
c4eaa20
Simplify tox.ini for Python 2.7.8
Dec 11, 2015
57c47c0
Add Google's protobuf library as a direct prerequisite
Dec 13, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.pyc
.python-version

.tox/

docs/_build

.*.swp
Expand Down
86 changes: 83 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ If your Riak server isn't running on localhost or you have built a
Riak devrel from source, use the environment variables
``RIAK_TEST_HOST``, ``RIAK_TEST_HTTP_PORT`` and
``RIAK_TEST_PB_PORT`` to specify where to find the Riak server.
``RIAK_TEST_PROTOCOL`` to specify which protocol to test. Can be
either ``pbc`` or ``http``.

Some of the connection tests need port numbers that are NOT in use. If
ports 1023 and 1022 are in use on your test system, set the
Expand All @@ -150,7 +152,7 @@ Testing Search

If you don't have `Riak Search
<http://docs.basho.com/riak/latest/dev/using/search/>`_ enabled, you
can set the ``SKIP_SEARCH`` environment variable to 1 skip those
can set the ``RUN_SEARCH`` environment variable to 0 skip those
tests.

If you don't have `Search 2.0 <https://github.com/basho/yokozuna>`_
Expand All @@ -176,15 +178,45 @@ You may alternately add these lines to `setup.cfg`
[create_bucket_types]
riak-admin=/Users/sean/dev/riak/rel/riak/bin/riak-admin

To skip the bucket-type tests, set the ``SKIP_BTYPES`` environment
To skip the bucket-type tests, set the ``RUN_BTYPES`` environment
variable to ``0``.

Testing Data Types (Riak 2+)
----------------------------

To test data types, you must set up bucket types (see above.)

To skip the data type tests, set the ``RUN_DATATYPES`` environment
variable to ``0``.

Testing Timeseries (Riak 2.1+)
------------------------------

To test timeseries data, you must run the ``setup_timeseries`` command,
which will create the bucket-types used in testing, or create them
manually yourself. It can be run like so (substituting ``$RIAK`` with
the root of your Riak install)

.. code-block:: console

./setup.py setup_timeseries --riak-admin=$RIAK/bin/riak-admin

You may alternately add these lines to `setup.cfg`

.. code-block:: ini

[setup_timeseries]
riak-admin=/Users/sean/dev/riak/rel/riak/bin/riak-admin

To enable the timeseries tests, set the ``RUN_TIMESERIES`` environment
variable to ``1``.

Testing Secondary Indexes
-------------------------

To test
`Secondary Indexes <http://docs.basho.com/riak/2.0.0/dev/using/2i/>`_,
the ``SKIP_INDEX`` environment variable must be set to 0 (or 1 to skip them.)
the ``RUN_INDEXES`` environment variable must be set to 1 (or 0 to skip them.)

Testing Security (Riak 2+)
--------------------------
Expand Down Expand Up @@ -212,3 +244,51 @@ To run the tests, then simply
.. code-block:: console

RUN_SECURITY=1 RIAK_TEST_HTTP_PORT=18098 python setup.py test

Contributors
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, but don't we already have a THANKS file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I'll move those here ... that's what @mjbrender has had us do with the other clients. I know one unit test reads the THANKS file so I'll address that.

--------------------------
- Andrew Thompson
- Andy Gross <andy@basho.com>
- Armon Dadgar
- Brett Hazen
- Brett Hoerner
- Brian Roach
- Bryan Fink
- Daniel Lindsley
- Daniel Néri
- Daniel Reverri
- David Koblas
- Dmitry Rozhkov
- Eric Florenzano
- Eric Moritz
- Filip de Waard
- Gilles Devaux
- Greg Nelson
- Greg Stein
- Gregory Burd
- Ian Plosker
- Jayson Baird <jay@mochimedia.com>
- Jeffrey Massung
- Jon Meredith <jmeredith@basho.com>
- Josip Lisec
- Justin Sheehy <justin@basho.com>
- Kevin Smith
- `Luke Bakken <https://github.com/lukebakken>`_
- Mark Erdmann
- Mark Phillips
- Mathias Meyer
- Matt Heitzenroder
- Mikhail Sobolev
- Reid Draper
- Russell Brown
- Rusty Klophaus
- Rusty Klophaus <rusty@basho.com>
- Scott Lystig Fritchie
- Sean Cribbs
- Shuhao Wu
- Silas Sewell
- Socrates Lee
- Soren Hansen
- Sreejith Kesavan
- Timothée Peignier
- William Kral
45 changes: 0 additions & 45 deletions THANKS

This file was deleted.

11 changes: 9 additions & 2 deletions buildbot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ test: setup test_normal test_security
test_normal:
@echo "Testing Riak Python Client (without security)"
@../setup.py disable_security --riak-admin=${RIAK_ADMIN}
@RUN_YZ=1 SKIP_DATATYPES=0 SKIP_INDEXES=0 ./tox_runner.sh ..
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=1 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..
@RIAK_TEST_PROTOCOL='http' RUN_YZ=1 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..

test_security:
@echo "Testing Riak Python Client (with security)"
@../setup.py enable_security --riak-admin=${RIAK_ADMIN}
@RUN_YZ=1 SKIP_INDEXES=0 RUN_SECURITY=1 SKIP_POOL=1 SKIP_RESOLVE=1 RIAK_TEST_HTTP_PORT=18098 ./tox_runner.sh ..
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=1 RUN_INDEXES=1 RUN_SECURITY=1 RUN_POOL=0 RUN_RESOLVE=0 ./tox_runner.sh ..
@RIAK_TEST_PROTOCOL='http' RUN_YZ=1 RUN_INDEXES=1 RUN_SECURITY=1 RUN_POOL=0 RUN_RESOLVE=0 RIAK_TEST_HTTP_PORT=18098 ./tox_runner.sh ..

test_timeseries:
@echo "Testing Riak Python Client (timeseries)"
@../setup.py disable_security --riak-admin=${RIAK_ADMIN}
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=0 RUN_DATATYPES=0 RUN_INDEXES=1 RUN_TIMESERIES=1 ./tox_runner.sh ..

# These are required to actually build all the Python versions:
# * pip install tox
Expand Down
13 changes: 13 additions & 0 deletions buildbot/tox_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

for pbin in .tox/*/bin
do
echo $pbin
pip="$pbin/pip"
$pip uninstall riak_pb --yes
$pip uninstall riak --yes
$pip uninstall protobuf --yes
$pip uninstall python3-riak-pb --yes
$pip uninstall python3-protobuf --yes
echo -----
done
20 changes: 10 additions & 10 deletions buildbot/tox_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ if [[ -z $(pyenv versions | grep riak_3.3.6) ]]; then
VERSION_ALIAS="riak_3.3.6" pyenv install 3.3.6
pyenv virtualenv riak_3.3.6 riak-py33
fi
if [[ -z $(pyenv versions | grep riak_2.7.10) ]]; then
VERSION_ALIAS="riak_2.7.10" pyenv install 2.7.10
pyenv virtualenv riak_2.7.10 riak-py27
if [[ -z $(pyenv versions | grep riak_3.5.1) ]]; then
VERSION_ALIAS="riak_3.5.1" pyenv install 3.5.1
pyenv virtualenv riak_3.5.1 riak-py35
fi
if [[ -z $(pyenv versions | grep riak_2.7.9) ]]; then
VERSION_ALIAS="riak_2.7.9" pyenv install 2.7.9
pyenv virtualenv riak_2.7.9 riak-py279
if [[ -z $(pyenv versions | grep riak_2.7.11) ]]; then
VERSION_ALIAS="riak_2.7.11" pyenv install 2.7.11
pyenv virtualenv riak_2.7.11 riak-py27
fi
if [[ -z $(pyenv versions | grep riak_2.6.9) ]]; then
VERSION_ALIAS="riak_2.6.9" pyenv install 2.6.9
pyenv virtualenv riak_2.6.9 riak-py26
if [[ -z $(pyenv versions | grep riak_2.7.8) ]]; then
VERSION_ALIAS="riak_2.7.8" pyenv install 2.7.8
pyenv virtualenv riak_2.7.8 riak-py278
fi
pyenv global riak-py34 riak-py33 riak-py27 riak-py279 riak-py26
pyenv global riak-py34 riak-py33 riak-py35 riak-py27 riak-py278
pyenv versions

# Now install tox
Expand Down
111 changes: 71 additions & 40 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import os.path


__all__ = ['create_bucket_types', 'setup_security', 'enable_security',
'disable_security', 'preconfigure', 'configure']
__all__ = ['create_bucket_types',
'setup_security', 'enable_security', 'disable_security',
'setup_timeseries',
'preconfigure', 'configure']


# Exception classes used by this module.
Expand Down Expand Up @@ -73,35 +75,7 @@ def check_output(*popenargs, **kwargs):
import json


class create_bucket_types(Command):
"""
Creates bucket-types appropriate for testing. By default this will create:

* `pytest-maps` with ``{"datatype":"map"}``
* `pytest-sets` with ``{"datatype":"set"}``
* `pytest-counters` with ``{"datatype":"counter"}``
* `pytest-consistent` with ``{"consistent":true}``
* `pytest-write-once` with ``{"write_once": true}``
* `pytest-mr`
* `pytest` with ``{"allow_mult":false}``
"""

description = "create bucket-types used in integration tests"

user_options = [
('riak-admin=', None, 'path to the riak-admin script')
]

_props = {
'pytest-maps': {'datatype': 'map'},
'pytest-sets': {'datatype': 'set'},
'pytest-counters': {'datatype': 'counter'},
'pytest-consistent': {'consistent': True},
'pytest-write-once': {'write_once': True},
'pytest-mr': {},
'pytest': {'allow_mult': False}
}

class bucket_type_commands:
def initialize_options(self):
self.riak_admin = None

Expand Down Expand Up @@ -171,6 +145,66 @@ def _btype_command(self, *args):
return cmd


class create_bucket_types(bucket_type_commands, Command):
"""
Creates bucket-types appropriate for testing. By default this will create:

* `pytest-maps` with ``{"datatype":"map"}``
* `pytest-sets` with ``{"datatype":"set"}``
* `pytest-counters` with ``{"datatype":"counter"}``
* `pytest-consistent` with ``{"consistent":true}``
* `pytest-write-once` with ``{"write_once": true}``
* `pytest-mr`
* `pytest` with ``{"allow_mult":false}``
"""

description = "create bucket-types used in integration tests"

user_options = [
('riak-admin=', None, 'path to the riak-admin script')
]

_props = {
'pytest-maps': {'datatype': 'map'},
'pytest-sets': {'datatype': 'set'},
'pytest-counters': {'datatype': 'counter'},
'pytest-consistent': {'consistent': True},
'pytest-write-once': {'write_once': True},
'pytest-mr': {},
'pytest': {'allow_mult': False}
}


class setup_timeseries(bucket_type_commands, Command):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why create a new class just for timeseries? Seems like you could create other classes for, say, datatypes to be consistent. Is there some special behavior here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured since TS isn't a real thing yet it would be nice to keep it separate and skippable.

"""
Creates bucket-types appropriate for timeseries.
"""

description = "create bucket-types used in timeseries tests"

user_options = [
('riak-admin=', None, 'path to the riak-admin script')
]

_props = {
'GeoCheckin': {
'n_val': 3,
'table_def': '''
CREATE TABLE GeoCheckin (
geohash varchar not null,
user varchar not null,
time timestamp not null,
weather varchar not null,
temperature double,
PRIMARY KEY(
(geohash, user, quantum(time, 15, m)),
geohash, user, time
)
)'''
}
}


class security_commands(object):
def check_security_command(self, *args):
cmd = self._security_command(*args)
Expand Down Expand Up @@ -396,9 +430,9 @@ def _update_riak_conf(self):
https_host = self.host + ':' + self.https_port
pb_host = self.host + ':' + self.pb_port
self._backup_file(self.riak_conf)
f = open(self.riak_conf, 'r', buffering=1)
conf = f.read()
f.close()
conf = None
with open(self.riak_conf, 'r', buffering=1) as f:
conf = f.read()
conf = re.sub(r'search\s+=\s+off', r'search = on', conf)
conf = re.sub(r'##[ ]+ssl\.', r'ssl.', conf)
conf = re.sub(r'ssl.certfile\s+=\s+\S+',
Expand Down Expand Up @@ -427,9 +461,8 @@ def _update_riak_conf(self):
# Older versions of OpenSSL client library need to match on the server
conf += 'tls_protocols.tlsv1 = on\n'
conf += 'tls_protocols.tlsv1.1 = on\n'
f = open(self.riak_conf, 'w', buffering=1)
f.write(conf)
f.close()
with open(self.riak_conf, 'w', buffering=1) as f:
f.write(conf)

def _backup_file(self, name):
backup = name + ".bak"
Expand Down Expand Up @@ -469,6 +502,4 @@ def run(self):
for cmd_name in self.get_sub_commands():
self.run_command(cmd_name)

sub_commands = [('create_bucket_types', None),
('setup_security', None)
]
sub_commands = [('create_bucket_types', None), ('setup_security', None)]
Loading