@@ -5711,16 +5711,6 @@ func (s *deploymentDelegatedOperatorInstanceTemplateTest) TestTelemetrySocketInj
57115711 }
57125712 return n
57135713 }
5714- // findContainer returns the named container (the main DO container,
5715- // not the telemetry-sidecar) from a pod spec.
5716- findContainer := func (containers []corev1.Container , name string ) * corev1.Container {
5717- for i , c := range containers {
5718- if c .Name == name {
5719- return & containers [i ]
5720- }
5721- }
5722- return nil
5723- }
57245714
57255715 testCases := []struct {
57265716 name string
@@ -5784,6 +5774,38 @@ func (s *deploymentDelegatedOperatorInstanceTemplateTest) TestTelemetrySocketInj
57845774 }
57855775}
57865776
5777+ // TestTelemetryDisabledOmitsSidecar verifies that when telemetry is disabled
5778+ // the rendered DO deployment carries neither the telemetry-sidecar container nor
5779+ // the telemetry-socket volume/mount. The disabled shape is also covered
5780+ // indirectly by TestContainerCount (container count is 1, not 2) and the
5781+ // disableTelemetry-based volume/mount tests; this is the focused negative
5782+ // assertion living next to the positive cases above.
5783+ func (s * deploymentDelegatedOperatorInstanceTemplateTest ) TestTelemetryDisabledOmitsSidecar () {
5784+ const socketName = "telemetry-socket"
5785+
5786+ options := & helm.Options {SetValues : map [string ]string {
5787+ "telemetry.enabled" : "false" ,
5788+ "delegatedOperatorDeployments.deployments.teamsDoCpuDefault.enabled" : "true" ,
5789+ }}
5790+ output := helm .RenderTemplate (s .T (), options , s .chartPath , s .releaseName , s .templates )
5791+
5792+ docs := strings .Split (output , "---" )
5793+ s .Require ().GreaterOrEqual (len (docs ), 2 , "expected at least one rendered deployment" )
5794+
5795+ var deployment appsv1.Deployment
5796+ helm .UnmarshalK8SYaml (s .T (), docs [1 ], & deployment )
5797+
5798+ s .Nil (findContainer (deployment .Spec .Template .Spec .Containers , "telemetry-sidecar" ),
5799+ "telemetry-sidecar container should be absent when telemetry is disabled" )
5800+ s .Nil (findVolume (deployment .Spec .Template .Spec .Volumes , socketName ),
5801+ "telemetry-socket volume should be absent when telemetry is disabled" )
5802+
5803+ main := findContainer (deployment .Spec .Template .Spec .Containers , "teams-do-cpu-default" )
5804+ s .Require ().NotNil (main , "main DO container not found" )
5805+ s .Nil (findVolumeMount (main .VolumeMounts , socketName ),
5806+ "telemetry-socket volumeMount should be absent when telemetry is disabled" )
5807+ }
5808+
57875809// TestTelemetrySidecarGpuEnv verifies that when a delegated-operator executor
57885810// requests a GPU (via resources.limits or resources.requests), its
57895811// telemetry-sidecar is given the NVIDIA_* env vars needed to read GPU metrics,
@@ -5792,23 +5814,6 @@ func (s *deploymentDelegatedOperatorInstanceTemplateTest) TestTelemetrySocketInj
57925814func (s * deploymentDelegatedOperatorInstanceTemplateTest ) TestTelemetrySidecarGpuEnv () {
57935815 const gpuResource = "nvidia.com/gpu"
57945816
5795- findContainer := func (containers []corev1.Container , name string ) * corev1.Container {
5796- for i , c := range containers {
5797- if c .Name == name {
5798- return & containers [i ]
5799- }
5800- }
5801- return nil
5802- }
5803- envValue := func (env []corev1.EnvVar , name string ) (string , bool ) {
5804- for _ , e := range env {
5805- if e .Name == name {
5806- return e .Value , true
5807- }
5808- }
5809- return "" , false
5810- }
5811-
58125817 // gpuKey escapes the dot in nvidia.com/gpu so helm --set treats the whole
58135818 // string as a single map key rather than a nested path.
58145819 gpuKey := func (section string ) string {
0 commit comments