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

playground: Code refine for args #2178

Merged
merged 1 commit into from
Apr 14, 2023
Merged

playground: Code refine for args #2178

merged 1 commit into from
Apr 14, 2023

Conversation

breezewish
Copy link
Member

@breezewish breezewish commented Apr 14, 2023

What problem does this PR solve?

There are many duplicate codes when introducing new args in TiUP Playground.

What is changed and how it works?

Keep code dry.

This PR is more like a re-implementation of #1365 in another way.

Check List

Tests

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

A simple test about how options looks like now after populateDefaultOpt:

❯ bin/tiup-playground nightly --mode tikv-slim
{"Mode":"tikv-slim","Version":"nightly","PD":{"Num":1},"TiDB":{"UpTimeout":60},"TiKV":{"Num":1},"TiFlash":{"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1","Monitor":true}

❯ bin/tiup-playground nightly --mode tidb
{"Mode":"tidb","Version":"nightly","PD":{"Num":1},"TiDB":{"Num":1,"UpTimeout":60},"TiKV":{"Num":1},"TiFlash":{"Num":1,"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1","Monitor":true}

❯ bin/tiup-playground nightly
{"Mode":"tidb","Version":"nightly","PD":{"Num":1},"TiDB":{"Num":1,"UpTimeout":60},"TiKV":{"Num":1},"TiFlash":{"Num":1,"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1","Monitor":true}

❯ bin/tiup-playground nightly --kv 4
{"Mode":"tidb","Version":"nightly","PD":{"Num":1},"TiDB":{"Num":1,"UpTimeout":60},"TiKV":{"Num":4},"TiFlash":{"Num":1,"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1","Monitor":true}

❯ bin/tiup-playground nightly --kv 4 --db 2
{"Mode":"tidb","Version":"nightly","PD":{"Num":1},"TiDB":{"Num":2,"UpTimeout":60},"TiKV":{"Num":4},"TiFlash":{"Num":1,"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1","Monitor":true}

❯ bin/tiup-playground nightly --without-monitor
{"Mode":"tidb","Version":"nightly","PD":{"Num":1},"TiDB":{"Num":1,"UpTimeout":60},"TiKV":{"Num":1},"TiFlash":{"Num":1,"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1"}

❯ bin/tiup-playground nightly --without-monitor --mode tikv-slim
{"Mode":"tikv-slim","Version":"nightly","PD":{"Num":1},"TiDB":{"UpTimeout":60},"TiKV":{"Num":1},"TiFlash":{"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1"}

❯ bin/tiup-playground nightly --monitor=false
Flag --monitor has been deprecated, Please use --without-monitor to control whether to disable monitor.
{"Mode":"tidb","Version":"nightly","PD":{"Num":1},"TiDB":{"Num":1,"UpTimeout":60},"TiKV":{"Num":1},"TiFlash":{"Num":1,"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1"}

❯ bin/tiup-playground nightly --monitor=true
Flag --monitor has been deprecated, Please use --without-monitor to control whether to disable monitor.
{"Mode":"tidb","Version":"nightly","PD":{"Num":1},"TiDB":{"Num":1,"UpTimeout":60},"TiKV":{"Num":1},"TiFlash":{"Num":1,"UpTimeout":120},"TiCDC":{},"TiKVCDC":{},"Pump":{},"Drainer":{},"Host":"127.0.0.1","Monitor":true}
  • No code

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release notes:

NONE

Signed-off-by: Wish <breezewish@outlook.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 14, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • kaaaaaaang

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 14, 2023

Codecov Report

Patch coverage: 86.36% and project coverage change: +0.18 🎉

Comparison is base (f4dae70) 56.06% compared to head (89a9e72) 56.24%.

❗ Current head 89a9e72 differs from pull request most recent head e760aec. Consider uploading reports for the commit e760aec to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2178      +/-   ##
==========================================
+ Coverage   56.06%   56.24%   +0.18%     
==========================================
  Files         317      317              
  Lines       33578    33454     -124     
==========================================
- Hits        18824    18814      -10     
+ Misses      12504    12396     -108     
+ Partials     2250     2244       -6     
Flag Coverage Δ
playground 15.45% <86.36%> (+0.07%) ⬆️
tiup 16.01% <ø> (ø)
unittest 22.77% <0.00%> (+0.10%) ⬆️

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

Impacted Files Coverage Δ
components/playground/playground.go 50.72% <0.00%> (+0.22%) ⬆️
components/playground/main.go 60.26% <87.69%> (+11.62%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 14, 2023
@breezewish
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@breezewish: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@kaaaaaaang
Copy link
Collaborator

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: e760aec

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 14, 2023
@ti-chi-bot ti-chi-bot merged commit 273e221 into master Apr 14, 2023
@ti-chi-bot ti-chi-bot deleted the wenxuan/arg-refine branch April 14, 2023 09:24
@kaaaaaaang kaaaaaaang added this to the 1.12.2 milestone May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants