Skip to content

osd-10308 adding unit test coverage for GCP forwarding rule - #270

Closed
ritmun wants to merge 8 commits into
openshift:masterfrom
ritmun:origin/new-osd-10308
Closed

ritmun wants to merge 8 commits into
openshift:masterfrom
ritmun:origin/new-osd-10308

Conversation

@ritmun

@ritmun ritmun commented Sep 27, 2022 •

Copy link
Copy Markdown
Contributor

Changes:

  1. Code coverage for GCP code for ensureGCPForwardingRuleForExtIP function
  2. Added GCPComputeClient to mock GCP client's GetForwardingRuleList function
  3. Added auto generated mock for GCP in pkg/cloudclient/mocks/mock_gcp.go

To test, run make test or run individual unit test TestEnsureGCPForwardingRuleForExtIP in pkg/cloudclient/gcp/private_test.go

Optional: To end to end test forwarding rule functionality, refer to description of the enhancement PR

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2022
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2022
@codecov

codecov Bot commented Sep 27, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #270 (5683f25) into master (1f39634) will increase coverage by 0.58%.
The diff coverage is 80.95%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #270      +/-   ##
==========================================
+ Coverage   39.80%   40.39%   +0.58%     
==========================================
  Files          26       27       +1     
  Lines        2271     2295      +24     
==========================================
+ Hits          904      927      +23     
- Misses       1295     1296       +1     
  Partials       72       72              
Impacted Files Coverage Δ
pkg/cloudclient/cloudclient.go 33.33% <ø> (ø)
pkg/cloudclient/gcp/gcp.go 53.52% <0.00%> (-1.56%) ⬇️
pkg/cloudclient/gcp/private.go 10.09% <50.00%> (+2.53%) ⬆️
pkg/cloudclient/mock_cloudclient/gcp/mock_gcp.go 100.00% <100.00%> (ø)
main.go 7.84% <0.00%> (-0.33%) ⬇️

@mjlshen

mjlshen commented Sep 27, 2022 •

Copy link
Copy Markdown
Contributor

/label tide/merge-method-squash

@openshift-ci openshift-ci Bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Sep 27, 2022
@openshift-ci openshift-ci Bot added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Sep 27, 2022
Comment thread pkg/cloudclient/gcp/gcp.go Resolved
@mjlshen

mjlshen commented Sep 27, 2022

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 27, 2022
@ritmun
ritmun requested review from mjlshen and removed request for fahlmant and sam-nguyen7 September 27, 2022 21:45
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 29, 2022
@openshift-ci

openshift-ci Bot commented Sep 29, 2022

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@openshift-ci

openshift-ci Bot commented Sep 29, 2022

Copy link
Copy Markdown
Contributor

@ritmun: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes/test-infra repository. I understand the commands that are listed here.

@fahlmant

fahlmant commented Oct 4, 2022 •

Copy link
Copy Markdown
Contributor

Copying over comment from previous version of this PR #255 (comment)

This changes the ergonomics of the code and makes it fairy complicated going forward but with no functional change, except to make mocking tests simpler. We have other functions with a similar pattern that would also all need to be refactored to this pattern if we want to test them as well.

IMO, we should instead abstract out the GCP API client from the gc Client to an interface with the list of required methods. That way we can pass in a mocked or "real" implementation to the gc Client struct.

@ritmun

ritmun commented Oct 11, 2022

Copy link
Copy Markdown
Contributor Author

Copying over comment from previous version of this PR #255 (comment)

This changes the ergonomics of the code and makes it fairy complicated going forward but with no functional change, except to make mocking tests simpler. We have other functions with a similar pattern that would also all need to be refactored to this pattern if we want to test them as well.

IMO, we should instead abstract out the GCP API client from the gc Client to an interface with the list of required methods. That way we can pass in a mocked or "real" implementation to the gc Client struct.

@fahlmant I'm surprised to see the same comment again, because I scrapped the methods from #255 completely and implemented what was asked for. For reference, your suggestion was
"Using interfaces is a common pattern in go and are easier to use" and that's what is implemented here https://coreos.slack.com/archives/CMD1L32M9/p1650390158081969?thread_ts=1650387229.978099&cid=CMD1L32M9

@ritmun

ritmun commented Oct 11, 2022

Copy link
Copy Markdown
Contributor Author

For

Copying over comment from previous version of this PR #255 (comment)
This changes the ergonomics of the code and makes it fairy complicated going forward but with no functional change, except to make mocking tests simpler. We have other functions with a similar pattern that would also all need to be refactored to this pattern if we want to test them as well.
IMO, we should instead abstract out the GCP API client from the gc Client to an interface with the list of required methods. That way we can pass in a mocked or "real" implementation to the gc Client struct.

@fahlmant I'm surprised to see the same comment again, because I scrapped the methods from #255 completely and implemented what was asked for. For reference, your suggestion was "Using interfaces is a common pattern in go and are easier to use" and that's what is implemented here https://coreos.slack.com/archives/CMD1L32M9/p1650390158081969?thread_ts=1650387229.978099&cid=CMD1L32M9

This change follows the pattern both Rafael and you are alluding to in your comments, per the example Rafael suggested (his link was moved but I found the relevant path in the project) https://github.com/openshift/gcp-project-operator/blob/master/controllers/projectclaim/projectclaim_controller.go

@openshift-ci

openshift-ci Bot commented Oct 12, 2022

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mjlshen, rafael-azevedo, ritmun
Once this PR has been reviewed and has the lgtm label, please assign sam-nguyen7 for approval by writing /assign @sam-nguyen7 in a comment. For more information see:The Kubernetes Code Review Process.

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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ritmun

ritmun commented Oct 18, 2022

Copy link
Copy Markdown
Contributor Author

/hold regression testing on GCP

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 18, 2022
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2022
@openshift-merge-robot

Copy link
Copy Markdown
Contributor

@ritmun: PR needs rebase.

Details

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 kubernetes/test-infra repository.

@openshift-bot

Copy link
Copy Markdown

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 31, 2023
@openshift-bot

Copy link
Copy Markdown

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci Bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 3, 2023
dustman9000 added a commit to dustman9000/cloud-ingress-operator that referenced this pull request Mar 13, 2023
Conventions:
- openshift/golang-osd-operator: Update
---
openshift/boilerplate@8b55746...4bf1a59

commit: 479ec3635d761fb91a59a884ef6bc29be8a15470
author: Christoph Blecker
Revert yq/python version bump

commit: 999bf51ca03b8add6de2f6cb83971c5c5a95bb93
author: Christoph Blecker
Remove tag-check exemption for config/Dockerfile

commit: f77a7379f0bef64b0eab6163f91e87bdd67f8b34
author: Christoph Blecker
Bump base image to v3.0.3

commit: 56d013c17a42b259a88e987ed6798d0fdc2f2c2a
author: Christoph Blecker
Hard code default branch

commit: fc2e7a8d1eb5dda50f086e0f16059957352defba
author: Christoph Blecker
Remove prescriptive URL from config/Dockerfile

commit: 82d19adadc2857c2359a8890631c081ac2824bda
author: Christoph Blecker
Rev boilerplate image to v3.0.3

commit: 46c46423d7f2df00731fbdcf3573773becd7c9e7
author: Christoph Blecker
Don't check tag-check or config/Dockerfile when checking for a tag

commit: ecfd17b4fed6a4aea80d5bdc551de7350a4d6fd8
author: Christoph Blecker
Add skopeo to boilerplate image

commit: de1f8d8aa7af04115fa2da8751c2d6a1f4227ddb
author: Christoph Blecker
Don't fail validate on changes to build/Dockerfile*

commit: 4b929d2cb15df8fd9100797f39d67cdfa5dea0ab
author: Christoph Blecker
Always pull fresh images in our build pipeline

commit: 89eaae4e4f08b7c1c4d4c168a64a1f6e2d6424e2
author: Christoph Blecker
Write olm-registry dockerfile so that it can be updated by dependabot

commit: 31dea5e0c0d561897eec99b72041b31a95e92e19
author: Ritu Mundhe
Adding necessary "Test" prefix to e2e test runner function

commit: 33deebe8c9f86d86aa773c9546d1545d06d0397c
author: Ritu Mundhe
whitespace cleanup

commit: 09b943656d3d41ed617178935e3807c1e2922e3e
author: Ritu Mundhe
moved test files to osde2e base dir. Other minor fixes. (openshift#270)

* moved test files to osde2e base dir. Other minor fixes.

* removed ginkgo.Recover() per openshift/boilerplate#269

commit: 08d5b433772ca42a7b541e6b31a0a0050d6b1d59
author: Dustin Row
Scope GO vars per make target instead of global

commit: 6f0542f471fbf37ced9e909a2e5bb29e7c1ac47e
author: Ritu Mundhe
renamed packagename without underscore

commit: c1321df3f70091c8492dd4ce2cca4ba2ca49baaf
author: Ritu Mundhe
removing default target from osde2e convention

commit: 7ceb63b0dcc24fdb829f652b943b414c5ffdc335
author: Dustin Row
Rename osde2e convention

commit: 566848f4eb17890aac7401536167e81e7642f037
author: Ritu Mundhe
reverted dynamic var eval

commit: 483a87cd016b84879adac3997d2af5806041bc26
author: Ritu Mundhe
renamed variable conflicting with other convention dirs

commit: b181cee588fa3373172fefbb5da1e7d5c2585f54
author: Ritu Mundhe
added note about exclusive use by operators.

commit: ff36e6cb4fb3f33cf26d34d38a4283de8cbd0b25
author: Ritu Mundhe
convention renamed to focus on operators

commit: f2283ca508e2f9af2e1f1d08e86051aefdad0386
author: Ritu Mundhe
SDCICD-917 Added boilerplate for osde2e test harness (openshift#262)

* SDCICD-917 Added boilerplate for osde2e test harness

* SDCICD-917 Moved into new osde2e dedicated convention

* convention name

commit: 56a55bd887dd24422f3b535cebda0ad3f9e8ac16
author: Michael Shen
Update golangci-lint and removing deprecated checks: varcheck, structcheck, and deadcode

Signed-off-by: Michael Shen <[email protected]>

commit: f107cf95439ba3b90f3ad374f57a76e376b32c18
author: Ritu Mundhe
SDCICD-854 adding /osde2e framework to operators. Need to exclude this folder from unit tests.
@openshift-bot

Copy link
Copy Markdown

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci Bot closed this Apr 2, 2023
@openshift-ci

openshift-ci Bot commented Apr 2, 2023

Copy link
Copy Markdown
Contributor

@openshift-bot: Closed this PR.

Details

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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 kubernetes/test-infra repository.

jbpratt added a commit to jbpratt/cloud-ingress-operator that referenced this pull request Aug 15, 2023
Conventions:
- openshift/golang-osd-operator: Update
- openshift/golang-osd-operator-osde2e: Subscribe
---
openshift/boilerplate@8b55746...92d91d4

commit: e54dfc24bf74099164f165a01c756f188224bc50
author: Ritu Mundhe
dockerfile template fix

commit: 6699b052ab9e59f909b8424b538d77be19ef100e
author: Michael Shen
Allow generation of embedded ObjectMeta in CRDs

This will allow for using metav1.ObjectMeta's in nested fields. Without
this option, the generated metadata field is non-functional as described
in kubernetes-sigs/controller-tools#557.

Signed-off-by: Michael Shen <[email protected]>

Co-authored-by: Alice Hubenko <[email protected]>

commit: cac1395fbae95d2dc43aeeec649dc46c04d065c4
author: Bo Meng
update owners

commit: 4c6d460e088fc7520d58cfeb2e5f457228b6ec13
author: Ritu Mundhe
fixed hardcoded operator namein osde2e convention template

commit: 56ec373e5d204115567d6a399e8cbfcdb71669cb
author: Ryan Williams
Replace addon with operator name for osde2e boilerplate

This commit modifies the following:
  * Rename the junit output filename to include operator name
  * Update readme to remove the word "addon"

commit: a000622561d57cefe749978b6505be030f3114bb
author: Ritu Mundhe
renamed test tags from "integration" to "osde2e" for specificity

commit: bbb667c6d0ad14399c2e572acab68dd01ffa3f18
author: Dustin Row
Exclude build/Dockerfile* from initial git status check

commit: 7a16980d213b68b1a982ae3a710a5cee4b983491
author: Ritu Mundhe
fix: escaped quote in template

commit: ba40cfc5f02b30b6f9c4d1f420c14da7edd8a6c3
author: Ritu Mundhe
osde2e dockerfile contains building ginkgo binary (openshift#284)

* osde2e dockerfile contains building ginkgo binary

* Update ubi version

Co-authored-by: Michael Shen <[email protected]>

* Update go base image version

Co-authored-by: Michael Shen <[email protected]>

---------

Co-authored-by: Michael Shen <[email protected]>

commit: 023d6fc8e9714428c149c7c1343e24b53449f4bd
author: Ritu Mundhe
reverting docker registry credentials for test-harness for app-interface

commit: 50a4abf7890faa6bdbda0faa03cde25b5ba64be0
author: Ritu Mundhe
updating docker registry credentials for test-harness for ci-operator

commit: b2e3e1b90c2e5a60020cba909d2112b76021f201
author: Diego Santamaria
Swap sed command delimiter

I believe this will explode because $TEST_IMAGE contains /s. I would use some other delimiter for that sed command -- one that can't appear in a URI -- e.g.:

Co-authored-by: Eric Fried <[email protected]>

Remove project.mk

commit: 7adb0b88cea0e8527b4d32ddeb9c5425e83aa7a3
author: Diego Santamaria
Swap sed command delimiter

I believe this will explode because $TEST_IMAGE contains /s. I would use some other delimiter for that sed command -- one that can't appear in a URI -- e.g.:

Co-authored-by: Eric Fried <[email protected]>

commit: 19ae2a423b085b1ae0b650374570da1784a8daa3
author: Diego Santamaria
Add acceptance Test convention

commit: f9e6c350556d9d5845babbb46686639a01945d03
author: Diego Santamaria
Initial Commit for PD boiletPlate

commit: 479ec3635d761fb91a59a884ef6bc29be8a15470
author: Christoph Blecker
Revert yq/python version bump

commit: 999bf51ca03b8add6de2f6cb83971c5c5a95bb93
author: Christoph Blecker
Remove tag-check exemption for config/Dockerfile

commit: f77a7379f0bef64b0eab6163f91e87bdd67f8b34
author: Christoph Blecker
Bump base image to v3.0.3

commit: 56d013c17a42b259a88e987ed6798d0fdc2f2c2a
author: Christoph Blecker
Hard code default branch

commit: fc2e7a8d1eb5dda50f086e0f16059957352defba
author: Christoph Blecker
Remove prescriptive URL from config/Dockerfile

commit: 82d19adadc2857c2359a8890631c081ac2824bda
author: Christoph Blecker
Rev boilerplate image to v3.0.3

commit: 46c46423d7f2df00731fbdcf3573773becd7c9e7
author: Christoph Blecker
Don't check tag-check or config/Dockerfile when checking for a tag

commit: ecfd17b4fed6a4aea80d5bdc551de7350a4d6fd8
author: Christoph Blecker
Add skopeo to boilerplate image

commit: de1f8d8aa7af04115fa2da8751c2d6a1f4227ddb
author: Christoph Blecker
Don't fail validate on changes to build/Dockerfile*

commit: 4b929d2cb15df8fd9100797f39d67cdfa5dea0ab
author: Christoph Blecker
Always pull fresh images in our build pipeline

commit: 89eaae4e4f08b7c1c4d4c168a64a1f6e2d6424e2
author: Christoph Blecker
Write olm-registry dockerfile so that it can be updated by dependabot

commit: 31dea5e0c0d561897eec99b72041b31a95e92e19
author: Ritu Mundhe
Adding necessary "Test" prefix to e2e test runner function

commit: 33deebe8c9f86d86aa773c9546d1545d06d0397c
author: Ritu Mundhe
whitespace cleanup

commit: 09b943656d3d41ed617178935e3807c1e2922e3e
author: Ritu Mundhe
moved test files to osde2e base dir. Other minor fixes. (openshift#270)

* moved test files to osde2e base dir. Other minor fixes.

* removed ginkgo.Recover() per openshift/boilerplate#269

commit: 08d5b433772ca42a7b541e6b31a0a0050d6b1d59
author: Dustin Row
Scope GO vars per make target instead of global

commit: 6f0542f471fbf37ced9e909a2e5bb29e7c1ac47e
author: Ritu Mundhe
renamed packagename without underscore

commit: c1321df3f70091c8492dd4ce2cca4ba2ca49baaf
author: Ritu Mundhe
removing default target from osde2e convention

commit: 7ceb63b0dcc24fdb829f652b943b414c5ffdc335
author: Dustin Row
Rename osde2e convention

commit: 566848f4eb17890aac7401536167e81e7642f037
author: Ritu Mundhe
reverted dynamic var eval

commit: 483a87cd016b84879adac3997d2af5806041bc26
author: Ritu Mundhe
renamed variable conflicting with other convention dirs

commit: b181cee588fa3373172fefbb5da1e7d5c2585f54
author: Ritu Mundhe
added note about exclusive use by operators.

commit: ff36e6cb4fb3f33cf26d34d38a4283de8cbd0b25
author: Ritu Mundhe
convention renamed to focus on operators

commit: f2283ca508e2f9af2e1f1d08e86051aefdad0386
author: Ritu Mundhe
SDCICD-917 Added boilerplate for osde2e test harness (openshift#262)

* SDCICD-917 Added boilerplate for osde2e test harness

* SDCICD-917 Moved into new osde2e dedicated convention

* convention name

commit: 56a55bd887dd24422f3b535cebda0ad3f9e8ac16
author: Michael Shen
Update golangci-lint and removing deprecated checks: varcheck, structcheck, and deadcode

Signed-off-by: Michael Shen <[email protected]>

commit: f107cf95439ba3b90f3ad374f57a76e376b32c18
author: Ritu Mundhe
SDCICD-854 adding /osde2e framework to operators. Need to exclude this folder from unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants