@@ -37,10 +37,16 @@ import (
37
37
"github.com/elastic/elastic-agent/pkg/component"
38
38
"github.com/elastic/elastic-agent/pkg/component/runtime"
39
39
agentclient "github.com/elastic/elastic-agent/pkg/control/v2/client"
40
+ "github.com/elastic/elastic-agent/pkg/core/logger"
40
41
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
41
42
"github.com/elastic/elastic-agent/pkg/utils/broadcaster"
42
43
)
43
44
45
+ var testSecretMarkerFunc = func (* logger.Logger , * config.Config ) error {
46
+ // no-op secret marker function for testing
47
+ return nil
48
+ }
49
+
44
50
func TestVarsManagerError (t * testing.T ) {
45
51
// Set a one-second timeout -- nothing here should block, but if it
46
52
// does let's report a failure instead of timing out the test runner.
@@ -470,6 +476,7 @@ func TestCoordinatorReportsInvalidPolicy(t *testing.T) {
470
476
vars : emptyVars (t ),
471
477
ast : emptyAST (t ),
472
478
componentPIDTicker : time .NewTicker (time .Second * 30 ),
479
+ secretMarkerFunc : testSecretMarkerFunc ,
473
480
}
474
481
475
482
// Send an invalid config update and confirm that Coordinator reports
@@ -585,6 +592,7 @@ func TestCoordinatorReportsComponentModelError(t *testing.T) {
585
592
vars : emptyVars (t ),
586
593
ast : emptyAST (t ),
587
594
componentPIDTicker : time .NewTicker (time .Second * 30 ),
595
+ secretMarkerFunc : testSecretMarkerFunc ,
588
596
}
589
597
590
598
// This configuration produces a valid AST but its EQL condition is
@@ -653,7 +661,7 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
653
661
// does let's report a failure instead of timing out the test runner.
654
662
ctx , cancel := context .WithTimeout (context .Background (), time .Second )
655
663
defer cancel ()
656
- logger := logp .NewLogger ("testing" )
664
+ log := logp .NewLogger ("testing" )
657
665
658
666
configChan := make (chan ConfigChange , 1 )
659
667
@@ -668,10 +676,16 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
668
676
newServerFn := func (* monitoringCfg.MonitoringConfig ) (reload.ServerController , error ) {
669
677
return monitoringServer , nil
670
678
}
671
- monitoringReloader := reload .NewServerReloader (newServerFn , logger , monitoringCfg .DefaultConfig ())
679
+ monitoringReloader := reload .NewServerReloader (newServerFn , log , monitoringCfg .DefaultConfig ())
680
+
681
+ secretMarkerCalled := false
682
+ mockSecretMarkerFunc := func (* logger.Logger , * config.Config ) error {
683
+ secretMarkerCalled = true
684
+ return nil
685
+ }
672
686
673
687
coord := & Coordinator {
674
- logger : logger ,
688
+ logger : log ,
675
689
agentInfo : & info.AgentInfo {},
676
690
stateBroadcaster : broadcaster .New (State {}, 0 , 0 ),
677
691
managerChans : managerChans {
@@ -680,6 +694,7 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
680
694
runtimeMgr : runtimeManager ,
681
695
vars : emptyVars (t ),
682
696
componentPIDTicker : time .NewTicker (time .Second * 30 ),
697
+ secretMarkerFunc : mockSecretMarkerFunc ,
683
698
}
684
699
coord .RegisterMonitoringServer (monitoringReloader )
685
700
@@ -700,6 +715,8 @@ inputs:
700
715
coord .runLoopIteration (ctx )
701
716
assert .True (t , cfgChange .acked , "Coordinator should ACK a successful policy change" )
702
717
718
+ assert .True (t , secretMarkerCalled , "secret marker should be called" )
719
+
703
720
// server is started by default
704
721
assert .True (t , monitoringServer .startTriggered )
705
722
assert .True (t , monitoringServer .isRunning )
@@ -819,6 +836,7 @@ func TestCoordinatorPolicyChangeUpdatesRuntimeAndOTelManager(t *testing.T) {
819
836
otelMgr : otelManager ,
820
837
vars : emptyVars (t ),
821
838
componentPIDTicker : time .NewTicker (time .Second * 30 ),
839
+ secretMarkerFunc : testSecretMarkerFunc ,
822
840
}
823
841
824
842
// Create a policy with one input and one output (no otel configuration)
@@ -950,6 +968,7 @@ func TestCoordinatorReportsRuntimeManagerUpdateFailure(t *testing.T) {
950
968
runtimeMgr : runtimeManager ,
951
969
vars : emptyVars (t ),
952
970
componentPIDTicker : time .NewTicker (time .Second * 30 ),
971
+ secretMarkerFunc : testSecretMarkerFunc ,
953
972
}
954
973
955
974
// Send an empty policy which should forward an empty component model to
@@ -1011,6 +1030,7 @@ func TestCoordinatorReportsOTelManagerUpdateFailure(t *testing.T) {
1011
1030
otelMgr : otelManager ,
1012
1031
vars : emptyVars (t ),
1013
1032
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1033
+ secretMarkerFunc : testSecretMarkerFunc ,
1014
1034
}
1015
1035
1016
1036
// Send an empty policy which should forward an empty component model to
@@ -1074,6 +1094,7 @@ func TestCoordinatorAppliesVarsToPolicy(t *testing.T) {
1074
1094
runtimeMgr : runtimeManager ,
1075
1095
vars : emptyVars (t ),
1076
1096
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1097
+ secretMarkerFunc : testSecretMarkerFunc ,
1077
1098
}
1078
1099
1079
1100
// Create a policy with one input and one output
0 commit comments