-
Notifications
You must be signed in to change notification settings - Fork 72
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 <[email protected]>
- Loading branch information
Showing
40 changed files
with
496 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,26 @@ | ||
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): | ||
""" | ||
No documentation has been provided for the api_v1_test actor. | ||
""" | ||
|
||
name = 'api_v1_test' | ||
consumes = () | ||
produces = () | ||
apis = (TestAPI,) | ||
tags = (FirstPhaseTag, WorkflowApiTestWorkflowTag) | ||
|
||
def process(self): | ||
api = TestAPI() | ||
if api.order_change(1, 2, 3) != (1, 2, 3): | ||
raise StopActorExecutionError("order change API failure") | ||
|
||
if api.survivor("APIV1Test") != "survivor.v3.APIV1Test": | ||
raise StopActorExecutionError("v1 survivor test failure") | ||
|
||
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,22 @@ | ||
from leapp.actors import Actor | ||
from leapp.tags import FirstPhaseTag, WorkflowApiTestWorkflowTag | ||
from leapp.workflows.api.v2 import TestAPI | ||
|
||
class ApiV2Test(Actor): | ||
""" | ||
No documentation has been provided for the api_v2_test actor. | ||
""" | ||
|
||
name = 'api_v2_test' | ||
consumes = () | ||
produces = () | ||
apis = (TestAPI,) | ||
tags = (FirstPhaseTag, WorkflowApiTestWorkflowTag) | ||
|
||
def process(self): | ||
api = TestAPI() | ||
if api.order_change(3, 2, 1) != (1, 2, 3): | ||
raise StopActorExecutionError("order change API failure") | ||
|
||
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,23 @@ | ||
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): | ||
""" | ||
No documentation has been provided for the api_v3_test actor. | ||
""" | ||
|
||
name = 'api_v3_test' | ||
consumes = () | ||
produces = () | ||
apis = (TestAPI,) | ||
tags = (FirstPhaseTag, WorkflowApiTestWorkflowTag) | ||
|
||
def process(self): | ||
api = TestAPI() | ||
if api.order_change(2, 3, 1) != (1, 2, 3): | ||
raise StopActorExecutionError("order change API failure") | ||
|
||
if api.survivor("APIV3Test") != "survivor.v3.APIV3Test": | ||
raise StopActorExecutionError("v3 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,34 @@ | ||
from leapp.actors import Actor | ||
from leapp.exceptions import StopActorExecutionError | ||
from leapp.tags import FirstPhaseTag, WorkflowApiTestWorkflowTag | ||
from leapp.workflows.api.v3 import DepCheckAPI1, DepCheckAPI2, DepCheckAPI3, DepCheckAPI4 | ||
|
||
|
||
class DepCheck(Actor): | ||
""" | ||
No documentation has been provided for the dep_check actor. | ||
""" | ||
|
||
name = 'dep_check' | ||
consumes = () | ||
produces = () | ||
apis = (DepCheckAPI4,) | ||
tags = (FirstPhaseTag, WorkflowApiTestWorkflowTag) | ||
|
||
def process(self): | ||
api1 = DepCheckAPI1() | ||
if len(api1.consume()) != 1: | ||
raise StopActorExecutionError( | ||
"Expected 1 result from DepCheckAPI1.consume => {}".format(len(api1.consume()))) | ||
|
||
api2 = DepCheckAPI2() | ||
api2.produce() | ||
|
||
api3 = DepCheckAPI3() | ||
if len(api3.consume()) != 2: | ||
raise StopActorExecutionError( | ||
"Expected 2 results from DepCheckAPI3.consume => {}".format(len(api3.consume()))) | ||
|
||
api4 = DepCheckAPI4() | ||
api4.produce() | ||
|
Oops, something went wrong.