Skip to content

Commit

Permalink
Merge pull request #297 from spinkube/dani/remove-duplicate-e2e
Browse files Browse the repository at this point in the history
tests: move label and annotation tests from e2e -> integration
  • Loading branch information
endocrimes authored Aug 15, 2024
2 parents 9246b2c + b37b4b1 commit ba46e24
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 106 deletions.
106 changes: 0 additions & 106 deletions e2e/podlabel_test.go

This file was deleted.

80 changes: 80 additions & 0 deletions internal/controller/spinapp_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,83 @@ func TestConstructDeployment_WithPodLabels(t *testing.T) {
require.Len(t, deployment.Spec.Template.Labels, 3)
require.Equal(t, deployment.Spec.Template.Labels[key], value)
}

func TestReconcile_Integration_AnnotationAndLabelPropagataion(t *testing.T) {
t.Parallel()

envTest, mgr, _ := setupController(t)

ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Second)
defer cancelFunc()

var wg sync.WaitGroup
wg.Add(1)
go func() {
require.NoError(t, mgr.Start(ctx))
wg.Done()
}()

// Create an executor that creates a deployment with a given runtimeClassName
executor := &spinv1alpha1.SpinAppExecutor{
ObjectMeta: metav1.ObjectMeta{
Name: "executor",
Namespace: "default",
},
Spec: spinv1alpha1.SpinAppExecutorSpec{
CreateDeployment: true,
DeploymentConfig: &spinv1alpha1.ExecutorDeploymentConfig{
RuntimeClassName: "a-runtime-class",
},
},
}

require.NoError(t, envTest.k8sClient.Create(ctx, executor))

spinApp := &spinv1alpha1.SpinApp{
ObjectMeta: metav1.ObjectMeta{
Name: "app",
Namespace: "default",
},
Spec: spinv1alpha1.SpinAppSpec{
Executor: "executor",
Image: "ghcr.io/radu-matei/perftest:v1",
PodLabels: map[string]string{
"my.pod.label": "value",
},
PodAnnotations: map[string]string{
"my.pod.annotation": "value",
},
DeploymentAnnotations: map[string]string{
"my.deployment.annotation": "value",
},
},
}

require.NoError(t, envTest.k8sClient.Create(ctx, spinApp))

// Wait for the underlying deployment to exist
var deployment appsv1.Deployment
require.Eventually(t, func() bool {
err := envTest.k8sClient.Get(ctx,
types.NamespacedName{
Namespace: "default",
Name: "app"},
&deployment)
return err == nil
}, 3*time.Second, 100*time.Millisecond)

require.Equal(t, "a-runtime-class", *deployment.Spec.Template.Spec.RuntimeClassName)
require.Equal(t,
map[string]string{
"core.spinoperator.dev/app-name": "app",
"core.spinoperator.dev/app.app.status": "ready",
"my.pod.label": "value",
},
deployment.Spec.Template.ObjectMeta.Labels)
require.Equal(t, map[string]string{"my.pod.annotation": "value"}, deployment.Spec.Template.ObjectMeta.Annotations)
require.Equal(t, map[string]string{"my.deployment.annotation": "value"}, deployment.ObjectMeta.Annotations)

// Terminate the context to force the manager to shut down.
cancelFunc()
wg.Wait()
}

0 comments on commit ba46e24

Please sign in to comment.