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 unit test of certificate package #4204

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

luolanzone
Copy link
Contributor

@luolanzone luolanzone commented Sep 6, 2022

This is for #4142

Signed-off-by: Lan Luo luola@vmware.com

@@ -177,7 +174,7 @@ func (c *CACertController) syncConversionWebhooks(caCert []byte) error {
}
if updated {
if _, err := c.apiExtensionClient.ApiextensionsV1().CustomResourceDefinitions().Update(context.TODO(), crdDef, metav1.UpdateOptions{}); err != nil {
return err
return fmt.Errorf("error updating antrea CA cert of CustomResourceDefinition %s: %v", name, err)
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 the error format the same as other sync functions.

@@ -44,8 +43,6 @@ const (
// CACertController is responsible for taking the CA certificate from the
// caContentProvider and publishing it to the ConfigMap and the APIServices.
type CACertController struct {
mutex sync.RWMutex
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unused field.

@luolanzone luolanzone mentioned this pull request Sep 6, 2022
37 tasks
@codecov
Copy link

codecov bot commented Sep 6, 2022

Codecov Report

Merging #4204 (5c48b55) into main (264aefa) will increase coverage by 2.53%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4204      +/-   ##
==========================================
+ Coverage   58.30%   60.83%   +2.53%     
==========================================
  Files         384      384              
  Lines       54376    54375       -1     
==========================================
+ Hits        31702    33081    +1379     
+ Misses      20257    18873    -1384     
- Partials     2417     2421       +4     
Flag Coverage Δ
integration-tests 34.80% <ø> (+0.06%) ⬆️
kind-e2e-tests 48.96% <0.00%> (+7.60%) ⬆️
unit-tests 42.25% <100.00%> (+0.31%) ⬆️
Impacted Files Coverage Δ
pkg/apiserver/certificate/cacert_controller.go 84.25% <100.00%> (+20.37%) ⬆️
...catesigningrequest/ipsec_csr_signing_controller.go 61.65% <0.00%> (-2.46%) ⬇️
pkg/controller/grouping/controller.go 65.13% <0.00%> (-1.98%) ⬇️
...llers/multicluster/member_clusterset_controller.go 73.24% <0.00%> (-0.44%) ⬇️
...llers/multicluster/leader_clusterset_controller.go 55.65% <0.00%> (-0.39%) ⬇️
pkg/agent/nodeportlocal/k8s/npl_controller.go 73.06% <0.00%> (+0.23%) ⬆️
pkg/ovs/ovsconfig/ovs_client.go 65.66% <0.00%> (+0.25%) ⬆️
pkg/agent/secondarynetwork/podwatch/controller.go 74.30% <0.00%> (+0.39%) ⬆️
pkg/controller/ipam/validate.go 80.32% <0.00%> (+0.54%) ⬆️
pkg/agent/agent.go 50.79% <0.00%> (+0.68%) ⬆️
... and 47 more

@luolanzone luolanzone force-pushed the add-cert-unit-tests branch 3 times, most recently from 033b832 to 17d2d9e Compare September 7, 2022 06:55
@luolanzone luolanzone requested review from jianjuns and tnqn September 8, 2022 01:46
Comment on lines 312 to 320
existingWebhook *admissionregistrationv1.MutatingWebhookConfiguration
existingOptionalWebhook *admissionregistrationv1.MutatingWebhookConfiguration
Copy link
Member

Choose a reason for hiding this comment

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

Is it simpler to just use an existingWebhook slice, which represents the objects that will be added to storage before testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, refined, thanks.

Copy link
Member

Choose a reason for hiding this comment

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

didn't see update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, misunderstood the comments, merge them into a slice. thanks.

pkg/apiserver/certificate/cacert_controller_test.go Outdated Show resolved Hide resolved
pkg/apiserver/certificate/cacert_controller_test.go Outdated Show resolved Hide resolved
pkg/apiserver/certificate/cacert_controller_test.go Outdated Show resolved Hide resolved
Signed-off-by: Lan Luo <luola@vmware.com>
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Sep 13, 2022

/skip-all

@tnqn tnqn merged commit 11b0a57 into antrea-io:main Sep 13, 2022
@luolanzone luolanzone deleted the add-cert-unit-tests branch September 14, 2022 01:32
heanlan pushed a commit to heanlan/antrea that referenced this pull request Mar 29, 2023
Signed-off-by: Lan Luo <luola@vmware.com>
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.

2 participants