This commit is contained in:
Chaoyi Yuan 2019-12-03 16:55:27 +08:00 коммит произвёл GitHub
Родитель c8520a99d5
Коммит d43febbc90
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 93 добавлений и 15 удалений

Просмотреть файл

@ -141,10 +141,7 @@ class Modules:
# sample: 'localhost:5000/filtermodule:0.0.1-amd64'
tags_to_build = set()
self.output.info("Validating deployment template %s" % template_file)
deployment_manifest = DeploymentManifest(self.envvars, self.output, self.utility, template_file, True, False)
deployment_manifest.validate_deployment_template()
deployment_manifest.expand_environment_variables()
deployment_manifest = DeploymentManifest(self.envvars, self.output, self.utility, template_file, True, True)
# get image tags for ${MODULES.modulename.xxx} placeholder
modules_path = os.path.join(template_file_folder, self.envvars.MODULES_PATH)

Просмотреть файл

@ -34,7 +34,6 @@ requirements = [
'python-dotenv',
'requests >= 2.20.0, < 2.21',
'fstrings',
'msrestazure~=0.4.32',
'azure-cli-core',
'azure-cli-iot',
'azure-cli-profile',
@ -46,7 +45,7 @@ requirements = [
'six',
'applicationinsights < 0.11.8',
'commentjson == 0.7.2',
'pyyaml>=3.10,<4.3',
'pyyaml>=4.1,<=4.2b4',
'pypiwin32==219; sys_platform == "win32" and python_version < "3.6"',
'pypiwin32==223; sys_platform == "win32" and python_version >= "3.6"'
]

Просмотреть файл

@ -0,0 +1,79 @@
{
"$schema-template": "1.0.0",
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.0",
"runtime": {
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": "",
"registryCredentials": {}
}
},
"systemModules": {
"edgeAgent": {
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:${RUNTIME_TAG}",
"createOptions": {}
}
},
"edgeHub": {
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:${RUNTIME_TAG}",
"createOptions": {
"HostConfig": {
"PortBindings": {
"5671/tcp": [
{
"HostPort": "5671"
}
],
"8883/tcp": [
{
"HostPort": "8883"
}
],
"443/tcp": [
{
"HostPort": "443"
}
]
}
}
}
}
}
},
"modules": {
"tempSensor": {
"version": "1.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:${RUNTIME_TAG}",
"createOptions": {}
}
}
}
}
},
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.0",
"routes": {
"sensorTofiltermodule": "FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/filtermodule/inputs/input1\")"
},
"storeAndForwardConfiguration": {
"timeToLiveSecs": ${TTL}
}
}
}
}
}

Просмотреть файл

@ -484,15 +484,8 @@ def test_validate_deployment_template_and_manifest_failed():
assert "ERROR" not in result.output
# File name should be printed
assert "Validating deployment template %s" % deployment_file_name in result.output
assert "Validating generated deployment manifest %s" % os.path.join("config", deployment_file_name) in result.output
# All schema errors should be detected, not only the first error
assert "Warning: Deployment template schema error: 'address' is a required property. "
"Property path:modulesContent->$edgeAgent->properties.desired->runtime->settings->registryCredentials->test" in result.output
assert "Warning: Deployment template schema error: 1 is not of type 'string'. "
"Property path:modulesContent->$edgeAgent->properties.desired->runtime->settings->registryCredentials->test->username" in result.output
assert "Warning: Deployment template schema validation failed" in result.output
assert "Deployment template schema validation passed" not in result.output
assert "Warning: Deployment manifest schema error: 'address' is a required property. "
"Property path:modulesContent->$edgeAgent->properties.desired->runtime->settings->registryCredentials->test" in result.output
assert "Warning: Deployment manifest schema error: 1 is not of type 'string'. "
@ -525,8 +518,6 @@ def test_validate_deployment_template_and_manifest_success():
result = runner_invoke(['genconfig', '-f', deployment_file_name])
assert "ERROR" not in result.output
assert "Deployment template schema validation passed" in result.output
assert "Warning: Deployment template schema validation failed" not in result.output
assert "Deployment manifest schema validation passed" in result.output
assert "Warning: Deployment manifest schema validation failed" not in result.output
assert "Validation for all createOptions passed" in result.output
@ -575,6 +566,18 @@ def test_fail_gen_config_on_validation_error():
assert "ERROR" not in result.output
def test_gen_config_with_non_string_placeholder():
os.chdir(tests_assets_dir)
os.environ["TTL"] = "7200"
deployment_file_name = "deployment.template.non_str_placeholder.json"
if get_docker_os_type() == "windows":
result = runner_invoke(['genconfig', '-P', get_platform_type(), '-f', deployment_file_name, '--fail-on-validation-error'])
else:
result = runner_invoke(['genconfig', '-f', deployment_file_name, '--fail-on-validation-error'])
assert "ERROR" not in result.output
@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='windows container does not support local registry image')
def test_push_modules_to_local_registry(prepare_solution_with_env):
env_container_registry_server = os.getenv("CONTAINER_REGISTRY_SERVER")