@@ -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.
@@ -471,6 +477,7 @@ func TestCoordinatorReportsInvalidPolicy(t *testing.T) {
471
477
vars : emptyVars (t ),
472
478
ast : emptyAST (t ),
473
479
componentPIDTicker : time .NewTicker (time .Second * 30 ),
480
+ secretMarkerFunc : testSecretMarkerFunc ,
474
481
}
475
482
476
483
// Send an invalid config update and confirm that Coordinator reports
@@ -587,6 +594,7 @@ func TestCoordinatorReportsComponentModelError(t *testing.T) {
587
594
vars : emptyVars (t ),
588
595
ast : emptyAST (t ),
589
596
componentPIDTicker : time .NewTicker (time .Second * 30 ),
597
+ secretMarkerFunc : testSecretMarkerFunc ,
590
598
}
591
599
592
600
// This configuration produces a valid AST but its EQL condition is
@@ -655,7 +663,7 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
655
663
// does let's report a failure instead of timing out the test runner.
656
664
ctx , cancel := context .WithTimeout (context .Background (), time .Second )
657
665
defer cancel ()
658
- logger := logp .NewLogger ("testing" )
666
+ log := logp .NewLogger ("testing" )
659
667
660
668
configChan := make (chan ConfigChange , 1 )
661
669
@@ -670,10 +678,16 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
670
678
newServerFn := func (* monitoringCfg.MonitoringConfig ) (reload.ServerController , error ) {
671
679
return monitoringServer , nil
672
680
}
673
- monitoringReloader := reload .NewServerReloader (newServerFn , logger , monitoringCfg .DefaultConfig ())
681
+ monitoringReloader := reload .NewServerReloader (newServerFn , log , monitoringCfg .DefaultConfig ())
682
+
683
+ secretMarkerCalled := false
684
+ mockSecretMarkerFunc := func (* logger.Logger , * config.Config ) error {
685
+ secretMarkerCalled = true
686
+ return nil
687
+ }
674
688
675
689
coord := & Coordinator {
676
- logger : logger ,
690
+ logger : log ,
677
691
agentInfo : & info.AgentInfo {},
678
692
stateBroadcaster : broadcaster .New (State {}, 0 , 0 ),
679
693
managerChans : managerChans {
@@ -683,6 +697,7 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
683
697
otelMgr : & fakeOTelManager {},
684
698
vars : emptyVars (t ),
685
699
componentPIDTicker : time .NewTicker (time .Second * 30 ),
700
+ secretMarkerFunc : mockSecretMarkerFunc ,
686
701
}
687
702
coord .RegisterMonitoringServer (monitoringReloader )
688
703
@@ -703,6 +718,8 @@ inputs:
703
718
coord .runLoopIteration (ctx )
704
719
assert .True (t , cfgChange .acked , "Coordinator should ACK a successful policy change" )
705
720
721
+ assert .True (t , secretMarkerCalled , "secret marker should be called" )
722
+
706
723
// server is started by default
707
724
assert .True (t , monitoringServer .startTriggered )
708
725
assert .True (t , monitoringServer .isRunning )
@@ -822,6 +839,7 @@ func TestCoordinatorPolicyChangeUpdatesRuntimeAndOTelManager(t *testing.T) {
822
839
otelMgr : otelManager ,
823
840
vars : emptyVars (t ),
824
841
componentPIDTicker : time .NewTicker (time .Second * 30 ),
842
+ secretMarkerFunc : testSecretMarkerFunc ,
825
843
}
826
844
827
845
// Create a policy with one input and one output (no otel configuration)
@@ -994,6 +1012,7 @@ func TestCoordinatorPolicyChangeUpdatesRuntimeAndOTelManagerWithOtelComponents(t
994
1012
specs : specs ,
995
1013
vars : emptyVars (t ),
996
1014
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1015
+ secretMarkerFunc : testSecretMarkerFunc ,
997
1016
}
998
1017
999
1018
// Create a policy with one input and one output (no otel configuration)
@@ -1092,6 +1111,7 @@ func TestCoordinatorReportsRuntimeManagerUpdateFailure(t *testing.T) {
1092
1111
1093
1112
vars : emptyVars (t ),
1094
1113
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1114
+ secretMarkerFunc : testSecretMarkerFunc ,
1095
1115
}
1096
1116
1097
1117
// Send an empty policy which should forward an empty component model to
@@ -1153,6 +1173,7 @@ func TestCoordinatorReportsOTelManagerUpdateFailure(t *testing.T) {
1153
1173
otelMgr : otelManager ,
1154
1174
vars : emptyVars (t ),
1155
1175
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1176
+ secretMarkerFunc : testSecretMarkerFunc ,
1156
1177
}
1157
1178
1158
1179
// Send an empty policy which should forward an empty component model to
@@ -1217,6 +1238,7 @@ func TestCoordinatorAppliesVarsToPolicy(t *testing.T) {
1217
1238
otelMgr : & fakeOTelManager {},
1218
1239
vars : emptyVars (t ),
1219
1240
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1241
+ secretMarkerFunc : testSecretMarkerFunc ,
1220
1242
}
1221
1243
1222
1244
// Create a policy with one input and one output
0 commit comments