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

chore: add additional comments to code/structs, and sanity tests to verify functions are called within the expected context #151

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

jgwest
Copy link
Member

@jgwest jgwest commented Aug 14, 2024

This PR:

  • Adds comments to important structs/fields within the code.
    • Comments describe the behaviour as it currently exists, but I'm happy to revert/modify any items that are expected to have a different future behaviour.
  • Adds some sanity tests to code to ensure that agent-only code is only run in agent-only context, and vice versa for principal.
  • We don't have E2E tests setup for this repo yet (see issue Add E2E framework and initial set of simple tests, to run as part of PRs #137), so I manually verified I've not broken anything by setting up the demo-env and ensuring the basic workflow still works.

@jgwest jgwest force-pushed the add-comments-to-repo-aug-2024 branch from 4812652 to b9f765d Compare August 14, 2024 13:20
@jgwest jgwest changed the title chore: add additional code/struct comments and sanity tests to verify function are called in the expected context chore: add additional comments to code/structs, and sanity tests to verify function are called in the expected context Aug 14, 2024
@jgwest jgwest changed the title chore: add additional comments to code/structs, and sanity tests to verify function are called in the expected context chore: add additional comments to code/structs, and sanity tests to verify functions are called within the expected context Aug 14, 2024
@jgwest jgwest force-pushed the add-comments-to-repo-aug-2024 branch from 4bfde1a to 6c1efa1 Compare August 14, 2024 19:04
@jgwest jgwest force-pushed the add-comments-to-repo-aug-2024 branch from 6c1efa1 to 492afa7 Compare August 14, 2024 19:04
@@ -238,29 +254,30 @@ func (s *Server) loadTLSConfig() (*tls.Config, error) {
return tlsConfig, nil
}

// Listener returns the listener of Server s
func (s *Server) Listener() *Listener {
// ListenerForE2EOnly returns the listener of Server s
Copy link
Member Author

@jgwest jgwest Aug 15, 2024

Choose a reason for hiding this comment

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

For all the *E2EOnly field changes here:

When I initially saw these struct fields, I noticed these fields are not exported from the struct, which implies they are for internal package use only.

BUT, then I noticed we are making the contents of these fields available by exporting these functions. For example, Queues() could be called to retrieve the internal queues reference of the principal.

Finally, I noticed that they were only being used for the E2E tests, so I have renamed these functions to allow them to still be used by E2E tests, but to make it obvious they are not for general use.

(If you were expecting these functions WOULD be available for general use, or just generally don't like the name scheme, I'm happy to revert this part of the PR)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good points there, great observations. I think at some point in time we made use of at least the Listener function, but since then move forward do something else.

I guess I'm fine with renaming those functions for now.

@@ -75,7 +76,7 @@ func (a *Agent) sender(stream eventstreamapi.EventStream_SubscribeClient) error
}
logCtx.Tracef("Grabbed an item")
if item == nil {
// FIXME: Is this really the right thing to do?
// TODO: Is this really the right thing to do?
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed FIXME to TODO. This seemed to be the only instance of FIXME in the code. Happy to revert this part of the PR if FIXME was intentional.

@@ -133,26 +134,6 @@ func (a *Agent) receiver(stream eventstreamapi.EventStream_SubscribeClient) erro
if err != nil {
logCtx.WithError(err).Errorf("Unable to process incoming event")
}
// switch ev.Type() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This code was moved into its own function which is called above, and is no longer needed.

@jgwest jgwest marked this pull request as ready for review August 15, 2024 08:51
@jgwest jgwest requested a review from jannfis August 15, 2024 08:51
Copy link
Collaborator

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@jannfis jannfis merged commit e93b66d into argoproj-labs:main Aug 15, 2024
11 checks passed
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