-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch introduces initial necessary changes for the Workflow API support. The Workflow API allows the actor to specify APIs to use and it will not to have to specify anymore messages to consume or produce. With this, it is possible to implement pure code API functions for actor writers, where they do not have to work with messages but directly can work with data. This allows us to provide a stable API that is not changed, however we can change the messages and system below. Additionally we can use multiple versions of the API where we can allow to change APIs in newer versions to make them more useful to consumers of the API, however we could keep the old versions around to keep their original code working. Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
- Loading branch information
Showing
40 changed files
with
588 additions
and
10 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
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
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,17 @@ | ||
class WorkflowAPI(object): | ||
produces = () | ||
consumes = () | ||
apis = () | ||
|
||
def __init__(self): | ||
pass | ||
|
||
@classmethod | ||
def serialize(cls): | ||
return { | ||
'name': cls.__name__, | ||
'module': cls.__module__, | ||
'consumes': [model.__name__ for model in cls.consumes], | ||
'produces': [model.__name__ for model in cls.produces], | ||
'apis': [api.__name__ for api in cls.apis] | ||
} |
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 @@ | ||
{"name": "workflow-api-tests", "id": "e8bfeffe-9131-4792-bcc3-760628e0fc4b"} |
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,6 @@ | ||
|
||
[repositories] | ||
repo_path=${repository:root_dir} | ||
|
||
[database] | ||
path=${repository:state_dir}/leapp.db |
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,33 @@ | ||
[loggers] | ||
keys=urllib3,root | ||
|
||
[formatters] | ||
keys=leapp | ||
|
||
[handlers] | ||
keys=leapp_audit,stream | ||
|
||
[formatter_leapp] | ||
format=%(asctime)s.%(msecs)-3d %(levelname)-8s PID: %(process)d %(name)s: %(message)s | ||
datefmt=%Y-%m-%d %H:%M:%S | ||
class=logging.Formatter | ||
|
||
[logger_urllib3] | ||
level=WARN | ||
qualname=urllib3 | ||
handlers=stream | ||
|
||
[logger_root] | ||
level=DEBUG | ||
handlers=leapp_audit,stream | ||
|
||
[handler_leapp_audit] | ||
class=leapp.logger.LeappAuditHandler | ||
formatter=leapp | ||
args=() | ||
|
||
[handler_stream] | ||
class=StreamHandler | ||
level=ERROR | ||
formatter=leapp | ||
args=(sys.stderr,) |
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,30 @@ | ||
from leapp.actors import Actor | ||
from leapp.exceptions import StopActorExecutionError | ||
from leapp.tags import FirstPhaseTag, WorkflowApiTestWorkflowTag | ||
from leapp.workflows.api.v1 import TestAPI | ||
|
||
|
||
class ApiV1Test(Actor): | ||
""" | ||
This actor will check that the testing API ApiV3Test is behaving as expected. | ||
""" | ||
|
||
name = 'api_v1_test' | ||
consumes = () | ||
produces = () | ||
apis = (TestAPI,) | ||
tags = (FirstPhaseTag, WorkflowApiTestWorkflowTag) | ||
|
||
def process(self): | ||
api = TestAPI() | ||
# Expected output is always the order a, b, c | ||
# The parameter order here also is however a, b, c | ||
if api.order_change(1, 2, 3) != (1, 2, 3): | ||
raise StopActorExecutionError("order change API failure") | ||
|
||
# Expected is that the input is prefixed with 'survivor.v3.' | ||
if api.survivor("APIV1Test") != "survivor.v3.APIV1Test": | ||
raise StopActorExecutionError("v1 survivor test failure") | ||
|
||
# Ensure removed is available and works (Doesn't really do anything just ensures not to have an exception) | ||
api.removed("ApiV1Test calls removed method") |
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,26 @@ | ||
from leapp.actors import Actor | ||
from leapp.tags import FirstPhaseTag, WorkflowApiTestWorkflowTag | ||
from leapp.workflows.api.v2 import TestAPI | ||
|
||
|
||
class ApiV2Test(Actor): | ||
""" | ||
This actor will check that the testing API ApiV3Test is behaving as expected. | ||
""" | ||
|
||
name = 'api_v2_test' | ||
consumes = () | ||
produces = () | ||
apis = (TestAPI,) | ||
tags = (FirstPhaseTag, WorkflowApiTestWorkflowTag) | ||
|
||
def process(self): | ||
api = TestAPI() | ||
# Expected output is always the order a, b, c | ||
# The parameter order here is however c, b, a | ||
if api.order_change(3, 2, 1) != (1, 2, 3): | ||
raise StopActorExecutionError("order change API failure") | ||
|
||
# Expected is that the input is prefixed with 'survivor.v3.' | ||
if api.survivor("APIV2Test") != "survivor.v3.APIV2Test": | ||
raise StopActorExecutionError("v2 survivor test failure") |
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,27 @@ | ||
from leapp.actors import Actor | ||
from leapp.exceptions import StopActorExecutionError | ||
from leapp.tags import FirstPhaseTag, WorkflowApiTestWorkflowTag | ||
from leapp.workflows.api.v3 import TestAPI | ||
|
||
|
||
class ApiV3Test(Actor): | ||
""" | ||
This actor will check that the testing API ApiV3Test is behaving as expected. | ||
""" | ||
|
||
name = 'api_v3_test' | ||
consumes = () | ||
produces = () | ||
apis = (TestAPI,) | ||
tags = (FirstPhaseTag, WorkflowApiTestWorkflowTag) | ||
|
||
def process(self): | ||
api = TestAPI() | ||
# Expected output is always the order a, b, c | ||
# The parameter order here is however b, c, a | ||
if api.order_change(2, 3, 1) != (1, 2, 3): | ||
raise StopActorExecutionError("order change API failure") | ||
|
||
# Expected is that the input is prefixed with 'survivor.v3.' | ||
if api.survivor("APIV3Test") != "survivor.v3.APIV3Test": | ||
raise StopActorExecutionError("v3 survivor test failure") |
Oops, something went wrong.