This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathkibana_test.py
852 lines (689 loc) · 21.3 KB
/
kibana_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
import os
import sys
sys.path.insert(1, os.path.join(sys.path[0], "../../helpers"))
from helpers import helm_template
name = "release-name-kibana"
elasticsearchHosts = "https://elasticsearch-master:9200"
def test_defaults():
config = """
"""
r = helm_template(config)
assert name in r["deployment"]
assert name in r["service"]
s = r["service"][name]["spec"]
assert s["ports"][0]["port"] == 5601
assert s["ports"][0]["name"] == "http"
assert s["ports"][0]["protocol"] == "TCP"
assert s["ports"][0]["targetPort"] == 5601
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["name"] == "kibana"
assert c["image"].startswith("docker.elastic.co/kibana/kibana:")
assert c["ports"][0]["containerPort"] == 5601
assert c["env"][0]["name"] == "ELASTICSEARCH_HOSTS"
assert c["env"][0]["value"] == elasticsearchHosts
assert c["env"][1]["name"] == "ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES"
assert c["env"][1]["value"] == "/usr/share/kibana/config/certs/ca.crt"
assert c["env"][2]["name"] == "SERVER_HOST"
assert c["env"][2]["value"] == "0.0.0.0"
assert 'http "/app/kibana"' in c["readinessProbe"]["exec"]["command"][-1]
# Empty customizable defaults
assert "imagePullSecrets" not in r["deployment"][name]["spec"]["template"]["spec"]
assert "tolerations" not in r["deployment"][name]["spec"]["template"]["spec"]
assert "nodeSelector" not in r["deployment"][name]["spec"]["template"]["spec"]
assert "ingress" not in r
assert r["deployment"][name]["spec"]["strategy"]["type"] == "Recreate"
# Make sure that the default 'annotation' dictionary is empty
assert "annotations" not in r["service"][name]["metadata"]
# Make sure that the default 'loadBalancerSourceRanges' list is empty
assert "loadBalancerSourceRanges" not in r["service"][name]["spec"]
# Make sure that the default 'loadBalancerIP' string is empty
assert "loadBalancerIP" not in r["service"][name]["spec"]
assert "hostAliases" not in r["deployment"][name]["spec"]["template"]["spec"]
def test_overriding_the_elasticsearch_hosts():
config = """
elasticsearchHosts: 'http://hello.world'
"""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["env"][0]["name"] == "ELASTICSEARCH_HOSTS"
assert c["env"][0]["value"] == "http://hello.world"
def test_overriding_the_elasticsearch_url():
config = """
elasticsearchURL: 'http://hello.world'
"""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["env"][0]["name"] == "ELASTICSEARCH_URL"
assert c["env"][0]["value"] == "http://hello.world"
def test_overriding_the_port():
config = """
httpPort: 5602
"""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["ports"][0]["containerPort"] == 5602
assert r["service"][name]["spec"]["ports"][0]["targetPort"] == 5602
def test_adding_env_from():
config = """
envFrom:
- secretRef:
name: secret-name
"""
r = helm_template(config)
secretRef = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0][
"envFrom"
][0]["secretRef"]
assert secretRef == {"name": "secret-name"}
def test_adding_an_extra_volume_with_volume_mount():
config = """
extraVolumes:
- name: extras
emptyDir: {}
extraVolumeMounts:
- name: extras
mountPath: /usr/share/extras
readOnly: true
"""
r = helm_template(config)
extraVolume = r["deployment"][name]["spec"]["template"]["spec"]["volumes"]
assert {"name": "extras", "emptyDir": {}} in extraVolume
extraVolumeMounts = r["deployment"][name]["spec"]["template"]["spec"]["containers"][
0
]["volumeMounts"]
assert {
"name": "extras",
"mountPath": "/usr/share/extras",
"readOnly": True,
} in extraVolumeMounts
def test_adding_image_pull_secrets():
config = """
imagePullSecrets:
- name: test-registry
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"]["imagePullSecrets"][0]["name"]
== "test-registry"
)
def test_adding_tolerations():
config = """
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoExecute"
tolerationSeconds: 3600
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"]["tolerations"][0]["key"]
== "key1"
)
def test_adding_a_node_selector():
config = """
nodeSelector:
disktype: ssd
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"]["nodeSelector"]["disktype"]
== "ssd"
)
def test_adding_an_affinity_rule():
config = """
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- kibana
topologyKey: kubernetes.io/hostname
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"]["affinity"][
"podAntiAffinity"
]["requiredDuringSchedulingIgnoredDuringExecution"][0]["topologyKey"]
== "kubernetes.io/hostname"
)
def test_adding_a_extra_container():
config = """
extraContainers: |
- name: do-something
image: busybox
command: ['do', 'something']
"""
r = helm_template(config)
extraContainer = r["deployment"][name]["spec"]["template"]["spec"]["containers"]
assert {
"name": "do-something",
"image": "busybox",
"command": ["do", "something"],
} in extraContainer
def test_adding_a_extra_container_as_yaml():
config = """
extraContainers:
- name: do-something
image: busybox
command: ['do', 'something']
"""
r = helm_template(config)
extraContainer = r["deployment"][name]["spec"]["template"]["spec"]["containers"]
assert {
"name": "do-something",
"image": "busybox",
"command": ["do", "something"],
} in extraContainer
def test_adding_a_extra_init_container():
config = """
extraInitContainers: |
- name: do-something
image: busybox
command: ['do', 'something']
"""
r = helm_template(config)
extraInitContainer = r["deployment"][name]["spec"]["template"]["spec"][
"initContainers"
]
assert {
"name": "do-something",
"image": "busybox",
"command": ["do", "something"],
} in extraInitContainer
def test_adding_a_extra_init_container_as_yaml():
config = """
extraInitContainers:
- name: do-something
image: busybox
command: ['do', 'something']
"""
r = helm_template(config)
extraInitContainer = r["deployment"][name]["spec"]["template"]["spec"][
"initContainers"
]
assert {
"name": "do-something",
"image": "busybox",
"command": ["do", "something"],
} in extraInitContainer
def test_adding_an_ingress_rule():
config = """
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
hosts:
- host: kibana.elastic.co
paths:
- path: /
- path: /testpath
servicePort: 8888
- host: ''
paths:
- path: /
- host: kibana.hello.there
paths:
- path: /mypath
servicePort: 9999
tls:
- secretName: elastic-co-wildcard
hosts:
- kibana.elastic.co
"""
r = helm_template(config)
assert name in r["ingress"]
i = r["ingress"][name]["spec"]
assert i["tls"][0]["hosts"][0] == "kibana.elastic.co"
assert i["tls"][0]["secretName"] == "elastic-co-wildcard"
assert i["rules"][0]["host"] == "kibana.elastic.co"
assert i["rules"][0]["http"]["paths"][0]["path"] == "/"
assert i["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)
assert i["rules"][0]["http"]["paths"][1]["path"] == "/testpath"
assert i["rules"][0]["http"]["paths"][1]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][1]["backend"]["service"]["port"]["number"]
== 8888
)
assert i["rules"][1]["host"] is None
assert i["rules"][1]["http"]["paths"][0]["path"] == "/"
assert i["rules"][1]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][1]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)
assert i["rules"][2]["host"] == "kibana.hello.there"
assert i["rules"][2]["http"]["paths"][0]["path"] == "/mypath"
assert i["rules"][2]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][2]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 9999
)
def test_adding_a_deprecated_ingress_rule():
config = """
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
path: /
hosts:
- kibana.elastic.co
tls:
- secretName: elastic-co-wildcard
hosts:
- kibana.elastic.co
"""
r = helm_template(config)
assert name in r["ingress"]
i = r["ingress"][name]["spec"]
assert i["tls"][0]["hosts"][0] == "kibana.elastic.co"
assert i["tls"][0]["secretName"] == "elastic-co-wildcard"
assert i["rules"][0]["host"] == "kibana.elastic.co"
assert i["rules"][0]["http"]["paths"][0]["path"] == "/"
assert i["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)
def test_adding_an_ingress_rule_wildcard():
config = """
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
hosts:
- host: kibana.elastic.co
paths:
- path: /
tls:
- secretName: elastic-co-wildcard
hosts:
- "*.elastic.co"
"""
r = helm_template(config)
assert name in r["ingress"]
i = r["ingress"][name]["spec"]
assert i["tls"][0]["hosts"][0] == "*.elastic.co"
assert i["tls"][0]["secretName"] == "elastic-co-wildcard"
assert i["rules"][0]["host"] == "kibana.elastic.co"
assert i["rules"][0]["http"]["paths"][0]["path"] == "/"
assert i["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)
def test_adding_a_deprecated_ingress_rule_wildcard():
config = """
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
path: /
hosts:
- kibana.elastic.co
tls:
- secretName: elastic-co-wildcard
hosts:
- "*.elastic.co"
"""
r = helm_template(config)
assert name in r["ingress"]
i = r["ingress"][name]["spec"]
assert i["tls"][0]["hosts"][0] == "*.elastic.co"
assert i["tls"][0]["secretName"] == "elastic-co-wildcard"
assert i["rules"][0]["host"] == "kibana.elastic.co"
assert i["rules"][0]["http"]["paths"][0]["path"] == "/"
assert i["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)
def test_override_the_default_update_strategy():
config = """
updateStrategy:
type: "RollingUpdate"
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
"""
r = helm_template(config)
assert r["deployment"][name]["spec"]["strategy"]["type"] == "RollingUpdate"
assert (
r["deployment"][name]["spec"]["strategy"]["rollingUpdate"]["maxUnavailable"]
== 1
)
assert r["deployment"][name]["spec"]["strategy"]["rollingUpdate"]["maxSurge"] == 1
def test_using_a_name_override():
config = """
nameOverride: overrider
"""
r = helm_template(config)
assert "overrider-kibana" in r["deployment"]
def test_setting_a_custom_service_account():
config = """
serviceAccount: notdefault
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"]["serviceAccount"]
== "notdefault"
)
def test_setting_pod_security_context():
config = """
podSecurityContext:
runAsUser: 1001
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"]["securityContext"][
"runAsUser"
]
== 1001
)
def test_adding_in_kibana_config():
config = """
kibanaConfig:
kibana.yml: |
key:
nestedkey: value
dot.notation: test
other-config.yml: |
hello = world
"""
r = helm_template(config)
c = r["configmap"][name + "-config"]["data"]
assert "kibana.yml" in c
assert "other-config.yml" in c
assert "nestedkey: value" in c["kibana.yml"]
assert "dot.notation: test" in c["kibana.yml"]
assert "hello = world" in c["other-config.yml"]
d = r["deployment"][name]["spec"]["template"]["spec"]
assert {"configMap": {"name": name + "-config"}, "name": "kibanaconfig"} in d[
"volumes"
]
assert {
"mountPath": "/usr/share/kibana/config/kibana.yml",
"name": "kibanaconfig",
"subPath": "kibana.yml",
} in d["containers"][0]["volumeMounts"]
assert {
"mountPath": "/usr/share/kibana/config/other-config.yml",
"name": "kibanaconfig",
"subPath": "other-config.yml",
} in d["containers"][0]["volumeMounts"]
assert (
"configchecksum"
in r["deployment"][name]["spec"]["template"]["metadata"]["annotations"]
)
def test_changing_the_protocol():
config = """
protocol: https
"""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert "https://" in c["readinessProbe"]["exec"]["command"][-1]
def test_changing_the_health_check_path():
config = """
healthCheckPath: "/kibana/app/kibana"
"""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert 'http "/kibana/app/kibana"' in c["readinessProbe"]["exec"]["command"][-1]
def test_priority_class_name():
config = """
priorityClassName: ""
"""
r = helm_template(config)
spec = r["deployment"][name]["spec"]["template"]["spec"]
assert "priorityClassName" not in spec
config = """
priorityClassName: "highest"
"""
r = helm_template(config)
priority_class_name = r["deployment"][name]["spec"]["template"]["spec"][
"priorityClassName"
]
assert priority_class_name == "highest"
def test_service_labels():
config = ""
r = helm_template(config)
assert "label1" not in r["service"][name]["metadata"]["labels"]
config = """
service:
labels:
label1: value1
"""
r = helm_template(config)
assert r["service"][name]["metadata"]["labels"]["label1"] == "value1"
def test_service_annotations():
config = """
service:
annotations:
cloud.google.com/load-balancer-type: "Internal"
"""
r = helm_template(config)
s = r["service"][name]["metadata"]["annotations"][
"cloud.google.com/load-balancer-type"
]
assert s == "Internal"
config = """
service:
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
"""
r = helm_template(config)
s = r["service"][name]["metadata"]["annotations"][
"service.beta.kubernetes.io/aws-load-balancer-internal"
]
assert s == "0.0.0.0/0"
def test_service_load_balancer_source_ranges():
config = """
service:
loadBalancerSourceRanges:
- 0.0.0.0/0
"""
r = helm_template(config)
l = r["service"][name]["spec"]["loadBalancerSourceRanges"][0]
assert l == "0.0.0.0/0"
config = """
service:
loadBalancerSourceRanges:
- 192.168.0.0/24
- 192.168.1.0/24
"""
r = helm_template(config)
l = r["service"][name]["spec"]["loadBalancerSourceRanges"][0]
assert l == "192.168.0.0/24"
l = r["service"][name]["spec"]["loadBalancerSourceRanges"][1]
assert l == "192.168.1.0/24"
def test_adding_a_nodePort():
config = ""
r = helm_template(config)
assert "nodePort" not in r["service"][name]["spec"]["ports"][0]
config = """
service:
nodePort: 30001
"""
r = helm_template(config)
assert r["service"][name]["spec"]["ports"][0]["nodePort"] == 30001
def test_override_the_serverHost():
config = """
serverHost: "localhost"
"""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["env"][2]["name"] == "SERVER_HOST"
assert c["env"][2]["value"] == "localhost"
def test_adding_pod_annotations():
config = """
podAnnotations:
iam.amazonaws.com/role: es-role
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["metadata"]["annotations"][
"iam.amazonaws.com/role"
]
== "es-role"
)
def test_override_imagePullPolicy():
config = ""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["imagePullPolicy"] == "IfNotPresent"
config = """
imagePullPolicy: Always
"""
r = helm_template(config)
c = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["imagePullPolicy"] == "Always"
def test_adding_pod_labels():
config = """
labels:
app.kubernetes.io/name: kibana
"""
r = helm_template(config)
assert (
r["deployment"][name]["metadata"]["labels"]["app.kubernetes.io/name"]
== "kibana"
)
assert (
r["deployment"][name]["spec"]["template"]["metadata"]["labels"][
"app.kubernetes.io/name"
]
== "kibana"
)
def test_service_to_pod_label_selectors():
config = ""
r = helm_template(config)
assert all(
l in r["deployment"][name]["spec"]["template"]["metadata"]["labels"].items()
for l in r["service"][name]["spec"]["selector"].items()
)
def test_service_to_pod_label_selectors_with_custom_labels():
config = """
labels:
app.kubernetes.io/name: kibana
"""
r = helm_template(config)
assert all(
l in r["deployment"][name]["spec"]["template"]["metadata"]["labels"].items()
for l in r["service"][name]["spec"]["selector"].items()
)
def test_adding_a_secret_mount_with_subpath():
config = """
secretMounts:
- name: elastic-certificates
secretName: elastic-certs
path: /usr/share/elasticsearch/config/certs
subPath: cert.crt
"""
r = helm_template(config)
d = r["deployment"][name]["spec"]["template"]["spec"]
assert {
"mountPath": "/usr/share/elasticsearch/config/certs",
"subPath": "cert.crt",
"name": "elastic-certificates",
} in d["containers"][0]["volumeMounts"]
def test_adding_a_secret_mount_without_subpath():
config = """
secretMounts:
- name: elastic-certificates
secretName: elastic-certs
path: /usr/share/elasticsearch/config/certs
"""
r = helm_template(config)
d = r["deployment"][name]["spec"]["template"]["spec"]
assert {
"mountPath": "/usr/share/elasticsearch/config/certs",
"name": "elastic-certificates",
} in d["containers"][0]["volumeMounts"]
def test_adding_lifecycle_events():
config = """
lifecycle:
postStart:
exec:
command: ['/bin/true']
"""
r = helm_template(config)
d = r["deployment"][name]["spec"]["template"]["spec"]
p = d["containers"][0]["lifecycle"]["postStart"]
assert p["exec"]["command"][0] == "/bin/true"
def test_setting_fullnameOverride():
config = """
fullnameOverride: 'kibana-custom'
"""
r = helm_template(config)
custom_name = "kibana-custom"
assert custom_name in r["deployment"]
assert custom_name in r["service"]
assert r["service"][custom_name]["spec"]["ports"][0]["port"] == 5601
assert (
r["deployment"][custom_name]["spec"]["template"]["spec"]["containers"][0][
"name"
]
== "kibana"
)
def test_adding_loadBalancerIP():
config = """
service:
loadBalancerIP: 12.5.11.79
"""
r = helm_template(config)
assert r["service"][name]["spec"]["loadBalancerIP"] == "12.5.11.79"
def test_service_port_name():
r = helm_template("")
config = """
service:
httpPortName: istio
"""
r = helm_template(config)
assert r["service"][name]["spec"]["ports"][0]["name"] == "istio"
def test_hostaliases():
config = """
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "foo.local"
- "bar.local"
"""
r = helm_template(config)
hostAliases = r["deployment"][name]["spec"]["template"]["spec"]["hostAliases"]
assert {"ip": "127.0.0.1", "hostnames": ["foo.local", "bar.local"]} in hostAliases
def test_default_automount_sa_token():
config = """
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"][
"automountServiceAccountToken"
]
is True
)
def test_disable_automount_sa_token():
config = """
automountToken: false
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"][
"automountServiceAccountToken"
]
is False
)
def test_adding_annotations():
config = """
annotations:
iam.amazonaws.com/role: es-role
"""
r = helm_template(config)
assert (
r["deployment"][name]["metadata"]["annotations"]["iam.amazonaws.com/role"]
== "es-role"
)