-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e test for component filtering
Signed-off-by: Kate Goldenring <[email protected]>
- Loading branch information
1 parent
9668cab
commit cd5ab7d
Showing
8 changed files
with
120 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
resources: | ||
- manager.yaml | ||
- manager.yaml | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
images: | ||
- name: ghcr.io/spinkube/spin-operator | ||
newName: ghcr.io/spinkube/spin-operator | ||
newTag: dev |
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
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,90 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/e2e-framework/klient" | ||
"sigs.k8s.io/e2e-framework/klient/wait" | ||
"sigs.k8s.io/e2e-framework/klient/wait/conditions" | ||
"sigs.k8s.io/e2e-framework/pkg/envconf" | ||
"sigs.k8s.io/e2e-framework/pkg/features" | ||
|
||
spinapps_v1alpha1 "github.com/spinkube/spin-operator/api/v1alpha1" | ||
"github.com/spinkube/spin-operator/e2e/helper" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestSelectiveDeployment checks that the operator and shim have support for running a subset of a Spin app's components | ||
func TestSelectiveDeployment(t *testing.T) { | ||
var client klient.Client | ||
|
||
// TODO: Use an image from a sample app in this repository | ||
appImage := "ghcr.io/kate-goldenring/spin-operator/examples/spin-salutations:20241022-144454" | ||
testSpinAppName := "test-component-filtering" | ||
|
||
defaultTest := features.New("default and most minimal setup"). | ||
Setup(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
|
||
client = cfg.Client() | ||
|
||
if err := spinapps_v1alpha1.AddToScheme(client.Resources(testNamespace).GetScheme()); err != nil { | ||
t.Fatalf("failed to register the spinapps_v1alpha1 types with Kubernetes scheme: %s", err) | ||
} | ||
|
||
return ctx | ||
}). | ||
Assess("spin app custom resource is created", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
testSpinApp := newSpinAppCR(testSpinAppName, appImage, "containerd-shim-spin", []string{"hello"}) | ||
|
||
if err := client.Resources().Create(ctx, testSpinApp); err != nil { | ||
t.Fatalf("Failed to create spinapp: %s", err) | ||
} | ||
return ctx | ||
}). | ||
Assess("spin app deployment and service are available", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
// wait for deployment to be ready | ||
if err := wait.For( | ||
conditions.New(client.Resources()).DeploymentAvailable(testSpinAppName, testNamespace), | ||
wait.WithTimeout(3*time.Minute), | ||
wait.WithInterval(time.Second), | ||
); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
svc := &v1.ServiceList{ | ||
Items: []v1.Service{ | ||
{ObjectMeta: metav1.ObjectMeta{Name: testSpinAppName, Namespace: testNamespace}}, | ||
}, | ||
} | ||
|
||
if err := wait.For( | ||
conditions.New(client.Resources()).ResourcesFound(svc), | ||
wait.WithTimeout(3*time.Minute), | ||
wait.WithInterval(500*time.Millisecond), | ||
); err != nil { | ||
t.Fatal(err) | ||
} | ||
return ctx | ||
}). | ||
Assess("spin app is only serving hello component", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
helper.EnsureDebugContainer(t, ctx, cfg, testNamespace) | ||
|
||
_, status, err := helper.CurlSpinApp(t, ctx, cfg, testNamespace, testSpinAppName, "/hi", "") | ||
|
||
require.NoError(t, err) | ||
require.Equal(t, 200, status) | ||
|
||
_, status, err = helper.CurlSpinApp(t, ctx, cfg, testNamespace, testSpinAppName, "/bye", "") | ||
|
||
require.NoError(t, err) | ||
require.Equal(t, 404, status) | ||
|
||
return ctx | ||
}). | ||
Feature() | ||
testEnv.Test(t, defaultTest) | ||
} |
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