Skip to content
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

Feature/delete rec additional test data set #133

Merged

Conversation

rachmadaniHaryono
Copy link
Collaborator

mostly about non integer input and 'max' keyword input.

related #132

@jarun
Copy link
Owner

jarun commented Mar 22, 2017

Do I need to do anything here?

@rachmadaniHaryono
Copy link
Collaborator Author

Maybe answer the question from 132,start fix with max keywords and set if the test separation is correct?

@jarun
Copy link
Owner

jarun commented Mar 22, 2017

Answered. Please check https://travis-ci.org/jarun/Buku/jobs/213773882

I think the API delete_rec() is not even called.

@rachmadaniHaryono
Copy link
Collaborator Author

I think the API delete_rec() is not even called

You are right, I will fix it in next commit

@rachmadaniHaryono
Copy link
Collaborator Author

rachmadaniHaryono commented Mar 23, 2017

if is_range == True and high == max, is high equal to 3 or 4?

3

try it once again, and imo it should be 4 instead of 3 e.g.

bdb.delete_rec(is_range=True, low=2, high='max')
# should be equal to
bdb.delete_rec(is_range=True, low=2, high=4)
# as in range(2, 4) -> [2, 3]
#
# but if high=3
bdb.delete_rec(is_range=True, low=2, high=3)
# equal to range(2,3) -> [2]

@jarun
Copy link
Owner

jarun commented Mar 23, 2017

The query we are using is:

'DELETE from bookmarks where id BETWEEN ? AND ?'

So it will delete both 2 and 3 when you pass 2, 3. It doesn't work exactly like range() in this case.

@jarun
Copy link
Owner

jarun commented Mar 24, 2017

Travis failed. Can you please explain the test case:

test_bukuDb.py::test_delete_rec_negative[-1-0-max-True] FAILED

What do you pass here? How many records in DB? What is max? What are you expecting as output?

@rachmadaniHaryono
Copy link
Collaborator Author

rachmadaniHaryono commented Mar 24, 2017

What do you pass here?

setup = None, index = -1, low = 0, high = 'max', is_range = True

https://travis-ci.org/jarun/Buku/jobs/214497928#L614

it expect the database to be cleared. even when high == 'max'.

What is max?

i thought you expect max as acceptable input on delete_rec? from the last thread

Some example acid test values for range:

0 - max
-0 - max
...

e:

How many records in DB?

still 3, maybe i will add after testing add_rec

@jarun
Copy link
Owner

jarun commented Mar 24, 2017

Initially when I mentioned max I intended MAX_INT. I understand now we refer to max_id in DB as max. So what is the integer value of max in the test case? Is it 3 (as you have 3 records in the DB)?

If you pass: -1, 0, 3, True
all the 3 records will be deleted and the API will return True.

Are you expecting the same output?

@rachmadaniHaryono
Copy link
Collaborator Author

rachmadaniHaryono commented Mar 24, 2017

Initially when I mentioned max I intended MAX_INT. I understand now we refer to max_id in DB as max. So what is the integer value of max in the test case? Is it 3 (as you have 3 records in the DB)?

it is my misunderstanding. i thought string max is valid input for low, high and index. the max on current test of is only string 'max'. i will change it to the value of max record on db on next commit

and yes the actual value of max right now is 3.

If you pass: -1, 0, 3, True
all the 3 records will be deleted and the API will return True.

Are you expecting the same output?

for this

setup = None, index = -1, low = 0, high = 'max', is_range = True

yes, just as you said.

all the 3 records will be deleted and the API will return True.

@jarun
Copy link
Owner

jarun commented Mar 24, 2017

So I guess you have to change max to len(records_in_DB) in the test cases, right? I think the ones with max are failing.

@jarun
Copy link
Owner

jarun commented Mar 26, 2017

I believe the following test cases are sufficient to test delete_rec with non-int:

test_bukuDb.py::test_delete_rec_on_non_interger[a-a-1-True] PASSED
test_bukuDb.py::test_delete_rec_on_non_interger[a-a-1-False] PASSED
test_bukuDb.py::test_delete_rec_on_non_interger[a-1-a-True] PASSED

The other test cases redundantly test the same paths and increase the time required to complete the tests.

I think we should resort to intelligent manually built up test cases than going for matrix based brute-force test.

For another example, I see tons of test_print_single_rec. Why? I wouldn't even bother testing this API with so many test cases.

@rachmadaniHaryono
Copy link
Collaborator Author

I think we should resort to intelligent manually built up test than going for matrix baed brute-force test.

i have the same problem too. so today i actually look up for python-hypothesis and use it on test.

with this i found a bug regarding big integer with 2 situations

  • when using it with index, it will raise OverflowError. max value of integer that sqlite3 3 can handle is 9223372036854775807 http://stackoverflow.com/questions/4448284/sqlite3-integer-max-value
  • when using it with range (and normalized low value == 0), it will take a long time. it is caused by this loop for index in range(low, high + 1):. i think this should be fixed.

In another example, I see tons of test_print_single_rec. Why?

i will change the test with hypothesis and see if there is another bug.

other things is about test package. the current test packages are put on two place, travis and setup.py. this should be only on setup.py and travis can install with python setup.py develop.

@jarun
Copy link
Owner

jarun commented Mar 26, 2017

this should be only on setup.py and travis can install with python setup.py develop.

Sure!

@rachmadaniHaryono
Copy link
Collaborator Author

rachmadaniHaryono commented Mar 26, 2017

Sure!

ok, i will do it. please fix the loop for is_range==True.

e: i am wrong with python setup.py develop. it only used so installed package change everytime the current package change.

to merge these travis and setup, i have to add extras in setup.py. developer can install it with pip install -e .[tests] (e flag is optional, but recommended).

relate so http://stackoverflow.com/a/18879288/1766261

it is working on travis, but not on zsh(i will fiind out later)

e2: for zsh the command is pip install -e .\[extra\] link: http://stackoverflow.com/a/30239714/1766261 (see the comment)

@rachmadaniHaryono rachmadaniHaryono force-pushed the feature/delete_rec-additional-test-data-set branch from 13153e1 to a160a6b Compare March 26, 2017 12:44
@jarun
Copy link
Owner

jarun commented Mar 26, 2017

please fix the loop for is_range==True

What's the issue with that?

@jarun
Copy link
Owner

jarun commented Mar 26, 2017

Why are you using int(MAX_SQLITE_INT + 1), specifically why are you adding 1?

@rachmadaniHaryono
Copy link
Collaborator Author

rachmadaniHaryono commented Mar 27, 2017

Why are you using int(MAX_SQLITE_INT + 1), specifically why are you adding 1?

i am trying to recreate the same OverflowError issue with index. but it can't be tested because this part of the code

for index in range(low, high + 1):
    self.compactdb(index, delay_commit=True)

when high value is unnecessarily high enough this will take time and and cause the error on travis. travis will raise error when a test case don't respond after ~10m

here is similar sqlite issue which happen to django https://code.djangoproject.com/ticket/27397


the actual number of MAX_SQLITE_INT is 2^63-1 instead of 2^47. it will be fixed on next commit

@rachmadaniHaryono rachmadaniHaryono force-pushed the feature/delete_rec-additional-test-data-set branch from d2d2b6e to 1eba948 Compare March 27, 2017 14:20
@jarun
Copy link
Owner

jarun commented Mar 27, 2017

Thanks for the investigation! Let's pass MAX_SQLITE_INT. I can add a check before range but I believe we may never hit this issue in reality.

@jarun
Copy link
Owner

jarun commented Mar 27, 2017

Also, please reduce the number of tests for test_delete_rec_on_non_integer.

I'm even thinking of removing the non-int case because we are clear we want integers. Feel free to take a call on this.

@rachmadaniHaryono rachmadaniHaryono force-pushed the feature/delete_rec-additional-test-data-set branch from 3b4cf59 to 1eeac89 Compare March 27, 2017 15:06
@rachmadaniHaryono
Copy link
Collaborator Author

rachmadaniHaryono commented Mar 27, 2017

i did several skip, but unfortunately skip + parametrize isnt working on py3.3 and py3.4, possibly related to this pytest-dev/pytest#1296

i think this is finished, right?

next would be

  • simplify test_print_single_rec
  • test print_rec
  • tox

e:

I can add a check before range but I believe we may never hit this issue in reality.

imo it is better to fix this.

even if the number will not met in reality, any high number input will make program take unnecessary time to process

@jarun
Copy link
Owner

jarun commented Mar 27, 2017

i think this is finished, right?

As I mentioned earlier, we should reduce the test cases for delete_rec with non-int to just 3 cases:

test_bukuDb.py::test_delete_rec_on_non_interger[a-a-1-True] PASSED
test_bukuDb.py::test_delete_rec_on_non_interger[a-a-1-False] PASSED
test_bukuDb.py::test_delete_rec_on_non_interger[a-1-a-True] PASSED

rest of the cases are redundant.

@jarun jarun merged commit 6a5f051 into jarun:master Mar 27, 2017
@jarun
Copy link
Owner

jarun commented Mar 27, 2017

Thank you!

@rachmadaniHaryono rachmadaniHaryono deleted the feature/delete_rec-additional-test-data-set branch March 27, 2017 17:05
@jarun
Copy link
Owner

jarun commented Mar 27, 2017

next would be

simplify test_print_single_rec
test print_rec
tox

yes, please proceed.

This was referenced Mar 28, 2017
jarun pushed a commit that referenced this pull request Mar 28, 2017
* new: test: additional data test set.

* new: test: test on non integer.

* chg: test: rename function for consistency.

* chg: test: change normalize function.

* chg: test: change max value for high var

* fix: test: use normalized index

* fix: test: remove 'max' as valid value

* chg: test: use hypothesis to test delete_rec index

* new: test: add hypothesis package

* chg: test: use hypothesis to test delete_rec index

* chg: test:  add hypothesis to travis

* chg: test: limit integer test.

* chg: dev: remove unused test

* fix: test: fix test on non integer.

* new: test: add big integer test on range in delete_rec method.

* fix: test: fix high low diff

* fix: test: skip only for python<3.5

* chg: test: change test_delete_rec_range_and_big_int

- remove skip
- use constant value instead sys.maxsize
- fix assert

* chg: test: use setup.py to manage test package instead travis

* chg: test: add tests extras on setup.py

* chg: test: change install test package.

* fix: test: fix whitespace

* fix: test: MAX_SQLITE_INT value

* chg: test: skip test for python<3.5

* fix: test: fix import

* chg: test: skip Impossible test

* chg: test: simplify test_delete_rec_on_non_interger
jarun pushed a commit that referenced this pull request Mar 28, 2017
* new: test: test for delete_rec (#132)

* chg: dev: add db instance for delay_commit check
* chg: dev: remove unused delete_rec test
* chg: test: not check delay commit on empty db test.
* chg: test: use simpler precise test for delete_rec
* fix: test: change pytest parametrize arg
* fix: test: fix instance of BukuDb
* fix: test: fix test.
* fix: test: logic on expected db len
* new: test: test for delete_rec
* new: test: test for delete_rec on empty database

* Needs timely commitment.

Removing the base implementation for rest APIs. At this point I believe it will
Be better handled by someone who needs it. The current contributions in this
area are very very infrequent. Defects and PRs remain pen over fortnights. It's
difficult to expect the same team to maintain the piece of code even if we ever
receive the full implementation from them.

* Roll ToDo list

* Feature/delete rec additional test data set (#133)

* new: test: additional data test set.

* new: test: test on non integer.

* chg: test: rename function for consistency.

* chg: test: change normalize function.

* chg: test: change max value for high var

* fix: test: use normalized index

* fix: test: remove 'max' as valid value

* chg: test: use hypothesis to test delete_rec index

* new: test: add hypothesis package

* chg: test: use hypothesis to test delete_rec index

* chg: test:  add hypothesis to travis

* chg: test: limit integer test.

* chg: dev: remove unused test

* fix: test: fix test on non integer.

* new: test: add big integer test on range in delete_rec method.

* fix: test: fix high low diff

* fix: test: skip only for python<3.5

* chg: test: change test_delete_rec_range_and_big_int

- remove skip
- use constant value instead sys.maxsize
- fix assert

* chg: test: use setup.py to manage test package instead travis

* chg: test: add tests extras on setup.py

* chg: test: change install test package.

* fix: test: fix whitespace

* fix: test: MAX_SQLITE_INT value

* chg: test: skip test for python<3.5

* fix: test: fix import

* chg: test: skip Impossible test

* chg: test: simplify test_delete_rec_on_non_interger

* Feature/tox test (#138)

* chg: test: mark slow test

* new: test: config for tox

* chg: test: mark function as non tox

* new: test: test print_rec with hypothesis

* chg: test: simplify test for print_single_rec

* fix: test: fix index test on test_print_rec_hypothesis

* fix: test: fix tox setting.

* fix: test: change test_print_single_rec to python3.5 only
@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants