Skip to content

test: run cases for datetime with 2.11 fixes #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/packing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup Python and basic packing tools
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'

- name: Install tools for packing and verification
run: pip3 install wheel twine
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'

- name: Remove connector source code
run: python3 .github/scripts/remove_source_code.py
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'

- name: Remove connector source code
run: python3 .github/scripts/remove_source_code.py
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
- name: Setup Python and basic packing tools
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'

- name: Install tools for package publishing
run: pip3 install twine
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup python3 for tests
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: '3.11'

- name: Install connector requirements
run: pip3 install -r requirements.txt
Expand Down
60 changes: 24 additions & 36 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
msgpack-deps:
# latest msgpack will be installed as a part of requirements.txt
- ''
Expand All @@ -42,17 +43,17 @@ jobs:
# "This page is taking too long to load." error. Thus we use
# pairwise testing.
include:
- tarantool: '2.8'
python: '3.10'
- tarantool: '2.11'
python: '3.11'
msgpack-deps: 'msgpack-python==0.4.0'
- tarantool: '2.8'
python: '3.10'
- tarantool: '2.11'
python: '3.11'
msgpack-deps: 'msgpack==0.5.0'
- tarantool: '2.8'
python: '3.10'
- tarantool: '2.11'
python: '3.11'
msgpack-deps: 'msgpack==0.6.2'
- tarantool: '2.8'
python: '3.10'
- tarantool: '2.11'
python: '3.11'
msgpack-deps: 'msgpack==1.0.4'

steps:
Expand Down Expand Up @@ -114,15 +115,15 @@ jobs:
fail-fast: false
matrix:
tarantool:
- bundle: 'bundle-1.10.11-0-gf0b0e7ecf-r470'
path: ''
- bundle: 'bundle-2.8.3-21-g7d35cd2be-r470'
path: ''
- bundle: 'bundle-2.10.0-1-gfa775b383-r486-linux-x86_64'
path: ''
- bundle: 'sdk-gc64-2.11.0-rc2-0-r557.linux.x86_64'
- bundle: 'sdk-1.10.15-0-r563'
path: 'release/linux/x86_64/1.10/'
- bundle: 'sdk-2.8.4-0-r563'
path: 'release/linux/x86_64/2.8/'
- bundle: 'sdk-gc64-2.10.7-0-r563.linux.x86_64'
path: 'release/linux/x86_64/2.10/'
- bundle: 'sdk-gc64-2.11.0-0-r563.linux.x86_64'
path: 'release/linux/x86_64/2.11/'
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
python: ['3.6', '3.11']

steps:
- name: Clone the connector
Expand Down Expand Up @@ -169,8 +170,8 @@ jobs:
source tarantool-enterprise/env.sh
make test
env:
TEST_TNT_SSL: ${{ matrix.tarantool.bundle == 'bundle-2.10.0-1-gfa775b383-r486-linux-x86_64' ||
matrix.tarantool.bundle == 'sdk-gc64-2.11.0-rc2-0-r557.linux.x86_64'}}
TEST_TNT_SSL: ${{ matrix.tarantool.bundle == 'sdk-gc64-2.10.7-0-r563.linux.x86_64' ||
matrix.tarantool.bundle == 'sdk-gc64-2.11.0-0-r563.linux.x86_64'}}

run_tests_pip_branch_install_linux:
# We want to run on external PRs, but not on our own internal
Expand All @@ -191,10 +192,7 @@ jobs:
- '2.11'
python:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- name: Clone the connector repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -244,12 +242,10 @@ jobs:
matrix:
# Use reduced test matrix cause Windows pipelines are long.
tarantool:
- '1.10'
- '2.8'
- '2.10.0.g0a5ce0b9c-1'
- '2.11.0.g247a9a418-1'
python:
- '3.6'
- '3.10'
- '3.11'

steps:
- name: Clone the connector
Expand All @@ -271,15 +267,7 @@ jobs:
with:
distribution: Ubuntu-20.04

- name: Install tarantool ${{ matrix.tarantool }} for WSL (2.8 and older)
if: (matrix.tarantool == '1.10') || (matrix.tarantool == '2.8')
shell: wsl-bash_Ubuntu-20.04 {0}
run: |
curl -L https://tarantool.io/installer.sh | VER=${{ matrix.tarantool }} bash -s -- --type "release"
sudo apt install -y tarantool tarantool-dev

- name: Install tarantool ${{ matrix.tarantool }} for WSL (2.10 and newer)
if: (matrix.tarantool != '1.10') && (matrix.tarantool != '2.8')
shell: wsl-bash_Ubuntu-20.04 {0}
run: |
curl -L https://tarantool.io/release/2/installer.sh | bash -s
Expand Down Expand Up @@ -324,10 +312,10 @@ jobs:
matrix:
# Use reduced test matrix cause Windows pipelines are long.
tarantool:
- '2.10.0.g0a5ce0b9c-1'
- '2.11.0.g247a9a418-1'
python:
- '3.6'
- '3.10'
- '3.11'
steps:
- name: Clone the connector repo
uses: actions/checkout@v3
Expand Down
12 changes: 0 additions & 12 deletions tarantool/msgpack_ext/types/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,18 +532,6 @@ def __sub__(self, other):
self_dt = self._datetime
other_dt = other._datetime

# Tarantool datetime subtraction ignores timezone info, but it is a bug:
#
# Tarantool 2.10.1-0-g482d91c66
#
# tarantool> datetime.new{tz='MSK'} - datetime.new{tz='UTC'}
# ---
# - +0 seconds
# ...
#
# Refer to https://github.com/tarantool/tarantool/issues/7698
# for possible updates.

if self_dt.tzinfo != other_dt.tzinfo:
other_dt = other_dt.astimezone(self_dt.tzinfo)

Expand Down
13 changes: 13 additions & 0 deletions test/suites/lib/skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ def skip_or_run_datetime_test(func):
'does not support datetime type')


def skip_or_run_datetime_2_11_test(func):
"""
Decorator to skip or run tests related to datetime module with
fixes introduced in 2.11 release.

See https://github.com/tarantool/tarantool/issues/7698 and
https://github.com/tarantool/tarantool/issues/7700
"""

return skip_or_run_test_tarantool(func, '2.11.0',
'does not provide required datetime fixes')


def skip_or_run_error_extra_info_test(func):
"""
Decorator to skip or run tests related to extra error info
Expand Down
17 changes: 9 additions & 8 deletions test/suites/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from tarantool.msgpack_ext.unpacker import ext_hook as unpacker_ext_hook

from .lib.tarantool_server import TarantoolServer
from .lib.skip import skip_or_run_datetime_test
from .lib.skip import skip_or_run_datetime_test, skip_or_run_datetime_2_11_test


class TestSuiteDatetime(unittest.TestCase):
Expand Down Expand Up @@ -381,21 +381,23 @@ def test_tarantool_datetime_subtraction(self):
datetime_subtraction_different_timezones_case = {
'arg_1': tarantool.Datetime(year=2001, month=2, day=3, tz='UTC'),
'arg_2': tarantool.Datetime(year=2001, month=2, day=3, tz='MSK'),
'res': tarantool.Interval(day=1, hour=-21),
# Tarantool datetime comparison is naive, our tarantool.Interval comparison is naive too.
# So even though day=1, hour=-21 is the same as minute=180, test assertion fails.
'res_python': tarantool.Interval(day=1, hour=-21),
'res_tarantool': tarantool.Interval(minute=180),
}

def test_python_datetime_subtraction_different_timezones(self):
case = self.datetime_subtraction_different_timezones_case

self.assertEqual(case['arg_1'] - case['arg_2'], case['res'])
self.assertEqual(case['arg_1'] - case['arg_2'], case['res_python'])

@skip_or_run_datetime_test
@unittest.skip('See https://github.com/tarantool/tarantool/issues/7698')
@skip_or_run_datetime_2_11_test
def test_tarantool_datetime_subtraction_different_timezones(self):
case = self.datetime_subtraction_different_timezones_case

self.assertSequenceEqual(self.con.call('sub', case['arg_1'], case['arg_2']),
[case['res']])
[case['res_tarantool']])

interval_arithmetic_cases = {
'year': {
Expand Down Expand Up @@ -515,8 +517,7 @@ def test_python_datetime_addition_winter_time_switch(self):

self.assertEqual(case['arg_1'] + case['arg_2'], case['res'])

@skip_or_run_datetime_test
@unittest.skip('See https://github.com/tarantool/tarantool/issues/7700')
@skip_or_run_datetime_2_11_test
def test_tarantool_datetime_addition_winter_time_switch(self):
case = self.datetime_addition_winter_time_switch_case

Expand Down