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

Improve antctl mc subcommand's unit test #4183

Merged
merged 1 commit into from
Sep 14, 2022

Conversation

luolanzone
Copy link
Contributor

@luolanzone luolanzone commented Aug 31, 2022

  1. Add a few unit tests for antctl mc codes.
  2. Refine some codes.

For #4142

func SetupKubeconfig(kubeconfig *rest.Config) {
// TODO: generate kubeconfig in Antrea agent for antctl in-Pod access.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move this line to avoid to show this as method description.

@@ -112,7 +112,7 @@ func (o *ClusterSetJoinConfig) validateAndComplete() error {
return fmt.Errorf("the ClusterSet ID is required")
}
if o.ClusterID == "" {
return fmt.Errorf("the member ClusterID is required")
return fmt.Errorf("the ClusterID of member cluster is required")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keep member's output consistent with leader's output

@luolanzone luolanzone added the area/multi-cluster Issues or PRs related to multi cluster. label Aug 31, 2022
@codecov
Copy link

codecov bot commented Aug 31, 2022

Codecov Report

Merging #4183 (668069b) into main (53bb0c3) will increase coverage by 4.39%.
The diff coverage is 68.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4183      +/-   ##
==========================================
+ Coverage   58.35%   62.74%   +4.39%     
==========================================
  Files         374      396      +22     
  Lines       53893    54457     +564     
==========================================
+ Hits        31447    34167    +2720     
+ Misses      20069    17780    -2289     
- Partials     2377     2510     +133     
Flag Coverage Δ
e2e-tests 55.95% <ø> (?)
integration-tests 34.68% <ø> (-0.16%) ⬇️
kind-e2e-tests 48.83% <ø> (+0.07%) ⬆️
unit-tests 43.77% <68.22%> (+1.78%) ⬆️
Impacted Files Coverage Δ
...g/antctl/raw/multicluster/deploy/leader_cluster.go 52.77% <ø> (+1.42%) ⬆️
...g/antctl/raw/multicluster/deploy/member_cluster.go 52.77% <ø> (+1.42%) ⬆️
...kg/antctl/raw/multicluster/deploy/deploy_helper.go 51.69% <37.03%> (+51.69%) ⬆️
pkg/antctl/raw/multicluster/create/access_token.go 79.62% <53.84%> (+48.86%) ⬆️
pkg/antctl/raw/multicluster/init.go 66.66% <61.11%> (+48.74%) ⬆️
pkg/antctl/raw/multicluster/common/common.go 75.69% <63.63%> (+75.69%) ⬆️
pkg/antctl/raw/multicluster/common/cleanup.go 80.00% <70.58%> (+80.00%) ⬆️
pkg/antctl/raw/multicluster/get/resourceimport.go 87.95% <80.95%> (+66.11%) ⬆️
pkg/antctl/raw/multicluster/get/resourceexport.go 89.01% <86.66%> (+66.28%) ⬆️
pkg/antctl/raw/multicluster/join.go 74.85% <88.88%> (+60.23%) ⬆️
... and 110 more

docs/multicluster/quick-start.md Outdated Show resolved Hide resolved
}
defer file.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it cause any issue without your fix?

Copy link
Contributor Author

@luolanzone luolanzone Sep 1, 2022

Choose a reason for hiding this comment

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

I didn't actually execute it to get an error. But according to the codes, the file will be nil when the output format parameter is empty, and it will return invalid argument if file.Close() is called.

pkg/antctl/raw/multicluster/deploy/deploy_helper.go Outdated Show resolved Hide resolved
pkg/antctl/raw/multicluster/deploy/deploy_helper.go Outdated Show resolved Hide resolved
pkg/antctl/raw/multicluster/get/resourceimport.go Outdated Show resolved Hide resolved
pkg/antctl/raw/multicluster/join.go Outdated Show resolved Hide resolved
@luolanzone luolanzone force-pushed the improve-antctl-mc-test branch 3 times, most recently from a19e688 to 9368391 Compare September 5, 2022 00:59
@luolanzone luolanzone mentioned this pull request Sep 5, 2022
37 tasks
@luolanzone luolanzone force-pushed the improve-antctl-mc-test branch 3 times, most recently from e990e86 to 51ab877 Compare September 6, 2022 07:38
Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

LGTM. A suggestion for documentation.

@@ -47,8 +47,9 @@ mode, and all member clusters in a ClusterSet must use the same tunnel type.
## Steps with antctl

`antctl` provides a couple of commands to facilitate deployment, configuration,
and troubleshooting of Antrea Multi-cluster. This section describes the steps
to deploy Antrea Multi-cluster and set up the example ClusterSet using `antctl`.
and troubleshooting of Antrea Multi-cluster. Please refer to the [`antctl` installation guide](../antctl.md#installation)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel better to move "Refer to antctl installation guide..." to the beginning of the next paragraph.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@luolanzone luolanzone force-pushed the improve-antctl-mc-test branch from 51ab877 to 5807bbc Compare September 7, 2022 01:21
cluster's API server, and it needs a kubeconfig file for that. Please refer to
the [`antctl` Multi-cluster manual](antctl.md) to learn more about the
kubeconfig file configuration, and the `antctl` Multi-cluster commands.
Please refer to the [`antctl` installation guide](../antctl.md#installation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading through the sentences, it probably works better to move this one to the end of the paragraph:

Please refer to the antctl Multi-cluster manual to learn
more about the kubeconfig file configuration, and the antctl Multi-cluster commands. For installation of antctl, please refer to the installation guide.

What you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, that looks more readable. I will move it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thanks.

@luolanzone luolanzone force-pushed the improve-antctl-mc-test branch from 5807bbc to 8bc6b96 Compare September 7, 2022 01:37
jianjuns
jianjuns previously approved these changes Sep 7, 2022
@luolanzone luolanzone force-pushed the improve-antctl-mc-test branch 2 times, most recently from 2aa1eb0 to 0dcb935 Compare September 9, 2022 02:46
jianjuns
jianjuns previously approved these changes Sep 9, 2022
@jianjuns
Copy link
Contributor

jianjuns commented Sep 9, 2022

/test-multicluster-e2e
/skip-all

1. Add unit tests for antctl mc codes.
2. Refine some codes.

Signed-off-by: Lan Luo <[email protected]>
@luolanzone luolanzone force-pushed the improve-antctl-mc-test branch from c237ba1 to 668069b Compare September 14, 2022 02:19
@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e
/skip-all

@jianjuns Could you take a look again? I have verified new antctl with this PR, it works fine. Thanks.

@jianjuns
Copy link
Contributor

/skip-all

@jianjuns jianjuns merged commit c5a5209 into antrea-io:main Sep 14, 2022
heanlan pushed a commit to heanlan/antrea that referenced this pull request Mar 29, 2023
1. Add unit tests for antctl mc codes.
2. Refine some codes.

Signed-off-by: Lan Luo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/multi-cluster Issues or PRs related to multi cluster.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants