Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surpress deprecated warnings for core components #1929

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bin/internal/prepare-workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion bin/internal/start-component.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions bin/utils/component-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
37 changes: 35 additions & 2 deletions tests/sanity/test/utils-scripts/test-component-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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';
Expand Down Expand Up @@ -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() {

Expand Down Expand Up @@ -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`);
});
Expand Down