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

Added keyword for ingress create and delete #94

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ command_line = -m unittest discover
source =
src/
[report]
fail_under = 82
fail_under = 81
Copy link
Collaborator

Choose a reason for hiding this comment

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

We would rather increase the coverage not decrease, it would be best to add unit tests for this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it was wrongly committed but this PR will create and delete ingress in a namespace.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We cannot decrease coverage, please resolve conflicts

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Keyword for list daemonset [#50](https://github.com/devopsspiral/KubeLibrary/pull/50) by [@satish-nubolab](https://github.com/satish-nubolab)
- Keyword for CustomObjectsApi [#54](https://github.com/devopsspiral/KubeLibrary/pull/54) by [@mika-b](https://github.com/mika-b)
- Example tests for Ambassador CRDs [#63](https://github.com/devopsspiral/KubeLibrary/pull/63) by [@Nilsty](https://github.com/Nilsty)
- Example tests for Ambassador CRDs [#63](https://github.com/devopsspiral/KubeLibrary/pull/63) by [@Nilsty](https://github.com/Nilsty)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update changelog after release v0.5.0

- Keyword for edit ,create and delete ingress [#52]((https://github.com/devopsspiral/KubeLibrary/pull/94) by [@satish-nubolab](https://github.com/satish-nubolab)

### Fixed
- Fix for cert validation disabling not being possible for all api clients [#61](https://github.com/devopsspiral/KubeLibrary/pull/61) by [@m-wcislo](https://github.com/m-wcislo)
Expand Down
22 changes: 22 additions & 0 deletions src/KubeLibrary/KubeLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,3 +884,25 @@ def filter_endpoints_names(self, endpoints):
List of endpoint objects
"""
return [endpoints.metadata.name for endpoints in endpoints.items]

def create_ingress_in_namespace(self, namespace, body):
"""Creates Ingress in a namespace
Returns created ingress
- ``body``:
Ingress object.
- ``namespace``:
Namespace to check
"""
ret = self.extensionsv1beta1.create_namespaced_ingress(namespace=namespace, body=body)
return ret

def delete_ingress_in_namespace(self, name, namespace):
"""Deletes Ingress in a namespace
Returns V1 status
- ``name``:
Ingress name
- ``namespace``:
Namespace to check
"""
ret = self.extensionsv1beta1.delete_namespaced_ingress(name=name, namespace=namespace)
return ret
12 changes: 12 additions & 0 deletions testcases/ingress/ingress.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,16 @@ Resource ./ingress_kw.robot
Ingresses by label
[Tags] other
List ingresses by label kubelib-tests app.kubernetes.io/instance=kubelib-test

Ingresses in namespace
[Tags] other prerelease
List all ingresses in namespace kubelib-tests

Working on Ingress
[Tags] other prerelease
List all ingresses in namespace kubelib-tests
Edit obtained ingress my-ingress
Create new ingress in namespace kubelib-tests
Delete created ingress in namespace my-ingress kubelib-tests


31 changes: 31 additions & 0 deletions testcases/ingress/ingress_kw.robot
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,34 @@ List ingresses by label
... msg=Expected labels do not match.
Log Ingress Host Url: ${ingress_details.spec.rules[0].host} console=True
END

List all ingresses in namespace
[Arguments] ${namespace}
@{namespace_ingresses}= Get Ingresses In Namespace ${namespace}
Log \nIngresses in namespace ${namespace}: console=True
Length Should Be ${namespace_ingresses} 1
FOR ${ingress} IN @{namespace_ingresses}
${ingress_details}= Get Ingress Details In Namespace ${ingress} ${namespace}
Log ${ingress_details.metadata.name} console=True
Set Global Variable ${ingress_name} ${ingress_details.metadata.name}
Set Global Variable ${ingress} ${ingress_details}
END

Edit obtained ingress
[Arguments] ${ingress_name}
${ingress.metadata.name}= Set Variable ${ingress_name}
${ingress.metadata.resource_version}= Set Variable ${None}
Set Global Variable ${new_ingress} ${ingress}

Create new ingress in namespace
[Arguments] ${namespace}
Log \nCreate new ingress in namespace ${namespace} console=True
${new_ing}= Create Ingress In Namespace ${namespace} ${new_ingress}
Log ${new_ing} console=True

Delete created ingress in namespace
[Arguments] ${ingress_name} ${namespace}
Log \nDelete ingress in namespace ${namespace} console=True
Log ${ingress_name} console=True
${status}= Delete Ingress In Namespace ${ingress_name} ${namespace}
Log ${status}