@@ -1036,8 +1036,9 @@ func TestCoordinatorPolicyChangeUpdatesRuntimeAndOTelManagerWithOtelComponents(t
1036
1036
secretMarkerFunc : testSecretMarkerFunc ,
1037
1037
}
1038
1038
1039
- // Create a policy with one input and one output (no otel configuration)
1040
- cfg := config .MustNewConfigFrom (`
1039
+ t .Run ("mixed policy" , func (t * testing.T ) {
1040
+ // Create a policy with one input and one output (no otel configuration)
1041
+ cfg := config .MustNewConfigFrom (`
1041
1042
outputs:
1042
1043
default:
1043
1044
type: elasticsearch
@@ -1064,38 +1065,87 @@ service:
1064
1065
- nop
1065
1066
` )
1066
1067
1067
- // Send the policy change and make sure it was acknowledged.
1068
- cfgChange := & configChange {cfg : cfg }
1069
- configChan <- cfgChange
1070
- coord .runLoopIteration (ctx )
1071
- assert .True (t , cfgChange .acked , "Coordinator should ACK a successful policy change" )
1072
-
1073
- // Make sure the runtime manager received the expected component update.
1074
- // An assert.Equal on the full component model doesn't play nice with
1075
- // the embedded proto structs, so instead we verify the important fields
1076
- // manually (sorry).
1077
- assert .True (t , updated , "Runtime manager should be updated after a policy change" )
1078
- require .Equal (t , 1 , len (components ), "Test policy should generate one component" )
1079
- assert .True (t , otelUpdated , "OTel manager should be updated after a policy change" )
1080
- require .NotNil (t , otelConfig , "OTel manager should have config" )
1068
+ // Send the policy change and make sure it was acknowledged.
1069
+ cfgChange := & configChange {cfg : cfg }
1070
+ configChan <- cfgChange
1071
+ coord .runLoopIteration (ctx )
1072
+ assert .True (t , cfgChange .acked , "Coordinator should ACK a successful policy change" )
1073
+
1074
+ // Make sure the runtime manager received the expected component update.
1075
+ // An assert.Equal on the full component model doesn't play nice with
1076
+ // the embedded proto structs, so instead we verify the important fields
1077
+ // manually (sorry).
1078
+ assert .True (t , updated , "Runtime manager should be updated after a policy change" )
1079
+ require .Equal (t , 1 , len (components ), "Test policy should generate one component" )
1080
+ assert .True (t , otelUpdated , "OTel manager should be updated after a policy change" )
1081
+ require .NotNil (t , otelConfig , "OTel manager should have config" )
1082
+
1083
+ runtimeComponent := components [0 ]
1084
+ assert .Equal (t , "system/metrics-default" , runtimeComponent .ID )
1085
+ require .NotNil (t , runtimeComponent .Err , "Input with no spec should produce a component error" )
1086
+ assert .Equal (t , "input not supported" , runtimeComponent .Err .Error (), "Input with no spec should report 'input not supported'" )
1087
+ require .Equal (t , 2 , len (runtimeComponent .Units ))
1088
+
1089
+ units := runtimeComponent .Units
1090
+ // Verify the input unit
1091
+ assert .Equal (t , "system/metrics-default-test-other-input" , units [0 ].ID )
1092
+ assert .Equal (t , client .UnitTypeInput , units [0 ].Type )
1093
+ assert .Equal (t , "test-other-input" , units [0 ].Config .Id )
1094
+ assert .Equal (t , "system/metrics" , units [0 ].Config .Type )
1095
+
1096
+ // Verify the output unit
1097
+ assert .Equal (t , "system/metrics-default" , units [1 ].ID )
1098
+ assert .Equal (t , client .UnitTypeOutput , units [1 ].Type )
1099
+ assert .Equal (t , "elasticsearch" , units [1 ].Config .Type )
1100
+ })
1081
1101
1082
- runtimeComponent := components [0 ]
1083
- assert .Equal (t , "system/metrics-default" , runtimeComponent .ID )
1084
- require .NotNil (t , runtimeComponent .Err , "Input with no spec should produce a component error" )
1085
- assert .Equal (t , "input not supported" , runtimeComponent .Err .Error (), "Input with no spec should report 'input not supported'" )
1086
- require .Equal (t , 2 , len (runtimeComponent .Units ))
1102
+ t .Run ("unsupported otel output option" , func (t * testing.T ) {
1103
+ // Create a policy with one input and one output (no otel configuration)
1104
+ cfg := config .MustNewConfigFrom (`
1105
+ outputs:
1106
+ default:
1107
+ type: elasticsearch
1108
+ hosts:
1109
+ - localhost:9200
1110
+ indices: [] # not supported by the elasticsearch exporter
1111
+ inputs:
1112
+ - id: test-input
1113
+ type: filestream
1114
+ use_output: default
1115
+ _runtime_experimental: otel
1116
+ - id: test-other-input
1117
+ type: system/metrics
1118
+ use_output: default
1119
+ receivers:
1120
+ nop:
1121
+ exporters:
1122
+ nop:
1123
+ service:
1124
+ pipelines:
1125
+ traces:
1126
+ receivers:
1127
+ - nop
1128
+ exporters:
1129
+ - nop
1130
+ ` )
1087
1131
1088
- units := runtimeComponent .Units
1089
- // Verify the input unit
1090
- assert .Equal (t , "system/metrics-default-test-other-input" , units [0 ].ID )
1091
- assert .Equal (t , client .UnitTypeInput , units [0 ].Type )
1092
- assert .Equal (t , "test-other-input" , units [0 ].Config .Id )
1093
- assert .Equal (t , "system/metrics" , units [0 ].Config .Type )
1132
+ // Send the policy change and make sure it was acknowledged.
1133
+ cfgChange := & configChange {cfg : cfg }
1134
+ configChan <- cfgChange
1135
+ coord .runLoopIteration (ctx )
1136
+ assert .True (t , cfgChange .acked , "Coordinator should ACK a successful policy change" )
1137
+
1138
+ // Make sure the runtime manager received the expected component update.
1139
+ // An assert.Equal on the full component model doesn't play nice with
1140
+ // the embedded proto structs, so instead we verify the important fields
1141
+ // manually (sorry).
1142
+ assert .True (t , updated , "Runtime manager should be updated after a policy change" )
1143
+ assert .True (t , otelUpdated , "OTel manager should be updated after a policy change" )
1144
+ require .NotNil (t , otelConfig , "OTel manager should have config" )
1145
+
1146
+ assert .Len (t , components , 2 , "both components should be assigned to the runtime manager" )
1147
+ })
1094
1148
1095
- // Verify the output unit
1096
- assert .Equal (t , "system/metrics-default" , units [1 ].ID )
1097
- assert .Equal (t , client .UnitTypeOutput , units [1 ].Type )
1098
- assert .Equal (t , "elasticsearch" , units [1 ].Config .Type )
1099
1149
}
1100
1150
1101
1151
func TestCoordinatorReportsRuntimeManagerUpdateFailure (t * testing.T ) {
0 commit comments