https://pulumi.com logo
Title
d

dry-salesmen-32588

05/05/2022, 3:57 PM
might have found a bug in pulumis python test setup - seems to be related to helm template rendering - who is available to discuss this
e

echoing-dinner-19531

05/05/2022, 4:01 PM
Feel free to open a github issue to discuss it. We've got the community summit currently running so probably don't have anyone synchronously available.
d

dry-salesmen-32588

05/05/2022, 4:02 PM
ill be happy to report it to github, - but could also be a simple error on my behalf tho. running a simple unittest script:
import unittest
import pulumi

class MyMocks(pulumi.runtime.Mocks):
    def new_resource(self, args: pulumi.runtime.MockResourceArgs):
        return [args.name + '_id', args.inputs]
    def call(self, args: pulumi.runtime.MockCallArgs):
        return {}

pulumi.runtime.set_mocks(MyMocks())

import infrastructure.infrastructure as infrastructure

class TestingWithMocks(unittest.TestCase):

    @pulumi.runtime.test
    def test_kms_key(self):        
        def check_deletionwindow(args):
            deletionwindow = args[0]
            shouldbe = 10
            self.assertEqual(deletionwindow, shouldbe, "deletion windows must be = '10'")

        return pulumi.Output.all(infrastructure.kmskey.deletion_window_in_days).apply(check_deletionwindow)
where my infrastructure does aws resources and kubernetes helm resource rendering the error reported by pytest is (seems to be failing at rendering a helm chart):
...
------
x = '{"namespace": "vault_id", "include_test_hook_resources": null, "skip_crd_rendering": null, "skip_await": null, "value... "1.15.8", "fetch_opts": {"repo": "<https://kubernetes-charts.banzaicloud.com>"}, "release_name": "banzaivaultinjector"}'

>   objects = json_opts.apply(lambda x: pulumi.runtime.invoke('kubernetes:helm:template',
                                                              {'jsonOpts': x}, invoke_opts).value['result'])
E   TypeError: 'NoneType' object is not subscriptable

../../../.local/lib/python3.8/site-packages/pulumi_kubernetes/helm/v3/helm.py:598: TypeError
============ short test summary info ==========================
FAILED test_unittest.py::TestingWithMocks::test_kms_key - TypeError: 'NoneType' object is not subscriptable
============ 1 failed, 58 warnings in 7.21s =======================
the helm render it seems to be failing at is here (snippet from my infrastructure.py)
banzaivaultinjectorchart = Chart(
    "banzaivaultinjector", 
    ChartOpts(
        chart="vault-secrets-webhook",
        version="1.15.8",
        namespace=namespace.id,
        fetch_opts= FetchOpts(
            repo="<https://kubernetes-charts.banzaicloud.com>",
        ),
        values={"debug": False}
    ),
    ResourceOptions(provider=k8s_provider, depends_on=[vaultchart], custom_timeouts=CustomTimeouts(create='1m'))
)
theres a dependency on a previous chart (hashicorp vault), and using a simple kubeconfig context provider
if you want this info copy pasted to github ill be happy to do so
v

victorious-continent-984

05/05/2022, 4:59 PM
I’ve faced the same issue but for yaml.ConfigFile resource. in the line:
__ret__ = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts).value['result']
Seems that the issue might be related to the fact that those resources based of
pulumi.ComponentResource
.
e

echoing-dinner-19531

05/06/2022, 12:26 PM
Yeh can you raise this on github, I don't know the unit testing library well enough for say for sure if this is a bug or user error, but it looks like its probably a bug with handling component vs custom calls.