Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Scorsolini <[email protected]>
  • Loading branch information
phisco committed Jul 1, 2023
1 parent ff39a1e commit 41a5968
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 36 deletions.
31 changes: 21 additions & 10 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,24 @@ E2E_TEST_FLAGS="-test.v -test.failfast -destroy-kind-cluster=false"
# local build of Crossplane in this scenario, so you'll have to do it yourself.
E2E_TEST_FLAGS="-create-kind-cluster=false -destroy-kind-cluster=false -kubeconfig=$HOME/.kube/config"

# Run the CrossplaneUpgrade feature, against an existing kind cluster named "kind" (or creating it if it doesn't exist),
# without installing Crossplane first, as the feature expects the cluster to be empty, but still loading the images to
# it. Setting the tests to fail fast and not destroying the cluster afterward in order to allow debugging it.
E2E_TEST_FLAGS="-test.v -v 4 -test.failfast -destroy-kind-cluster=false -kind-cluster-name=kind -install-crossplane=false -feature=CrossplaneUpgrade" make e2e

# Run the all tests not installing or upgrading Crossplane against the currently selected cluster where Crossplane has already been installed.
E2E_TEST_FLAGS="-test.v -v 4 -test.failfast -kubeconfig=$HOME/.kube/config -skip-labels install-crossplane=true -create-kind-cluster=false -install-crossplane=false" make go.build e2e-run-tests```
# Run the CrossplaneUpgrade feature, against an existing kind cluster named
# "kind" (or creating it if it doesn't exist), # without installing Crossplane
# first, as the feature expects the cluster to be empty, but still loading the
# images to # it. Setting the tests to fail fast and not destroying the cluster
# afterward in order to allow debugging it.
E2E_TEST_FLAGS="-test.v -v 4 -test.failfast \
-destroy-kind-cluster=false \
-kind-cluster-name=kind \
-install-crossplane=false \
-feature=CrossplaneUpgrade" make e2e

# Run the all tests not installing or upgrading Crossplane against the currently
# selected cluster where Crossplane has already been installed.
E2E_TEST_FLAGS="-test.v -v 4 -test.failfast \
-kubeconfig=$HOME/.kube/config \
-skip-labels install-crossplane=true \
-create-kind-cluster=false \
-install-crossplane=false" make go.build e2e-run-tests
```

## Test Parallelism
Expand All @@ -78,7 +89,7 @@ We try to follow this pattern when adding a new test:

1. Define a single feature per Test function, if possible.
1. Setup a directory of plain YAML manifests per test - i.e. test fixtures - at
`e2e/manifests/<area>/<test>`, usually with a `prerequisites` sub-folder
`e2e/manifests/<area>/<test>`, usually with a `setup` sub-folder
containing resources to be deployed at setup phase and cleaned up during the
teardown. Try to avoid reusing other feature's fixtures, as this would introduce
hidden dependencies between tests.
Expand All @@ -102,9 +113,9 @@ We try to follow this pattern when adding a new test:
not strictly part of the feature being tested, but are needed to make it
work, and actions that are needed to clean up the environment after the test
has run.
1. Use the `Asses` steps to define the steps required to exercise the actual
1. Use `Assess` steps to define the steps required to exercise the actual
feature at hand.
1. Use `Asses` steps to define both conditions that should hold and actions that
1. Use `Assess` steps to define both conditions that should hold and actions that
should be performed. In the former case use active descriptions, e.g.
`InstallProviderNop`, while in the latter use passive descriptions, e.g.
`ProviderNopIsInstalled`.
Expand Down
32 changes: 16 additions & 16 deletions test/e2e/apiextensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func TestCompositionMinimal(t *testing.T) {
WithLabel(LabelArea, LabelAreaAPIExtensions).
WithLabel(LabelSize, LabelSizeSmall).
WithSetup("PrerequisitesAreCreated", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "prerequisites/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "prerequisites/*.yaml"),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "prerequisites/definition.yaml", apiextensionsv1.WatchingComposite()),
funcs.ApplyResources(FieldManager, manifests, "setup/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "setup/*.yaml"),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "setup/definition.yaml", apiextensionsv1.WatchingComposite()),
)).
Assess("ClaimCreated", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "claim.yaml"),
Expand All @@ -60,8 +60,8 @@ func TestCompositionMinimal(t *testing.T) {
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "claim.yaml"),
)).
WithTeardown("PrerequisitesAreDeleted", funcs.AllOf(
funcs.DeleteResources(manifests, "prerequisites/*.yaml"),
funcs.ResourcesDeletedWithin(3*time.Minute, manifests, "prerequisites/*.yaml"),
funcs.DeleteResources(manifests, "setup/*.yaml"),
funcs.ResourcesDeletedWithin(3*time.Minute, manifests, "setup/*.yaml"),
)).
Feature(),
)
Expand All @@ -79,9 +79,9 @@ func TestCompositionPatchAndTransform(t *testing.T) {
WithLabel(LabelArea, LabelAreaAPIExtensions).
WithLabel(LabelSize, LabelSizeSmall).
WithSetup("CreatePrerequisites", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "prerequisites/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "prerequisites/*.yaml"),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "prerequisites/definition.yaml", apiextensionsv1.WatchingComposite()),
funcs.ApplyResources(FieldManager, manifests, "setup/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "setup/*.yaml"),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "setup/definition.yaml", apiextensionsv1.WatchingComposite()),
)).
Assess("CreateClaim", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "claim.yaml"),
Expand All @@ -97,8 +97,8 @@ func TestCompositionPatchAndTransform(t *testing.T) {
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "claim.yaml"),
)).
WithTeardown("DeleteAllPrerequisites", funcs.AllOf(
funcs.DeleteResources(manifests, "prerequisites/*.yaml"),
funcs.ResourcesDeletedWithin(3*time.Minute, manifests, "prerequisites/*.yaml"),
funcs.DeleteResources(manifests, "setup/*.yaml"),
funcs.ResourcesDeletedWithin(3*time.Minute, manifests, "setup/*.yaml"),
)).
Feature(),
)
Expand Down Expand Up @@ -135,18 +135,18 @@ func TestCompositionValidation(t *testing.T) {
funcs.ReadyToTestWithin(1*time.Minute, namespace),
)).
WithSetup("ApplyPrerequisites", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "prerequisites/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "prerequisites/*.yaml"),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "prerequisites/definition.yaml", apiextensionsv1.WatchingComposite()),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "prerequisites/provider.yaml", pkgv1.Healthy(), pkgv1.Active()),
funcs.ApplyResources(FieldManager, manifests, "setup/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "setup/*.yaml"),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "setup/definition.yaml", apiextensionsv1.WatchingComposite()),
funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "setup/provider.yaml", pkgv1.Healthy(), pkgv1.Active()),
)).
WithTeardown("DeleteValidComposition", funcs.AllOf(
funcs.DeleteResources(manifests, "*-valid.yaml"),
funcs.ResourcesDeletedWithin(30*time.Second, manifests, "*-valid.yaml"),
)).
WithTeardown("DeletePrerequisites", funcs.AllOf(
funcs.DeleteResources(manifests, "prerequisites/*.yaml"),
funcs.ResourcesDeletedWithin(3*time.Minute, manifests, "prerequisites/*.yaml"),
funcs.DeleteResources(manifests, "setup/*.yaml"),
funcs.ResourcesDeletedWithin(3*time.Minute, manifests, "setup/*.yaml"),
)).
// Disable our feature flag.
WithTeardown("DisableAlphaCompositionValidation", funcs.AllOf(
Expand Down
20 changes: 10 additions & 10 deletions test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ func TestCrossplaneLifecycle(t *testing.T) {
WithLabel(LabelSize, LabelSizeSmall).
WithLabel(LabelInstallCrossplane, LabelInstallCrossplaneTrue).
WithSetup("CreatePrerequisites", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "prerequisites/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "prerequisites/*.yaml"),
funcs.ApplyResources(FieldManager, manifests, "setup/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "setup/*.yaml"),
)).
WithSetup("XRDAreEstablished", funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "prerequisites/definition.yaml", apiextensionsv1.WatchingComposite())).
WithSetup("XRDAreEstablished", funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "setup/definition.yaml", apiextensionsv1.WatchingComposite())).
WithSetup("CreateClaim", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "claim.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "claim.yaml"),
Expand All @@ -69,8 +69,8 @@ func TestCrossplaneLifecycle(t *testing.T) {
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "claim.yaml"),
)).
Assess("DeleteAllPrerequisites", funcs.AllOf(
funcs.DeleteResources(manifests, "prerequisites/*.yaml"),
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "prerequisites/*.yaml"),
funcs.DeleteResources(manifests, "setup/*.yaml"),
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "setup/*.yaml"),
)).
Assess("UninstallCrossplane", funcs.AllOf(
funcs.AsFeaturesFunc(funcs.HelmUninstall(helm.WithName(helmReleaseName), helm.WithNamespace(namespace))),
Expand Down Expand Up @@ -112,10 +112,10 @@ func TestCrossplaneLifecycle(t *testing.T) {
)),
funcs.ReadyToTestWithin(1*time.Minute, namespace))).
Assess("CreateClaimPrerequisites", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "prerequisites/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "prerequisites/*.yaml"),
funcs.ApplyResources(FieldManager, manifests, "setup/*.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "setup/*.yaml"),
)).
Assess("XRDIsEstablished", funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "prerequisites/definition.yaml", apiextensionsv1.WatchingComposite())).
Assess("XRDIsEstablished", funcs.ResourcesHaveConditionWithin(1*time.Minute, manifests, "setup/definition.yaml", apiextensionsv1.WatchingComposite())).
Assess("CreateClaim", funcs.AllOf(
funcs.ApplyResources(FieldManager, manifests, "claim.yaml"),
funcs.ResourcesCreatedWithin(30*time.Second, manifests, "claim.yaml"),
Expand All @@ -135,8 +135,8 @@ func TestCrossplaneLifecycle(t *testing.T) {
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "claim.yaml"),
)).
WithTeardown("DeleteAllPrerequisites", funcs.AllOf(
funcs.DeleteResources(manifests, "prerequisites/*.yaml"),
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "prerequisites/*.yaml"),
funcs.DeleteResources(manifests, "setup/*.yaml"),
funcs.ResourcesDeletedWithin(2*time.Minute, manifests, "setup/*.yaml"),
)).
Feature(),
)
Expand Down

0 comments on commit 41a5968

Please sign in to comment.