@@ -429,6 +429,152 @@ func TestEnsurePod_Metrics(t *testing.T) {
429429 },
430430 },
431431 },
432+ {
433+ Name : "Agency Pod with sidecar metrics exporter and port override, with enabled deployment tls" ,
434+ ArangoDeployment : & api.ArangoDeployment {
435+ Spec : api.DeploymentSpec {
436+ Image : util .NewString (testImage ),
437+ Authentication : noAuthentication ,
438+ TLS : tlsSpec ,
439+ Metrics : func () api.MetricsSpec {
440+ m := metricsSpec .DeepCopy ()
441+
442+ m .Port = util .NewUInt16 (9999 )
443+
444+ m .Mode = api .MetricsModeSidecar .New ()
445+
446+ return * m
447+ }(),
448+ },
449+ },
450+ Helper : func (t * testing.T , deployment * Deployment , testCase * testCaseStruct ) {
451+ deployment .status .last = api.DeploymentStatus {
452+ Members : api.DeploymentStatusMembers {
453+ Agents : api.MemberStatusList {
454+ firstAgentStatus ,
455+ },
456+ },
457+ Images : createTestImages (false ),
458+ }
459+
460+ testCase .createTestPodData (deployment , api .ServerGroupAgents , firstAgentStatus )
461+ testCase .ExpectedPod .ObjectMeta .Labels [k8sutil .LabelKeyArangoExporter ] = testYes
462+ },
463+ ExpectedEvent : "member agent is created" ,
464+ ExpectedPod : core.Pod {
465+ Spec : core.PodSpec {
466+ Volumes : []core.Volume {
467+ k8sutil .CreateVolumeEmptyDir (k8sutil .ArangodVolumeName ),
468+ createTestTLSVolume (api .ServerGroupAgentsString , firstAgentStatus .ID ),
469+ k8sutil .CreateVolumeWithSecret (k8sutil .ExporterJWTVolumeName , testExporterToken ),
470+ },
471+ Containers : []core.Container {
472+ {
473+ Name : k8sutil .ServerContainerName ,
474+ Image : testImage ,
475+ Command : createTestCommandForAgent (firstAgentStatus .ID , true , false , false ),
476+ Ports : createTestPorts (),
477+ VolumeMounts : []core.VolumeMount {
478+ k8sutil .ArangodVolumeMount (),
479+ k8sutil .TlsKeyfileVolumeMount (),
480+ },
481+ Resources : emptyResources ,
482+ LivenessProbe : createTestLivenessProbe (httpProbe , true , "" , k8sutil .ArangoPort ),
483+ ImagePullPolicy : core .PullIfNotPresent ,
484+ SecurityContext : securityContext .NewSecurityContext (),
485+ },
486+ func () core.Container {
487+ z := testCreateExporterContainerWithPortAndSecureEndpoint (true , true , emptyResources , 9999 )
488+
489+ z .VolumeMounts = append (z .VolumeMounts , k8sutil .TlsKeyfileVolumeMount ())
490+
491+ z .Command = append (z .Command , "--mode=passthru" )
492+ return z
493+ }(),
494+ },
495+ RestartPolicy : core .RestartPolicyNever ,
496+ TerminationGracePeriodSeconds : & defaultAgentTerminationTimeout ,
497+ Hostname : testDeploymentName + "-" + api .ServerGroupAgentsString + "-" + firstAgentStatus .ID ,
498+ Subdomain : testDeploymentName + "-int" ,
499+ Affinity : k8sutil .CreateAffinity (testDeploymentName , api .ServerGroupAgentsString ,
500+ false , "" ),
501+ },
502+ },
503+ },
504+ {
505+ Name : "Agency Pod with sidecar metrics exporter and port override, with enabled deployment tls but disabled metrics tls" ,
506+ ArangoDeployment : & api.ArangoDeployment {
507+ Spec : api.DeploymentSpec {
508+ Image : util .NewString (testImage ),
509+ Authentication : noAuthentication ,
510+ TLS : tlsSpec ,
511+ Metrics : func () api.MetricsSpec {
512+ m := metricsSpec .DeepCopy ()
513+
514+ m .Port = util .NewUInt16 (9999 )
515+
516+ m .Mode = api .MetricsModeSidecar .New ()
517+
518+ m .TLS = util .NewBool (false )
519+
520+ return * m
521+ }(),
522+ },
523+ },
524+ Helper : func (t * testing.T , deployment * Deployment , testCase * testCaseStruct ) {
525+ deployment .status .last = api.DeploymentStatus {
526+ Members : api.DeploymentStatusMembers {
527+ Agents : api.MemberStatusList {
528+ firstAgentStatus ,
529+ },
530+ },
531+ Images : createTestImages (false ),
532+ }
533+
534+ testCase .createTestPodData (deployment , api .ServerGroupAgents , firstAgentStatus )
535+ testCase .ExpectedPod .ObjectMeta .Labels [k8sutil .LabelKeyArangoExporter ] = testYes
536+ },
537+ ExpectedEvent : "member agent is created" ,
538+ ExpectedPod : core.Pod {
539+ Spec : core.PodSpec {
540+ Volumes : []core.Volume {
541+ k8sutil .CreateVolumeEmptyDir (k8sutil .ArangodVolumeName ),
542+ createTestTLSVolume (api .ServerGroupAgentsString , firstAgentStatus .ID ),
543+ k8sutil .CreateVolumeWithSecret (k8sutil .ExporterJWTVolumeName , testExporterToken ),
544+ },
545+ Containers : []core.Container {
546+ {
547+ Name : k8sutil .ServerContainerName ,
548+ Image : testImage ,
549+ Command : createTestCommandForAgent (firstAgentStatus .ID , true , false , false ),
550+ Ports : createTestPorts (),
551+ VolumeMounts : []core.VolumeMount {
552+ k8sutil .ArangodVolumeMount (),
553+ k8sutil .TlsKeyfileVolumeMount (),
554+ },
555+ Resources : emptyResources ,
556+ LivenessProbe : createTestLivenessProbe (httpProbe , true , "" , k8sutil .ArangoPort ),
557+ ImagePullPolicy : core .PullIfNotPresent ,
558+ SecurityContext : securityContext .NewSecurityContext (),
559+ },
560+ func () core.Container {
561+ z := testCreateExporterContainerWithPortAndSecureEndpoint (true , false , emptyResources , 9999 )
562+
563+ z .VolumeMounts = append (z .VolumeMounts , k8sutil .TlsKeyfileVolumeMount ())
564+
565+ z .Command = append (z .Command , "--mode=passthru" )
566+ return z
567+ }(),
568+ },
569+ RestartPolicy : core .RestartPolicyNever ,
570+ TerminationGracePeriodSeconds : & defaultAgentTerminationTimeout ,
571+ Hostname : testDeploymentName + "-" + api .ServerGroupAgentsString + "-" + firstAgentStatus .ID ,
572+ Subdomain : testDeploymentName + "-int" ,
573+ Affinity : k8sutil .CreateAffinity (testDeploymentName , api .ServerGroupAgentsString ,
574+ false , "" ),
575+ },
576+ },
577+ },
432578 }
433579
434580 runTestCases (t , testCases ... )
0 commit comments