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

cat/play: tip that multiple files can be processed #1029

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

patapenka-alexey
Copy link
Contributor

@TarantoolBot document
Title: tip that multiple files can be processed by tt cat and tt play

This patch updates help of the cat and play commands to highlights that multiple files can be processed.

$ tt cat /path/to/1.xlog /path/to/2.snap 
$ tt play <URI> /path/to/1.xlog /path/to/2.snap 

Closes #1018
Closes #1019

@patapenka-alexey patapenka-alexey marked this pull request as draft November 20, 2024 14:20
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh1019-cat-allow-to-specify-multiple-wal-files branch from a0b1cb8 to 95cb73e Compare November 21, 2024 05:36
@patapenka-alexey patapenka-alexey marked this pull request as ready for review November 21, 2024 05:53
@patapenka-alexey
Copy link
Contributor Author

I also reformatted the cat and play command tests a bit.

@oleg-jukovec oleg-jukovec requested review from dmyger and themilchenko and removed request for oleg-jukovec and DerekBum November 21, 2024 07:51
@oleg-jukovec oleg-jukovec added the full-ci Enables full ci tests label Nov 21, 2024
Copy link
Contributor

@themilchenko themilchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just 2 NITs for your discretion.

test/integration/cat/test_cat.py Outdated Show resolved Hide resolved
test/integration/play/test_play.py Outdated Show resolved Hide resolved
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh1019-cat-allow-to-specify-multiple-wal-files branch from 95cb73e to 124f1be Compare November 21, 2024 09:40
assert re.search(r"lsn: 512", output)
assert re.search(r"space_id: 320", output)
assert re.search(r"space_id: 296", output)
def make_test_cat_args_param(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: what is the benefit of this extra layer of abstraction?

Copy link
Contributor Author

@patapenka-alexey patapenka-alexey Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set default values for all parameters, and could skip them in some test cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where a parameter can be omitted and default values used instead?
Even so, it is more transparent to have an explicit indication that the input is “empty” data than to do so implicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where a parameter can be omitted and default values used instead?

Yes. I removed this code from places, where it does not needed.



def test_cat_xlog_file(tt_cmd, tmp_path):
@pytest.mark.parametrize(TEST_CAT_ARGS_CCONFIG, [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to hide a set of arguments in the variable? It doesn't seem transparent to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I found the case, when two sets of the parameters are used. I just decided not to delete this. Maybe it makes the code overloaded, I agree. Do you think I should remove it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. As for me, it makes the code a bit difficult to understand.
  2. It complicates the ability to make local changes, as there is an unnecessary binding to a variable that can be used elsewhere, and you need to maintain consistency across different places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@pytest.mark.parametrize(TEST_CAT_ARGS_CCONFIG, [
make_test_cat_args_param(
# Testing with unset .xlog or .snap file.
cat_result=1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that cat_result is the return code of the external utility?
It looks like we are testing the operation of this utility. It should be enough to check whether it succeeds or not, and with what code it doesn't matter.
Therefore, it would be more correct to split the test - one for successful cases, the other for error cases.

Copy link
Contributor Author

@patapenka-alexey patapenka-alexey Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return code of the external utility?

Nope, this is result of tt cat <args> command execution.

split the test

Now they divided to common part and timestamp testing part. I thought that a good idea not to mix them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right about the “good idea not to mix them”, that's the reason why it's better to stick with that idea to the end and separate them into successful and unsuccessful ones as well.
So it would be something like:

  • common success
  • common fail
  • timestamp success
  • timestamp fail

This separation will make the code simpler, remove unnecessary parameterization at the input and unnecessary flow control (if-else) inside the test function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I divided tests by arguments and results.

assert re.search(r"space_id: 320", output)
assert re.search(r"space_id: 296", output)
def make_test_cat_args_param(
args=[],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Python is dangerous the use a mutable data types for the default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, my mistake. Fixed.

@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh1019-cat-allow-to-specify-multiple-wal-files branch from 124f1be to c7ada0e Compare November 22, 2024 13:19
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh1019-cat-allow-to-specify-multiple-wal-files branch from c7ada0e to 7795e70 Compare November 22, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full-ci Enables full ci tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cat: allow to specify multiple WAL files play: allow to specify multiple WAL files
4 participants