@@ -41,10 +41,16 @@ import (
41
41
"github.com/elastic/elastic-agent/pkg/component"
42
42
"github.com/elastic/elastic-agent/pkg/component/runtime"
43
43
agentclient "github.com/elastic/elastic-agent/pkg/control/v2/client"
44
+ "github.com/elastic/elastic-agent/pkg/core/logger"
44
45
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
45
46
"github.com/elastic/elastic-agent/pkg/utils/broadcaster"
46
47
)
47
48
49
+ var testSecretMarkerFunc = func (* logger.Logger , * config.Config ) error {
50
+ // no-op secret marker function for testing
51
+ return nil
52
+ }
53
+
48
54
func TestVarsManagerError (t * testing.T ) {
49
55
// Set a one-second timeout -- nothing here should block, but if it
50
56
// does let's report a failure instead of timing out the test runner.
@@ -475,6 +481,7 @@ func TestCoordinatorReportsInvalidPolicy(t *testing.T) {
475
481
vars : emptyVars (t ),
476
482
ast : emptyAST (t ),
477
483
componentPIDTicker : time .NewTicker (time .Second * 30 ),
484
+ secretMarkerFunc : testSecretMarkerFunc ,
478
485
}
479
486
480
487
// Send an invalid config update and confirm that Coordinator reports
@@ -591,6 +598,7 @@ func TestCoordinatorReportsComponentModelError(t *testing.T) {
591
598
vars : emptyVars (t ),
592
599
ast : emptyAST (t ),
593
600
componentPIDTicker : time .NewTicker (time .Second * 30 ),
601
+ secretMarkerFunc : testSecretMarkerFunc ,
594
602
}
595
603
596
604
// This configuration produces a valid AST but its EQL condition is
@@ -659,7 +667,7 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
659
667
// does let's report a failure instead of timing out the test runner.
660
668
ctx , cancel := context .WithTimeout (context .Background (), time .Second )
661
669
defer cancel ()
662
- logger := logp .NewLogger ("testing" )
670
+ log := logp .NewLogger ("testing" )
663
671
664
672
configChan := make (chan ConfigChange , 1 )
665
673
@@ -674,10 +682,16 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
674
682
newServerFn := func (* monitoringCfg.MonitoringConfig ) (reload.ServerController , error ) {
675
683
return monitoringServer , nil
676
684
}
677
- monitoringReloader := reload .NewServerReloader (newServerFn , logger , monitoringCfg .DefaultConfig ())
685
+ monitoringReloader := reload .NewServerReloader (newServerFn , log , monitoringCfg .DefaultConfig ())
686
+
687
+ secretMarkerCalled := false
688
+ mockSecretMarkerFunc := func (* logger.Logger , * config.Config ) error {
689
+ secretMarkerCalled = true
690
+ return nil
691
+ }
678
692
679
693
coord := & Coordinator {
680
- logger : logger ,
694
+ logger : log ,
681
695
agentInfo : & info.AgentInfo {},
682
696
stateBroadcaster : broadcaster .New (State {}, 0 , 0 ),
683
697
managerChans : managerChans {
@@ -687,6 +701,7 @@ func TestCoordinatorPolicyChangeUpdatesMonitorReloader(t *testing.T) {
687
701
otelMgr : & fakeOTelManager {},
688
702
vars : emptyVars (t ),
689
703
componentPIDTicker : time .NewTicker (time .Second * 30 ),
704
+ secretMarkerFunc : mockSecretMarkerFunc ,
690
705
}
691
706
coord .RegisterMonitoringServer (monitoringReloader )
692
707
@@ -707,6 +722,8 @@ inputs:
707
722
coord .runLoopIteration (ctx )
708
723
assert .True (t , cfgChange .acked , "Coordinator should ACK a successful policy change" )
709
724
725
+ assert .True (t , secretMarkerCalled , "secret marker should be called" )
726
+
710
727
// server is started by default
711
728
assert .True (t , monitoringServer .startTriggered )
712
729
assert .True (t , monitoringServer .isRunning )
@@ -826,6 +843,7 @@ func TestCoordinatorPolicyChangeUpdatesRuntimeAndOTelManager(t *testing.T) {
826
843
otelMgr : otelManager ,
827
844
vars : emptyVars (t ),
828
845
componentPIDTicker : time .NewTicker (time .Second * 30 ),
846
+ secretMarkerFunc : testSecretMarkerFunc ,
829
847
}
830
848
831
849
// Create a policy with one input and one output (no otel configuration)
@@ -998,6 +1016,7 @@ func TestCoordinatorPolicyChangeUpdatesRuntimeAndOTelManagerWithOtelComponents(t
998
1016
specs : specs ,
999
1017
vars : emptyVars (t ),
1000
1018
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1019
+ secretMarkerFunc : testSecretMarkerFunc ,
1001
1020
}
1002
1021
1003
1022
// Create a policy with one input and one output (no otel configuration)
@@ -1096,6 +1115,7 @@ func TestCoordinatorReportsRuntimeManagerUpdateFailure(t *testing.T) {
1096
1115
1097
1116
vars : emptyVars (t ),
1098
1117
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1118
+ secretMarkerFunc : testSecretMarkerFunc ,
1099
1119
}
1100
1120
1101
1121
// Send an empty policy which should forward an empty component model to
@@ -1157,6 +1177,7 @@ func TestCoordinatorReportsOTelManagerUpdateFailure(t *testing.T) {
1157
1177
otelMgr : otelManager ,
1158
1178
vars : emptyVars (t ),
1159
1179
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1180
+ secretMarkerFunc : testSecretMarkerFunc ,
1160
1181
}
1161
1182
1162
1183
// Send an empty policy which should forward an empty component model to
@@ -1221,6 +1242,7 @@ func TestCoordinatorAppliesVarsToPolicy(t *testing.T) {
1221
1242
otelMgr : & fakeOTelManager {},
1222
1243
vars : emptyVars (t ),
1223
1244
componentPIDTicker : time .NewTicker (time .Second * 30 ),
1245
+ secretMarkerFunc : testSecretMarkerFunc ,
1224
1246
}
1225
1247
1226
1248
// Create a policy with one input and one output
0 commit comments