@@ -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 {
@@ -118,6 +120,7 @@ func TestInjectPythonSDK(t *testing.T) {
118
120
},
119
121
},
120
122
},
123
+ wheelKind : "manylinux" ,
121
124
expected : corev1.Pod {
122
125
Spec : corev1.PodSpec {
123
126
Volumes : []corev1.Volume {
@@ -195,6 +198,7 @@ func TestInjectPythonSDK(t *testing.T) {
195
198
},
196
199
},
197
200
},
201
+ wheelKind : "manylinux" ,
198
202
expected : corev1.Pod {
199
203
Spec : corev1.PodSpec {
200
204
Volumes : []corev1.Volume {
@@ -271,6 +275,7 @@ func TestInjectPythonSDK(t *testing.T) {
271
275
},
272
276
},
273
277
},
278
+ wheelKind : "manylinux" ,
274
279
expected : corev1.Pod {
275
280
Spec : corev1.PodSpec {
276
281
Volumes : []corev1.Volume {
@@ -423,6 +428,7 @@ func TestInjectPythonSDK(t *testing.T) {
423
428
},
424
429
},
425
430
},
431
+ wheelKind : "manylinux" ,
426
432
expected : corev1.Pod {
427
433
Spec : corev1.PodSpec {
428
434
Volumes : []corev1.Volume {
@@ -499,6 +505,7 @@ func TestInjectPythonSDK(t *testing.T) {
499
505
},
500
506
},
501
507
},
508
+ wheelKind : "manylinux" ,
502
509
expected : corev1.Pod {
503
510
Spec : corev1.PodSpec {
504
511
Containers : []corev1.Container {
@@ -515,11 +522,163 @@ func TestInjectPythonSDK(t *testing.T) {
515
522
},
516
523
err : fmt .Errorf ("the container defines env var value via ValueFrom, envVar: %s" , envPythonPath ),
517
524
},
525
+ {
526
+ name : "musllinux wheelKind defined" ,
527
+ Python : v1alpha1.Python {Image : "foo/bar:1" },
528
+ pod : corev1.Pod {
529
+ Spec : corev1.PodSpec {
530
+ Containers : []corev1.Container {
531
+ {},
532
+ },
533
+ },
534
+ },
535
+ wheelKind : "musllinux" ,
536
+ expected : corev1.Pod {
537
+ Spec : corev1.PodSpec {
538
+ Volumes : []corev1.Volume {
539
+ {
540
+ Name : pythonVolumeName ,
541
+ VolumeSource : corev1.VolumeSource {
542
+ EmptyDir : & corev1.EmptyDirVolumeSource {
543
+ SizeLimit : & defaultVolumeLimitSize ,
544
+ },
545
+ },
546
+ },
547
+ },
548
+ InitContainers : []corev1.Container {
549
+ {
550
+ Name : "opentelemetry-auto-instrumentation-python" ,
551
+ Image : "foo/bar:1" ,
552
+ Command : []string {"cp" , "-r" , "/autoinstrumentation-musl/." , "/otel-auto-instrumentation-python" },
553
+ VolumeMounts : []corev1.VolumeMount {{
554
+ Name : "opentelemetry-auto-instrumentation-python" ,
555
+ MountPath : "/otel-auto-instrumentation-python" ,
556
+ }},
557
+ },
558
+ },
559
+ Containers : []corev1.Container {
560
+ {
561
+ VolumeMounts : []corev1.VolumeMount {
562
+ {
563
+ Name : "opentelemetry-auto-instrumentation-python" ,
564
+ MountPath : "/otel-auto-instrumentation-python" ,
565
+ },
566
+ },
567
+ Env : []corev1.EnvVar {
568
+ {
569
+ Name : "PYTHONPATH" ,
570
+ Value : fmt .Sprintf ("%s:%s" , "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation" , "/otel-auto-instrumentation-python" ),
571
+ },
572
+ {
573
+ Name : "OTEL_EXPORTER_OTLP_PROTOCOL" ,
574
+ Value : "http/protobuf" ,
575
+ },
576
+ {
577
+ Name : "OTEL_TRACES_EXPORTER" ,
578
+ Value : "otlp" ,
579
+ },
580
+ {
581
+ Name : "OTEL_METRICS_EXPORTER" ,
582
+ Value : "otlp" ,
583
+ },
584
+ },
585
+ },
586
+ },
587
+ },
588
+ },
589
+ err : nil ,
590
+ },
591
+ {
592
+ name : "wheelKind not defined" ,
593
+ Python : v1alpha1.Python {Image : "foo/bar:1" },
594
+ pod : corev1.Pod {
595
+ Spec : corev1.PodSpec {
596
+ Containers : []corev1.Container {
597
+ {},
598
+ },
599
+ },
600
+ },
601
+ wheelKind : "" ,
602
+ expected : corev1.Pod {
603
+ Spec : corev1.PodSpec {
604
+ Volumes : []corev1.Volume {
605
+ {
606
+ Name : pythonVolumeName ,
607
+ VolumeSource : corev1.VolumeSource {
608
+ EmptyDir : & corev1.EmptyDirVolumeSource {
609
+ SizeLimit : & defaultVolumeLimitSize ,
610
+ },
611
+ },
612
+ },
613
+ },
614
+ InitContainers : []corev1.Container {
615
+ {
616
+ Name : "opentelemetry-auto-instrumentation-python" ,
617
+ Image : "foo/bar:1" ,
618
+ Command : []string {"cp" , "-r" , "/autoinstrumentation/." , "/otel-auto-instrumentation-python" },
619
+ VolumeMounts : []corev1.VolumeMount {{
620
+ Name : "opentelemetry-auto-instrumentation-python" ,
621
+ MountPath : "/otel-auto-instrumentation-python" ,
622
+ }},
623
+ },
624
+ },
625
+ Containers : []corev1.Container {
626
+ {
627
+ VolumeMounts : []corev1.VolumeMount {
628
+ {
629
+ Name : "opentelemetry-auto-instrumentation-python" ,
630
+ MountPath : "/otel-auto-instrumentation-python" ,
631
+ },
632
+ },
633
+ Env : []corev1.EnvVar {
634
+ {
635
+ Name : "PYTHONPATH" ,
636
+ Value : fmt .Sprintf ("%s:%s" , "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation" , "/otel-auto-instrumentation-python" ),
637
+ },
638
+ {
639
+ Name : "OTEL_EXPORTER_OTLP_PROTOCOL" ,
640
+ Value : "http/protobuf" ,
641
+ },
642
+ {
643
+ Name : "OTEL_TRACES_EXPORTER" ,
644
+ Value : "otlp" ,
645
+ },
646
+ {
647
+ Name : "OTEL_METRICS_EXPORTER" ,
648
+ Value : "otlp" ,
649
+ },
650
+ },
651
+ },
652
+ },
653
+ },
654
+ },
655
+ err : nil ,
656
+ },
657
+ {
658
+ name : "wheelKind not supported" ,
659
+ Python : v1alpha1.Python {Image : "foo/bar:1" },
660
+ pod : corev1.Pod {
661
+ Spec : corev1.PodSpec {
662
+ Containers : []corev1.Container {
663
+ {},
664
+ },
665
+ },
666
+ },
667
+ wheelKind : "not supported" ,
668
+ expected : corev1.Pod {
669
+ Spec : corev1.PodSpec {
670
+ Containers : []corev1.Container {
671
+ {},
672
+ },
673
+ },
674
+ },
675
+ err : fmt .Errorf ("provided instrumentation.opentelemetry.io/python-wheel-kind annotation value 'not supported' is not supported" ),
676
+ },
518
677
}
519
678
520
679
for _ , test := range tests {
521
680
t .Run (test .name , func (t * testing.T ) {
522
- pod , err := injectPythonSDK (test .Python , test .pod , 0 )
681
+ pod , err := injectPythonSDK (test .Python , test .pod , 0 , test . wheelKind )
523
682
assert .Equal (t , test .expected , pod )
524
683
assert .Equal (t , test .err , err )
525
684
})
0 commit comments