diff options
Diffstat (limited to 'dcae-cli/dcae_cli/commands/tests')
5 files changed, 48 insertions, 43 deletions
diff --git a/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_end.json b/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_end.json index f2f12f9..9642a6e 100644 --- a/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_end.json +++ b/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_end.json @@ -35,15 +35,28 @@ "parameters": { "app_config" : [ {"name" : "some_param", - "description" : "some desc", - "value" : "some_value"} + "description" : "some desc", + "value" : "some_value", + "designer_editable" : false, + "sourced_at_deployment" : false, + "policy_editable" : false} ], "app_preferences" : [ {"name" : "some_param2", "description" : "some desc2", - "value" : "some_value2"} + "value" : "some_value2", + "designer_editable" : false, + "sourced_at_deployment" : false, + "policy_editable" : false} ], - "program_preferences" : [{"program_type" : "flows", "program_id" : "WhoFlow", "program_pref" : [{"name" : "some_param3","description" : "some desc3", "value" : "some_value3"}]}] + "program_preferences" : [{"program_type" : "flows", + "program_id" : "WhoFlow", + "program_pref" : [{"name" : "some_param3", + "description" : "some desc3", + "value" : "some_value3", + "designer_editable" : false, + "sourced_at_deployment" : false, + "policy_editable" : false}]}] }, "auxilary": { "streamname":"who", diff --git a/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_start.json b/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_start.json index c4a807e..83b5c28 100644 --- a/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_start.json +++ b/dcae-cli/dcae_cli/commands/tests/mocked_components/cdap/spec_start.json @@ -35,14 +35,28 @@ "app_config" : [ {"name" : "some_param", "description" : "some desc", - "value" : "some_value"} + "value" : "some_value", + "designer_editable" : false, + "sourced_at_deployment" : false, + "policy_editable" : false} ], "app_preferences" : [ {"name" : "some_param2", "description" : "some desc2", - "value" : "some_value2"} + "value" : "some_value2", + "designer_editable" : false, + "sourced_at_deployment" : false, + "policy_editable" : false} ], - "program_preferences" : [{"program_type" : "flows", "program_id" : "WhoFlow", "program_pref" : [{"name" : "some_param3","description" : "some desc3", "value" : "some_value3"}]}] + "program_preferences" : [{"program_type" : "flows", + "program_id" : "WhoFlow", + "program_pref" : [{"name" : "some_param3", + "description" : "some desc3", + "value" : "some_value3", + "designer_editable" : false, + "sourced_at_deployment" : false, + "policy_editable" : false} + ]}] }, "auxilary": { "streamname":"who", diff --git a/dcae-cli/dcae_cli/commands/tests/mocked_components/collector/kpi-collector.comp.json b/dcae-cli/dcae_cli/commands/tests/mocked_components/collector/kpi-collector.comp.json index 5508e90..5b86d9c 100644 --- a/dcae-cli/dcae_cli/commands/tests/mocked_components/collector/kpi-collector.comp.json +++ b/dcae-cli/dcae_cli/commands/tests/mocked_components/collector/kpi-collector.comp.json @@ -24,7 +24,10 @@ { "name": "sleep_sec", "value": 0.75, - "description": "Number of seconds to sleep between publishes" + "description": "Number of seconds to sleep between publishes", + "designer_editable": false, + "sourced_at_deployment": false, + "policy_editable": false } ], "auxilary": { diff --git a/dcae-cli/dcae_cli/commands/tests/mocked_components/model/anomaly-model.comp.json b/dcae-cli/dcae_cli/commands/tests/mocked_components/model/anomaly-model.comp.json index e5f5889..3e2d142 100644 --- a/dcae-cli/dcae_cli/commands/tests/mocked_components/model/anomaly-model.comp.json +++ b/dcae-cli/dcae_cli/commands/tests/mocked_components/model/anomaly-model.comp.json @@ -29,7 +29,10 @@ { "name": "threshold", "value": 0.75, - "description": "Probability threshold to exceed to be anomalous" + "description": "Probability threshold to exceed to be anomalous", + "designer_editable" : false, + "sourced_at_deployment" : false, + "policy_editable" : false } ], "auxilary": { diff --git a/dcae-cli/dcae_cli/commands/tests/test_component_cmd.py b/dcae-cli/dcae_cli/commands/tests/test_component_cmd.py index 67769eb..2bba4cf 100644 --- a/dcae-cli/dcae_cli/commands/tests/test_component_cmd.py +++ b/dcae-cli/dcae_cli/commands/tests/test_component_cmd.py @@ -41,7 +41,7 @@ def _get_spec(path): def test_comp_docker(mock_cli_config, mock_db_url, obj=None): - obj = {'catalog': MockCatalog(purge_existing=True, db_name='dcae_cli.test.db', + obj = {'catalog': MockCatalog(purge_existing=True, db_name='dcae_cli.test.db', enforce_image=False, db_url=mock_db_url), 'config': {'user': 'test-user'}} @@ -113,63 +113,35 @@ def test_comp_cdap(obj=None): 3) runs a cdap component using our "Rework" broker 4) undeploys the cdap component using our "Rework" broker - NOTE: TODO: Mocking out the broker would be an improvement over this, probably. This is impure. Mocking the broker owuld be a huge undertaking, though. + NOTE: TODO: Mocking out the broker would be an improvement over this, probably. This is impure. Mocking the broker owuld be a huge undertaking, though. """ obj = {'catalog': MockCatalog(purge_existing=True, db_name='dcae_cli.test.db'), 'config': {'user': 'test-user'}} runner = CliRunner() - + #add the data format df = os.path.join(TEST_DIR, 'mocked_components', 'cdap', 'format.json') cmd = "data_format add {:}".format(df).split() assert runner.invoke(cli, cmd, obj=obj).exit_code == 0 - + #add the CDAP components # TODO: Need to update the host jar = 'http://make-me-valid/HelloWorld-3.4.3.jar' - + comp_cdap_start = os.path.join(TEST_DIR, 'mocked_components', 'cdap', 'spec_start.json') cmd = "component add {0}".format(comp_cdap_start).split() print(cmd) result = runner.invoke(cli, cmd, obj=obj) print(result.output) assert result.exit_code == 0 - + comp_cdap_end = os.path.join(TEST_DIR, 'mocked_components', 'cdap', 'spec_end.json') cmd = "component add {0}".format(comp_cdap_end).split() print(cmd) result = runner.invoke(cli, cmd, obj=obj) print(result.output) assert result.exit_code == 0 - - #run the terminating component first - cmd = "component run --force cdap.helloworld.mock.catalog.testing.endnode".split() - print(cmd) - result = runner.invoke(cli, cmd, obj=obj) - print(result.output) - assert result.exit_code == 0 - - #run the component again: this time the second component finds the first - cmd = "component run --force cdap.helloworld.mock.catalog.testing.startnode".split() - print(cmd) - result = runner.invoke(cli, cmd, obj=obj) - assert "config_key 'service_call_example' has no compatible downstream components." not in result.output #touchdown baby - assert result.exit_code == 0 - - #sleep - time.sleep(5) - - #delete the components - cmd = "component undeploy cdap.helloworld.mock.catalog.testing.startnode".split() - print(cmd) - result = runner.invoke(cli, cmd, obj=obj) - assert result.exit_code == 0 - - cmd = "component undeploy cdap.helloworld.mock.catalog.testing.endnode".split() - print(cmd) - result = runner.invoke(cli, cmd, obj=obj) - assert result.exit_code == 0 if __name__ == '__main__': '''Test area''' |