@@ -906,144 +906,6 @@ func Test_AutopilotOverrides(t *testing.T) {
906906					return  fmt .Errorf ("trace-agent container not found" )
907907				}
908908
909- 				return  nil 
910- 			},
911- 		},
912- 		{
913- 			name : "autopilot enabled with core-agent and process-agent" ,
914- 			loadFunc : func (c  client.Client ) * v2alpha1.DatadogAgent  {
915- 				autopilotKey  :=  experimental .ExperimentalAnnotationPrefix  +  "/"  +  experimental .ExperimentalAutopilotSubkey 
916- 				dda  :=  testutils .NewInitializedDatadogAgentBuilder (resourcesNamespace , resourcesName ).
917- 					WithAPMEnabled (false ).
918- 					WithLiveProcessEnabled (true ).
919- 					WithNPMEnabled (true ).
920- 					WithClusterChecksEnabled (false ).
921- 					WithAdmissionControllerEnabled (false ).
922- 					WithOrchestratorExplorerEnabled (false ).
923- 					WithKSMEnabled (false ).
924- 					WithDogstatsdUnixDomainSocketConfigEnabled (false ).
925- 					WithAnnotations (map [string ]string {
926- 						autopilotKey : "true" ,
927- 					}).
928- 					Build ()
929- 
930- 				_  =  c .Create (context .TODO (), dda )
931- 				return  dda 
932- 			},
933- 			wantFunc : func (t  * testing.T , c  client.Client ) error  {
934- 				expectedContainers  :=  []string {
935- 					string (apicommon .CoreAgentContainerName ),
936- 					string (apicommon .ProcessAgentContainerName ),
937- 				}
938- 				if  err  :=  verifyDaemonsetContainers (c , resourcesNamespace , dsName , expectedContainers ); err  !=  nil  {
939- 					return  err 
940- 				}
941- 
942- 				ds  :=  & appsv1.DaemonSet {}
943- 				if  err  :=  c .Get (context .TODO (), types.NamespacedName {Namespace : resourcesNamespace , Name : dsName }, ds ); err  !=  nil  {
944- 					return  err 
945- 				}
946- 
947- 				processAgentFound  :=  false 
948- 				for  _ , ctn  :=  range  ds .Spec .Template .Spec .Containers  {
949- 					if  ctn .Name  ==  string (apicommon .ProcessAgentContainerName ) {
950- 						expectedCommand  :=  []string {
951- 							"process-agent" ,
952- 							"-config=/etc/datadog-agent/datadog.yaml" ,
953- 						}
954- 						if  ! reflect .DeepEqual (ctn .Command , expectedCommand ) {
955- 							return  fmt .Errorf ("process-agent command incorrect, expected: %v, got: %v" , expectedCommand , ctn .Command )
956- 						}
957- 
958- 						forbiddenMounts  :=  map [string ]struct {}{
959- 							common .AuthVolumeName :            {},
960- 							common .CriSocketVolumeName :       {},
961- 							common .DogstatsdSocketVolumeName : {},
962- 						}
963- 						for  _ , m  :=  range  ctn .VolumeMounts  {
964- 							if  _ , found  :=  forbiddenMounts [m .Name ]; found  {
965- 								return  fmt .Errorf ("forbidden mount %s found in process-agent is not allowed in GKE Autopilot" , m .Name )
966- 							}
967- 						}
968- 						processAgentFound  =  true 
969- 					}
970- 				}
971- 				if  ! processAgentFound  {
972- 					return  fmt .Errorf ("process-agent container not found" )
973- 				}
974- 
975- 				return  nil 
976- 			},
977- 		},
978- 		{
979- 			name : "autopilot enabled with all containers (core, trace, process)" ,
980- 			loadFunc : func (c  client.Client ) * v2alpha1.DatadogAgent  {
981- 				autopilotKey  :=  experimental .ExperimentalAnnotationPrefix  +  "/"  +  experimental .ExperimentalAutopilotSubkey 
982- 				dda  :=  testutils .NewInitializedDatadogAgentBuilder (resourcesNamespace , resourcesName ).
983- 					WithAPMEnabled (true ).
984- 					WithLiveProcessEnabled (true ).
985- 					WithNPMEnabled (true ).
986- 					WithClusterChecksEnabled (false ).
987- 					WithAdmissionControllerEnabled (false ).
988- 					WithOrchestratorExplorerEnabled (false ).
989- 					WithKSMEnabled (false ).
990- 					WithDogstatsdUnixDomainSocketConfigEnabled (false ).
991- 					WithAnnotations (map [string ]string {
992- 						autopilotKey : "true" ,
993- 					}).
994- 					Build ()
995- 
996- 				_  =  c .Create (context .TODO (), dda )
997- 				return  dda 
998- 			},
999- 			wantFunc : func (t  * testing.T , c  client.Client ) error  {
1000- 				expectedContainers  :=  []string {
1001- 					string (apicommon .CoreAgentContainerName ),
1002- 					string (apicommon .TraceAgentContainerName ),
1003- 					string (apicommon .ProcessAgentContainerName ),
1004- 				}
1005- 				if  err  :=  verifyDaemonsetContainers (c , resourcesNamespace , dsName , expectedContainers ); err  !=  nil  {
1006- 					return  err 
1007- 				}
1008- 
1009- 				ds  :=  & appsv1.DaemonSet {}
1010- 				if  err  :=  c .Get (context .TODO (), types.NamespacedName {Namespace : resourcesNamespace , Name : dsName }, ds ); err  !=  nil  {
1011- 					return  err 
1012- 				}
1013- 
1014- 				traceAgentFound  :=  false 
1015- 				processAgentFound  :=  false 
1016- 				for  _ , ctn  :=  range  ds .Spec .Template .Spec .Containers  {
1017- 					switch  ctn .Name  {
1018- 					case  string (apicommon .TraceAgentContainerName ):
1019- 						expectedCommand  :=  []string {
1020- 							"trace-agent" ,
1021- 							"-config=/etc/datadog-agent/datadog.yaml" ,
1022- 						}
1023- 						if  ! reflect .DeepEqual (ctn .Command , expectedCommand ) {
1024- 							return  fmt .Errorf ("trace-agent command incorrect, expected: %v, got: %v" , expectedCommand , ctn .Command )
1025- 						}
1026- 						traceAgentFound  =  true 
1027- 
1028- 					case  string (apicommon .ProcessAgentContainerName ):
1029- 						expectedCommand  :=  []string {
1030- 							"process-agent" ,
1031- 							"-config=/etc/datadog-agent/datadog.yaml" ,
1032- 						}
1033- 						if  ! reflect .DeepEqual (ctn .Command , expectedCommand ) {
1034- 							return  fmt .Errorf ("process-agent command incorrect, expected: %v, got: %v" , expectedCommand , ctn .Command )
1035- 						}
1036- 						processAgentFound  =  true 
1037- 					}
1038- 				}
1039- 
1040- 				if  ! traceAgentFound  {
1041- 					return  fmt .Errorf ("trace-agent container not found" )
1042- 				}
1043- 				if  ! processAgentFound  {
1044- 					return  fmt .Errorf ("process-agent container not found" )
1045- 				}
1046- 
1047909				return  nil 
1048910			},
1049911		},
0 commit comments