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

Add crd support #109

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

siaomingjeng
Copy link
Contributor

@siaomingjeng siaomingjeng commented Jun 23, 2022

Add Custom Resource Definition (CRD)

Following the existing Custom Resource Object functions to add support for CRD read and list.

Fixes #108

Before merge following needs to be applied:

  • At least one example testcase added in testcases/
  • Library Documentation regenerated according to Generate docs
  • PR entry added in CHANGELOG.md in In progress section
  • All new testcases tagged as prerelease along other tags to exclude it from execution until released on PyPI
  • Coverage threshold increased in .coveragerc if new coverage is higher than actual, see the lint-and-coverage step in CI
fail_under = 86

@m-wcislo
Copy link
Collaborator

Let's move discussion here. Seems the problem you faced in grafana helm issue: grafana/helm-charts#1515

@siaomingjeng
Copy link
Contributor Author

siaomingjeng commented Jul 15, 2022

Can anybody help with the test requirements?

Get below error when trying to add test in test/test_KubeLibrary.py. Looks like the test run engineer does not have permission to read CRD's.

Traceback (most recent call last):
File "/home/circleci/.local/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/home/circleci/.local/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/home/circleci/.local/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

@m-wcislo
Copy link
Collaborator

I think the problem is that in unit tests you are actually trying to connect to real cluster which doesn't exist, you are not using mock

@mock.patch('kubernetes.client.BatchV1beta1Api.<your functionality>')

which would allow your test to act as cluster is in place

${crd_name} repos.configmanagement.gke.io

*** Test Cases ***
Check All The Custom Resource Definitions Exist
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are missing

[Tags]    other

as a result they are not executed in CI

@@ -783,3 +783,11 @@ def test_read_namespaced_cron_job(self, mock_lnp):
cron_job_details2 = kl.get_cron_job_details_in_namespace('hello', 'default')
self.assertEqual(cron_job_details.items.metadata.labels.TestLabel, cron_job_details2.items.metadata.labels.TestLabel)
self.assertEqual('mytestlabel', cron_job_details.items.metadata.labels.TestLabel)

def test_read_cluster_custom_definition(self):
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add mocks and perform actual check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reply! Really appreciate it. Will fix it later on.

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

Successfully merging this pull request may close these issues.

Add support for CRD list and read
2 participants