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

feat: Initial E2E framework and simple tests #211

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jopit
Copy link
Contributor

@jopit jopit commented Oct 30, 2024

Initial E2E framework and simple tests

Resolves issue #137

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

Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

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

Looks great, very nice, thanks @jopit! I added some minor comments I noticed while reading through the code, let me know what you think.

I had a couple of questions but they are more general project questions for everyone, so I will loop in Jann et al.

One other question from me:

Any changes in 'argocd-agent/test/e2e2' that you would suggest we may want to port back to 'argocd-agent/hack/demo-env'?

  • For example, extra timeout logic in 'setup-vcluster-env.sh' looked useful for both
  • Removal of .data from Secrets defined in argocd-secret.yaml

setup-e2e2:
test/e2e2/test-env/setup-vcluster-env.sh create

.PHONY: start-argocd-agent
Copy link
Member

Choose a reason for hiding this comment

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

Re: the Makefile target of start-argocd-agent. Rather than start-argocd-agent, which might imply this would start Argo agent for development purposes (similar to make start from Argo CD), WDYT about:

  • start-argocd-agent-for-e2e (maybe too long?)
  • start-e2e / start-e2e2 (shorter, this is what we use in argo cd, and in rollouts operator)
  • Other options?

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. Changed it to start-e2e2

"k8s.io/client-go/restmapper"
)

type KubeObject interface {
Copy link
Member

Choose a reason for hiding this comment

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

Could add a comment here for KubeObject and KubeObjectList indicating these are similar to Object and ObjectList from controller-runtime, or even more generally that this package aims to provide a similar style interface to controller-runtime (which we are avoiding adding a dependency on here).

IMHO this might be useful comment to add (and presuming my assumption is true), but it's up to you!

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.

err := suite.ManagedAgentClient.Get(suite.Ctx, key, &app, metav1.GetOptions{})
return err == nil
}, 30*time.Second, 1*time.Second)

Copy link
Member

Choose a reason for hiding this comment

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

Can we check that the content (.spec field) is the same between the managed-agent and principal, as well? It's very likely, but it can't hurt to check.

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.

return err == nil
}, 30*time.Second, 1*time.Second)

// Delete the app from the principal
Copy link
Member

Choose a reason for hiding this comment

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

Let me know if you think this is scope creep from the original requirements, but before we delete the Application in the next step, can we test the update case, as well?

E.g. just making a small change to one of the fields of the Application on principal, and making sure it percolates down to managed-agent.

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.

// Delete the app from the autonomous-agent
err = suite.AutonomousAgentClient.Delete(suite.Ctx, &app, metav1.DeleteOptions{})
requires.NoError(err)

Copy link
Member

Choose a reason for hiding this comment

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

Same as above, can be useful to check .spec is in sync, and to test the update case before deleting.

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.

err := suite.ManagedAgentClient.Get(suite.Ctx, key, &app, metav1.GetOptions{})
return err == nil
}, 30*time.Second, 1*time.Second)

Copy link
Member

Choose a reason for hiding this comment

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

As mentioned elsewhere, can be useful to verify that the .Spec fields are the same in both places.

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.

err := suite.PrincipalClient.Get(suite.Ctx, principalKey, &app, metav1.GetOptions{})
return err == nil
}, 30*time.Second, 1*time.Second)

Copy link
Member

Choose a reason for hiding this comment

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

As above, couldn't hurt to verify .specs are the same.

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.

exit 1
fi
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
test -f cmd/agent/main.go || (echo "Script should be run from argocd-agent's root path" >&2; exit 1)
Copy link
Member

Choose a reason for hiding this comment

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

Rather than testing that the script is run from the correct place, would it be preferable to just add cd $SCRIPTPATH/../../.. before go run to ensure that this is always true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved this by making the same changes that Jann made to the demo-env scripts to allow running from anywhere in the repo tree, PR #193

exit 1
fi
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
test -f cmd/agent/main.go || (echo "Script should be run from argocd-agent's root path" >&2; exit 1)
Copy link
Member

Choose a reason for hiding this comment

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

Same as automonous above, can use SCRIPTPATH if it makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved this by making the same changes that Jann made to the demo-env scripts to allow running from anywhere in the repo tree, PR #193

exit 1
fi
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
test -f cmd/principal/main.go || (echo "Script should be run from argocd-agent's root path" >&2; exit 1)
Copy link
Member

Choose a reason for hiding this comment

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

Same as autonomous above, can use SCRIPTPATH if it makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved this by making the same changes that Jann made to the demo-env scripts to allow running from anywhere in the repo tree, PR #193

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.83%. Comparing base (237faa7) to head (5bd3dca).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #211      +/-   ##
==========================================
- Coverage   46.89%   46.83%   -0.06%     
==========================================
  Files          57       57              
  Lines        4956     4951       -5     
==========================================
- Hits         2324     2319       -5     
  Misses       2451     2451              
  Partials      181      181              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jopit jopit force-pushed the gitops-5159-e2e-test-framework branch from f4f1592 to f70c232 Compare November 5, 2024 18:49
@jopit jopit force-pushed the gitops-5159-e2e-test-framework branch 2 times, most recently from b08036b to 7c34544 Compare November 7, 2024 19:44
@jopit jopit force-pushed the gitops-5159-e2e-test-framework branch from 7c34544 to 5bd3dca Compare November 7, 2024 19:50
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.

4 participants