def test_should_support_annotations(self): docs = render_chart( values={"createUserJob": {"annotations": {"foo": "bar"}}}, show_only=["templates/jobs/create-user-job.yaml"], ) annotations = jmespath.search("spec.template.metadata.annotations", docs[0]) assert "foo" in annotations assert "bar" == annotations["foo"]
def test_limit_ranges_template(self): docs = render_chart( values={ "limits": [{ "max": { "cpu": "500m" }, "min": { "min": "200m" }, "type": "Container" }] }, show_only=["templates/limitrange.yaml"], ) assert "LimitRange" == jmespath.search("kind", docs[0]) assert "500m" == jmespath.search("spec.limits[0].max.cpu", docs[0])
def test_resource_quota_template(self): docs = render_chart( values={ "quotas": { "configmaps": "10", "persistentvolumeclaims": "4", "pods": "4", "replicationcontrollers": "20", "secrets": "10", "services": "10", } }, show_only=["templates/resourcequota.yaml"], ) assert "ResourceQuota" == jmespath.search("kind", docs[0]) assert "20" == jmespath.search("spec.hard.replicationcontrollers", docs[0])
def test_should_create_valid_affinity_tolerations_and_node_selector(self): docs = render_chart( values={ "createUserJob": { "affinity": { "nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [ { "matchExpressions": [ {"key": "foo", "operator": "In", "values": ["true"]}, ] } ] } } }, "tolerations": [ {"key": "dynamic-pods", "operator": "Equal", "value": "true", "effect": "NoSchedule"} ], "nodeSelector": {"diskType": "ssd"}, } }, show_only=["templates/jobs/create-user-job.yaml"], ) assert "Job" == jmespath.search("kind", docs[0]) assert "foo" == jmespath.search( "spec.template.spec.affinity.nodeAffinity." "requiredDuringSchedulingIgnoredDuringExecution." "nodeSelectorTerms[0]." "matchExpressions[0]." "key", docs[0], ) assert "ssd" == jmespath.search( "spec.template.spec.nodeSelector.diskType", docs[0], ) assert "dynamic-pods" == jmespath.search( "spec.template.spec.tolerations[0].key", docs[0], )
def test_should_run_by_default(self): docs = render_chart(show_only=["templates/jobs/create-user-job.yaml"]) assert "create-user" == jmespath.search("spec.template.spec.containers[0].name", docs[0]) assert 50000 == jmespath.search("spec.template.spec.securityContext.runAsUser", docs[0])
def test_limit_ranges_are_not_added_by_default(self): docs = render_chart(show_only=["templates/limitrange.yaml"]) assert docs == []
def test_resource_quota_are_not_added_by_default(self): docs = render_chart(show_only=["templates/resourcequota.yaml"], ) assert docs == []