Skip to content

Commit

Permalink
UT
Browse files Browse the repository at this point in the history
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
  • Loading branch information
lubronzhan committed Jan 31, 2024
1 parent 6d2e6d2 commit 6225b42
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/provisioner/objects/dataplane/dataplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ func checkDaemonSetHasMetricsPort(t *testing.T, ds *appsv1.DaemonSet, port int32
t.Errorf("container has unexpected metrics port %d", port)
}

func checkEnvoyDeploymentHasAffinity(t *testing.T, d *appsv1.Deployment, contour *model.Contour) {
t.Helper()
if apiequality.Semantic.DeepEqual(*d.Spec.Template.Spec.Affinity,
corev1.Affinity{
PodAntiAffinity: &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
LabelSelector: EnvoyPodSelector(contour),
TopologyKey: "kubernetes.io/hostname",
},
},
},
}) {
return
}
t.Errorf("container has unexpected affinity %v", d.Spec.Template.Spec.Affinity)
}

func TestDesiredDaemonSet(t *testing.T) {
name := "ds-test"
cntr := model.Default(fmt.Sprintf("%s-ns", name), name)
Expand Down Expand Up @@ -360,6 +378,7 @@ func TestDesiredDeployment(t *testing.T) {
testEnvoyImage := "docker.io/envoyproxy/envoy:test"
deploy := desiredDeployment(cntr, testContourImage, testEnvoyImage)
checkDeploymentHasStrategy(t, deploy, cntr.Spec.EnvoyDeploymentStrategy)
checkEnvoyDeploymentHasAffinity(t, deploy, cntr)
}

func TestNodePlacementDaemonSet(t *testing.T) {
Expand Down

0 comments on commit 6225b42

Please sign in to comment.