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

backend: extract protocol processing from Authenticator and add a test suite #22

Merged
merged 4 commits into from
Aug 3, 2022
Merged

Conversation

djshow832
Copy link
Collaborator

@djshow832 djshow832 commented Aug 1, 2022

What problem does this PR solve?

Issue Number: close #29

Problem Summary:

We need to mock a client and server to test authentication and command processing. To reuse the code of parsing and writing the MySQL protocol, we also need to extract the MySQL protocol-related code to PacketIO.

What is changed and how it works:

  • Extract MySQL protocol related code from Authenticator to PacketIO.
  • Define a testSuite, which creates a SQL client and a SQL server that connect to the proxy with TCP connection
    • Both the mocked client and server act like a real client and server: they parse data and respond to the proxy.
    • We can test various client capabilities, auth-plugins, and TLS configs using the mocked client and server. We create M^N combinations of the possibilities to test.
    • We test the correctness by checking whether the data received by the client is equal to the data sent from the server and vice versa.
  • Test Authenticator using testSuite. testSuite will be also used for testing CmdProcessing.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change (Don't forget to add the declarative for API)
  • Has weirctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@djshow832 djshow832 requested a review from xhebox August 1, 2022 07:25
@xhebox xhebox mentioned this pull request Aug 1, 2022
8 tasks
pkg/proxy/backend/test_suite.go Outdated Show resolved Hide resolved
pkg/proxy/backend/authenticator_test.go Outdated Show resolved Hide resolved
pkg/proxy/backend/authenticator_test.go Outdated Show resolved Hide resolved
pkg/proxy/net/mysql.go Outdated Show resolved Hide resolved
pkg/proxy/net/mysql.go Outdated Show resolved Hide resolved
pkg/proxy/net/mysql.go Show resolved Hide resolved
pkg/proxy/backend/test_suite.go Outdated Show resolved Hide resolved
pkg/proxy/backend/test_suite.go Outdated Show resolved Hide resolved
pkg/proxy/backend/test_suite.go Outdated Show resolved Hide resolved
pkg/proxy/backend/authenticator_test.go Outdated Show resolved Hide resolved
@xhebox xhebox merged commit 080c85f into pingcap:main Aug 3, 2022
@djshow832 djshow832 deleted the mock_io branch August 3, 2022 02:49
@xhebox xhebox mentioned this pull request Aug 3, 2022
2 tasks
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.

Add tests for Authenticator
2 participants