Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test CRD's #158

Open
Frankkkkk opened this issue Dec 23, 2019 · 14 comments
Open

How to test CRD's #158

Frankkkkk opened this issue Dec 23, 2019 · 14 comments
Labels
enhancement New feature or request

Comments

@Frankkkkk
Copy link

Hi,
First of all, thanks for your library, it's great !

We'd like to tests our custom CRDs + Custom Resources with kubetest.

When created our custom resources automatically create some services, pods, etc. These can be tested with kubetest methods, but how can we test the existence/metadata of these custom resources themselves ?

I'd be willing to create some more definitions (i.e. objects/customresources.py and objects/customresourcedefinition.py), but do you think that it would be the right choice ?

Thanks,
Cheers

@edaniszewski
Copy link
Contributor

Hi, thanks for the question and for using the library! The idea of adding support for CRDs + Custom Resources sounds great to me. I haven't personally dealt with CRDs very much, but from my knowledge of them and a quick reading on the CRD docs, I think having additional definitions like you mentioned (object/customresources, ...) makes sense.

If you want to work on support for this, or get that work started, that would be awesome! I could eventually work on adding support for it as well, but it may take a little while to get started on it.

@edaniszewski edaniszewski added the enhancement New feature or request label Dec 26, 2019
@Frankkkkk
Copy link
Author

Hi,
It's "good" to see that nobody's working on it for now. I'll probably start implementing these features in January as we'll need them ;-) I'll ping you once that I have a working POC.
Cheers,

@Frankkkkk
Copy link
Author

FYI: I'm putting my work on hold for some weeks because of:

It's already implemented on python openshift's API https://github.com/openshift/openshift-restclient-python and with some hope should be soon implemented in kubernetes' API.

@bukowa
Copy link
Contributor

bukowa commented Jan 19, 2020

Couldn't we auto generate ApiObjects from kubernetes library?
All of this looks very generic. Maybe ApiObjects can be made more generic also.

    def load_configmap(self, path, set_namespace=True):
        """Load a manifest YAML into a ConfigMap object.

        By default, this will augment the ConfigMap object with
        the generated test case namespace. This behavior can be
        disabled with the ``set_namespace`` flag.

        Args:
            path (str): The path to the ConfigMap manifest.
            set_namespace (bool): Enable/disable the automatic
                augmentation of the ConfigMap namespace.

        Returns:
            objects.ConfigMap: The ConfigMap for the specified manifest.
        """
        log.info('loading configmap from path: %s', path)
        configmap = objects.ConfigMap.load(path)
        if set_namespace:
            configmap.namespace = self.namespace
        return configmap

    def load_deployment(self, path, set_namespace=True):
        """Load a manifest YAML into a Deployment object.

        By default, this will augment the Deployment object with
        the generated test case namespace. This behavior can be
        disabled with the ``set_namespace`` flag.

        Args:
            path (str): The path to the Deployment manifest.
            set_namespace (bool): Enable/disable the automatic
                augmentation of the Deployment namespace.

        Returns:
            objects.Deployment: The Deployment for the specified manifest.
        """
        log.info('loading deployment from path: %s', path)
        deployment = objects.Deployment.load(path)
        if set_namespace:
            deployment.namespace = self.namespace
        return deployment

@YiannisGkoufas
Copy link

Would it be possible instead to retrieve the kubernetes client.ApiClient ?
So then we would at least create/delete CRDs like it's described here: kubernetes-client/python#740

Thanks!

@Frankkkkk
Copy link
Author

FYI: I've created pykorm, which is a python ORM for kubernetes. It was originally meant for CRDs, but supports native objects too !

Cheers

@YiannisGkoufas
Copy link

Nice @Frankkkkk ! looks good! Do you have an example with kubetest as well?

@Frankkkkk
Copy link
Author

There's an example from pykorm's tests: https://github.com/Frankkkkk/pykorm/blob/master/tests/test_filter.py#L4

It's not fully integrated yet into kubetest, sadly. I should propose a MR someday but sadly my priorities aren't these for the moment..

@YiannisGkoufas
Copy link

Will definitely give it a shot! How can I install it though? pip install pykorm fails with:

ERROR: Could not find a version that satisfies the requirement pykorm
ERROR: No matching distribution found for pykorm

@Frankkkkk
Copy link
Author

Maybe you're using python <= 3.6 (pykorm is python >= 3.7) ? Don't hesitate to open an issue there so we can't track the bug :-)

@eshepelyuk
Copy link

Hello, is there any improvements on this issue, except the link from above ?
https://github.com/Frankkkkk/pykorm/blob/master/tests/test_filter.py#L4

@guidoiaquinti
Copy link

guidoiaquinti commented Dec 10, 2021

Hello, is there any improvements on this issue, except the link from above ?

Bump on this. @Frankkkkk can you provide an update on this when you have some time? I can also try to tackle this once I know the status 🙇

@Frankkkkk
Copy link
Author

Hi @guidoiaquinti Nothing from my part on kubetest. We're principally using pykorm for CRD resources now.
Cheers !

@guidoiaquinti
Copy link

Thank you for the prompt reply @Frankkkkk ! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants