-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from pehala/httpbin_object
Remove Httpbin templates
- Loading branch information
Showing
11 changed files
with
163 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Deployment related objects""" | ||
import openshift as oc | ||
|
||
from testsuite.openshift import OpenShiftObject, Selector | ||
from testsuite.utils import asdict | ||
|
||
|
||
class Deployment(OpenShiftObject): | ||
"""Kubernetes Deployment object""" | ||
|
||
@classmethod | ||
def create_instance( | ||
cls, openshift, name, container_name, image, ports: dict[str, int], selector: Selector, labels: dict[str, str] | ||
): | ||
""" | ||
Creates new instance of Deployment | ||
Supports only single container Deployments everything else should be edited directly | ||
""" | ||
model: dict = { | ||
"kind": "Deployment", | ||
"apiVersion": "apps/v1", | ||
"metadata": { | ||
"name": name, | ||
"labels": labels, | ||
}, | ||
"spec": { | ||
"selector": asdict(selector), | ||
"template": { | ||
"metadata": {"labels": {"deployment": name, **labels}}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"image": image, | ||
"name": container_name, | ||
"imagePullPolicy": "IfNotPresent", | ||
"ports": [{"name": name, "containerPort": port} for name, port in ports.items()], | ||
} | ||
] | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
return cls(model, context=openshift.context) | ||
|
||
def wait_for_ready(self, timeout=90): | ||
"""Waits until Deployment is marked as ready""" | ||
with oc.timeout(timeout): | ||
success, _, _ = self.self_selector().until_all(success_func=lambda obj: "readyReplicas" in obj.model.status) | ||
assert success, f"Deployment {self.name()} did not get ready in time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Service related objects""" | ||
from dataclasses import dataclass, asdict | ||
|
||
from testsuite.openshift import OpenShiftObject | ||
|
||
|
||
@dataclass | ||
class ServicePort: | ||
"""Kubernetes Service Port object""" | ||
|
||
name: str | ||
port: int | ||
targetPort: int | str # pylint: disable=invalid-name | ||
|
||
|
||
class Service(OpenShiftObject): | ||
"""Kubernetes Service object""" | ||
|
||
@classmethod | ||
def create_instance( | ||
cls, | ||
openshift, | ||
name, | ||
selector: dict[str, str], | ||
ports: list[ServicePort], | ||
labels: dict[str, str] = None, | ||
): | ||
"""Creates new Service""" | ||
model: dict = { | ||
"kind": "Service", | ||
"apiVersion": "v1", | ||
"metadata": { | ||
"name": name, | ||
"labels": labels, | ||
}, | ||
"spec": { | ||
"ports": [asdict(port) for port in ports], | ||
"selector": selector, | ||
}, | ||
} | ||
return cls(model, context=openshift.context) | ||
|
||
def get_port(self, name): | ||
"""Returns port definition for a port with said name""" | ||
for port in self.model.spec.ports: | ||
if port["name"] == name: | ||
return port | ||
raise KeyError(f"No port with name {name} exists") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters