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

Prepare for dynamic domains in big tests #3109

Merged
merged 3 commits into from
May 25, 2021
Merged

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented May 5, 2021

This PR makes it possible to run big tests with the dynamic domains test spec.

It includes a few separate changes, but they are all connected:

  • Introducing helpers for host types that are used in acc_e2e_SUITE.
  • Replacing get_host_type with get_domain_host_type...
  • ...which makes it safe to temporarily enable mongoose_subhosts...
  • ...which is needed to run filter_local_packet for host types...
  • ...which is needed by the tests.

The last commit is optional. The code can work without it, but after spending some time on testing different versions this one seems to be the best. I explained the motivation in the commit message.

This PR does not include tests for the bug related to the use in get_host_type in too many places. I think it can be done in a follow-up PR. Manual test shows that the bug is not present anymore.

@chrzaszcz chrzaszcz marked this pull request as draft May 5, 2021 15:40
@codecov
Copy link

codecov bot commented May 5, 2021

Codecov Report

Merging #3109 (a5ccb12) into master (8e05121) will increase coverage by 0.01%.
The diff coverage is 95.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3109      +/-   ##
==========================================
+ Coverage   79.40%   79.42%   +0.01%     
==========================================
  Files         395      395              
  Lines       32127    32147      +20     
==========================================
+ Hits        25512    25533      +21     
+ Misses       6615     6614       -1     
Impacted Files Coverage Δ
src/auth/ejabberd_auth_rdbms.erl 55.69% <0.00%> (ø)
src/ejabberd_c2s.erl 89.20% <ø> (-0.23%) ⬇️
src/ejabberd_router.erl 73.78% <ø> (ø)
...rc/mongoose_client_api/mongoose_client_api_sse.erl 57.89% <ø> (ø)
src/ejabberd_sm.erl 84.17% <85.71%> (+0.21%) ⬆️
src/mod_commands.erl 93.83% <92.85%> (-0.61%) ⬇️
src/admin_extra/service_admin_extra_gdpr.erl 94.82% <100.00%> (ø)
src/admin_extra/service_admin_extra_roster.erl 87.24% <100.00%> (+0.08%) ⬆️
src/auth/ejabberd_auth.erl 83.87% <100.00%> (ø)
src/domain/mongoose_domain_api.erl 100.00% <100.00%> (ø)
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e05121...a5ccb12. Read the comment docs.

@chrzaszcz chrzaszcz force-pushed the multi-tenancy-tests branch 8 times, most recently from 4b05240 to e7b1d55 Compare May 24, 2021 09:45
The implementation of 'get_host_type' changed, but the calls did not,
  which led to accepting subdomains where they should not be accepted.

Also:
  - Call 'filter_local_packet' for host type
  - To work correctly for subdomains,
      'mongoose_subhosts' needs to be used temporarily.
- Configure the host type in the test spec
- Remove domain_isolation_SUITE (for now)
  - It was passing before because both the test and the code
      were not using dynamic domains, it started failing
      after the previous commit, which fixed the code.
  - The module itself has a bug (reported)
  - It uses MUC Light which lacks dynamic domain support (for now)
  - It needs to use host types
Motivation:
  - Avoiding unnecessary ETS lookups.
  - Limiting 'mongoose_acc:new' logic to handling the data structure
  - It is not clear whether the default mapping should use
      'get_host_type' or 'get_domain_host_type'.
  - Sometimes it is much better for the module to verify the result,
      e.g. make sure the host type exists.
  - The host type was sometimes not needed, but it was obtained
      implicitly. Most often when it is actually needed,
      it is already known to the caller so it can be set explicitly,
      sparing the extra ETS lookup.
    IMO this good practice is further encouraged by not having a default.
@chrzaszcz chrzaszcz changed the title Use host types in test suites Prepare for dynamic domains in big tests May 24, 2021
@chrzaszcz chrzaszcz marked this pull request as ready for review May 24, 2021 10:54
@@ -9,7 +9,7 @@
%% http://www.erlang.org/doc/apps/common_test/run_test_chapter.html#test_specifications
{include, "tests"}.

{suites, "tests", domain_isolation_SUITE}.
{suites, "tests", acc_e2e_SUITE}.
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we remove domain_isolation_SUITE?

Copy link
Member Author

@chrzaszcz chrzaszcz May 25, 2021

Choose a reason for hiding this comment

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

This suite was passing only because filter_local_packet was executed per domain. The mod_domain_isolation module does not support dynamic domains yet. The tests suite itself also does not use host types correctly and it needs to be addressed. I think it should be done in a separate story.

Copy link
Collaborator

@DenysGonchar DenysGonchar left a comment

Choose a reason for hiding this comment

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

looks fine

@DenysGonchar DenysGonchar merged commit 3d1b4ad into master May 25, 2021
@DenysGonchar DenysGonchar deleted the multi-tenancy-tests branch May 25, 2021 07:26
@Premwoik Premwoik added this to the 5.0.0 milestone Oct 5, 2021
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.

3 participants