@@ -733,6 +733,40 @@ agent.monitoring.enabled: false
733733 ctx , cancel := testcontext .WithDeadline (t , t .Context (), time .Now ().Add (5 * time .Minute ))
734734 defer cancel ()
735735
736+ // since we set the output to a nonexistent ES endpoint, we expect it to be degraded, but the input to be healthy
737+ assertBeatsReady := func (t * assert.CollectT , status * atesting.AgentStatusOutput , runtime component.RuntimeManager ) {
738+ var componentVersionInfoName string
739+ switch runtime {
740+ case "otel" :
741+ componentVersionInfoName = "beats-receiver"
742+ default :
743+ componentVersionInfoName = "beat-v2-client"
744+ }
745+
746+ // agent should be degraded
747+ assert .Equal (t , int (cproto .State_DEGRADED ), status .State )
748+ assert .Equal (t , 1 , len (status .Components ))
749+
750+ // all the components should be degraded, their output units should be degraded, the input units should be healthy,
751+ // and should identify themselves appropriately via their version info
752+ for _ , comp := range status .Components {
753+ assert .Equal (t , int (cproto .State_DEGRADED ), comp .State )
754+ assert .Equal (t , componentVersionInfoName , comp .VersionInfo .Name )
755+ for _ , unit := range comp .Units {
756+ var expectedState cproto.State
757+ switch unit .UnitType {
758+ case int (cproto .UnitType_INPUT ):
759+ expectedState = cproto .State_HEALTHY
760+ case int (cproto .UnitType_OUTPUT ):
761+ expectedState = cproto .State_DEGRADED
762+ }
763+ assert .Equal (t , int (expectedState ), unit .State ,
764+ "expected state of unit %s to be %s, got %s" ,
765+ unit .UnitID , expectedState .String (), cproto .State (unit .State ).String ())
766+ }
767+ }
768+ }
769+
736770 // set up a standalone agent
737771 fixture , err := define .NewFixtureFromLocalBuild (t , define .Version ())
738772 require .NoError (t , err )
@@ -749,7 +783,7 @@ agent.monitoring.enabled: false
749783 var statusErr error
750784 status , statusErr := fixture .ExecStatus (ctx )
751785 assert .NoError (collect , statusErr )
752- assertBeatsHealthy (collect , & status , component .ProcessRuntimeManager , 1 )
786+ assertBeatsReady (collect , & status , component .ProcessRuntimeManager )
753787 return
754788 }, 1 * time .Minute , 1 * time .Second )
755789
@@ -761,7 +795,7 @@ agent.monitoring.enabled: false
761795 var statusErr error
762796 status , statusErr := fixture .ExecStatus (ctx )
763797 assert .NoError (collect , statusErr )
764- assertBeatsHealthy (collect , & status , component .OtelRuntimeManager , 1 )
798+ assertBeatsReady (collect , & status , component .ProcessRuntimeManager )
765799 return
766800 }, 1 * time .Minute , 1 * time .Second )
767801
0 commit comments