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