Skip to content

Commit 19454a2

Browse files
author
Luke Bakken
committed
Python 2.6 changes
1 parent e226683 commit 19454a2

5 files changed

Lines changed: 57 additions & 40 deletions

File tree

buildbot/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ test: setup test_normal test_security
2626
test_normal:
2727
@echo "Testing Riak Python Client (without security)"
2828
@../setup.py disable_security --riak-admin=${RIAK_ADMIN}
29-
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=1 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..
30-
@RIAK_TEST_PROTOCOL='http' RUN_YZ=1 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..
29+
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=0 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..
30+
@RIAK_TEST_PROTOCOL='http' RUN_YZ=0 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..
3131

3232
test_security:
3333
@echo "Testing Riak Python Client (with security)"
3434
@../setup.py enable_security --riak-admin=${RIAK_ADMIN}
35-
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=1 RUN_INDEXES=1 RUN_SECURITY=1 RUN_POOL=0 RUN_RESOLVE=0 ./tox_runner.sh ..
36-
@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 ..
35+
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=0 RUN_INDEXES=1 RUN_SECURITY=1 RUN_POOL=0 RUN_RESOLVE=0 ./tox_runner.sh ..
36+
@RIAK_TEST_PROTOCOL='http' RUN_YZ=0 RUN_INDEXES=1 RUN_SECURITY=1 RUN_POOL=0 RUN_RESOLVE=0 RIAK_TEST_HTTP_PORT=18098 ./tox_runner.sh ..
3737

3838
# These are required to actually build all the Python versions:
3939
# * pip install tox

buildbot/tox_cleanup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
for pbin in .tox/*/bin
4+
do
5+
echo $pbin
6+
pip="$pbin/pip"
7+
$pip uninstall riak_pb --yes
8+
$pip uninstall riak --yes
9+
$pip uninstall protobuf --yes
10+
$pip uninstall python3-riak-pb --yes
11+
$pip uninstall python3-protobuf --yes
12+
echo -----
13+
done

riak/tests/test_timeseries.py

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@
2525
ts0 = datetime.datetime(2015, 1, 1, 12, 0, 0)
2626
ts1 = ts0 + fiveMins
2727

28+
now = datetime.datetime.utcfromtimestamp(144379690)
29+
fiveMinsAgo = now - fiveMins
30+
tenMinsAgo = fiveMinsAgo - fiveMins
31+
fifteenMinsAgo = tenMinsAgo - fiveMins
32+
twentyMinsAgo = fifteenMinsAgo - fiveMins
33+
twentyFiveMinsAgo = twentyMinsAgo - fiveMins
34+
35+
codec = RiakPbcCodec()
36+
nowMsec = codec._unix_time_millis(now)
37+
tenMinsAgoMsec = codec._unix_time_millis(tenMinsAgo)
38+
twentyMinsAgoMsec = codec._unix_time_millis(twentyMinsAgo)
39+
40+
rows = [
41+
['hash1', 'user2', twentyFiveMinsAgo, 'typhoon', 90.3],
42+
['hash1', 'user2', twentyMinsAgo, 'hurricane', 82.3],
43+
['hash1', 'user2', fifteenMinsAgo, 'rain', 79.0],
44+
['hash1', 'user2', fiveMinsAgo, 'wind', None],
45+
['hash1', 'user2', now, 'snow', 20.1]
46+
]
47+
2848

2949
@unittest.skipUnless(RUN_TIMESERIES, 'RUN_TIMESERIES is 0')
3050
class TimeseriesUnitTests(unittest.TestCase):
@@ -169,46 +189,23 @@ class TimeseriesTests(IntegrationTestBase, unittest.TestCase):
169189
@classmethod
170190
def setUpClass(cls):
171191
super(TimeseriesTests, cls).setUpClass()
172-
cls.now = datetime.datetime.utcfromtimestamp(144379690)
173-
fiveMinsAgo = cls.now - fiveMins
174-
tenMinsAgo = fiveMinsAgo - fiveMins
175-
fifteenMinsAgo = tenMinsAgo - fiveMins
176-
twentyMinsAgo = fifteenMinsAgo - fiveMins
177-
twentyFiveMinsAgo = twentyMinsAgo - fiveMins
178192

179193
client = cls.create_client()
180194
table = client.table(table_name)
181-
rows = [
182-
['hash1', 'user2', twentyFiveMinsAgo, 'typhoon', 90.3],
183-
['hash1', 'user2', twentyMinsAgo, 'hurricane', 82.3],
184-
['hash1', 'user2', fifteenMinsAgo, 'rain', 79.0],
185-
['hash1', 'user2', fiveMinsAgo, 'wind', None],
186-
['hash1', 'user2', cls.now, 'snow', 20.1]
187-
]
188195
ts_obj = table.new(rows)
189196
result = ts_obj.store()
190197
if not result:
191198
raise AssertionError("expected success")
192199
client.close()
193200

194-
codec = RiakPbcCodec()
195-
cls.nowMsec = codec._unix_time_millis(cls.now)
196-
cls.fiveMinsAgo = fiveMinsAgo
197-
cls.twentyMinsAgo = twentyMinsAgo
198-
cls.twentyFiveMinsAgo = twentyFiveMinsAgo
199-
cls.tenMinsAgoMsec = codec._unix_time_millis(tenMinsAgo)
200-
cls.twentyMinsAgoMsec = codec._unix_time_millis(twentyMinsAgo)
201-
cls.numCols = len(rows[0])
202-
cls.rows = rows
203-
204201
def validate_data(self, ts_obj):
205202
if ts_obj.columns is not None:
206-
self.assertEqual(len(ts_obj.columns), self.numCols)
203+
self.assertEqual(len(ts_obj.columns), 5)
207204
self.assertEqual(len(ts_obj.rows), 1)
208205
row = ts_obj.rows[0]
209206
self.assertEqual(row[0], 'hash1')
210207
self.assertEqual(row[1], 'user2')
211-
self.assertEqual(row[2], self.fiveMinsAgo)
208+
self.assertEqual(row[2], fiveMinsAgo)
212209
self.assertEqual(row[3], 'wind')
213210
self.assertIsNone(row[4])
214211

@@ -233,8 +230,8 @@ def test_query_that_matches_some_data(self):
233230
"""
234231
query = fmt.format(
235232
table=table_name,
236-
t1=self.tenMinsAgoMsec,
237-
t2=self.nowMsec)
233+
t1=tenMinsAgoMsec,
234+
t2=nowMsec)
238235
ts_obj = self.client.ts_query('GeoCheckin', query)
239236
self.validate_data(ts_obj)
240237

@@ -247,12 +244,12 @@ def test_query_that_matches_more_data(self):
247244
"""
248245
query = fmt.format(
249246
table=table_name,
250-
t1=self.twentyMinsAgoMsec,
251-
t2=self.nowMsec)
247+
t1=twentyMinsAgoMsec,
248+
t2=nowMsec)
252249
ts_obj = self.client.ts_query('GeoCheckin', query)
253250
j = 0
254-
for i, want in enumerate(self.rows):
255-
if want[2] == self.twentyFiveMinsAgo:
251+
for i, want in enumerate(rows):
252+
if want[2] == twentyFiveMinsAgo:
256253
continue
257254
got = ts_obj.rows[j]
258255
j += 1
@@ -264,13 +261,13 @@ def test_get_with_invalid_key(self):
264261
self.client.ts_get('GeoCheckin', key)
265262

266263
def test_get_single_value(self):
267-
key = ['hash1', 'user2', self.fiveMinsAgo]
264+
key = ['hash1', 'user2', fiveMinsAgo]
268265
ts_obj = self.client.ts_get('GeoCheckin', key)
269266
self.assertIsNotNone(ts_obj)
270267
self.validate_data(ts_obj)
271268

272269
def test_get_single_value_via_table(self):
273-
key = ['hash1', 'user2', self.fiveMinsAgo]
270+
key = ['hash1', 'user2', fiveMinsAgo]
274271
table = Table(self.client, 'GeoCheckin')
275272
ts_obj = table.get(key)
276273
self.assertIsNotNone(ts_obj)
@@ -289,10 +286,11 @@ def test_stream_keys(self):
289286
self.assertEqual('user2', key[1])
290287
# TODO RTS-367 ENABLE
291288
# self.assertIsInstance(key[2], datetime.datetime)
292-
self.assertEqual(len(streamed_keys), 5)
289+
keylen = len(streamed_keys)
290+
self.assertTrue(keylen == 5 or keylen == 4)
293291

294292
def test_delete_single_value(self):
295-
key = ['hash1', 'user2', self.twentyFiveMinsAgo]
293+
key = ['hash1', 'user2', twentyFiveMinsAgo]
296294
rslt = self.client.ts_delete('GeoCheckin', key)
297295
self.assertTrue(rslt)
298296
ts_obj = self.client.ts_get('GeoCheckin', key)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
os_env_pythonpath = os.environ.get('PYTHONPATH')
1717
if os_env_pythonpath is not None:
1818
for ppath in os_env_pythonpath.split(os.pathsep):
19-
if ppath.find('riak_pb/python/lib') != -1:
19+
if ppath.find('riak_pb/python/lib') != -1 or ppath.find('riak_pb/python3/lib') != -1:
2020
riak_pb_messages = os.path.join(ppath, 'riak_pb', 'messages.py')
2121
if os.path.exists(riak_pb_messages):
2222
riak_pb_in_pythonpath = True

tox.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
envlist = py26, py279, py27, py33, py34
88

99
[testenv]
10+
basepython =
11+
py26: python2.6
12+
py279: {env:HOME}/.pyenv/versions/riak-py279/bin/python2.7
13+
py27: python2.7
14+
py33: python3.3
15+
py34: python3.4
1016
install_command = pip install --upgrade {packages}
1117
commands = {envpython} setup.py test
1218
deps = six

0 commit comments

Comments
 (0)