-
Notifications
You must be signed in to change notification settings - Fork 13
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
jopit
wants to merge
4
commits into
argoproj-labs:main
Choose a base branch
from
jopit:gitops-5159-e2e-test-framework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,496
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Running the end-to-end tests locally | ||
|
||
## Setup | ||
|
||
The e2e test scripts require [vcluster](https://github.com/loft-sh/vcluster) to be installed on your system. They also require an administrative connection to a host cluster. | ||
|
||
**Warning** Don't run these scripts against a cluster that you care about, there is no guarantee they won't break the cluster in some way. | ||
|
||
The scripts use `vcluster` to create three virtual clusters on the host cluster: | ||
|
||
* vcluster-control-plane - For hosting the control plane and principal | ||
* vcluster-agent-managed - A cluster with agent in managed mode | ||
* vcluster-agent-autonomous - A cluster with agent in autonomous mode | ||
|
||
The scripts will install Argo CD to each of those vclusters, in varying degrees of completeness. | ||
|
||
Both the vcluster and Argo CD installations require that LoadBalancer functionality is available on the host cluster. | ||
|
||
## Running the tests | ||
|
||
To setup the test environment on the cluster, execute the following command from the repository root: | ||
|
||
```shell | ||
make setup-e2e2 | ||
``` | ||
|
||
To run the principal and agents, execute the following command from the repository root: | ||
|
||
```shell | ||
make start-e2e2 | ||
``` | ||
|
||
To run the tests, execute the following command from the repository root in a separate terminal instance: | ||
|
||
```shell | ||
make test-e2e2 | ||
``` | ||
|
||
# Writing new end-to-end tests | ||
|
||
There is some helper code in the `fixture` subdirectory. The tests use the [stretchr/testify](https://github.com/stretchr/testify) test framework. New tests should be created as part of a test suite, either an existing one or, preferably, as part of a new one. | ||
|
||
A new test suite should embed the `fixture.BaseSuite` struct, which will provide some automatic setup and teardown functionality for the suite. | ||
|
||
```go | ||
type MyTestSuite struct { | ||
fixture.BaseSuite | ||
} | ||
``` | ||
|
||
This will configure your suite with a `context.Context` as well as three `kubernetes clients`, one for the principal vcluster, one for the managed-agent vcluster, and one for the autonomous-agent vcluster. This is implemented in the `SetupSuite()` method which has been defined on the BaseSuite. If your suite does not need it's own `SetupSuite()` method, the one from BaseSuite will be used automatically. If you do need to specify a `SetupSuite()` method for your own suite, be sure to call the BaseSuite's method as the first thing. | ||
|
||
```go | ||
func (suite *MyTestSuite) SetupSuite() { | ||
suite.BaseSuite.SetupSuite() | ||
... | ||
} | ||
``` | ||
|
||
The BaseSuite also defines the `SetupTest()` and `TearDownTest()` methods to perform cleanup. If your suite does not need it's own version of these methods, the ones from BaseSuite will be used automatically. If you do need to specify one of these methods for your own suite, be sure to call the BaseSuite's method as the first thing. | ||
|
||
```go | ||
func (suite *MyTestSuite) TearDownTest() { | ||
suite.BaseSuite.TearDownTest() | ||
... | ||
} | ||
``` | ||
|
||
The kubernetes client is a wrapper around `client-go/dynamic`. It is able to access the ArgoCD types as well as the types from `k8s.io/api/core/v1`, `k8s.io/api/apps/v1`, and `k8s.io/api/rbac/v1`. If you need support for additional types, you can add then to the scheme used in the `NewKubeClient` function in `fixture/kubeclient.go` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: the
Makefile
target ofstart-argocd-agent
. Rather thanstart-argocd-agent
, which might imply this would start Argo agent for development purposes (similar tomake 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)There was a problem hiding this comment.
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