-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
86 changed files
with
357 additions
and
352 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
testsuite/certificates/__init__.py → testsuite/certificates.py
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
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
2 changes: 1 addition & 1 deletion
2
...uite/openshift/objects/envoy/wristband.py → testsuite/gateway/envoy/wristband.py
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
File renamed without changes.
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
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,16 @@ | ||
"""Classes related to lifecycle management""" | ||
import abc | ||
|
||
|
||
class LifecycleObject(abc.ABC): | ||
"""Any objects which has its lifecycle controlled by create() and delete() methods""" | ||
|
||
@abc.abstractmethod | ||
def commit(self): | ||
"""Commits resource. | ||
if there is some reconciliation needed, the method should wait until it is all reconciled""" | ||
|
||
@abc.abstractmethod | ||
def delete(self): | ||
"""Removes resource, | ||
if there is some reconciliation needed, the method should wait until it is all reconciled""" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"""OpenShift common objects""" | ||
import functools | ||
|
||
from openshift import APIObject, timeout | ||
|
||
from testsuite.lifecycle import LifecycleObject | ||
|
||
|
||
class OpenShiftObject(APIObject, LifecycleObject): | ||
"""Custom APIObjects which tracks if the object was already committed to the server or not""" | ||
|
||
def __init__(self, dict_to_model=None, string_to_model=None, context=None): | ||
super().__init__(dict_to_model, string_to_model, context) | ||
self.committed = False | ||
|
||
def commit(self): | ||
""" | ||
Creates object on the server and returns created entity. | ||
It will be the same class but attributes might differ, due to server adding/rejecting some of them. | ||
""" | ||
self.create(["--save-config=true"]) | ||
self.committed = True | ||
return self.refresh() | ||
|
||
def delete(self, ignore_not_found=True, cmd_args=None): | ||
"""Deletes the resource, by default ignored not found""" | ||
with timeout(30): | ||
deleted = super().delete(ignore_not_found, cmd_args) | ||
self.committed = False | ||
return deleted | ||
|
||
|
||
def modify(func): | ||
"""Wraps method of a subclass of OpenShiftObject to use modify_and_apply when the object | ||
is already committed to the server, or run it normally if it isn't. | ||
All methods modifying the target object in any way should be decorated by this""" | ||
|
||
def _custom_partial(func, *args, **kwargs): | ||
"""Custom partial function which makes sure that self is always assigned correctly""" | ||
|
||
def _func(self): | ||
func(self, *args, **kwargs) | ||
|
||
return _func | ||
|
||
@functools.wraps(func) | ||
def _wrap(self, *args, **kwargs): | ||
if self.committed: | ||
result, _ = self.modify_and_apply(_custom_partial(func, *args, **kwargs)) | ||
assert result.status | ||
else: | ||
func(self, *args, **kwargs) | ||
|
||
return _wrap |
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
2 changes: 1 addition & 1 deletion
2
testsuite/openshift/objects/config_map.py → testsuite/openshift/config_map.py
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
Oops, something went wrong.