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

Switch to host names in integration tests #950

Merged
merged 5 commits into from
Dec 8, 2020

Conversation

fln
Copy link
Contributor

@fln fln commented Nov 30, 2020

What problem does this PR solve?

This PR updates refactors integration tests to use host names instead of IP addresses. It resolves #337.

What is changed and how it works?

All IP literals in the integration tests are replaced with host names n1 to n5.

This allows us to make integration test topology files immutable and remove extra topology file templating step.

Extra topology file full_scale_in_tidb_2nd.yaml is introduced for second tidb scaling operation to avoid topology file mutation during the test.

Using host names in the integration tests will help us to maintain compatibility with services declared using host names. There should be no extra maintenance to support using IP addresses.

Check List

Tests

Integration tests now tests functionality added in #948 and #949.

Side effects

Using host names will most likely break some services which are not yet tested with integration tests. But hopefully this will help ups to expand host name support where needed.

Related changes

Includes code from #948 and #949.

Release notes:

NONE

@codecov-io
Copy link

codecov-io commented Nov 30, 2020

Codecov Report

Merging #950 (328c0d9) into master (efce389) will decrease coverage by 0.10%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #950      +/-   ##
==========================================
- Coverage   55.85%   55.75%   -0.11%     
==========================================
  Files         263      263              
  Lines       19541    19541              
==========================================
- Hits        10915    10895      -20     
- Misses       6900     6911      +11     
- Partials     1726     1735       +9     
Flag Coverage Δ
cluster 43.25% <ø> (-0.13%) ⬇️
dm 24.31% <ø> (-0.07%) ⬇️
integrate 49.94% <ø> (-0.12%) ⬇️
playground 20.26% <ø> (ø)
tiup 16.79% <ø> (ø)
unittest 23.07% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/utils/http_client.go 66.66% <0.00%> (-5.56%) ⬇️
pkg/cluster/api/pdapi.go 57.27% <0.00%> (-4.34%) ⬇️
pkg/cluster/task/tls.go 61.53% <0.00%> (-3.85%) ⬇️
pkg/cluster/api/dmapi.go 58.26% <0.00%> (-1.74%) ⬇️

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 efce389...328c0d9. Read the comment docs.

@fln fln changed the title Host names in integration tests Switch to host names in integration tests Nov 30, 2020
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-rebase labels Nov 30, 2020
@fln fln force-pushed the host_names_in_integration_tests branch from 3a55657 to c422d54 Compare November 30, 2020 12:21
@fln
Copy link
Contributor Author

fln commented Nov 30, 2020

@9547 PRs are split. Just noticed that I have overlooked the request to have mixed IP and host name tests.

Mixing host names and IP addresses in tests is not that trivial.

If we mix host names and IP address in a single topology - tiup-cluster will treat them as different hosts and complain about ports being already in use by external services.

Leaving some tests with host names while other test with IP addresses also causes issue because full.yaml is shared between scale and cmd tests.

Is there any chance full test suite switch to host names would be accepted smile ?

Alternatively would a simple test of just building a minimal cluster and tearing it down using only IP addresses suffice? My opinion is that if we have code that works with host names it should with high confidence work with IP addresses as well without explicit testing.

fln added 3 commits November 30, 2020 23:22
This commit updates TLS certificate generator to detect if IP address or
host name was used as host value. If host name is detected field `DNSNames`
of x509 SAN extenstion is used instead of `IPAddresses`.

* https://en.wikipedia.org/wiki/Subject_Alternative_Name
* https://tools.ietf.org/html/rfc5280#section-4.2.1.6

This contributes towards fixing pingcap#337.
This commit updates run_pd.sh template to use `listen_host` for
--peer-urls flag instead of `host`.

This allows us to use server hostname instead of IP addresse. Without
this change if PD service is declared using hostname it fails to start,
reporting an error that it can not bind to given interface.

Metadata variable `listen_host` was introduced in pingcap#495 and is already used for
the --client-urls flag.

This should resolve pingcap#337 and partially implement pingcap#691.
This PR updates refactors integration tests to use host names instead of
IP addresses. It resolves pingcap#337.

All IP literals in the integration tests are replaced with host names
`n1` to `n5`.

This allows us to make integration test topology files immutable and
remove extra topology file templating step.

Extra topology file `full_scale_in_tidb_2nd.yaml` is introduced for
second tidb scaling operation to avoid topology file mutation during the
test.

Using host names in the integration tests will help us to maintain
compatibility with services declared using host names. There should be
no extra maintenance to support using IP addresses.
@fln fln force-pushed the host_names_in_integration_tests branch from c422d54 to aa451b7 Compare November 30, 2020 21:22
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 5, 2020
@9547
Copy link
Contributor

9547 commented Dec 5, 2020

If we mix host names and IP address in a single topology - tiup-cluster will treat them as different hosts and complain about ports being already in use by external services.

indeed, they are different nodes, only the same if the dns record of the host equals the ip.

Leaving some tests with host names while other test with IP addresses also causes issue because full.yaml is shared between scale and cmd tests.

Are you run those tests locally? eq:

docker exec -it tiup-control-panel
bash /tiup-cluster/tests/tiup-cluster/run.sh

If so, the cmd and scale tests are running in serial, and the base env was not destroyed between tests :), but in Github Action, the environment is recreated before each test case is running. So don't worry about the shared problem.

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 8, 2020
@lucklove
Copy link
Member

lucklove commented Dec 8, 2020

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 8, 2020
@lucklove
Copy link
Member

lucklove commented Dec 8, 2020

/merge

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 8, 2020
@ti-chi-bot
Copy link
Member

Can merge label has been added.

Git tree hash: 328c0d9

@ti-chi-bot ti-chi-bot merged commit 4ac0eaa into pingcap:master Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time-contributor size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

failed to start pd with the host name in topo.yaml
6 participants