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

Add unit tests for xds package #8419

Merged
merged 4 commits into from
Jun 26, 2023
Merged

Add unit tests for xds package #8419

merged 4 commits into from
Jun 26, 2023

Conversation

davidjumani
Copy link
Contributor

@davidjumani davidjumani commented Jun 26, 2023

Description

Adds additional tests to the xds package

Context

https://github.com/solo-io/solo-projects/issues/5113

Checklist:

  • I included a concise, user-facing changelog (for details, see https://github.com/solo-io/go-utils/tree/main/changelogutils) which references the issue that is resolved.
  • If I updated APIs (our protos) or helm values, I ran make -B install-go-tools generated-code to ensure there will be no code diff
  • I followed guidelines laid out in the Gloo Edge contribution guide
  • I opened a draft PR or added the work in progress label if my PR is not ready for review
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

BOT NOTES:
resolves https://github.com/solo-io/solo-projects/issues/5113

@github-actions github-actions bot added the keep pr updated signals bulldozer to keep pr up to date with base branch label Jun 26, 2023
@solo-changelog-bot
Copy link

Issues linked to changelog:
https://github.com/solo-io/solo-projects/issues/5113

@davidjumani davidjumani marked this pull request as ready for review June 26, 2023 15:25
Copy link
Contributor

@elcasteel elcasteel left a comment

Choose a reason for hiding this comment

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

The new tests look good to me. I don't have enough context to know whether there are additional tests that we should add.

sam-heilbron
sam-heilbron previously approved these changes Jun 26, 2023
Copy link
Contributor

@sam-heilbron sam-heilbron left a comment

Choose a reason for hiding this comment

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

LGTM

elcasteel
elcasteel previously approved these changes Jun 26, 2023
Copy link
Contributor

@elcasteel elcasteel left a comment

Choose a reason for hiding this comment

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

for future reference github/bulldozer will automatically squash changes and it's more readable to leave the commit history intact until then

sam-heilbron
sam-heilbron previously approved these changes Jun 26, 2023
nodeRoleHasher := xds.NewNodeRoleHasher()
node := &envoy_config_core_v3.Node{}
// Ensure it returns the fallback key if the role field in the node metadata is not present
Expect(nodeRoleHasher.ID(node)).To(Equal(xds.FallbackNodeCacheKey))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I've tried to lean away from comments above assertions, and instead use the "optional desscription" (https://onsi.github.io/gomega/#annotating-assertions) field of an assertion to perform that documentation. That way if the assertion fails, it shows that relevant details.

Not a blocker, just wanted to share this pattern

@davidjumani davidjumani dismissed stale reviews from sam-heilbron and elcasteel via 59c2010 June 26, 2023 16:13
elcasteel
elcasteel previously approved these changes Jun 26, 2023
sam-heilbron
sam-heilbron previously approved these changes Jun 26, 2023
nodeRoleHasher := xds.NewNodeRoleHasher()
node := &envoy_config_core_v3.Node{}
Expect(nodeRoleHasher.ID(node)).To(Equal(xds.FallbackNodeCacheKey),
fmt.Sprintf("Should return %s if the role field in the node metadata is not present", xds.FallbackNodeCacheKey))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: https://onsi.github.io/gomega/#annotating-assertions you don't need to call fmt.Sprintf, that will be handled by Gomega directly. You can just pass the format and the parameters (example in the docs that I linked)

@davidjumani davidjumani dismissed stale reviews from sam-heilbron and elcasteel via 8c248d5 June 26, 2023 16:20
@github-actions
Copy link

Visit the preview URL for this PR (updated for commit 8c248d5):

https://gloo-edge--pr8419-add-xds-tests-2bxskvli.web.app

(expires Mon, 03 Jul 2023 16:42:00 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 77c2b86e287749579b7ff9cadb81e099042ef677

@soloio-bulldozer soloio-bulldozer bot merged commit 9ec6aa0 into main Jun 26, 2023
12 checks passed
@soloio-bulldozer soloio-bulldozer bot deleted the add-xds-tests branch June 26, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep pr updated signals bulldozer to keep pr up to date with base branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants