Skip to content

Commit

Permalink
Add unit test to ensure applicationArgs are read
Browse files Browse the repository at this point in the history
This is part of YAN-968.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
  • Loading branch information
rtobar authored and awicenec committed Apr 21, 2022
1 parent 2b28d4b commit 0aa4e09
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 1 deletion.
99 changes: 99 additions & 0 deletions daliuge-engine/test/graphs/application_args.graph
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[
{
"oid": "a",
"type": "app",
"app": "dlg.apps.simple.RandomArrayApp",
"rank": [
0
],
"loop_cxt": null,
"tw": 5,
"num_cpus": 1,
"appclass": "dlg.apps.simple.RandomArrayApp",
"execution_time": 5,
"group_start": false,
"input_error_threshold": 0,
"n_tries": 1,
"applicationArgs": {
"size": {
"text": "Size",
"value": 50,
"defaultValue": "100",
"description": "The size of the array",
"readonly": false,
"type": "Integer",
"precious": false,
"options": [],
"positional": false
},
"integer": {
"text": "Integer",
"value": true,
"defaultValue": "True",
"description": "Generate integer array?",
"readonly": false,
"type": "Boolean",
"precious": false,
"options": [],
"positional": false
},
"low": {
"text": "Low",
"value": 34,
"defaultValue": "0",
"description": "Low value of range in array [inclusive]",
"readonly": false,
"type": "Float",
"precious": false,
"options": [],
"positional": false
},
"high": {
"text": "High",
"value": 3456,
"defaultValue": "1",
"description": "High value of range of array [exclusive]",
"readonly": false,
"type": "Float",
"precious": false,
"options": [],
"positional": false
}
},
"iid": "0",
"lg_key": -2,
"dt": "PythonApp",
"nm": "RandomArrayApp",
"outputs": [
{
"b": "array"
}
],
"node": "127.0.0.1",
"island": "127.0.0.1"
},
{
"oid": "b",
"type": "plain",
"storage": "Memory",
"rank": [
0
],
"loop_cxt": null,
"dw": 5,
"data_volume": 5,
"group_end": false,
"applicationArgs": {},
"iid": "0",
"lg_key": -3,
"dt": "Memory",
"nm": "Memory",
"producers": [
{
"a": "array"
}
],
"node": "127.0.0.1",
"island": "127.0.0.1"
}
]
20 changes: 19 additions & 1 deletion daliuge-engine/test/test_graph_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from dlg.ddap_protocol import DROPLinkType, DROPRel
from dlg.drop import InMemoryDROP, SharedMemoryDROP, ContainerDROP, AppDROP, DirectoryContainer
from dlg.common import Categories
from dlg.apps.simple import RandomArrayApp


# Used in the textual representation of the graphs in these tests
Expand Down Expand Up @@ -165,4 +166,21 @@ def test_namedPorts(self):
# dropSpecs = graph_loader.loadDropSpecs(graphSpec)
a = graph_loader.createGraphFromDropSpecList(graphSpec)
dummy = a


def test_applicationArgs(self):
"""
Use a graph with applicationArgs and make sure applications see their
arguments
"""
with pkg_resources.resource_stream(
"test", "graphs/application_args.graph"
) as f: # @UndefinedVariable
graphSpec = json.load(f)
graph = graph_loader.createGraphFromDropSpecList(graphSpec)
app = graph[0]
self.assertEqual(app.__class__, RandomArrayApp)
self.assertEqual(app.size, 50)
self.assertEqual(app.integer, True)
self.assertEqual(app.low, 34)
self.assertEqual(app.high, 3456)

0 comments on commit 0aa4e09

Please sign in to comment.