@@ -179,6 +179,120 @@ func TestInjectNodeJSSDK(t *testing.T) {
179
179
},
180
180
err : fmt .Errorf ("the container defines env var value via ValueFrom, envVar: %s" , envNodeOptions ),
181
181
},
182
+ {
183
+ name : "NODE_OPTIONS not defined and UseImport true" ,
184
+ NodeJS : v1alpha1.NodeJS {Image : "foo/bar:1" , UseImport : true },
185
+ pod : corev1.Pod {
186
+ Spec : corev1.PodSpec {
187
+ Containers : []corev1.Container {
188
+ {},
189
+ },
190
+ },
191
+ },
192
+ expected : corev1.Pod {
193
+ Spec : corev1.PodSpec {
194
+ Volumes : []corev1.Volume {
195
+ {
196
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
197
+ VolumeSource : corev1.VolumeSource {
198
+ EmptyDir : & corev1.EmptyDirVolumeSource {
199
+ SizeLimit : & defaultVolumeLimitSize ,
200
+ },
201
+ },
202
+ },
203
+ },
204
+ InitContainers : []corev1.Container {
205
+ {
206
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
207
+ Image : "foo/bar:1" ,
208
+ Command : []string {"cp" , "-r" , "/autoinstrumentation/." , "/otel-auto-instrumentation-nodejs" },
209
+ VolumeMounts : []corev1.VolumeMount {{
210
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
211
+ MountPath : "/otel-auto-instrumentation-nodejs" ,
212
+ }},
213
+ },
214
+ },
215
+ Containers : []corev1.Container {
216
+ {
217
+ VolumeMounts : []corev1.VolumeMount {
218
+ {
219
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
220
+ MountPath : "/otel-auto-instrumentation-nodejs" ,
221
+ },
222
+ },
223
+ Env : []corev1.EnvVar {
224
+ {
225
+ Name : "NODE_OPTIONS" ,
226
+ Value : " --import /otel-auto-instrumentation-nodejs/autoinstrumentation.mjs" ,
227
+ },
228
+ },
229
+ },
230
+ },
231
+ },
232
+ },
233
+ err : nil ,
234
+ },
235
+ {
236
+ name : "NODE_OPTIONS defined and UseImport true" ,
237
+ NodeJS : v1alpha1.NodeJS {Image : "foo/bar:1" , Resources : testResourceRequirements , UseImport : true },
238
+ pod : corev1.Pod {
239
+ Spec : corev1.PodSpec {
240
+ Containers : []corev1.Container {
241
+ {
242
+ Env : []corev1.EnvVar {
243
+ {
244
+ Name : "NODE_OPTIONS" ,
245
+ Value : "-Dbaz=bar" ,
246
+ },
247
+ },
248
+ },
249
+ },
250
+ },
251
+ },
252
+ expected : corev1.Pod {
253
+ Spec : corev1.PodSpec {
254
+ Volumes : []corev1.Volume {
255
+ {
256
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
257
+ VolumeSource : corev1.VolumeSource {
258
+ EmptyDir : & corev1.EmptyDirVolumeSource {
259
+ SizeLimit : & defaultVolumeLimitSize ,
260
+ },
261
+ },
262
+ },
263
+ },
264
+ InitContainers : []corev1.Container {
265
+ {
266
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
267
+ Image : "foo/bar:1" ,
268
+ Command : []string {"cp" , "-r" , "/autoinstrumentation/." , "/otel-auto-instrumentation-nodejs" },
269
+ VolumeMounts : []corev1.VolumeMount {{
270
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
271
+ MountPath : "/otel-auto-instrumentation-nodejs" ,
272
+ }},
273
+ Resources : testResourceRequirements ,
274
+ },
275
+ },
276
+ Containers : []corev1.Container {
277
+ {
278
+ VolumeMounts : []corev1.VolumeMount {
279
+ {
280
+ Name : "opentelemetry-auto-instrumentation-nodejs" ,
281
+ MountPath : "/otel-auto-instrumentation-nodejs" ,
282
+ },
283
+ },
284
+ Env : []corev1.EnvVar {
285
+ {
286
+ Name : "NODE_OPTIONS" ,
287
+ Value : "-Dbaz=bar" + " --import /otel-auto-instrumentation-nodejs/autoinstrumentation.mjs" ,
288
+ },
289
+ },
290
+ },
291
+ },
292
+ },
293
+ },
294
+ err : nil ,
295
+ },
182
296
}
183
297
184
298
for _ , test := range tests {
0 commit comments