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

refactor: use string type for server and servers #9614

Merged
merged 4 commits into from Dec 30, 2022

Conversation

zmstone
Copy link
Member

@zmstone zmstone commented Dec 26, 2022

Fixes https://emqx.atlassian.net/browse/EMQX-8600

Refactor the server and servers fields schema to use string() type for better code reuss.
Also better readability: the server() type was a list().

This PR also included an enhancement to allow setting host.name:port from environment variable.
Prior to this change, the env EMQX_BRIDGES__MQTT__AAA__SERVER='localhost:1883' is parsed as
#{<<"server">> => #{<<"localhost" => 1883}} then end up in a type check failure.
This has caused quite some confusion for users who don't know that the value has to be quoted.

After this fix, the converter for server and servers will try to format the map back to comma-separated
host.name:port list.

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Changed lines covered in coverage report
  • Change log has been added to changes/ dir
  • For internal contributor: there is a jira ticket to track this change
  • [n/a] If there should be document changes, a PR to emqx-docs.git is sent, or a jira ticket is created to follow up
  • Schema changes are backward compatible

@zmstone zmstone force-pushed the 1222-fix-parse-server-port branch 14 times, most recently from e2737b7 to 168dd71 Compare December 29, 2022 15:16
@zmstone zmstone marked this pull request as ready for review December 29, 2022 15:17
@zmstone zmstone requested a review from a team December 29, 2022 19:51
apps/emqx/src/emqx_config.erl Show resolved Hide resolved
apps/emqx/src/emqx_schema.erl Outdated Show resolved Hide resolved
apps/emqx/src/emqx_schema.erl Outdated Show resolved Hide resolved
apps/emqx/src/emqx_schema.erl Outdated Show resolved Hide resolved
apps/emqx/src/emqx_schema.erl Outdated Show resolved Hide resolved
apps/emqx/src/emqx_schema.erl Show resolved Hide resolved
apps/emqx/src/emqx_schema.erl Show resolved Hide resolved
apps/emqx/src/emqx_schema.erl Show resolved Hide resolved

-export([resolve_dns/2]).

%% @doc Mostly for meck.
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: using the unstick option doesn't work?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not a sticky module.
The issue of mocking inet_res is it has too large of a scope which may cause the tests to become flaky.

apps/emqx_statsd/src/emqx_statsd_schema.erl Outdated Show resolved Hide resolved
changes/v5.0.14-cn.md Outdated Show resolved Hide resolved
end.

%% HOCON tries to be very informative about all the detailed errors
%% it's maybe too much when reporting to the user
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be interesting to have a way to disable this compaction when more info is needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah.
don't feel like it's a high prio at the moment.

apps/emqx_connector/test/emqx_connector_mongo_tests.erl Outdated Show resolved Hide resolved
apps/emqx/test/emqx_schema_tests.erl Show resolved Hide resolved
apps/emqx/test/emqx_schema_tests.erl Show resolved Hide resolved
apps/emqx/test/emqx_schema_tests.erl Outdated Show resolved Hide resolved
apps/emqx/test/emqx_schema_tests.erl Show resolved Hide resolved
thalesmg
thalesmg previously approved these changes Dec 30, 2022
apps/emqx/test/emqx_schema_tests.erl Show resolved Hide resolved
@@ -18,151 +18,135 @@

-include_lib("eunit/include/eunit.hrl").

-define(DEFAULT_MONGO_PORT, 27017).
srv_record_test() ->
with_dns_mock(
Copy link
Contributor

Choose a reason for hiding this comment

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

There's also emqx_common_test_helpers:with_mock/4.

@zmstone zmstone merged commit 9f403e4 into emqx:master Dec 30, 2022
@zmstone zmstone deleted the 1222-fix-parse-server-port branch December 30, 2022 18:38
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.

None yet

2 participants