@@ -29,6 +29,7 @@ func TestInjectPythonSDK(t *testing.T) {
29
29
name string
30
30
v1alpha1.Python
31
31
pod corev1.Pod
32
+ wheelKind string
32
33
expected corev1.Pod
33
34
err error
34
35
}{
@@ -42,6 +43,7 @@ func TestInjectPythonSDK(t *testing.T) {
42
43
},
43
44
},
44
45
},
46
+ wheelKind : "manylinux" ,
45
47
expected : corev1.Pod {
46
48
Spec : corev1.PodSpec {
47
49
Volumes : []corev1.Volume {
@@ -114,6 +116,7 @@ func TestInjectPythonSDK(t *testing.T) {
114
116
},
115
117
},
116
118
},
119
+ wheelKind : "manylinux" ,
117
120
expected : corev1.Pod {
118
121
Spec : corev1.PodSpec {
119
122
Volumes : []corev1.Volume {
@@ -187,6 +190,7 @@ func TestInjectPythonSDK(t *testing.T) {
187
190
},
188
191
},
189
192
},
193
+ wheelKind : "manylinux" ,
190
194
expected : corev1.Pod {
191
195
Spec : corev1.PodSpec {
192
196
Volumes : []corev1.Volume {
@@ -259,6 +263,7 @@ func TestInjectPythonSDK(t *testing.T) {
259
263
},
260
264
},
261
265
},
266
+ wheelKind : "manylinux" ,
262
267
expected : corev1.Pod {
263
268
Spec : corev1.PodSpec {
264
269
Volumes : []corev1.Volume {
@@ -331,6 +336,7 @@ func TestInjectPythonSDK(t *testing.T) {
331
336
},
332
337
},
333
338
},
339
+ wheelKind : "manylinux" ,
334
340
expected : corev1.Pod {
335
341
Spec : corev1.PodSpec {
336
342
Volumes : []corev1.Volume {
@@ -403,6 +409,7 @@ func TestInjectPythonSDK(t *testing.T) {
403
409
},
404
410
},
405
411
},
412
+ wheelKind : "manylinux" ,
406
413
expected : corev1.Pod {
407
414
Spec : corev1.PodSpec {
408
415
Containers : []corev1.Container {
@@ -419,11 +426,163 @@ func TestInjectPythonSDK(t *testing.T) {
419
426
},
420
427
err : fmt .Errorf ("the container defines env var value via ValueFrom, envVar: %s" , envPythonPath ),
421
428
},
429
+ {
430
+ name : "musllinux wheelKind defined" ,
431
+ Python : v1alpha1.Python {Image : "foo/bar:1" },
432
+ pod : corev1.Pod {
433
+ Spec : corev1.PodSpec {
434
+ Containers : []corev1.Container {
435
+ {},
436
+ },
437
+ },
438
+ },
439
+ wheelKind : "musllinux" ,
440
+ expected : corev1.Pod {
441
+ Spec : corev1.PodSpec {
442
+ Volumes : []corev1.Volume {
443
+ {
444
+ Name : pythonVolumeName ,
445
+ VolumeSource : corev1.VolumeSource {
446
+ EmptyDir : & corev1.EmptyDirVolumeSource {
447
+ SizeLimit : & defaultVolumeLimitSize ,
448
+ },
449
+ },
450
+ },
451
+ },
452
+ InitContainers : []corev1.Container {
453
+ {
454
+ Name : "opentelemetry-auto-instrumentation-python" ,
455
+ Image : "foo/bar:1" ,
456
+ Command : []string {"cp" , "-r" , "/autoinstrumentation-musl/." , "/otel-auto-instrumentation-python" },
457
+ VolumeMounts : []corev1.VolumeMount {{
458
+ Name : "opentelemetry-auto-instrumentation-python" ,
459
+ MountPath : "/otel-auto-instrumentation-python" ,
460
+ }},
461
+ },
462
+ },
463
+ Containers : []corev1.Container {
464
+ {
465
+ VolumeMounts : []corev1.VolumeMount {
466
+ {
467
+ Name : "opentelemetry-auto-instrumentation-python" ,
468
+ MountPath : "/otel-auto-instrumentation-python" ,
469
+ },
470
+ },
471
+ Env : []corev1.EnvVar {
472
+ {
473
+ Name : "PYTHONPATH" ,
474
+ Value : fmt .Sprintf ("%s:%s" , "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation" , "/otel-auto-instrumentation-python" ),
475
+ },
476
+ {
477
+ Name : "OTEL_EXPORTER_OTLP_PROTOCOL" ,
478
+ Value : "http/protobuf" ,
479
+ },
480
+ {
481
+ Name : "OTEL_TRACES_EXPORTER" ,
482
+ Value : "otlp" ,
483
+ },
484
+ {
485
+ Name : "OTEL_METRICS_EXPORTER" ,
486
+ Value : "otlp" ,
487
+ },
488
+ },
489
+ },
490
+ },
491
+ },
492
+ },
493
+ err : nil ,
494
+ },
495
+ {
496
+ name : "wheelKind not defined" ,
497
+ Python : v1alpha1.Python {Image : "foo/bar:1" },
498
+ pod : corev1.Pod {
499
+ Spec : corev1.PodSpec {
500
+ Containers : []corev1.Container {
501
+ {},
502
+ },
503
+ },
504
+ },
505
+ wheelKind : "" ,
506
+ expected : corev1.Pod {
507
+ Spec : corev1.PodSpec {
508
+ Volumes : []corev1.Volume {
509
+ {
510
+ Name : pythonVolumeName ,
511
+ VolumeSource : corev1.VolumeSource {
512
+ EmptyDir : & corev1.EmptyDirVolumeSource {
513
+ SizeLimit : & defaultVolumeLimitSize ,
514
+ },
515
+ },
516
+ },
517
+ },
518
+ InitContainers : []corev1.Container {
519
+ {
520
+ Name : "opentelemetry-auto-instrumentation-python" ,
521
+ Image : "foo/bar:1" ,
522
+ Command : []string {"cp" , "-r" , "/autoinstrumentation/." , "/otel-auto-instrumentation-python" },
523
+ VolumeMounts : []corev1.VolumeMount {{
524
+ Name : "opentelemetry-auto-instrumentation-python" ,
525
+ MountPath : "/otel-auto-instrumentation-python" ,
526
+ }},
527
+ },
528
+ },
529
+ Containers : []corev1.Container {
530
+ {
531
+ VolumeMounts : []corev1.VolumeMount {
532
+ {
533
+ Name : "opentelemetry-auto-instrumentation-python" ,
534
+ MountPath : "/otel-auto-instrumentation-python" ,
535
+ },
536
+ },
537
+ Env : []corev1.EnvVar {
538
+ {
539
+ Name : "PYTHONPATH" ,
540
+ Value : fmt .Sprintf ("%s:%s" , "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation" , "/otel-auto-instrumentation-python" ),
541
+ },
542
+ {
543
+ Name : "OTEL_EXPORTER_OTLP_PROTOCOL" ,
544
+ Value : "http/protobuf" ,
545
+ },
546
+ {
547
+ Name : "OTEL_TRACES_EXPORTER" ,
548
+ Value : "otlp" ,
549
+ },
550
+ {
551
+ Name : "OTEL_METRICS_EXPORTER" ,
552
+ Value : "otlp" ,
553
+ },
554
+ },
555
+ },
556
+ },
557
+ },
558
+ },
559
+ err : nil ,
560
+ },
561
+ {
562
+ name : "wheelKind not supported" ,
563
+ Python : v1alpha1.Python {Image : "foo/bar:1" },
564
+ pod : corev1.Pod {
565
+ Spec : corev1.PodSpec {
566
+ Containers : []corev1.Container {
567
+ {},
568
+ },
569
+ },
570
+ },
571
+ wheelKind : "not supported" ,
572
+ expected : corev1.Pod {
573
+ Spec : corev1.PodSpec {
574
+ Containers : []corev1.Container {
575
+ {},
576
+ },
577
+ },
578
+ },
579
+ err : fmt .Errorf ("provided instrumentation.opentelemetry.io/python-wheel-kind annotation value 'not supported' is not supported" ),
580
+ },
422
581
}
423
582
424
583
for _ , test := range tests {
425
584
t .Run (test .name , func (t * testing.T ) {
426
- pod , err := injectPythonSDK (test .Python , test .pod , 0 )
585
+ pod , err := injectPythonSDK (test .Python , test .pod , 0 , test . wheelKind )
427
586
assert .Equal (t , test .expected , pod )
428
587
assert .Equal (t , test .err , err )
429
588
})
0 commit comments