From d4fbc4d79756bd26fd9bdefdd63ef3b6158b43e5 Mon Sep 17 00:00:00 2001 From: "Jack (T.) Jia" Date: Thu, 28 Jan 2021 12:19:20 -0500 Subject: [PATCH] surpress deprecated warnings for core components Signed-off-by: Jack (T.) Jia --- bin/internal/prepare-workspace.sh | 8 +++- bin/internal/start-component.sh | 4 +- bin/utils/component-utils.sh | 15 ++++++++ .../utils-scripts/test-component-utils.js | 37 ++++++++++++++++++- 4 files changed, 59 insertions(+), 5 deletions(-) diff --git a/bin/internal/prepare-workspace.sh b/bin/internal/prepare-workspace.sh index d6b31f50d6..fdd0e055b2 100644 --- a/bin/internal/prepare-workspace.sh +++ b/bin/internal/prepare-workspace.sh @@ -99,7 +99,9 @@ validate_components() { validate_script=$(read_component_manifest "${component_dir}" ".commands.validate" 2>/dev/null) if [ -z "${validate_script}" -o "${validate_script}" = "null" ]; then # backward compatible purpose - print_formatted_warn "${LOGGING_SERVICE_ID}" "${LOGGING_SCRIPT_NAME}:${LINENO}" "- unable to determine validate script from component ${component_id} manifest, fall back to default bin/validate.sh" + if [ $(is_core_component "${component_dir}") != "true" ]; then + print_formatted_warn "${LOGGING_SERVICE_ID}" "${LOGGING_SCRIPT_NAME}:${LINENO}" "- unable to determine validate script from component ${component_id} manifest, fall back to default bin/validate.sh" + fi validate_script=bin/validate.sh fi if [ -x "${validate_script}" ]; then @@ -195,7 +197,9 @@ configure_components() { configure_script=$(read_component_manifest "${component_dir}" ".commands.configure" 2>/dev/null) if [ -z "${configure_script}" -o "${configure_script}" = "null" ]; then # backward compatible purpose - print_formatted_warn "${LOGGING_SERVICE_ID}" "${LOGGING_SCRIPT_NAME}:${LINENO}" "* unable to determine configure script from component ${component_id} manifest, fall back to default bin/configure.sh" + if [ $(is_core_component "${component_dir}") != "true" ]; then + print_formatted_warn "${LOGGING_SERVICE_ID}" "${LOGGING_SCRIPT_NAME}:${LINENO}" "* unable to determine configure script from component ${component_id} manifest, fall back to default bin/configure.sh" + fi configure_script=bin/configure.sh fi if [ -x "${configure_script}" ]; then diff --git a/bin/internal/start-component.sh b/bin/internal/start-component.sh index fbd6eefc36..7adf612b4e 100644 --- a/bin/internal/start-component.sh +++ b/bin/internal/start-component.sh @@ -65,7 +65,9 @@ export LAUNCH_COMPONENT="${component_dir}/bin" start_script=$(read_component_manifest "${component_dir}" ".commands.start" 2>/dev/null) if [ -z "${start_script}" -o "${start_script}" = "null" ]; then # backward compatible purpose - print_formatted_warn "${LOGGING_SERVICE_ID}" "${LOGGING_SCRIPT_NAME}:${LINENO}" "unable to determine start script from component ${component_id} manifest, fall back to default bin/start.sh" + if [ $(is_core_component "${component_dir}") != "true" ]; then + print_formatted_warn "${LOGGING_SERVICE_ID}" "${LOGGING_SCRIPT_NAME}:${LINENO}" "unable to determine start script from component ${component_id} manifest, fall back to default bin/start.sh" + fi start_script=${component_dir}/bin/start.sh fi if [ -n "${component_dir}" ]; then diff --git a/bin/utils/component-utils.sh b/bin/utils/component-utils.sh index 5ba8a8fc91..08dd88acff 100644 --- a/bin/utils/component-utils.sh +++ b/bin/utils/component-utils.sh @@ -57,6 +57,21 @@ find_component_directory() { echo "${component_dir}" } +############################### +# Check if component is core component +# +# Required environment variables: +# - ROOT_DIR +# +# @param string component directory +# Output true|false +is_core_component() { + component_dir=$1 + + core_component_dir=${ROOT_DIR}/components + [[ $component_dir == "${core_component_dir}"* ]] && echo true || echo false +} + ############################### # Detect and verify file encoding # diff --git a/tests/sanity/test/utils-scripts/test-component-utils.js b/tests/sanity/test/utils-scripts/test-component-utils.js index ed5437eab9..c254f2434a 100644 --- a/tests/sanity/test/utils-scripts/test-component-utils.js +++ b/tests/sanity/test/utils-scripts/test-component-utils.js @@ -17,6 +17,7 @@ describe('verify utils/component-utils', function() { const TMP_EXT_DIR = 'sanity_test_extensions'; const dummy_component_name = 'sanity_test_dummy'; let component_runtime_dir; + let component_instance_dir; before('prepare SSH connection', async function() { await sshHelper.prepareConnection(); @@ -31,6 +32,7 @@ describe('verify utils/component-utils', function() { TMP_DIR = tmpOnServer || '/tmp'; debug(`TMP_DIR=${TMP_DIR}`); component_runtime_dir = `${TMP_DIR}/${TMP_EXT_DIR}/${dummy_component_name}`; + component_instance_dir = `${process.env.ZOWE_INSTANCE_DIR}/workspace/${dummy_component_name}`; }); const find_component_directory = 'find_component_directory'; @@ -86,6 +88,39 @@ describe('verify utils/component-utils', function() { }); + const is_core_component = 'is_core_component'; + describe(`verify ${is_core_component}`, function() { + before('create test component', async function() { + await sshHelper.executeCommandWithNoError(`rm -rf ${component_runtime_dir} && mkdir -p ${component_runtime_dir} && rm -fr ${component_instance_dir} && echo 'name: ${dummy_component_name}' > ${component_runtime_dir}/manifest.yaml`); + }); + + after('dispose test component', async function() { + await sshHelper.executeCommandWithNoError(`rm -rf ${component_runtime_dir} && rm -fr ${component_instance_dir}`); + }); + + it('test with core component', async function() { + const component = 'jobs-api'; + await test_component_function_has_expected_rc_stdout_stderr( + 'echo $' + `(${is_core_component} "` + '$' + `(find_component_directory ${component})")`, + {}, + { + stdout: 'true', + } + ); + }); + + it('test with non-core component', async function() { + await test_component_function_has_expected_rc_stdout_stderr( + 'echo $' + `(${is_core_component} "` + '$' + `(find_component_directory ${dummy_component_name})")`, + {}, + { + stdout: 'false', + } + ); + }); + + }); + const read_component_manifest = 'read_component_manifest'; describe(`verify ${read_component_manifest}`, function() { @@ -201,8 +236,6 @@ describe('verify utils/component-utils', function() { const convert_component_manifest = 'convert_component_manifest'; describe(`verify ${convert_component_manifest}`, function() { - const component_instance_dir = `${process.env.ZOWE_INSTANCE_DIR}/workspace/${dummy_component_name}`; - before('create test component', async function() { await sshHelper.executeCommandWithNoError(`rm -rf ${component_runtime_dir} && mkdir -p ${component_runtime_dir} && rm -fr ${component_instance_dir} && echo 'name: ${dummy_component_name}' > ${component_runtime_dir}/manifest.yaml`); });