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

Tests Frang #265

Merged
merged 60 commits into from
Nov 25, 2022
Merged

Tests Frang #265

merged 60 commits into from
Nov 25, 2022

Conversation

KonsKo
Copy link
Contributor

@KonsKo KonsKo commented Aug 5, 2022

I prepared my work pass it to Nadia, because now she is gonna make Frang tests.
I upload almost everything I have except tests I was stacked with. Something was made some time ago, something not. I disabled several tests with comment Disabled for PR (them should be fixed). I repeat, I did not fix them, because task was passed to Nadia.

Also, there is some cleaning for multiple_listeners.

@ProshNad, after PR is done, take a look of tests and do everything you want.

The related issues is tempesta-tech/tempesta#673

@KonsKo KonsKo marked this pull request as ready for review August 5, 2022 23:26
@KonsKo KonsKo requested a review from nickzaev August 5, 2022 23:29
@ProshNad
Copy link
Contributor

It so happened that I already took a branch kk-test and fixed broken tests and added my new tests. Next time I will do everything in my branch, but this time we agreed to leave it like that and do a review in this branch.

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

This mostly looks like an acceptance testing, than a real functional tests. This is a security feature, so please pay much more attention to all the corner and confusing cases. Please review https://github.com/tempesta-tech/tempesta/wiki/HTTP-security and all the tests.

cert_gen.sh Outdated Show resolved Hide resolved
createst.sh Outdated Show resolved Hide resolved
multiple_listeners/config_for_tests_template.txt Outdated Show resolved Hide resolved
t_frang/test_connection_rate_burst.py Show resolved Hide resolved
t_frang/test_header_cnt.py Show resolved Hide resolved
t_frang/test_tls_rate_burst.py Outdated Show resolved Hide resolved
t_frang/test_tls_rate_burst.py Outdated Show resolved Hide resolved
t_frang/test_tls_rate_burst.py Outdated Show resolved Hide resolved
t_frang/test_tls_rate_burst.py Outdated Show resolved Hide resolved
t_frang/test_request_rate_burst.py Outdated Show resolved Hide resolved
@krizhanovsky krizhanovsky removed the request for review from const-t September 26, 2022 20:52
Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

This is a tremendous work, but there are still many issues which must be fixed.

.gitignore Show resolved Hide resolved
t_frang/test_http_method_override_allowed.py Outdated Show resolved Hide resolved
t_frang/test_http_method_override_allowed.py Show resolved Hide resolved
t_frang/test_http_method_override_allowed.py Show resolved Hide resolved
t_frang/test_http_method_override_allowed.py Outdated Show resolved Hide resolved
t_frang/test_http_trailer_split_allowed.py Outdated Show resolved Hide resolved
t_frang/test_http_trailer_split_allowed.py Outdated Show resolved Hide resolved
t_frang/test_length.py Outdated Show resolved Hide resolved
t_frang/test_request_rate_burst.py Outdated Show resolved Hide resolved
t_frang/test_request_rate_burst.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nickzaev nickzaev left a comment

Choose a reason for hiding this comment

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

To sum up:

  • multiple_listeners group of test has already been fixed in plain configs for multiple listeners #275, so you just need to rebase your branch onto master, resolving conflicts
  • There should be some autoformatting applied to this entire PR since changing every commented line's formatting by hand is not that productive. I suggest you to commit all your changes though before applying one, hence there will be many changes and you might not like some of them
  • The majority of test files contain some base class and just one class directly inherited from it, on the other hand the tests are being grouped by files (not by classes) and it is very unlikely that, say, there will be another class in t_frang/test_client_body_timeout.py any soon. So what's the point having that inheritance approach all over the place?
  • About a solid third of the tests code consists of almost identical Nginx configurations which either don't differ at all or just in very minor parts, so it looks more that we test Nginx rather than Tempesta :) Why not just reuse FrangTestCase everywhere possible at least just for consistency's sake?
  • If we actually fall for that approach of using inheritance and all, the parts of starting off backends and Tempesta should be in setUp method of some base class and not get repeated for every test as it is for now.
  • Constants are massively overused, indeed, what's point of having such constants as ONE?

Regarding running the tests, some of them resulted in errors because of you using non-standard path to the encryption keys:

Ran 98 tests in 307.733s

FAILED (failures=1, errors=83)

Hit me up when it gets fixed and I'll give it a try again.

.gitignore Outdated
@@ -2,4 +2,4 @@ tests_config.ini
tests_resume.json
tests_log.log
*.pyc
*~
*~
Copy link
Contributor

Choose a reason for hiding this comment

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

These files usually get extended by piping, redirecting, etc. That is why there should be a newline character at the end, so why do you delete this one?

Copy link
Contributor

Choose a reason for hiding this comment

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

added

t_frang/frang_test_case.py Outdated Show resolved Hide resolved
'type': 'nginx',
'status_uri': 'http://${server_ip}:8000/nginx_status',
'config': """
pid ${pid};
Copy link
Contributor

Choose a reason for hiding this comment

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

This test has the very same nginx configuration as FrangTestCase, so why it's not being reused if we already put it in a separate class and file only with that configuration?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes you are right I will fix it

Copy link
Contributor

Choose a reason for hiding this comment

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

I parametrized all tests with base class - FrangTestCase

self.assertEqual(0, len(deproxy_cl3.responses))

self.assertFalse(deproxy_cl.connection_is_closed())
self.assertTrue(deproxy_cl2.connection_is_closed())#all clients should be blocked here, but for some reason only one gets closed
Copy link
Contributor

Choose a reason for hiding this comment

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

It should probably be the second argument to self.assertTrue, not a comment, so the person who sees this failure in logs would not have to look up the test code for the meaning of it. The same goes to all similar comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

connection_rate 4;
}

listen 127.0.0.4:8765;
Copy link
Contributor

Choose a reason for hiding this comment

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

IPs and other things that are subject to change should not be hardcoded, we have ${server_ip} and embedded runtime substitution with actual values for this particular purpose.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, fixed

}

tls_match_any_server_name;
tls_certificate RSA/tfw-root.crt;
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be tls_certificate ${tempesta_workdir}/tempesta.crt;

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, fixed

t_frang/test_host_required.py Outdated Show resolved Hide resolved
t_frang/test_http_ct_vals.py Outdated Show resolved Hide resolved
Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

There are still issues in the PR, but I think there is nothing for me to review next time, so I approve the PR.

@RomanBelozerov I reassign the PR to you to make a review with appropriate adjustments, which you think are required. Also could you please address all not addressed comments by me and @nickzaev .

@pale-emperor I add you to reviewers: the main point to pay attention is that the branch is stable enough to not to break our CI.

@pale-emperor
Copy link
Contributor

I have run the tests on CI node for several times and get stable errors in the tests listed below:

FAIL: test_h2_host_header_as_ipv6 (t_frang.test_host_required.FrangHostRequiredH2TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tempesta/tempesta-test/t_frang/test_host_required.py", line 520, in test_h2_host_header_as_ipv6
    self._test_base_scenario(
  File "/home/tempesta/tempesta-test/t_frang/test_host_required.py", line 578, in _test_base_scenario
    self.assertEqual(
AssertionError: 0 != 1 : Frang limits warning is not shown

======================================================================
FAIL: test_h2_host_header_mismatch (t_frang.test_host_required.FrangHostRequiredH2TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tempesta/tempesta-test/t_frang/test_host_required.py", line 504, in test_h2_host_header_mismatch
    self._test_base_scenario(
  File "/home/tempesta/tempesta-test/t_frang/test_host_required.py", line 578, in _test_base_scenario
    self.assertEqual(
AssertionError: 0 != 1 : Frang limits warning is not shown

======================================================================
FAIL: test_h2_host_header_missing (t_frang.test_host_required.FrangHostRequiredH2TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tempesta/tempesta-test/t_frang/test_host_required.py", line 496, in test_h2_host_header_missing
    self._test_base_scenario(
  File "/home/tempesta/tempesta-test/t_frang/test_host_required.py", line 578, in _test_base_scenario
    self.assertEqual(
AssertionError: 2 != 1 : Frang limits warning is not shown

======================================================================
FAIL: test_tls_connection_rate_on_the_limit (t_frang.test_tls_rate_burst.FrangTlsRateBurstTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tempesta/tempesta-test/t_frang/test_tls_rate_burst.py", line 539, in test_tls_connection_rate_on_the_limit
    self.assertEqual(
AssertionError: 1 != 0 : Expected nums of warnings in `journalctl`: 0, but got 1

…tests.

Removed tests for two clients (duplicate logic test_ip_block.py)
Replaced curl client for h2 tests. (it does not allow to change `authority` header).
…nection_rate`, `tls_connection_burst` tests.

Added tests with different connection (tls and non-tls).

Separated `tls_incomplete_connection_rate` tests.
Added tests for `concurrent_connections` with clear stats clean-up.
@RomanBelozerov
Copy link
Contributor

@nickzaev

multiple_listeners group of test has already been fixed in #275, so you just need to rebase your branch onto master, resolving conflicts

Done.

The majority of test files contain some base class and just one class directly inherited from it, on the other hand the tests are being grouped by files (not by classes) and it is very unlikely that, say, there will be another class in t_frang/test_client_body_timeout.py any soon. So what's the point having that inheritance approach all over the place?

If we actually fall for that approach of using inheritance and all, the parts of starting off backends and Tempesta should be in setUp method of some base class and not get repeated for every test as it is for now.

All tests are parameterized and general logic is moved to base class. Unnecessary inheritance removed.

About a solid third of the tests code consists of almost identical Nginx configurations which either don't differ at all or just in very minor parts, so it looks more that we test Nginx rather than Tempesta :) Why not just reuse FrangTestCase everywhere possible at least just for consistency's sake?

Constants are massively overused, indeed, what's point of having such constants as ONE?

Nginx replaced to deproxy. Duplicate config and single constants removed.

@RomanBelozerov
Copy link
Contributor

RomanBelozerov commented Nov 23, 2022

To sum up:

  • general logic is moved to FrangTestCase;
  • all tests are parametrized;
  • all tests are checked on CI;
  • all conversations are fixed;
  • client_body_timeout and client_header_timeout tests are grouped;
  • http_header_chunk_cnt and http_body_chunk_cnt tests are grouped;
  • connection_burst and connection_rate tests are grouped;
  • http_host_required h2 reworked with deproxy h2;
  • old frang tests removed;
  • added tests for ip_block directive after updating documentation;
  • added tests default value for multiple directives;
  • burst tests now use curl;
  • removed tests for multiple clients;

This PR requires changes #360

Copy link
Contributor

@const-t const-t left a comment

Choose a reason for hiding this comment

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

Looks good. Can be merged after fixing CI issues and small cleanup.

t_frang/test_host_required.py Show resolved Hide resolved
Copy link
Contributor

@pale-emperor pale-emperor left a comment

Choose a reason for hiding this comment

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

Works fine, except -R 3 args problem

…port_in_uri`, `test_host_header_no_port_in_host`. Port 80 is optional, therefore we expect 200 response for these tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants