Skip to content

Commit 9c651ad

Browse files
committed
merge with master
2 parents b7d522d + 98cdc16 commit 9c651ad

File tree

14 files changed

+533
-237
lines changed

14 files changed

+533
-237
lines changed

.github/workflows/ci.yml

Lines changed: 86 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,162 +10,179 @@ on:
1010

1111
jobs:
1212
build:
13-
name: Test on ${{ matrix.platform }} with Python ${{ matrix.python }}
13+
name: Test on ${{ matrix.platform }} with Python ${{ matrix.python }} with Redis ${{ matrix.redis-version }}
1414
runs-on: ${{ matrix.platform }}
1515
timeout-minutes: 40
1616
strategy:
1717
matrix:
18-
platform: ['ubuntu-20.04', 'macos-11']
18+
platform: ['ubuntu-22.04', 'macos-11']
1919
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
20+
redis-version: ['7.0', '7.2']
2021
fail-fast: false
2122
defaults:
2223
run:
2324
shell: bash -l -eo pipefail {0}
2425

2526
steps:
26-
- uses: actions/checkout@v3
27+
- name: checkout
28+
uses: actions/checkout@v3
2729
# Number of commits to fetch. 0 indicates all history for all branches and tags.
2830
with:
2931
fetch-depth: ''
3032

33+
- name: clone redis
34+
uses: actions/checkout@v3
35+
# Number of commits to fetch. 0 indicates all history for all branches and tags.
36+
with:
37+
fetch-depth: ''
38+
repository: 'redis/redis'
39+
ref: ${{matrix.redis-version}}
40+
path: redis
41+
3142
- name: Setup Python
3243
uses: actions/setup-python@v4
3344
with:
3445
python-version: ${{ matrix.python }}
3546
architecture: x64
3647

37-
- name: Cache pip
48+
- name: Setup Poetry
49+
uses: snok/install-poetry@v1
50+
with:
51+
version: 1.5.1
52+
virtualenvs-in-project: true
53+
virtualenvs-create: true
54+
installer-parallel: true
55+
56+
- name: Cache poetry
3857
uses: actions/cache@v3
3958
with:
40-
path: ~/.cache/pip # This path is specific to Ubuntu
59+
path: ~/.cache/poetry # This path is specific to Ubuntu
4160
# Look to see if there is a cache hit for the corresponding requirements file
4261
key: ${{ matrix.platform }}-${{ matrix.python }}-pyproject.toml-${{ hashFiles('pyproject.toml') }}
4362
restore-keys: |
4463
${{ matrix.platform }}-${{ matrix.python }}-pyproject.toml-${{hashFiles('pyproject.toml')}}}
4564
46-
- name: Setup automation
47-
run: |
48-
git clone --recursive https://github.com/RedisLabsModules/readies.git
49-
./readies/bin/getpy3
5065
5166
- name: Install Python dependencies
52-
run: |
53-
python3 -m pip install poetry
54-
python3 -m poetry config virtualenvs.create false
55-
python3 -m poetry export --dev --without-hashes -o requirements-${{matrix.platform}}-${{matrix.python}}.txt
56-
python3 -m pip install -r requirements-${{matrix.platform}}-${{matrix.python}}.txt
67+
run: poetry install -q
5768

58-
- name: Install Redis Server test dependencies
59-
run: |
60-
./readies/bin/getredis --workdir /tmp/redis -v 7 --keep
61-
ln -s /tmp/redis/redis redis
62-
redis-server --version
69+
- name: Install Redis Server
70+
working-directory: redis
71+
run: make BUILD_TLS=yes -j `nproc` install
72+
73+
- name: Generate test certificates #this step needs the redis repo to be cloned
74+
working-directory: redis
75+
run: ./utils/gen-test-certs.sh
6376

64-
- name: Generate test certificates
77+
- name: Copy certificates to tests/flow
6578
run: |
66-
cd redis
67-
rm -rf ./tests/unit/tls/
68-
./utils/gen-test-certs.sh
79+
mkdir -p tests/flow/tls
80+
cp redis/tests/tls/redis.crt tests/flow/tls
81+
cp redis/tests/tls/redis.key tests/flow/tls
82+
cp redis/tests/tls/ca.crt tests/flow/tls
6983
7084
- name: Unit Test with pytest
7185
timeout-minutes: 30
7286
run: |
73-
TLS="$PWD/redis/tests/tls"
87+
TLS="tests/flow/tls"
7488
TLS_CERT=$TLS/redis.crt \
7589
TLS_KEY=$TLS/redis.key \
7690
TLS_CACERT=$TLS/ca.crt \
7791
REDIS_BINARY=`command -v redis-server` \
78-
pytest --ignore=tests/flow --ignore=test_example.py -v
79-
80-
- name: Install RLTest
81-
run: |
82-
python3 -m pip install .
92+
poetry run pytest --ignore=tests/flow --ignore=test_example.py -v
8393
8494
- name: Flow Test OSS Single Module
95+
working-directory: tests/flow
8596
run: |
86-
cd tests/flow
8797
make -C modules
88-
CONTAINS_MODULES=1 RLTest --env oss -v --clear-logs --module modules/module1.so
98+
poetry run RLTest --env oss -v --clear-logs --module modules/module1.so --module-args "DUPLICATE_POLICY BLOCK"
8999
90100
- name: Flow Test OSS Multiple Modules --use-slaves
101+
working-directory: tests/flow
102+
if: (success() || failure())
91103
run: |
92-
cd tests/flow
93104
make -C modules
94-
CONTAINS_MODULES=1 RLTest --env oss -v --clear-logs \
105+
poetry run RLTest --env oss -v --clear-logs \
95106
--module modules/module1.so --module-args '' \
96107
--module modules/module2.so --module-args '' \
97108
--use-slaves
98109
99110
- name: Flow Test OSS Multiple Modules --use-aof
111+
working-directory: tests/flow
112+
if: (success() || failure())
100113
run: |
101-
cd tests/flow
102114
make -C modules
103-
CONTAINS_MODULES=1 RLTest --env oss -v --clear-logs \
104-
--module modules/module1.so --module-args '' \
105-
--module modules/module2.so --module-args '' \
106-
--use-aof
115+
poetry run RLTest --env oss -v --clear-logs \
116+
--module modules/module1.so --module-args '' \
117+
--module modules/module2.so --module-args '' \
118+
--use-aof
107119
108120
- name: Flow Test OSS Multiple Modules
121+
working-directory: tests/flow
122+
if: (success() || failure())
109123
run: |
110-
cd tests/flow
111124
make -C modules
112-
CONTAINS_MODULES=1 RLTest --env oss -v --clear-logs \
113-
--module modules/module1.so --module-args '' \
114-
--module modules/module2.so --module-args ''
125+
poetry run RLTest --env oss -v --clear-logs \
126+
--module modules/module1.so --module-args '' \
127+
--module modules/module2.so --module-args ''
115128
116129
- name: Flow Test OSS-CLUSTER Modules
130+
working-directory: tests/flow
131+
if: (success() || failure())
117132
run: |
118-
cd tests/flow
119133
make -C modules
120-
CONTAINS_MODULES=1 RLTest --env oss-cluster -v --clear-logs \
121-
--module modules/module1.so --module-args '' \
122-
--module modules/module2.so --module-args ''
134+
poetry run RLTest --env oss-cluster -v --clear-logs \
135+
--module modules/module1.so --module-args '' \
136+
--module modules/module2.so --module-args ''
123137
124138
- name: Flow Test OSS TCP
125-
run: |
126-
cd tests/flow
127-
RLTest --env oss -v --clear-logs
139+
working-directory: tests/flow
140+
if: (success() || failure())
141+
run: poetry run RLTest --env oss -v --clear-logs
128142

129143
- name: Flow Test OSS UNIX SOCKETS
130-
run: |
131-
cd tests/flow
132-
RLTest --env oss -v --clear-logs
144+
working-directory: tests/flow
145+
if: (success() || failure())
146+
run: poetry run RLTest --env oss -v --clear-logs
133147

134148
- name: Flow Test OSS TCP SLAVES
135-
run: |
136-
cd tests/flow
137-
RLTest --env oss -v --unix --clear-logs
149+
working-directory: tests/flow
150+
if: (success() || failure())
151+
run: poetry run RLTest --env oss -v --unix --clear-logs
138152

139153
- name: Flow Test OSS-CLUSTER TCP
140-
run: |
141-
cd tests/flow
142-
RLTest --env oss-cluster -v --clear-logs --shards-count 3
154+
working-directory: tests/flow
155+
if: (success() || failure())
156+
run: poetry run RLTest --env oss-cluster -v --clear-logs --shards-count 3
143157

144158
- name: Flow Test OSS TCP with TLS
159+
working-directory: tests/flow
160+
if: (success() || failure())
145161
run: |
146-
TLS="$PWD/redis/tests/tls"
147-
cd tests/flow
148-
RLTest --env oss -v --clear-logs \
162+
TLS="tls"
163+
poetry run RLTest --env oss -v --clear-logs \
149164
--tls-cert-file $TLS/redis.crt \
150165
--tls-key-file $TLS/redis.key \
151166
--tls-ca-cert-file $TLS/ca.crt \
152167
--tls
153168
154169
- name: Flow Test OSS-CLUSTER with TLS
170+
working-directory: tests/flow
171+
if: (success() || failure())
155172
run: |
156-
TLS="$PWD/redis/tests/tls"
157-
cd tests/flow
158-
RLTest --env oss-cluster --shards-count 3 -v --clear-logs \
173+
TLS="tls"
174+
poetry run RLTest --env oss-cluster --shards-count 3 -v --clear-logs \
159175
--tls-cert-file $TLS/redis.crt \
160176
--tls-key-file $TLS/redis.key \
161177
--tls-ca-cert-file $TLS/ca.crt \
162178
--tls
163179
164180
- name: Flow Test OSS-CLUSTER with SLAVES and TLS
181+
working-directory: tests/flow
182+
if: (success() || failure())
165183
run: |
166-
TLS="$PWD/redis/tests/tls"
167-
cd tests/flow
168-
RLTest --env oss-cluster --shards-count 3 --use-slaves -v --clear-logs \
184+
TLS="tls"
185+
poetry run RLTest --env oss-cluster --shards-count 3 --use-slaves -v --clear-logs \
169186
--tls-cert-file $TLS/redis.crt \
170187
--tls-key-file $TLS/redis.key \
171188
--tls-ca-cert-file $TLS/ca.crt \
@@ -174,12 +191,12 @@ jobs:
174191
- name: Generate coverage report
175192
if: matrix.python == '3.9' && matrix.platform != 'macos-11'
176193
run: |
177-
TLS="$PWD/redis/tests/tls"
194+
TLS="tests/flow/tls"
178195
TLS_CERT=$TLS/redis.crt \
179196
TLS_KEY=$TLS/redis.key \
180197
TLS_CACERT=$TLS/ca.crt \
181198
REDIS_BINARY=`command -v redis-server` \
182-
pytest --ignore=tests/flow --ignore=test_example.py --cov-config=.coveragerc --cov-report=xml --cov=RLTest
199+
poetry run pytest --ignore=tests/flow --ignore=test_example.py --cov-config=.coveragerc --cov-report=xml --cov=RLTest
183200
184201
- name: Upload coverage to Codecov
185202
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ htmlcov/
4545
.coverage
4646
.coverage.*
4747
.cache
48-
nosetests.xml
4948
coverage.xml
5049
*.cover
5150
.hypothesis/

RLTest/__main__.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import unittest
1212
import time
1313
import shlex
14+
import json
1415
from multiprocessing import Process, Queue
1516

1617
from RLTest.env import Env, TestAssertionFailure, Defaults
@@ -196,6 +197,10 @@ def do_normal_conn(self, line):
196197
'--log-dir', default='./logs',
197198
help='directory to write logs to')
198199

200+
parser.add_argument(
201+
'--log-level', default=None, metavar='LEVEL', choices=['debug', 'verbose', 'notice', 'warning'],
202+
help='sets the server log level')
203+
199204
parser.add_argument(
200205
'--use-slaves', action='store_const', const=True, default=False,
201206
help='run env with slaves enabled')
@@ -269,6 +274,10 @@ def do_normal_conn(self, line):
269274
'-s', '--no-output-catch', action='store_const', const=True, default=False,
270275
help='all output will be written to the stdout, no log files.')
271276

277+
parser.add_argument(
278+
'--verbose-information-on-failure', action='store_const', const=True, default=False,
279+
help='Print a verbose information on test failure')
280+
272281
parser.add_argument(
273282
'--enable-debug-command', action='store_const', const=True, default=False,
274283
help='On Redis 7, debug command need to be enabled in order to be used.')
@@ -414,6 +423,7 @@ def __init__(self):
414423
Defaults.binary = self.args.oss_redis_path
415424
Defaults.verbose = self.args.verbose
416425
Defaults.logdir = self.args.log_dir
426+
Defaults.loglevel = self.args.log_level
417427
Defaults.use_slaves = self.args.use_slaves
418428
Defaults.num_shards = self.args.shards_count
419429
Defaults.shards_ports = self.args.shards_ports.split(',') if self.args.shards_ports is not None else None
@@ -427,6 +437,7 @@ def __init__(self):
427437
Defaults.debug_pause = self.args.debug
428438
Defaults.debug_print = self.args.debug_print
429439
Defaults.no_capture_output = self.args.no_output_catch
440+
Defaults.print_verbose_information_on_failure = self.args.verbose_information_on_failure
430441
Defaults.debugger = debugger
431442
Defaults.sanitizer = sanitizer
432443
Defaults.exit_on_failure = self.args.exit_on_failure
@@ -660,6 +671,8 @@ def _runTest(self, test, numberOfAssertionFailed=0, prefix='', before=None, afte
660671
if passed:
661672
self.printPass(testFullName)
662673

674+
if hasException:
675+
numFailed += 1 # exception should be counted as failure
663676
return numFailed
664677

665678
def printSkip(self, name):
@@ -738,8 +751,19 @@ def run_jobs(jobs, results, port):
738751
done += 1
739752

740753
else:
741-
self._runTest(test)
754+
failures = self._runTest(test)
742755
done += 1
756+
757+
verboseInfo = {}
758+
if failures > 0 and Defaults.print_verbose_information_on_failure:
759+
lastEnv = self.currEnv
760+
verboseInfo['before_dispose'] = lastEnv.getInformationBeforeDispose()
761+
762+
# here the env is down so lets collect more info and print it
763+
if failures > 0 and Defaults.print_verbose_information_on_failure:
764+
verboseInfo['after_dispose'] = lastEnv.getInformationAfterDispose()
765+
lastEnv.debugPrint(json.dumps(verboseInfo, indent=2).replace('\\n', '\n'), force=True)
766+
743767
self.takeEnvDown(fullShutDown=True)
744768

745769
# serialized the results back

0 commit comments

Comments
 (0)