Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.1.0.dev1
current_version = 2.1.0.dev2
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

- name: Run flake8 on test directory
working-directory: ${{ matrix.package }}
run: python -m flake8 test/main/python --max-line-length 88
run: python -m flake8 src/test/python --max-line-length 88

#format:
#name: Check format ${{ matrix.package}}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/python/dlpx/virtualization/common/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
2 changes: 1 addition & 1 deletion dvp/src/main/python/dlpx/virtualization/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
2 changes: 1 addition & 1 deletion libs/src/main/python/dlpx/virtualization/libs/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ def prepare_upload_artifact(plugin_config_content, src_dir, schemas, manifest):
if plugin_config_content.get('luaName'):
artifact['luaName'] = plugin_config_content['luaName']

if plugin_config_content.get('minimumLuaVersion'):
artifact['minimumLuaVersion'] = plugin_config_content[
'minimumLuaVersion']

return artifact


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def __init__(self,
self.__pre_import_checks = [
self.__validate_plugin_config_content,
self.__validate_plugin_entry_point,
self.__check_for_undefined_names
self.__check_for_undefined_names,
self.__check_for_lua_name_and_min_version
]

@property
Expand Down Expand Up @@ -218,6 +219,28 @@ def __check_for_undefined_names(self):
if warnings and len(warnings) > 0:
raise exceptions.ValidationFailedError(warnings)

def __check_for_lua_name_and_min_version(self):
"""
Check if both lua name and minimum lua version are present if either
property is set.
"""
warnings = defaultdict(list)

if (self.__plugin_config_content.get('luaName') and not
self.__plugin_config_content.get('minimumLuaVersion')):
msg = ('Failed to process property "luaName" without '
'"minimumLuaVersion" set in the plugin config.')
warnings['exception'].append(exceptions.UserError(msg))

if (self.__plugin_config_content.get('minimumLuaVersion') and not
self.__plugin_config_content.get('luaName')):
msg = ('Failed to process property "minimumLuaVersion" without '
'"luaName" set in the plugin config.')
warnings['exception'].append(exceptions.UserError(msg))

if warnings and len(warnings) > 0:
raise exceptions.ValidationFailedError(warnings)

@staticmethod
def split_entry_point(entry_point):
entry_point_strings = entry_point.split(':')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"luaName": {
"type": "string",
"pattern": "^[a-z0-9_:-]+$"
},
"minimumLuaVersion": {
"type": "string",
"pattern": "^([0-9]+)\\.([0-9]+)$"
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
"luaName": {
"type": "string",
"pattern": "^[a-z0-9_:-]+$"
},
"minimumLuaVersion": {
"type": "string",
"pattern": "^([0-9]+)\\.([0-9]+)$"
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ def test_zip_and_encode_source_files_invalid_dir(src_dir):

@staticmethod
@mock.patch('compileall.compile_dir')
def test_zip_and_encode_source_files_compileall_fail(mock_compile, src_dir):
def test_zip_and_encode_source_files_compileall_fail(
mock_compile, src_dir):
mock_compile.return_value = 0
with pytest.raises(exceptions.UserError) as err_info:
build.zip_and_encode_source_files(src_dir)
Expand Down Expand Up @@ -655,10 +656,21 @@ def test_build_number_parameter(plugin_config_content, src_dir,
@staticmethod
@pytest.mark.parametrize('lua_name, expected', [
pytest.param('lua-toolkit-1', 'lua-toolkit-1'),
pytest.param(None, None)
pytest.param('nix_staged_python', 'nix_staged_python')
])
def test_lua_name_parameter(plugin_config_content, src_dir,
schema_content, expected):
upload_artifact = build.prepare_upload_artifact(
plugin_config_content, src_dir, schema_content, {})
assert expected == upload_artifact.get('luaName')

@staticmethod
@pytest.mark.parametrize(
'minimum_lua_version, expected',
[pytest.param('2.3', '2.3'),
pytest.param('2.4', '2.4')])
def test_minimum_lua_version_parameter(plugin_config_content, src_dir,
schema_content, expected):
upload_artifact = build.prepare_upload_artifact(
plugin_config_content, src_dir, schema_content, {})
assert expected == upload_artifact.get('minimumLuaVersion')
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,27 @@ def httpretty_enabled():

JOB_RESP_FAIL = (('{"type": "OKResult", "status": "OK", "result": '
'{"jobState": "FAILED", "events": []}}'), {
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})

JOB_RESP_TIMED_OUT = (('{"type": "OKResult", "status": "OK", "result": '
'{"jobState": "RUNNING", "events": []}}'), {
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})

PLUGIN_RESP_SUCCESS = (
'{"type": "ListResult", "status": "OK", "result": ['
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def artifact_file_created():
@pytest.fixture
def plugin_config_content(plugin_id, plugin_name, external_version, language,
host_types, plugin_type, entry_point, src_dir,
schema_file, manual_discovery, build_number, lua_name):
schema_file, manual_discovery, build_number,
lua_name, minimum_lua_version):
"""
This fixutre creates the dict expected in the properties yaml file the
customer must provide for the build and compile commands.
Expand Down Expand Up @@ -219,6 +220,9 @@ def plugin_config_content(plugin_id, plugin_name, external_version, language,
if lua_name:
config['luaName'] = lua_name

if minimum_lua_version:
config['minimumLuaVersion'] = minimum_lua_version

return config


Expand Down Expand Up @@ -282,6 +286,11 @@ def lua_name():
return 'lua-toolkit-1'


@pytest.fixture
def minimum_lua_version():
return "2.3"


@pytest.fixture
def artifact_manual_discovery():
return True
Expand Down Expand Up @@ -570,6 +579,7 @@ def basic_artifact_content(engine_api, virtual_source_definition,
'rootSquashEnabled': True,
'buildNumber': '2',
'luaName': 'lua-toolkit-1',
'minimumLuaVersion': '2.3',
'sourceCode': 'UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA==',
'manifest': {}
}
Expand Down Expand Up @@ -618,6 +628,7 @@ def artifact_content(engine_api, virtual_source_definition,
'rootSquashEnabled': True,
'buildNumber': '2',
'luaName': 'lua-toolkit-1',
'minimumLuaVersion': '2.3',
'manifest': {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class TestPackageUtil:
@staticmethod
def test_get_version():
assert package_util.get_version() == '2.1.0.dev1'
assert package_util.get_version() == '2.1.0.dev2'

@staticmethod
def test_get_virtualization_api_version():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_plugin_bad_config_file(plugin_config_file):

@staticmethod
@mock.patch('os.path.isabs', return_value=False)
def test_plugin_valid_content(src_dir, plugin_config_file,
def test_plugin_valid_content(plugin_config_file,
plugin_config_content):
validator = PluginValidator.from_config_content(
plugin_config_file, plugin_config_content,
Expand All @@ -67,7 +67,7 @@ def test_plugin_missing_field(plugin_config_file, plugin_config_content):
(1.0, "1.0 is not of type 'string'"),
('my_version', None), ('1.0.0', None),
('1.0.0_HF', None)])
def test_plugin_version_format(src_dir, plugin_config_file,
def test_plugin_version_format(plugin_config_file,
plugin_config_content, expected):
try:
validator = PluginValidator.from_config_content(
Expand All @@ -88,7 +88,7 @@ def test_plugin_version_format(src_dir, plugin_config_file,
('staged_plugin::staged', "'staged_plugin::staged' does not match"),
(':staged_plugin:staged:', "':staged_plugin:staged:' does not match"),
('staged_plugin:staged', None)])
def test_plugin_entry_point(src_dir, plugin_config_file,
def test_plugin_entry_point(plugin_config_file,
plugin_config_content, expected):
try:
validator = PluginValidator.from_config_content(
Expand All @@ -100,7 +100,7 @@ def test_plugin_entry_point(src_dir, plugin_config_file,
assert expected in message

@staticmethod
def test_plugin_additional_properties(src_dir, plugin_config_file,
def test_plugin_additional_properties(plugin_config_file,
plugin_config_content):
# Adding an unknown key
plugin_config_content['unknown_key'] = 'unknown_value'
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_multiple_validation_errors(plugin_config_file,
('STAGED', "'STAGED' does not match"),
('E3b69c61-4c30-44f7-92c0-504c8388b91e', None),
('e3b69c61-4c30-44f7-92c0-504c8388b91e', None)])
def test_plugin_id(mock_import_plugin, src_dir, plugin_config_file,
def test_plugin_id(plugin_config_file,
plugin_config_content, expected):
try:
validator = PluginValidator.from_config_content(
Expand All @@ -161,7 +161,7 @@ def test_plugin_id(mock_import_plugin, src_dir, plugin_config_file,
('0', "'0' does not match"),
('0.0.00', "'0.0.00' does not match"),
('0.1', None)])
def test_plugin_build_number_format(src_dir, plugin_config_file,
def test_plugin_build_number_format(plugin_config_file,
plugin_config_content, expected):
try:
validator = PluginValidator.from_config_content(
Expand All @@ -174,12 +174,11 @@ def test_plugin_build_number_format(src_dir, plugin_config_file,

@staticmethod
@mock.patch('os.path.isabs', return_value=False)
@pytest.mark.parametrize('lua_name, expected', [
('lua toolkit', "'lua toolkit' does not match"),
('!lua#toolkit', "'!lua#toolkit' does not match"),
(None, "should never get here")
])
def test_plugin_lua_name_format(src_dir, plugin_config_file,
@pytest.mark.parametrize(
'lua_name, expected',
[('lua toolkit', "'lua toolkit' does not match"),
('!lua#toolkit', "'!lua#toolkit' does not match")])
def test_plugin_lua_name_format(plugin_config_file,
plugin_config_content, expected):
try:
validator = PluginValidator.from_config_content(
Expand All @@ -189,3 +188,49 @@ def test_plugin_lua_name_format(src_dir, plugin_config_file,
except exceptions.SchemaValidationError as err_info:
message = err_info.message
assert expected in message

@staticmethod
@mock.patch('os.path.isabs', return_value=False)
@pytest.mark.parametrize('minimum_lua_version, expected',
[('1-2-3', "'1-2-3' does not match"),
('version1.0!', "'version1.0!' does not match"),
('2.3.4', "'2.3.4' does not match")])
def test_plugin_minimum_lua_version_format(plugin_config_file,
plugin_config_content,
expected):
try:
validator = PluginValidator.from_config_content(
plugin_config_file, plugin_config_content,
const.PLUGIN_CONFIG_SCHEMA)
validator.validate_plugin_config()
except exceptions.SchemaValidationError as err_info:
message = err_info.message
assert expected in message

@staticmethod
@pytest.mark.parametrize('minimum_lua_version', [None])
def test_plugin_lua_name_without_minimum_lua_version(
plugin_config_file, plugin_config_content):
try:
validator = PluginValidator.from_config_content(
plugin_config_file, plugin_config_content,
const.PLUGIN_CONFIG_SCHEMA)
validator.validate_plugin_config()
except exceptions.ValidationFailedError as err_info:
message = err_info.message
assert ('Failed to process property "luaName" without '
'"minimumLuaVersion" set in the plugin config.' in message)

@staticmethod
@pytest.mark.parametrize('lua_name', [None])
def test_plugin_minimum_lua_version_without_lua_name(
plugin_config_file, plugin_config_content):
try:
validator = PluginValidator.from_config_content(
plugin_config_file, plugin_config_content,
const.PLUGIN_CONFIG_SCHEMA)
validator.validate_plugin_config()
except exceptions.ValidationFailedError as err_info:
message = err_info.message
assert ('Failed to process property "minimumLuaVersion" without '
'"luaName" set in the plugin config.' in message)