Skip to content

Commit ba46e24

Browse files
authored
Merge pull request #297 from spinkube/dani/remove-duplicate-e2e
tests: move label and annotation tests from e2e -> integration
2 parents 9246b2c + b37b4b1 commit ba46e24

File tree

2 files changed

+80
-106
lines changed

2 files changed

+80
-106
lines changed

e2e/podlabel_test.go

Lines changed: 0 additions & 106 deletions
This file was deleted.

internal/controller/spinapp_controller_test.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,83 @@ func TestConstructDeployment_WithPodLabels(t *testing.T) {
431431
require.Len(t, deployment.Spec.Template.Labels, 3)
432432
require.Equal(t, deployment.Spec.Template.Labels[key], value)
433433
}
434+
435+
func TestReconcile_Integration_AnnotationAndLabelPropagataion(t *testing.T) {
436+
t.Parallel()
437+
438+
envTest, mgr, _ := setupController(t)
439+
440+
ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Second)
441+
defer cancelFunc()
442+
443+
var wg sync.WaitGroup
444+
wg.Add(1)
445+
go func() {
446+
require.NoError(t, mgr.Start(ctx))
447+
wg.Done()
448+
}()
449+
450+
// Create an executor that creates a deployment with a given runtimeClassName
451+
executor := &spinv1alpha1.SpinAppExecutor{
452+
ObjectMeta: metav1.ObjectMeta{
453+
Name: "executor",
454+
Namespace: "default",
455+
},
456+
Spec: spinv1alpha1.SpinAppExecutorSpec{
457+
CreateDeployment: true,
458+
DeploymentConfig: &spinv1alpha1.ExecutorDeploymentConfig{
459+
RuntimeClassName: "a-runtime-class",
460+
},
461+
},
462+
}
463+
464+
require.NoError(t, envTest.k8sClient.Create(ctx, executor))
465+
466+
spinApp := &spinv1alpha1.SpinApp{
467+
ObjectMeta: metav1.ObjectMeta{
468+
Name: "app",
469+
Namespace: "default",
470+
},
471+
Spec: spinv1alpha1.SpinAppSpec{
472+
Executor: "executor",
473+
Image: "ghcr.io/radu-matei/perftest:v1",
474+
PodLabels: map[string]string{
475+
"my.pod.label": "value",
476+
},
477+
PodAnnotations: map[string]string{
478+
"my.pod.annotation": "value",
479+
},
480+
DeploymentAnnotations: map[string]string{
481+
"my.deployment.annotation": "value",
482+
},
483+
},
484+
}
485+
486+
require.NoError(t, envTest.k8sClient.Create(ctx, spinApp))
487+
488+
// Wait for the underlying deployment to exist
489+
var deployment appsv1.Deployment
490+
require.Eventually(t, func() bool {
491+
err := envTest.k8sClient.Get(ctx,
492+
types.NamespacedName{
493+
Namespace: "default",
494+
Name: "app"},
495+
&deployment)
496+
return err == nil
497+
}, 3*time.Second, 100*time.Millisecond)
498+
499+
require.Equal(t, "a-runtime-class", *deployment.Spec.Template.Spec.RuntimeClassName)
500+
require.Equal(t,
501+
map[string]string{
502+
"core.spinoperator.dev/app-name": "app",
503+
"core.spinoperator.dev/app.app.status": "ready",
504+
"my.pod.label": "value",
505+
},
506+
deployment.Spec.Template.ObjectMeta.Labels)
507+
require.Equal(t, map[string]string{"my.pod.annotation": "value"}, deployment.Spec.Template.ObjectMeta.Annotations)
508+
require.Equal(t, map[string]string{"my.deployment.annotation": "value"}, deployment.ObjectMeta.Annotations)
509+
510+
// Terminate the context to force the manager to shut down.
511+
cancelFunc()
512+
wg.Wait()
513+
}

0 commit comments

Comments
 (0)