def on_parse_node(self): super().on_parse_node() self.name_node = get_tag_el_text(self.oozie_node, "name-node") self.params_dict = extract_param_values_from_action_node( self.oozie_node) _, self.hdfs_files = self.file_extractor.parse_node() _, self.hdfs_archives = self.archive_extractor.parse_node()
def test_extract_param_values_from_action_node_should_support_el_value( self): props = PropertySet(config={}, job_properties={ "userName": "******", "examplesRoot": "TEST_EXAMPLE_ROOT" }) # language=XML xml_content = """ <fragment> <param>INPUT=/user/${userName}/${examplesRoot}/apps/hive/input/</param> <param>OUTPUT=/user/${userName}/${examplesRoot}/apps/hive/output/</param> </fragment> """ node = ET.fromstring(xml_content) result = extract_param_values_from_action_node(node, props=props) self.assertEqual( { "INPUT": "/user/TEST_USERNAME/TEST_EXAMPLE_ROOT/apps/hive/input/", "OUTPUT": "/user/TEST_USERNAME/TEST_EXAMPLE_ROOT/apps/hive/output/", }, result, )
def _parse_oozie_node(self): self.resource_manager = get_tag_el_text(self.oozie_node, TAG_RESOURCE) self.name_node = get_tag_el_text(self.oozie_node, TAG_NAME) self.script_file_name = get_tag_el_text(self.oozie_node, TAG_SCRIPT) self.params_dict = extract_param_values_from_action_node( self.oozie_node) self.files, self.hdfs_files = self.file_extractor.parse_node() self.archives, self.hdfs_archives = self.archive_extractor.parse_node()
def test_extract_param_values_from_action_node_should_return_empty_dict_when_not_found( self): props = PropertySet(config={}, job_properties={ "userName": "******", "examplesRoot": "TEST_EXAMPLE_ROOT" }) node = ET.fromstring("<dummy></dummy>") result = extract_param_values_from_action_node(node, props=props) self.assertEqual({}, result)
def test_extract_param_values_from_action_node_should_parse_single_value( self): # language=XML xml_content = """ <fragment> <param>INPUT=VALUE</param> </fragment> """ node = ET.fromstring(xml_content) result = extract_param_values_from_action_node(node) self.assertEqual({"INPUT": "VALUE"}, result)
def test_extract_param_values_from_action_node_should_parse_single_value( self): props = PropertySet(config={}, job_properties={}) # language=XML xml_content = """ <fragment> <param>INPUT=VALUE</param> </fragment> """ node = ET.fromstring(xml_content) result = extract_param_values_from_action_node(node, props=props) self.assertEqual({"INPUT": "VALUE"}, result)
def _parse_oozie_node(self): res_man_text = self.oozie_node.find("resource-manager").text name_node_text = self.oozie_node.find("name-node").text script = self.oozie_node.find("script").text self.resource_manager = el_utils.replace_el_with_var(res_man_text, props=self.props, quote=False) self.name_node = el_utils.replace_el_with_var(name_node_text, props=self.props, quote=False) self.script_file_name = el_utils.replace_el_with_var(script, props=self.props, quote=False) self.params_dict = extract_param_values_from_action_node( self.oozie_node, props=self.props) self.files, self.hdfs_files = self.file_extractor.parse_node() self.archives, self.hdfs_archives = self.archive_extractor.parse_node()
def on_parse_node(self): super().on_parse_node() self._parse_config() self.query = get_tag_el_text(self.oozie_node, TAG_QUERY) self.script = get_tag_el_text(self.oozie_node, TAG_SCRIPT) if not self.query and not self.script: raise ParseException( f"Action Configuration does not include {TAG_SCRIPT} or {TAG_QUERY} element" ) if self.query and self.script: raise ParseException( f"Action Configuration include {TAG_SCRIPT} and {TAG_QUERY} element. " f"Only one can be set at the same time.") self.variables = extract_param_values_from_action_node(self.oozie_node) _, self.hdfs_files = self.file_extractor.parse_node() _, self.hdfs_archives = self.archive_extractor.parse_node()
def test_extract_param_values_from_action_node_should_support_el_value( self): # language=XML xml_content = """ <fragment> <param>INPUT=/user/${userName}/${examplesRoot}/apps/hive/input/</param> <param>OUTPUT=/user/${userName}/${examplesRoot}/apps/hive/output/</param> </fragment> """ node = ET.fromstring(xml_content) result = extract_param_values_from_action_node(node) self.assertEqual( { "INPUT": "/user/{{userName}}/{{examplesRoot}}/apps/hive/input/", "OUTPUT": "/user/{{userName}}/{{examplesRoot}}/apps/hive/output/", }, result, )
def test_extract_param_values_from_action_node_should_return_empty_dict_when_not_found( self): node = ET.fromstring("<dummy></dummy>") result = extract_param_values_from_action_node(node) self.assertEqual({}, result)