-
Notifications
You must be signed in to change notification settings - Fork 57
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
Comments
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. |
Hi, |
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. |
Couldn't we auto generate ApiObjects from kubernetes library? 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 |
Would it be possible instead to retrieve the kubernetes client.ApiClient ? Thanks! |
FYI: I've created pykorm, which is a python ORM for kubernetes. It was originally meant for CRDs, but supports native objects too ! Cheers |
Nice @Frankkkkk ! looks good! Do you have an example with kubetest as well? |
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.. |
Will definitely give it a shot! How can I install it though?
|
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 :-) |
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 🙇 |
Hi @guidoiaquinti Nothing from my part on kubetest. We're principally using pykorm for CRD resources now. |
Thank you for the prompt reply @Frankkkkk ! 🙇 |
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
The text was updated successfully, but these errors were encountered: