@@ -584,7 +584,7 @@ func fluentdDriverTest(taskDefinition string, t *testing.T) {
584
584
assert .NoError (t , err , "failed to find the log tag specified in the task definition" )
585
585
}
586
586
587
- // TestMetadataServiceValidator Tests that the metadata file can be accessed from the
587
+ // TestMetadataServiceValidator tests that the metadata file can be accessed from the
588
588
// container using the ECS_CONTAINER_METADATA_FILE environment variables
589
589
func TestMetadataServiceValidator (t * testing.T ) {
590
590
agentOptions := & AgentOptions {
@@ -609,6 +609,45 @@ func TestMetadataServiceValidator(t *testing.T) {
609
609
assert .Equal (t , 42 , exitCode , fmt .Sprintf ("Expected exit code of 42; got %d" , exitCode ))
610
610
}
611
611
612
+ // TestAgentIntrospectionValidator tests that the agent introspection endpoint can
613
+ // be accessed from within the container.
614
+ func TestAgentIntrospectionValidator (t * testing.T ) {
615
+ // Best effort to create a log group. It should be safe to even not do this
616
+ // as the log group gets created in the TestAWSLogsDriver functional test.
617
+ cwlClient := cloudwatchlogs .New (session .New (), aws .NewConfig ().WithRegion (* ECS .Config .Region ))
618
+ cwlClient .CreateLogGroup (& cloudwatchlogs.CreateLogGroupInput {
619
+ LogGroupName : aws .String (awslogsLogGroupName ),
620
+ })
621
+ agent := RunAgent (t , & AgentOptions {
622
+ EnableTaskENI : true ,
623
+ ExtraEnvironment : map [string ]string {
624
+ "ECS_AVAILABLE_LOGGING_DRIVERS" : `["awslogs"]` ,
625
+ },
626
+ })
627
+ defer agent .Cleanup ()
628
+ // The Agent version was 1.14.2 when we added changes to agent introspection
629
+ // endpoint feature for the last time.
630
+ agent .RequireVersion (">1.14.1" )
631
+
632
+ tdOverrides := make (map [string ]string )
633
+ tdOverrides ["$$$TEST_REGION$$$" ] = * ECS .Config .Region
634
+
635
+ task , err := agent .StartTaskWithTaskDefinitionOverrides (t , "agent-introspection-validator" , tdOverrides )
636
+ require .NoError (t , err , "Unable to start task" )
637
+ defer func () {
638
+ if err := task .Stop (); err != nil {
639
+ return
640
+ }
641
+ task .WaitStopped (waitTaskStateChangeDuration )
642
+ }()
643
+
644
+ err = task .WaitStopped (waitTaskStateChangeDuration )
645
+ require .NoError (t , err , "Error waiting for task to transition to STOPPED" )
646
+ exitCode , _ := task .ContainerExitcode ("agent-introspection-validator" )
647
+
648
+ assert .Equal (t , 42 , exitCode , fmt .Sprintf ("Expected exit code of 42; got %d" , exitCode ))
649
+ }
650
+
612
651
func TestTaskMetadataValidator (t * testing.T ) {
613
652
RequireDockerVersion (t , ">=17.06.0-ce" )
614
653
// Best effort to create a log group. It should be safe to even not do this
0 commit comments