Skip to content

Commit d97384b

Browse files
committed
code review changes
Signed-off-by: nadav mizrahi <[email protected]>
1 parent b2bcb7d commit d97384b

File tree

7 files changed

+59
-83
lines changed

7 files changed

+59
-83
lines changed

docs/dev_guide/ceph_s3_tests/ceph_s3_tests_guide.md

Lines changed: 29 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
2) Run All Ceph S3 Tests
77
3) Run a Single Ceph S3 Test
88
4) Debug a Single Ceph S3 Test
9-
5) Examples
9+
5) Compare to AWS Response (Inside Tester Pod)
10+
6) Examples
1011
* This guide describes developer steps to run Ceph S3 on a noobaa system on minikube.
1112

1213
## General Settings For Ceph S3 Tests
@@ -90,6 +91,12 @@ kubectl logs job/noobaa-tests-s3 -f
9091

9192
We run all the tests except the tests that appear in the lists `src/test/system_tests/ceph_s3_tests/s3-tests-lists` if you would like to add or remove a test you can edit those files (and then repeat the steps starting from 'Build Core And Tester Images (Noobaa-Core)' above).
9293

94+
Some tests are marked to be skipped in the tests code. usually because the enviorment doesn't support certain criteria. those tests will appear with a `[WARN]` tag and will be marked as "Test Skipped", for example:
95+
`[WARN] CONSOLE:: Test skipped: s3tests_boto3/functional/test_s3.py::test_lifecycle_transition`
96+
97+
In the test code the function:
98+
`pytest.skip("")` will mark them to be skipped.
99+
93100
## Run a Single Ceph S3 Test
94101

95102
### 1) Prerequisites:
@@ -137,20 +144,26 @@ Run the script that will create the necessary accounts in noobaa and update the
137144
node ./src/test/system_tests/ceph_s3_tests/test_ceph_s3_config_setup.js
138145
```
139146

140-
Note: If you want to ignore PythonDeprecationWarnings use (which will then ignore all Python warnings, so keep that in mind):
141-
```bash
142-
export PYTHONWARNINGS="ignore"
143-
```
147+
Note: If you want to ignore PythonDeprecationWarnings add the following flag to the test command (which will then ignore all Python warnings, so keep that in mind):
148+
`-- --disable-pytest-warnings`
149+
150+
note that every flag that comes after `--` is past to pytest from tox. so if there is already `--` in the command just put `--disable-pytest-warnings` as part of the flags after it, no need to add another `--` notation.
151+
152+
for example to add --disable-pytest-warnings to the command:
153+
`S3TEST_CONF=${PWD}/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf tox -c src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini -- -m 'not fails_on_aws' ${PWD}/src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/functional/test_s3.py::test_account_usage`
154+
155+
it should be:
156+
`S3TEST_CONF=${PWD}/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf tox -c src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini -- -m 'not fails_on_aws --disable-pytest-warnings ${PWD}/src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/functional/test_s3.py::test_account_usage`
144157

145158
### 5) Run a Test (Inside The Tester Pod)
146159
To run a test, from noobaa working directory:
147160
```bash
148-
S3TEST_CONF=$PWD/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf tox -c src/test/system_tests/ceph_s3_tests/s3_tests/tox.ini $PWD/src/test/system_tests/ceph_s3_tests/s3-tests/<test_name>
161+
S3TEST_CONF=${PWD}/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf tox -c src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini ${PWD}/src/test/system_tests/ceph_s3_tests/s3-tests/<test_name>
149162
```
150163
This should run the test on the noobaa deployment we've set up.
151164

152165
#### Test Name
153-
You can find a list of tests in the doc inside the file `ceph_s3_tests_list_single_test.txt`. Please notice that the test name has a certain structure <directory_name> are separated with `.` and the function to run (usually with a prefix `test_`) appears after the `:` sign.
166+
You can find a list of tests in the doc inside the file `ceph_s3_tests_list_single_test.txt`. Please notice that the test name has a certain structure <directory_name> are separated with `/`, the files end with the extention `.py` and the function to run (usually with a prefix `test_`) appears after the `::` sign.
154167
## Debug a Single Test (Inside The Tester Pod)
155168

156169
### 1) Prerequisites:
@@ -174,22 +187,22 @@ Since the file `./src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/fun
174187

175188
#### B. Temporary change - this change will be saved in the file inside the container, useful when you need a small change.
176189
You can edit the test by going to the test file and editing the test function. e.g. if you are working on test `s3tests_boto3.functional.test_s3:test_set_bucket_tagging` then you should `vi ./src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/functional/test_s3.py` and search for the function `test_set_bucket_tagging`.
177-
## Compare to AWS Response (Inside Tester Pod)
190+
### Compare to AWS Response (Inside Tester Pod)
178191
Prerequisites:
179192
Following the 'Run a Single Ceph S3 Test' steps until 'Deploy The Tester Deployment (Noobaa-Core Tab)'.
180193

181194
In this section we will do some manual changes that will allow you to check AWS response for a specific test (tests that do not use neither ACL nor tenant group).
182195
1) copy configuration file:
183196
```bash
184-
cp .src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf .src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf.aws
197+
cp src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf src/test/system_tests/ceph_s3_tests/test_ceph_s3_config_aws.conf
185198
```
186-
2) Change the new configuration file to match AWS details, `vi .src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf.aws`:
199+
2) Change the new configuration file to match AWS details, `vi src/test/system_tests/ceph_s3_tests/test_ceph_s3_config_aws.conf`:
187200
* host = s3.amazonaws.com
188201
* bucket prefix = choose_name (for example: `bucket prefix = foo-bucket` you will need to manually delete it from AWS, and its name will be `foo-bucket1`, it adds suffix of 1).
189202
* access_key, secret_key appears 3 times each in the file.
190203
3) Running tests with the new configuration files will run against AWS:
191204
```bash
192-
S3TEST_CONF=src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf.aws tox -c src/test/system_tests/ceph_s3_tests/s3_tests/tox.ini $PWD/src/test/system_tests/ceph_s3_tests/s3-tests/<test_name>
205+
S3TEST_CONF=${PWD}/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config_aws.conf tox -c src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini ${PWD}/src/test/system_tests/ceph_s3_tests/s3-tests/<test_name>
193206
```
194207
## Examples
195208

@@ -216,60 +229,12 @@ Following the 'Run a Single Ceph S3 Test' steps.
216229

217230
### 1) Test Pass
218231
For example: `s3tests_boto3/functional/test_s3.py::test_basic_key_count`
219-
```
220-
bash-4.4$ S3TEST_CONF=$PWD/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf tox -c src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini -- --disable-pytest-warnings $PWD/src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/functional/test_s3.py::test_account_usage
221-
222-
...
223-
224-
====================================================================================== 1 passed, 1 warning in 15.71s =======================================================================================
225-
_________________________________________________________________________________________________ summary __________________________________________________________________________________________________
226-
py: commands succeeded
227-
congratulations :)
232+
![alt text](images/tox_test_success.png)
228233

234+
note that there is the warning:
235+
`WARNING: could not copy distfile to //.tox/distshare`
236+
this warning is for tox to use the same dependancies between projects. this feature is depricated and not used on this project. in order to remove the warning you can modify src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini to include the following line in the `[tox]` section: `distshare = /root/node_modules/noobaa-core/.tox/distshare`
229237

230-
```
231238
### 2) Test Fail
232239
For example: `s3tests_boto3/functional/test_s3::test_account_usage.py`
233-
234-
```
235-
bash-4.4$ S3TEST_CONF=$PWD/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf tox -c src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/functional/test_s3.
236-
237-
...
238-
239-
================================================================================================= FAILURES =================================================================================================
240-
____________________________________________________________________________________________ test_account_usage ____________________________________________________________________________________________
241-
242-
...
243-
244-
------------------------------------------------------------------------------------------ Captured stdout setup -------------------------------------------------------------------------------------------
245-
246-
...
247-
248-
----------------------------------------------------------------------------------------- Captured stdout teardown -----------------------------------------------------------------------------------------
249-
250-
...
251-
252-
========================================================================================= short test summary info ==========================================================================================
253-
FAILED s3tests_boto3/functional/test_s3.py::test_account_usage - KeyError: 'Summary'
254-
====================================================================================== 1 failed, 2 warnings in 4.01s =======================================================================================
255-
ERROR: InvocationError for command '/root/node_modules/noobaa-core/src/test/system_tests/ceph_s3_tests/s3-tests/.tox/py/bin/pytest --disable-pytest-warnings /root/node_modules/noobaa-core/src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/functional/test_s3.py::test_account_usage' (exited with code 1)
256-
_________________________________________________________________________________________________ summary __________________________________________________________________________________________________
257-
ERROR: py: commands failed
258-
259-
260-
FAILED (errors=1)
261-
262-
```
263-
### 3) Wrong Test Name
264-
If you will use a test name that not written in the defined structure (as mentioned in 'Test Name' section) you will get a falsy OK.
265-
266-
For example: `s3tests_boto3.functional.test_s3.test_account_usage` instead of `s3tests_boto3.functional.test_s3:test_account_usage` (notice the use of the sign `:` before test).
267-
```
268-
bash-4.4$ S3TEST_CONF=$PWD/src/test/system_tests/ceph_s3_tests/test_ceph_s3_config.conf .tox -c src/test/system_tests/ceph_s3_tests/s3-tests/tox.ini src/test/system_tests/ceph_s3_tests/s3-tests/s3tests_boto3/functional/test_s3.py::test_account_usage
269-
270-
----------------------------------------------------------------------
271-
Ran 0 tests in 0.389s
272-
273-
OK
274-
```
275-
You can avoid it by using the name according to the structure or copy the test name from the file `ceph_s3_tests_list_single_test.txt`.
240+
![alt text](images/tox_test_failed.png)
Loading
Loading

src/deploy/NVA_build/Tests.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ WORKDIR /root/node_modules/noobaa-core/
2828
#
2929
##############################################################
3030
RUN ./src/test/system_tests/ceph_s3_tests/test_ceph_s3_deploy.sh $(pwd)
31+
# add group permissions to s3-tests directory (tox needs it in order to run)
3132
RUN cd ./src/test/system_tests/ceph_s3_tests/ && \
3233
chgrp -R 0 s3-tests && \
3334
chmod -R g=u s3-tests

src/test/system_tests/ceph_s3_tests/s3-tests-lists/s3_tests_pending_list.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,5 @@ s3tests_boto3/functional/test_s3.py::test_object_write_with_chunked_transfer_enc
7474
s3tests_boto3/functional/test_s3.py::test_versioning_concurrent_multi_object_delete
7575
s3tests_boto3/functional/test_s3.py::test_post_object_upload_size_rgw_chunk_size_bug
7676
s3tests_boto3/functional/test_s3.py::test_get_object_torrent
77+
s3tests_boto3/functional/test_s3select.py::test_count_json_operation
78+
s3tests_boto3/functional/test_s3select.py::test_column_sum_min_max

src/test/system_tests/ceph_s3_tests/test_ceph_s3.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const dbg = require('../../../util/debug_module')(__filename);
1515
dbg.set_process_name('test_ceph_s3');
1616
const argv = require('minimist')(process.argv.slice(2));
1717
delete argv._;
18-
const { S3_CEPH_TEST_SIGV4, CEPH_TEST, DEFAULT_NUMBER_OF_WORKERS } = require('./test_ceph_s3_constants.js');
18+
const { S3_CEPH_TEST_SIGV4, CEPH_TEST, DEFAULT_NUMBER_OF_WORKERS, TOX_ARGS } = require('./test_ceph_s3_constants.js');
1919

2020
const testing_status = {
2121
pass: [],
@@ -65,7 +65,7 @@ async function run_s3_tests() {
6565

6666
console.info(`CEPH TEST SUMMARY: Suite contains ${testing_status.total}, ran ${testing_status.pass.length + testing_status.fail.length + testing_status.skip.length} tests, Passed: ${testing_status.pass.length}, Skipped: ${testing_status.skip.length}, Failed: ${testing_status.fail.length}`);
6767
if (testing_status.skip.length) {
68-
console.warn(`CEPH TEST SUMMARY: ${testing_status.skip.length} skipped tests ${testing_status.skip.join('\n')}`);
68+
console.warn(`CEPH TEST SUMMARY: ${testing_status.skip.length} skipped tests \n${testing_status.skip.join('\n')}`);
6969
}
7070
if (testing_status.fail.length) {
7171
console.error(`CEPH TEST FAILED TESTS SUMMARY: ${testing_status.fail.length} failed tests \n${testing_status.fail.join('\n')}`);
@@ -75,9 +75,8 @@ async function run_s3_tests() {
7575

7676
async function run_all_tests() {
7777
console.info('Running Ceph S3 Tests...');
78-
const tox_args = `-c ${CEPH_TEST.test_dir}${CEPH_TEST.s3_test_dir}${CEPH_TEST.tox_config}`;
7978
const tests_list_command =
80-
`S3TEST_CONF=${process.cwd()}/${CEPH_TEST.test_dir}${CEPH_TEST.ceph_config} tox ${tox_args} -- -q --collect-only --disable-pytest-warnings 2>&1 | awk '{print $1}' | grep test`;
79+
`S3TEST_CONF=${process.cwd()}/${CEPH_TEST.test_dir}${CEPH_TEST.ceph_config} tox ${TOX_ARGS} -- -q --collect-only --disable-pytest-warnings 2>&1 | awk '{print $1}' | grep test`;
8180
try {
8281
tests_list = await os_utils.exec(tests_list_command, { ignore_rc: false, return_stdout: true });
8382
} catch (err) {
@@ -100,29 +99,35 @@ async function test_worker() {
10099
}
101100
}
102101

103-
async function run_single_test(test) {
102+
async function run_single_test(test_name) {
104103
let ceph_args = `S3TEST_CONF=${process.cwd()}/${CEPH_TEST.test_dir}${CEPH_TEST.ceph_config}`;
105-
const tox_args = `-c ${CEPH_TEST.test_dir}${CEPH_TEST.s3_test_dir}${CEPH_TEST.tox_config}`;
106-
if (S3_CEPH_TEST_SIGV4.includes(test)) {
104+
if (S3_CEPH_TEST_SIGV4.includes(test_name)) {
107105
ceph_args += ` S3_USE_SIGV4=true`;
108106
}
109-
let base_cmd = `${ceph_args} tox ${tox_args}`;
110-
if (!S3_CEPH_TEST_OUT_OF_SCOPE_REGEXP.test(test)) {
107+
let base_cmd = `${ceph_args} tox ${TOX_ARGS}`;
108+
if (!S3_CEPH_TEST_OUT_OF_SCOPE_REGEXP.test(test_name)) {
111109
try {
112-
if (test.includes('boto')) {
113-
base_cmd = `${ceph_args} tox ${tox_args} -- -m 'not fails_on_aws'`;
110+
if (test_name.includes('boto')) {
111+
base_cmd = `${ceph_args} tox ${TOX_ARGS} -- -m 'not fails_on_aws'`;
114112
}
115-
const res = await os_utils.exec(`${base_cmd} ${process.cwd()}/${CEPH_TEST.test_dir}${CEPH_TEST.s3_test_dir}${test}`, { ignore_rc: false, return_stdout: true });
116-
if (res.indexOf('SKIP') >= 0) {
117-
console.warn('Test skipped:', test);
118-
testing_status.skip.push(test);
113+
const res = await os_utils.exec(`${base_cmd} ${process.cwd()}/${CEPH_TEST.test_dir}${CEPH_TEST.s3_test_dir}${test_name}`, { ignore_rc: false, return_stdout: true });
114+
if (res.indexOf('skipped') >= 0) {
115+
console.warn('Test skipped:', test_name);
116+
testing_status.skip.push(test_name);
119117
} else {
120-
console.info('Test Passed:', test);
121-
testing_status.pass.push(test);
118+
console.info('Test Passed:', test_name);
119+
testing_status.pass.push(test_name);
122120
}
123121
} catch (err) {
124-
console.error('Test Failed:', test);
125-
testing_status.fail.push(test);
122+
// tox will exit with code 1 on error regardless of pytest exit code. pytest exit code 5 means no tests ran.
123+
// can happen when 'not fails_on_aws' flag is on for some tests (there are no boto3 tests for the test)
124+
if (err.stdout.indexOf("exited with code 5") >= 0) {
125+
console.warn('Test skipped:', test_name);
126+
testing_status.skip.push(test_name);
127+
} else {
128+
console.error('Test Failed:', test_name);
129+
testing_status.fail.push(test_name);
130+
}
126131
}
127132
}
128133
}

src/test/system_tests/ceph_s3_tests/test_ceph_s3_constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ const CEPH_TEST = {
8080

8181
const DEFAULT_NUMBER_OF_WORKERS = 5; //5 was the number of workers in the previous CI/CD process
8282

83+
const TOX_ARGS = `-c ${CEPH_TEST.test_dir}${CEPH_TEST.s3_test_dir}${CEPH_TEST.tox_config}`;
84+
8385

8486
exports.S3_CEPH_TEST_SIGV4 = S3_CEPH_TEST_SIGV4;
8587
exports.CEPH_TEST = CEPH_TEST;
8688
exports.DEFAULT_NUMBER_OF_WORKERS = DEFAULT_NUMBER_OF_WORKERS;
89+
exports.TOX_ARGS = TOX_ARGS;

0 commit comments

Comments
 (0)