From: Tony Hansen Date: Sat, 27 Feb 2021 01:16:03 +0000 (+0000) Subject: Merge "[DCAE] Release AA container" X-Git-Tag: 1.0.6-adapter-acumos~11 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=70b2bae8188291f5fe993cbdbf4a66dd3df2c846;hp=12e0465e74451c189872966fef1174df5953f6db;p=dcaegen2%2Fplatform.git Merge "[DCAE] Release AA container" --- diff --git a/adapter/acumos-deployment/values.yaml b/adapter/acumos-deployment/values.yaml index 78f4400..4b4a1b7 100644 --- a/adapter/acumos-deployment/values.yaml +++ b/adapter/acumos-deployment/values.yaml @@ -28,7 +28,8 @@ global: ingress: enabled: true virtualhost: - enabled: false + enabled: true + baseurl: "simpledemo.onap.org" config: distributorAPIURL: /distributor @@ -50,9 +51,10 @@ service: ingress: enabled: true service: - - baseaddr: "acumos-adapter" + - baseaddr: "dcaemod" name: "dcae-acumos-adapter" port: 9000 + path: "/acumos-adapter" annotations: nginx.ingress.kubernetes.io/ssl-redirect: "false" # Adapter can take a long time to respond, since diff --git a/adapter/acumos/setup.py b/adapter/acumos/setup.py index 35c7273..d667f0b 100644 --- a/adapter/acumos/setup.py +++ b/adapter/acumos/setup.py @@ -20,7 +20,7 @@ from setuptools import setup, find_packages setup( name="aoconversion", - version="1.0.3", + version="1.0.4-SNAPSHOT", packages=find_packages(exclude=["tests.*", "tests"]), author="Tommy Carpenter, Andrew Gauld", author_email="tommy@research.att.com, agauld@att.com", diff --git a/adapter/acumos/tests/conftest.py b/adapter/acumos/tests/conftest.py index 80351c8..4219f66 100644 --- a/adapter/acumos/tests/conftest.py +++ b/adapter/acumos/tests/conftest.py @@ -19,7 +19,9 @@ import os import pytest import requests + import aoconversion +from tests import testing_helpers @pytest.fixture @@ -29,3 +31,43 @@ def mock_schemas(monkeypatch): monkeypatch.setattr(aoconversion.utils.component_schema, 'path', schemadir + '/component-specification/dcae-cli-v2/component-spec-schema.json') monkeypatch.setattr(aoconversion.utils.dataformat_schema, 'path', schemadir + '/data-format/dcae-cli-v1/data-format-schema.json') monkeypatch.setattr(aoconversion.utils.schema_schema, 'ret', requests.get('https://json-schema.org/draft-04/schema#').json()) + + +def test_get_metadata(): + model_repo_path = testing_helpers.get_fixture_path('models') + model_name = 'example-model' + assert (aoconversion.utils.get_metadata(model_repo_path, model_name) == { + "schema": "acumos.schema.model:0.4.0", + "runtime": { + "name": "python", + "encoding": "protobuf", + "version": "3.6.8", + "dependencies": { + "pip": { + "indexes": [], + "requirements": [ + { + "name": "dill", + "version": "0.3.0" + }, + { + "name": "acumos", + "version": "0.8.0" + } + ] + }, + "conda": { + "channels": [], + "requirements": [] + } + } + }, + "name": "example-model", + "methods": { + "add": { + "input": "NumbersIn", + "output": "NumberOut", + "description": "Adds two integers" + } + } + }) diff --git a/adapter/acumos/tests/fixtures/config.yaml b/adapter/acumos/tests/fixtures/config.yaml new file mode 100644 index 0000000..207fe0c --- /dev/null +++ b/adapter/acumos/tests/fixtures/config.yaml @@ -0,0 +1,10 @@ +dcaeurl: https://git.onap.org/dcaegen2/platform/plain/mod +dcaeuser: aoadapter +onboardingurl: http://dcaemod-onboarding-api:8080/onboarding +onboardinguser: '' +onboardingpass: '' +certfile: /run/certs/cert.pem +dockerregistry: 'dockerregistry' +dockeruser: 'dockeruser' +dockerpass: 'dockerpass' +port: '90' \ No newline at end of file diff --git a/adapter/acumos/tests/test_convert.py b/adapter/acumos/tests/test_convert.py new file mode 100644 index 0000000..780cc55 --- /dev/null +++ b/adapter/acumos/tests/test_convert.py @@ -0,0 +1,92 @@ +# ============LICENSE_START==================================================== +# org.onap.dcae +# ============================================================================= +# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. +# ============================================================================= +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END====================================================== +''' +Unit tests for convert.py +should return docker_uri, dataformat and spec +''' + +import aoconversion +from testing_helpers import get_fixture_path + + +def test_gen_dcae_artifacts_for_model(monkeypatch): + model_repo_path = get_fixture_path('models') + model_name = 'example-model' + config = aoconversion.scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', tmpdir=model_repo_path) + spec = { + "self": { + "version": "1.0.0", + "name": "example-model", + "description": "Automatically generated from Acumos model", + "component_type": "docker", + }, + "services": {"calls": [], "provides": []}, + "streams": { + "subscribes": [ + {"config_key": "add_subscriber", "format": "NumbersIn", "version": "1.0.0", "type": "message_router"} + ], + "publishes": [ + {"config_key": "add_publisher", "format": "NumberOut", "version": "1.0.0", "type": "message_router"} + ], + }, + "parameters": [], + "auxilary": {"healthcheck": {"type": "http", "endpoint": "/healthcheck"}}, + "artifacts": [{"type": "docker image", "uri": "nexus01.fake.com:18443/example-model:latest"}], + } + dataformat = [ + { + "self": {"name": "NumbersIn", "version": "1.0.0"}, + "dataformatversion": "1.0.1", + "jsonschema": { + "title": "NumbersIn", + "type": "object", + "properties": { + "x": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}, + "y": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}, + }, + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": {}, + }, + }, + { + "self": {"name": "NumberOut", "version": "1.0.0"}, + "dataformatversion": "1.0.1", + "jsonschema": { + "title": "NumberOut", + "type": "object", + "properties": {"result": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}}, + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": {}, + }, + }, + ] + dockeruri = 'dockerregistry/example-model:latest' + + def mockreturn_dockeruri(config, model_name, model_version='latest'): + return dockeruri + + def mockreturn_dataformats(model_repo_path, model_name): + return dataformat + + def mockreturn_spec(model_repo_path, model_name, dataformat, dockeruri): + return spec + + monkeypatch.setattr(aoconversion.docker_gen, 'build_and_push_docker', mockreturn_dockeruri) + monkeypatch.setattr(aoconversion.dataformat_gen, 'generate_dcae_data_formats', mockreturn_dataformats) + monkeypatch.setattr(aoconversion.spec_gen, 'generate_spec', mockreturn_spec) + assert aoconversion.convert.gen_dcae_artifacts_for_model(config, model_name, 'latest') == (dockeruri, dataformat, spec) diff --git a/adapter/acumos/tests/test_docker.py b/adapter/acumos/tests/test_docker.py index 0d84038..2f618e6 100644 --- a/adapter/acumos/tests/test_docker.py +++ b/adapter/acumos/tests/test_docker.py @@ -16,8 +16,9 @@ # limitations under the License. # ============LICENSE_END====================================================== -from testing_helpers import get_json_fixture -from aoconversion import docker_gen +from testing_helpers import get_json_fixture, get_fixture_path +from aoconversion import docker_gen, scanner +import test_fed TEST_META = get_json_fixture("models/example-model/metadata.json") @@ -45,3 +46,10 @@ def test_generate_dockerfile(): CMD ["/app/example-model"] """ ) + + +def test_build_and_push_docker(monkeypatch): + model_repo_path = get_fixture_path('models') + config = scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', tmpdir=model_repo_path) + monkeypatch.setattr(docker_gen, 'APIClient', test_fed._mockdocker.APIClient) + assert(docker_gen.build_and_push_docker(config, 'example-model', model_version="latest") == 'dockerregistry/example-model:latest') diff --git a/adapter/acumos/tests/test_fed.py b/adapter/acumos/tests/test_fed.py index 6119976..c5400a3 100644 --- a/adapter/acumos/tests/test_fed.py +++ b/adapter/acumos/tests/test_fed.py @@ -172,3 +172,8 @@ def test_aoconversion(mock_schemas, tmpdir, monkeypatch): monkeypatch.setattr(requests, 'patch', _mockwww(_mockpatchdata)) aoc_scanner.scan(config) aoc_scanner.scan(config) + + +def test__derefconfig(): + config_path = get_test_file('config.yaml') + assert aoc_scanner._derefconfig('@' + config_path) == 'dcaeurl: https://git.onap.org/dcaegen2/platform/plain/mod' diff --git a/adapter/acumos/tox.ini b/adapter/acumos/tox.ini index bc94f22..deebf3b 100644 --- a/adapter/acumos/tox.ini +++ b/adapter/acumos/tox.ini @@ -32,7 +32,7 @@ setenv = commands= nodeenv -p npm install --global protobuf-jsonschema - pytest --verbose --junitxml xunit-results.xml --cov aoconversion --cov-report xml --cov-report html + pytest --verbose --junitxml xunit-results.xml --cov aoconversion --cov-report xml --cov-report html --cov-report term [testenv:flake8] basepython = python3.7 diff --git a/mod/bpgenerator/common/pom.xml b/mod/bpgenerator/common/pom.xml index 09c9757..ae4f716 100644 --- a/mod/bpgenerator/common/pom.xml +++ b/mod/bpgenerator/common/pom.xml @@ -29,7 +29,7 @@ 4.0.0 blueprint-generator-common - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT jar Common @@ -39,7 +39,7 @@ org.onap.dcaegen2.platform.mod blueprint-generator - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java index fbd0527..e08b28d 100644 --- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java @@ -4,8 +4,7 @@ * * org.onap.dcae * * ================================================================================ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. - * * ================================================================================ - * * Modifications Copyright (c) 2021 Nokia + * * Copyright (c) 2021 Nokia. All rights reserved. * * ================================================================================ * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. @@ -51,8 +50,6 @@ public class Constants { public static final String EMPTY_VALUE = ""; public static final String DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT_USING_DMAAP = "dcae.nodes.ContainerizedServiceComponentUsingDmaap"; - public static final String MEMORY_LIMIT_128Mi = "128Mi"; - public static final String CPU_LIMIT_250m = "250m"; public static final String CPU_LIMIT = "cpu_limit"; public static final String MEMORY_LIMIT = "memory_limit"; public static final String CPU_REQUEST = "cpu_request"; diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java index 0526f48..a84afb6 100644 --- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java @@ -178,7 +178,7 @@ public class BlueprintHelperService { *

* Default input type: "string". * - * @param inputType Input type, supported: "boolean", "integer" + * @param inputType Input type, supported: "boolean", "integer", "number" * @param defaultValue Default value of Type * @return */ @@ -187,6 +187,7 @@ public class BlueprintHelperService { case "boolean": return createBooleanInput(defaultValue); case "integer": + case "number": return createIntegerInput(defaultValue); default: return createStringInput(defaultValue); diff --git a/mod/bpgenerator/onap-executable/pom.xml b/mod/bpgenerator/onap-executable/pom.xml index ae20547..d1376c3 100644 --- a/mod/bpgenerator/onap-executable/pom.xml +++ b/mod/bpgenerator/onap-executable/pom.xml @@ -22,12 +22,12 @@ limitations under the License. blueprint-generator org.onap.dcaegen2.platform.mod - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT 4.0.0 blueprint-generator-onap-executable - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT jar OnapExecutable @@ -37,7 +37,7 @@ limitations under the License. org.onap.dcaegen2.platform.mod blueprint-generator-onap - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT compile diff --git a/mod/bpgenerator/onap/pom.xml b/mod/bpgenerator/onap/pom.xml index dc91f39..ccf24b6 100644 --- a/mod/bpgenerator/onap/pom.xml +++ b/mod/bpgenerator/onap/pom.xml @@ -29,7 +29,7 @@ 4.0.0 blueprint-generator-onap - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT jar Onap @@ -40,14 +40,14 @@ org.onap.dcaegen2.platform.mod blueprint-generator - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT org.onap.dcaegen2.platform.mod blueprint-generator-common - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT compile diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java index a3a9c97..ab33bfa 100644 --- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java @@ -4,6 +4,7 @@ * * org.onap.dcae * * ================================================================================ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * * Copyright (c) 2021 Nokia. All rights reserved. * * ================================================================================ * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. @@ -28,6 +29,7 @@ import org.onap.blueprintgenerator.model.common.GetInput; import org.onap.blueprintgenerator.model.common.ResourceConfig; import org.onap.blueprintgenerator.service.base.BlueprintHelperService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -46,6 +48,12 @@ public class ResourceConfigService { @Autowired private BlueprintHelperService blueprintHelperService; + @Value("${resources.cpuLimit}") + private String defaultCpuLimit; + + @Value("${resources.memoryLimit}") + private String defaultMemoryLimit; + /** * Creates Resouce Config for properties * @@ -59,10 +67,10 @@ public class ResourceConfigService { ResourceConfig resourceConfig = new ResourceConfig(); LinkedHashMap memoryLimit = - blueprintHelperService.createStringInput(Constants.MEMORY_LIMIT_128Mi); + blueprintHelperService.createStringInput(defaultMemoryLimit); LinkedHashMap cpuLimit = - blueprintHelperService.createStringInput(Constants.CPU_LIMIT_250m); + blueprintHelperService.createStringInput(defaultCpuLimit); name = blueprintHelperService.getNamePrefix(name); diff --git a/mod/bpgenerator/onap/src/main/resources/bpgen.properties b/mod/bpgenerator/onap/src/main/resources/bpgen.properties index 69a3ad6..5bc0ab0 100644 --- a/mod/bpgenerator/onap/src/main/resources/bpgen.properties +++ b/mod/bpgenerator/onap/src/main/resources/bpgen.properties @@ -4,7 +4,7 @@ # * org.onap.dcae # * ================================================================================ # * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. -# * Copyright (c) 2020 Nokia. All rights reserved. +# * Copyright (c) 2020-2021 Nokia. All rights reserved. # * ================================================================================ # * Licensed under the Apache License, Version 2.0 (the "License"); # * you may not use this file except in compliance with the License. @@ -23,10 +23,11 @@ # imports.onap.types=https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml -imports.onap.K8s.plugintypes=plugin:k8splugin?version=3.4.2 +imports.onap.K8s.plugintypes=plugin:k8splugin?version=>=3.5.1,<4.0.0 imports.onap.K8s.dcaepolicyplugin=plugin:dcaepolicyplugin?version=2.4.0 imports.dmaap.dmaapplugin=plugin:dmaap?version=1.5.0 import.Postgres=plugin:pgaas?version=1.3.0 import.Clamp=plugin:clamppolicyplugin?version=1.1.0 - +resources.cpuLimit=${BP_RESOURCES_CPU_LIMIT:250m} +resources.memoryLimit=${BP_RESOURCES_MEMORY_LIMIT:128Mi} diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java new file mode 100644 index 0000000..61f9353 --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java @@ -0,0 +1,175 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2021 Nokia Intellectual Property. All rights reserved. + * * ================================================================================ + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * * ============LICENSE_END========================================================= + * + * + */ + +package org.onap.blueprintgenerator.service.common; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.blueprintgenerator.model.common.Appconfig; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.model.componentspec.common.Parameters; +import org.onap.blueprintgenerator.service.InfoService; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.onap.blueprintgenerator.service.common.kafka.KafkaStreamService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigService.class, BlueprintHelperService.class, DmaapService.class, + InfoService.class, StreamService.class, KafkaStreamService.class}, + initializers = ConfigFileApplicationContextInitializer.class) +public class AppConfigServiceTest { + + private static final String TEST_PARAMETER_NAME = "testParameter"; + private static final String INPUTS = "inputs"; + private static final String TYPE = "type"; + private static final String DEFAULT = "default"; + + private static final String PARAMETERS_TYPE_STRING = "string"; + private static final String PARAMETERS_TYPE_INTEGER = "integer"; + private static final String PARAMETERS_TYPE_BOOLEAN = "boolean"; + private static final String PARAMETERS_TYPE_NUMBER = "number"; + + private static final String STRING_INPUT_TYPE = "string"; + private static final String INTEGER_INPUT_TYPE = "integer"; + private static final String BOOLEAN_INPUT_TYPE = "boolean"; + private static final String UNKNOWN_TYPE = "test_unknown_type"; + + private static final boolean BOOLEAN_TEST_VALUE = true; + private static final String TEST_STRING_VALUE = "testValue"; + private static final String APP_CONFIG = "appconfig"; + + @Autowired + private AppConfigService appConfigService; + + private OnapComponentSpec componentSpec; + + @Before + public void setUp() { + componentSpec = Mockito.mock(OnapComponentSpec.class); + } + + @Test + public void shouldCreateStringInputForStringParameter() { + + mockParameters(PARAMETERS_TYPE_STRING, TEST_STRING_VALUE); + Map> inputs = new HashMap<>(); + + Map appConfig = appConfigService.createAppconfig(inputs, componentSpec, false); + Map createdInputs = (Map) appConfig.get(INPUTS); + Map createdParameters = (Map) createdInputs.get(TEST_PARAMETER_NAME); + + assertAppConfigContainsParameterWithCorrectInputName(appConfig); + assertEquals(STRING_INPUT_TYPE, createdParameters.get(TYPE)); + assertEquals(TEST_STRING_VALUE, createdParameters.get(DEFAULT)); + } + + @Test + public void shouldCreateStringInputForUnknownParameter() { + + mockParameters(UNKNOWN_TYPE, TEST_STRING_VALUE); + Map> inputs = new HashMap<>(); + + Map appConfig = appConfigService.createAppconfig(inputs, componentSpec, false); + Map createdInputs = (Map) appConfig.get(INPUTS); + Map createdParameters = (Map) createdInputs.get(TEST_PARAMETER_NAME); + + assertAppConfigContainsParameterWithCorrectInputName(appConfig); + assertEquals(STRING_INPUT_TYPE, createdParameters.get(TYPE)); + assertEquals(TEST_STRING_VALUE, createdParameters.get(DEFAULT)); + } + + @Test + public void shouldCreateBooleanInputForBooleanParameter() { + + mockParameters(PARAMETERS_TYPE_BOOLEAN, BOOLEAN_TEST_VALUE); + Map> inputs = new HashMap<>(); + + Map appConfig = appConfigService.createAppconfig(inputs, componentSpec, false); + Map createdInputs = (Map) appConfig.get(INPUTS); + Map createdParameters = (Map) createdInputs.get(TEST_PARAMETER_NAME); + + assertAppConfigContainsParameterWithCorrectInputName(appConfig); + assertEquals(BOOLEAN_INPUT_TYPE, createdParameters.get(TYPE)); + assertEquals(BOOLEAN_TEST_VALUE, createdParameters.get(DEFAULT)); + } + + @Test + public void shouldCreateIntegerInputForIntegerParameter() { + + mockParameters(PARAMETERS_TYPE_INTEGER, 123); + Map> inputs = new HashMap<>(); + + Map appConfig = appConfigService.createAppconfig(inputs, componentSpec, false); + Map createdInputs = (Map) appConfig.get(INPUTS); + Map createdParameters = (Map) createdInputs.get(TEST_PARAMETER_NAME); + + assertAppConfigContainsParameterWithCorrectInputName(appConfig); + assertEquals(INTEGER_INPUT_TYPE, createdParameters.get(TYPE)); + assertEquals(123, createdParameters.get(DEFAULT)); + } + + @Test + public void shouldCreateIntegerInputForNumberParameter() { + + mockParameters(PARAMETERS_TYPE_NUMBER, 123); + Map> inputs = new HashMap<>(); + + Map appConfig = appConfigService.createAppconfig(inputs, componentSpec, false); + Map createdInputs = (Map) appConfig.get(INPUTS); + Map createdParameters = (Map) createdInputs.get(TEST_PARAMETER_NAME); + + + assertAppConfigContainsParameterWithCorrectInputName(appConfig); + assertEquals(INTEGER_INPUT_TYPE, createdParameters.get(TYPE)); + assertEquals(123, createdParameters.get(DEFAULT)); + } + + private void assertAppConfigContainsParameterWithCorrectInputName(Map appConfig) { + Appconfig appConfigModel = (Appconfig) appConfig.get(APP_CONFIG); + Object bpInputName = ((GetInput) appConfigModel.getParams().get(TEST_PARAMETER_NAME)).getBpInputName(); + assertEquals(bpInputName, TEST_PARAMETER_NAME); + } + + private void mockParameters(String type, Object value) { + Parameters testParameter = new Parameters(); + testParameter.setName(TEST_PARAMETER_NAME); + testParameter.setType(type); + testParameter.setSourced_at_deployment(true); + testParameter.setValue(value); + Parameters[] parametersArray = new Parameters[1]; + parametersArray[0] = testParameter; + when(componentSpec.getParameters()).thenReturn(parametersArray); + } +} diff --git a/mod/bpgenerator/pom.xml b/mod/bpgenerator/pom.xml index 540d3e2..dd157d9 100644 --- a/mod/bpgenerator/pom.xml +++ b/mod/bpgenerator/pom.xml @@ -30,7 +30,7 @@ org.onap.dcaegen2.platform.mod blueprint-generator - 1.7.2-SNAPSHOT + 1.7.3-SNAPSHOT pom diff --git a/mod/bpgenerator/version.properties b/mod/bpgenerator/version.properties index 75acd49..c3c1ab1 100644 --- a/mod/bpgenerator/version.properties +++ b/mod/bpgenerator/version.properties @@ -1,6 +1,6 @@ major=1 minor=7 -patch=2 +patch=3 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT diff --git a/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json b/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json old mode 100644 new mode 100755 index 56dbf3a..4a3597a --- a/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json +++ b/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json @@ -904,7 +904,8 @@ "type": "string" } } - } + }, + "required": ["host", "container"] }, "config_map_volume": { "type": "object", @@ -924,7 +925,8 @@ "type": "string" } } - } + }, + "required": ["config_volume", "container"] }, "docker_healthcheck_http": { "properties": { @@ -987,4 +989,4 @@ ] } } -} +} \ No newline at end of file diff --git a/mod/onboardingapi/ChangeLog.md b/mod/onboardingapi/ChangeLog.md index 28578d2..ede9878 100644 --- a/mod/onboardingapi/ChangeLog.md +++ b/mod/onboardingapi/ChangeLog.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.12.5] + +* Fix component-spec-schema bug: Failed validating 'oneOf' in schema['properties']['volumes']['items'] + + +## [2.12.4] + +* Update component-spec-schema to support: kafka stream subscribes and publishes, config maps as volumes + +## [2.12.3] + +* Add Python 3.8 support +* Use Integration base image ## [2.12.1] diff --git a/mod/onboardingapi/dcae_cli/_version.py b/mod/onboardingapi/dcae_cli/_version.py index 7081b3b..21fd154 100644 --- a/mod/onboardingapi/dcae_cli/_version.py +++ b/mod/onboardingapi/dcae_cli/_version.py @@ -19,4 +19,4 @@ # ECOMP is a trademark and service mark of AT&T Intellectual Property. # -*- coding: utf-8 -*- -__version__ = "2.12.4" +__version__ = "2.12.5" diff --git a/mod/onboardingapi/pom.xml b/mod/onboardingapi/pom.xml index 796816f..c9da793 100644 --- a/mod/onboardingapi/pom.xml +++ b/mod/onboardingapi/pom.xml @@ -24,7 +24,7 @@ limitations under the License. org.onap.dcaegen2.platform.mod dcaegen2-platform-mod-onboardingapi dcaegen2-platform-mod-onboardingapi - 2.12.4-SNAPSHOT + 2.12.5-SNAPSHOT http://maven.apache.org UTF-8 diff --git a/mod/runtimeapi/Changelog.md b/mod/runtimeapi/Changelog.md new file mode 100644 index 0000000..3dd643c --- /dev/null +++ b/mod/runtimeapi/Changelog.md @@ -0,0 +1,15 @@ +# Change Log + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [1.2.3] +- Update BPGenerator 1.7.3 + - Update default k8splugin import + - Externalize resource limits defaults for generated blueprints + +## [1.2.2] +- Update SpringFox dependencies to version 3.0.0 + - Swagger documentation URL changed from: /swagger-ui.html to: /swagger-ui/index.html diff --git a/mod/runtimeapi/pom.xml b/mod/runtimeapi/pom.xml index 61f6558..11e5580 100644 --- a/mod/runtimeapi/pom.xml +++ b/mod/runtimeapi/pom.xml @@ -34,7 +34,7 @@ limitations under the License. org.onap.dcaegen2.platform.mod runtimeapi - 1.2.0 + 1.2.3 dcaegen2-platform-mod-runtimeapi MOD Runtime API @@ -108,6 +108,17 @@ limitations under the License. 2.1.7.RELEASE pom import + + + org.springframework.plugin + spring-plugin-core + + + + + org.springframework.plugin + spring-plugin-core + 2.0.0.RELEASE diff --git a/mod/runtimeapi/runtime-core/pom.xml b/mod/runtimeapi/runtime-core/pom.xml index 7031714..5514cc9 100644 --- a/mod/runtimeapi/runtime-core/pom.xml +++ b/mod/runtimeapi/runtime-core/pom.xml @@ -25,12 +25,12 @@ limitations under the License. runtimeapi org.onap.dcaegen2.platform.mod - 1.2.0 + 1.2.3 4.0.0 runtime-core - 1.2.0 + 1.2.3 @@ -46,7 +46,7 @@ limitations under the License. org.onap.dcaegen2.platform.mod blueprint-generator-onap - 1.7.1 + 1.7.3 org.json diff --git a/mod/runtimeapi/runtime-web/pom.xml b/mod/runtimeapi/runtime-web/pom.xml index 4c1a7c4..8b70ea4 100644 --- a/mod/runtimeapi/runtime-web/pom.xml +++ b/mod/runtimeapi/runtime-web/pom.xml @@ -24,10 +24,10 @@ limitations under the License. org.onap.dcaegen2.platform.mod runtimeapi - 1.2.0 + 1.2.3 runtime-web - 1.2.0-SNAPSHOT + 1.2.3-SNAPSHOT jar runtime-web MOD Runtime Web Module @@ -35,7 +35,7 @@ limitations under the License. org.onap.dcaegen2.platform.mod runtime-core - 1.2.0 + 1.2.3 org.springframework.boot @@ -65,13 +65,13 @@ limitations under the License. io.springfox - springfox-swagger2 - 2.10.5 + springfox-boot-starter + 3.0.0 io.springfox springfox-swagger-ui - 2.10.5 + 3.0.0 org.json diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/RuntimeapiApplication.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/RuntimeapiApplication.java index 611b332..df79251 100644 --- a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/RuntimeapiApplication.java +++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/RuntimeapiApplication.java @@ -19,10 +19,8 @@ package org.onap.dcae.runtime.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; @SpringBootApplication -@EnableSwagger2WebMvc public class RuntimeapiApplication { public static void main(String[] args) { diff --git a/mod/runtimeapi/runtime-web/src/test/java/org/onap/dcae/runtime/web/controllers/TestFlowGraphController.java b/mod/runtimeapi/runtime-web/src/test/java/org/onap/dcae/runtime/web/controllers/TestFlowGraphController.java index 60ff810..942d2fd 100644 --- a/mod/runtimeapi/runtime-web/src/test/java/org/onap/dcae/runtime/web/controllers/TestFlowGraphController.java +++ b/mod/runtimeapi/runtime-web/src/test/java/org/onap/dcae/runtime/web/controllers/TestFlowGraphController.java @@ -81,7 +81,7 @@ public class TestFlowGraphController { @Test public void testSwaggerUi() throws Exception { - mockMvc.perform(get("/swagger-ui.html")) + mockMvc.perform(get("/swagger-ui/index.html")) .andExpect(status().isOk()); } diff --git a/mod2/catalog-service/pom.xml b/mod2/catalog-service/pom.xml index 9a82b7b..ff425cf 100644 --- a/mod2/catalog-service/pom.xml +++ b/mod2/catalog-service/pom.xml @@ -3,7 +3,7 @@ ~ ============LICENSE_START======================================================= ~ org.onap.dcae ~ ================================================================================ - ~ Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + ~ Copyright (c) 2020-2021 AT&T Intellectual Property. All rights reserved. ~ ================================================================================ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. @@ -110,6 +110,11 @@ 4.2.2 test + + org.json + json + 20190722 + diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java index 600c735..72bba72 100644 --- a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * org.onap.dcae * ================================================================================ - * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,10 @@ package org.onap.dcaegen2.platform.mod.model.deploymentartifact; +import java.util.ArrayList; +import java.util.List; import lombok.Data; +import org.onap.dcaegen2.platform.mod.model.policymodel.DistributionInfo; import org.springframework.data.mongodb.core.mapping.Document; import java.util.Map; @@ -48,4 +51,6 @@ public class DeploymentArtifact { private Map specificationInfo; + private DistributionInfo distributionInfo; + } diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/BlueprintDistributionUtils.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/BlueprintDistributionUtils.java new file mode 100644 index 0000000..2860a39 --- /dev/null +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/BlueprintDistributionUtils.java @@ -0,0 +1,140 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.util; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.PostConstruct; +import org.onap.dcaegen2.platform.mod.model.exceptions.policymodel.PolicyModelDistributionEnvNotFoundException; +import org.onap.dcaegen2.platform.mod.model.policymodel.EnvInfo; +import org.onap.dcaegen2.platform.mod.model.policymodel.PolicyModelDistributionEnv; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * Policy Model Service Utils to get URL, Username, Password, Webclient + */ + +@Component +public class BlueprintDistributionUtils { + + @Value("${dcae.platform.url.path}") + private String urlpath; + + @Value("${dcae.platform.dev.server}") + private String devServer; + + @Value("${dcae.platform.dev.port}") + private String devServerPort; + + @Value("${dcae.platform.dev.user}") + private String devServerUser; + + @Value("${dcae.platform.dev.password}") + private String devServerUserPassword; + + @Value("${dcae.platform.pst.server}") + private String pstServer; + + @Value("${dcae.platform.pst.port}") + private String pstServerPort; + + @Value("${dcae.platform.pst.user}") + private String pstServerUser; + + @Value("${dcae.platform.pst.password}") + private String pstServerUserPassword; + + @Value("${dcae.platform.ete.server}") + private String eteServer; + + @Value("${dcae.platform.ete.port}") + private String eteServerPort; + + @Value("${dcae.platform.ete.user}") + private String eteServerUser; + + @Value("${dcae.platform.ete.password}") + private String eteServerUserPassword; + + @Value("${dcae.platform.prod.server}") + private String prodServer; + + @Value("${dcae.platform.prod.port}") + private String prodServerPort; + + @Value("${dcae.platform.prod.user}") + private String prodServerUser; + + @Value("${dcae.platform.prod.password}") + private String prodServerUserPassword; + + Map envMap; + + /** + * Creates a Blueprint Distribution Dashboard URL for the Environment requested + */ + @PostConstruct + public void init() { + envMap = new HashMap<>(); + envMap.put(PolicyModelDistributionEnv.DEV.name(), EnvInfo.builder().url("https://"+ devServer + ":" + devServerPort + urlpath).username(devServerUser).password(devServerUserPassword).build()); + envMap.put(PolicyModelDistributionEnv.PST.name(), EnvInfo.builder().url("https://"+ pstServer + ":" + pstServerPort + urlpath).username(pstServerUser).password(pstServerUserPassword).build()); + envMap.put(PolicyModelDistributionEnv.ETE.name(), EnvInfo.builder().url("https://"+ eteServer + ":" + eteServerPort + urlpath).username(eteServerUser).password(eteServerUserPassword).build()); + envMap.put(PolicyModelDistributionEnv.PROD.name(), EnvInfo.builder().url("https://"+ prodServer + ":" + prodServerPort + urlpath).username(prodServerUser).password(prodServerUserPassword).build()); + } + + /** + * Generates a Blueprint Distribution Dashboard URL for the Environment + * + * @param env + * @return + */ + public String getBlueprintDashboardURL(String env) { + if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Blueprint Dashboard Environment with env %s invalid", env)); + return envMap.get(env).getUrl(); + } + + /** + * Generates a Blueprint Distribution Dashboard UserName for the Environment + * + * @param env + * @return + */ + + public String getBlueprintDashboardUserName(String env) { + if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Blueprint Dashboard Environment with env %s invalid", env)); + return envMap.get(env).getUsername(); + } + + + /** + * Generates a Blueprint Distribution Dashboard Password for the Environment + * + * @param env + * @return + */ + + public String getBlueprintDashboardPassword(String env) { + if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Blueprint Dashboard Environment with env %s invalid", env)); + return envMap.get(env).getPassword(); + } + +} diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java index 30e13ea..347e66b 100644 --- a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * org.onap.dcae * ================================================================================ - * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,55 +46,55 @@ import java.util.Map; @Component public class PolicyModelUtils { - @Value("${url.path}") + @Value("${policymodel.url.path}") private String urlpath; - @Value("${dev.server}") + @Value("${policymodel.dev.server}") private String devServer; - @Value("${dev.port}") + @Value("${policymodel.dev.port}") private String devServerPort; - @Value("${dev.user}") + @Value("${policymodel.dev.user}") private String devServerUser; - @Value("${dev.password}") + @Value("${policymodel.dev.password}") private String devServerUserPassword; - @Value("${pst.server}") + @Value("${policymodel.pst.server}") private String pstServer; - @Value("${pst.port}") + @Value("${policymodel.pst.port}") private String pstServerPort; - @Value("${pst.user}") + @Value("${policymodel.pst.user}") private String pstServerUser; - @Value("${pst.password}") + @Value("${policymodel.pst.password}") private String pstServerUserPassword; - @Value("${ete.server}") + @Value("${policymodel.ete.server}") private String eteServer; - @Value("${ete.port}") + @Value("${policymodel.ete.port}") private String eteServerPort; - @Value("${ete.user}") + @Value("${policymodel.ete.user}") private String eteServerUser; - @Value("${ete.password}") + @Value("${policymodel.ete.password}") private String eteServerUserPassword; - @Value("${prod.server}") + @Value("${policymodel.prod.server}") private String prodServer; - @Value("${prod.port}") + @Value("${policymodel.prod.port}") private String prodServerPort; - @Value("${prod.user}") + @Value("${policymodel.prod.user}") private String prodServerUser; - @Value("${prod.password}") + @Value("${policymodel.prod.password}") private String prodServerUserPassword; Map envMap; diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/SSLUtils.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/SSLUtils.java new file mode 100644 index 0000000..a5d313d --- /dev/null +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/SSLUtils.java @@ -0,0 +1,69 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.util; + +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +public final class SSLUtils { + + static { + // for localhost testing only + HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() { + public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { + return true; + } + }); + } + + private static final TrustManager[] UNQUESTIONING_TRUST_MANAGER = new TrustManager[] { new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } }; + + public static void turnOffSslChecking() throws NoSuchAlgorithmException, KeyManagementException { + // Install the all-trusting trust manager + final SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, UNQUESTIONING_TRUST_MANAGER, null); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + } + + public static void turnOnSslChecking() throws KeyManagementException, NoSuchAlgorithmException { + // Return it to the initial state (discovered by reflection, now hardcoded) + SSLContext.getInstance("SSL").init(null, null, null); + } + + private SSLUtils() { + throw new UnsupportedOperationException("Do not instantiate libraries."); + } +} \ No newline at end of file diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/BlueprintDistributionController.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/BlueprintDistributionController.java new file mode 100644 index 0000000..36fbb2f --- /dev/null +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/BlueprintDistributionController.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.web.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.onap.dcaegen2.platform.mod.model.policymodel.PolicyModelDistributionEnv; +import org.onap.dcaegen2.platform.mod.web.service.blueprintdistributionservice.BlueprintDistributionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(value = "/api/deployment-artifact") +@Api(tags = "Graph", description = "API to distribute Blueprint to DCAE") +public class BlueprintDistributionController { + + @Autowired + private BlueprintDistributionService blueprintDistributionService; + + @PostMapping(value = "/{deploymentArtifactId}/distribute") + @ApiOperation("Distribution of Blueprint to DCAE") + public ResponseEntity distributeBlueprint(@PathVariable(value = "deploymentArtifactId") String deploymentArtifactId + ,@RequestParam PolicyModelDistributionEnv env){ + + return blueprintDistributionService.distributeBlueprint(deploymentArtifactId,env.name()); + } + +} diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/blueprintdistributionservice/BlueprintDistributionService.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/blueprintdistributionservice/BlueprintDistributionService.java new file mode 100644 index 0000000..6f7ca68 --- /dev/null +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/blueprintdistributionservice/BlueprintDistributionService.java @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.web.service.blueprintdistributionservice; + + +import org.springframework.http.ResponseEntity; + +/** + * An interface to access Blueprint Distribution Services + */ + +public interface BlueprintDistributionService { + + public ResponseEntity distributeBlueprint(String deploymentArtifactId, String env); + +} diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/blueprintdistributionservice/BlueprintDistributionServiceImpl.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/blueprintdistributionservice/BlueprintDistributionServiceImpl.java new file mode 100644 index 0000000..6ae367c --- /dev/null +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/blueprintdistributionservice/BlueprintDistributionServiceImpl.java @@ -0,0 +1,113 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.web.service.blueprintdistributionservice; + +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.json.JSONObject; +import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact; +import org.onap.dcaegen2.platform.mod.model.policymodel.DistributionInfo; +import org.onap.dcaegen2.platform.mod.model.policymodel.PolicyModelStatus; +import org.onap.dcaegen2.platform.mod.model.restapi.ErrorResponse; +import org.onap.dcaegen2.platform.mod.model.restapi.SuccessResponse; +import org.onap.dcaegen2.platform.mod.util.BlueprintDistributionUtils; +import org.onap.dcaegen2.platform.mod.util.SSLUtils; +import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactGateway; +import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +@Setter +@Slf4j +public class BlueprintDistributionServiceImpl implements BlueprintDistributionService{ + + @Autowired + private DeploymentArtifactService deploymentArtifactService; + + @Autowired + private BlueprintDistributionUtils blueprintDistributionUtils; + + @Autowired + private DeploymentArtifactGateway deploymentArtifactGateway; + + @Autowired + private RestTemplate restTemplate; + + public ResponseEntity distributeBlueprint(String deploymentArtifactId, String env){ + DeploymentArtifact deploymentArtifact = deploymentArtifactService.findDeploymentArtifactById(deploymentArtifactId); + return postBlueprintToDcae(deploymentArtifact,env); + } + + private ResponseEntity postBlueprintToDcae(DeploymentArtifact deploymentArtifact, String env){ + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setBasicAuth(blueprintDistributionUtils.getBlueprintDashboardUserName(env),blueprintDistributionUtils.getBlueprintDashboardPassword(env)); + + DistributionInfo distributionInfo = DistributionInfo.builder().url(blueprintDistributionUtils.getBlueprintDashboardURL(env)).build(); + deploymentArtifact.setDistributionInfo(distributionInfo); + JSONObject blueprintJsonObject = prepareBlueprintJsonObject(deploymentArtifact); + HttpEntity request = new HttpEntity<>(blueprintJsonObject.toString(), headers); + + try{ + SSLUtils.turnOffSslChecking(); + String response = restTemplate.postForObject(blueprintDistributionUtils.getBlueprintDashboardURL(env),request,String.class); + log.info(response); + log.info(String.format("Distributed Blueprint to DCAE: %s", blueprintJsonObject.toString())); + distributionInfo.setStatus(PolicyModelStatus.SUCCESS); + deploymentArtifactGateway.save(deploymentArtifact); + blueprintJsonObject.put("distributionInfoStatus", PolicyModelStatus.SUCCESS.name()); + return new ResponseEntity<>(new SuccessResponse(blueprintJsonObject.toString()), HttpStatus.OK); + }catch (Exception e) { + log.error("Failed to push Blueprint to DCAE"); + log.error(e.getMessage()); + distributionInfo.setStatus(PolicyModelStatus.FAILED); + deploymentArtifactGateway.save(deploymentArtifact); + return new ResponseEntity<>(new ErrorResponse(e.getMessage()), HttpStatus.BAD_REQUEST); + } + } + + private JSONObject prepareBlueprintJsonObject(DeploymentArtifact deploymentArtifact) { + JSONObject blueprintJsonObject = new JSONObject(); + blueprintJsonObject.put("owner","dcae_mod"); + blueprintJsonObject.put("typeName",deploymentArtifact.getFileName()); + blueprintJsonObject.put("typeVersion",deploymentArtifact.getVersion()); + blueprintJsonObject.put("blueprintTemplate",deploymentArtifact.getContent()); + blueprintJsonObject.put("application","DCAE"); + blueprintJsonObject.put("component","dcae"); + blueprintJsonObject.put("distributionInfoUrl", deploymentArtifact.getDistributionInfo().getUrl()); + return blueprintJsonObject; + } + + @Bean + private RestTemplate getRestTemplate(){ + return new RestTemplate(); + } + +} diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/policymodel/PolicyModelServiceImpl.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/policymodel/PolicyModelServiceImpl.java index 58fc447..a5dcfd0 100644 --- a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/policymodel/PolicyModelServiceImpl.java +++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/policymodel/PolicyModelServiceImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * org.onap.dcae * ================================================================================ - * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,16 +52,16 @@ import java.util.List; @Slf4j public class PolicyModelServiceImpl implements PolicyModelService { - @Value("${dev.server}") + @Value("${policymodel.dev.server}") private String devServer; - @Value("${dev.port}") + @Value("${policymodel.dev.port}") private String devServerPort; - @Value("${dev.user}") + @Value("${policymodel.dev.user}") private String devServerUser; - @Value("${dev.password}") + @Value("${policymodel.dev.password}") private String devServerPassword; @Autowired diff --git a/mod2/catalog-service/src/main/resources/application.properties b/mod2/catalog-service/src/main/resources/application.properties index 93c7883..9930866 100644 --- a/mod2/catalog-service/src/main/resources/application.properties +++ b/mod2/catalog-service/src/main/resources/application.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # org.onap.dcae # ================================================================================ -# Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2020-2021 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,26 +25,51 @@ spring.data.mongodb.database=dcae_mod -#Distribution Info Environment details +# Policy Model Distribution Info Environment details -url.path=/policy/api/v1/policytypes +policymodel.url.path=/policy/api/v1/policytypes -dev.server=10.12.6.2 -dev.port=30522 -dev.user=healthcheck -dev.password=PASSWORD_GOES_HERE +policymodel.dev.server=10.12.6.2 +policymodel.dev.port=30522 +policymodel.dev.user=healthcheck +policymodel.dev.password=PASSWORD_GOES_HERE -pst.server=policy-api -pst.port=6969 -pst.user=healthcheck -pst.password=PASSWORD_GOES_HERE +policymodel.pst.server=policy-api +policymodel.pst.port=6969 +policymodel.pst.user=healthcheck +policymodel.pst.password=PASSWORD_GOES_HERE -ete.server=policy-api -ete.port=6969 -ete.user=healthcheck -ete.password=PASSWORD_GOES_HERE +policymodel.ete.server=policy-api +policymodel.ete.port=6969 +policymodel.ete.user=healthcheck +policymodel.ete.password=PASSWORD_GOES_HERE -prod.server=policy-api -prod.port=6969 -prod.user=healthcheck -prod.password=PASSWORD_GOES_HERE \ No newline at end of file +policymodel.prod.server=policy-api +policymodel.prod.port=6969 +policymodel.prod.user=healthcheck +policymodel.prod.password=PASSWORD_GOES_HERE + + +# Blueprint Distribution Info Environment details + +dcae.platform.url.path=/ccsdk-app/nb-api/v2/blueprints + +dcae.platform.dev.server:10.12.5.222 +dcae.platform.dev.port:30418 +dcae.platform.dev.user=su1234 +dcae.platform.dev.password=PASSWORD_GOES_HERE + +dcae.platform.pst.server:10.12.5.222 +dcae.platform.pst.port:30418 +dcae.platform.pst.user=su1234 +dcae.platform.pst.password=PASSWORD_GOES_HERE + +dcae.platform.ete.server:10.12.5.222 +dcae.platform.ete.port:30418 +dcae.platform.ete.user=su1234 +dcae.platform.ete.password=PASSWORD_GOES_HERE + +dcae.platform.prod.server:10.12.5.222 +dcae.platform.prod.port:30418 +dcae.platform.prod.user=su1234 +dcae.platform.prod.password=PASSWORD_GOES_HERE \ No newline at end of file diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/BlueprintDistributionObjectMother.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/BlueprintDistributionObjectMother.java new file mode 100644 index 0000000..3d06f26 --- /dev/null +++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/BlueprintDistributionObjectMother.java @@ -0,0 +1,29 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.objectmothers; + +public class BlueprintDistributionObjectMother { + public static final String BP_DISTRIBUTION_ENV = "DEV"; + public static final String BP_DISTRIBUTION_MODEL_ID = "5f74ed7877b37173993057f5"; + public static final String BP_DISTRIBUTION_USER = "User1"; + public static final String BP_DISTRIBUTION_PWD = "pwd"; + +} diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/BlueprintDistributionControllerTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/BlueprintDistributionControllerTest.java new file mode 100644 index 0000000..7414116 --- /dev/null +++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/BlueprintDistributionControllerTest.java @@ -0,0 +1,76 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.web; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.onap.dcaegen2.platform.mod.objectmothers.BlueprintDistributionObjectMother.BP_DISTRIBUTION_ENV; +import static org.onap.dcaegen2.platform.mod.objectmothers.BlueprintDistributionObjectMother.BP_DISTRIBUTION_MODEL_ID; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.onap.dcaegen2.platform.mod.model.restapi.SuccessResponse; +import org.onap.dcaegen2.platform.mod.web.controller.BlueprintDistributionController; +import org.onap.dcaegen2.platform.mod.web.service.blueprintdistributionservice.BlueprintDistributionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.web.servlet.MockMvc; + +@ExtendWith(SpringExtension.class) +@WebMvcTest(BlueprintDistributionController.class) +public class BlueprintDistributionControllerTest { + + @Autowired + MockMvc mockMvc; + + @MockBean + private BlueprintDistributionService mockBlueprintDistributionService; + + @BeforeEach + void setup() { + } + + + @Test + void test_distributeBlueprintById_shouldReturn201AndResponseBody() throws Exception { + + ResponseEntity mockResponseEntity = new ResponseEntity<>(new SuccessResponse("Success"), HttpStatus.OK); + + when(mockBlueprintDistributionService + .distributeBlueprint(BP_DISTRIBUTION_MODEL_ID,BP_DISTRIBUTION_ENV)).thenReturn(mockResponseEntity); + + mockMvc.perform(post("/api/deployment-artifact/" + BP_DISTRIBUTION_MODEL_ID + "/distribute") + .param("env",BP_DISTRIBUTION_ENV).contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + + verify(mockBlueprintDistributionService, times(1)).distributeBlueprint(BP_DISTRIBUTION_MODEL_ID,BP_DISTRIBUTION_ENV); + } + +} \ No newline at end of file diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/BlueprintDistributionServiceImplImplTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/BlueprintDistributionServiceImplImplTest.java new file mode 100644 index 0000000..0a8a785 --- /dev/null +++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/BlueprintDistributionServiceImplImplTest.java @@ -0,0 +1,125 @@ +/* + * ============LICENSE_START======================================================= + * org.onap.dcae + * ================================================================================ + * Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.platform.mod.web.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.onap.dcaegen2.platform.mod.objectmothers.BlueprintDistributionObjectMother.BP_DISTRIBUTION_ENV; +import static org.onap.dcaegen2.platform.mod.objectmothers.BlueprintDistributionObjectMother.BP_DISTRIBUTION_MODEL_ID; +import static org.onap.dcaegen2.platform.mod.objectmothers.BlueprintDistributionObjectMother.BP_DISTRIBUTION_PWD; +import static org.onap.dcaegen2.platform.mod.objectmothers.BlueprintDistributionObjectMother.BP_DISTRIBUTION_USER; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.jupiter.MockitoExtension; +import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact; +import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus; +import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother; +import org.onap.dcaegen2.platform.mod.util.BlueprintDistributionUtils; +import org.onap.dcaegen2.platform.mod.web.service.blueprintdistributionservice.BlueprintDistributionServiceImpl; +import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactGateway; +import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactServiceImpl; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +@ExtendWith(MockitoExtension.class) +class BlueprintDistributionServiceImplImplTest { + + @Spy + private BlueprintDistributionServiceImpl mockBlueprintDistributionServiceImpl = new BlueprintDistributionServiceImpl(); + + @Mock + private DeploymentArtifactServiceImpl deploymentArtifactService; + + @Mock + private BlueprintDistributionUtils blueprintDistributionUtils; + + @Mock + private DeploymentArtifactGateway deploymentArtifactGateway; + + @Mock + private RestTemplate restTemplate; + + DeploymentArtifact deploymentArtifact; + + + + @BeforeEach + void initialize(){ + mockBlueprintDistributionServiceImpl.setDeploymentArtifactService(deploymentArtifactService); + mockBlueprintDistributionServiceImpl.setDeploymentArtifactGateway(deploymentArtifactGateway); + mockBlueprintDistributionServiceImpl.setBlueprintDistributionUtils(blueprintDistributionUtils); + mockBlueprintDistributionServiceImpl.setRestTemplate(restTemplate); + deploymentArtifact = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV); + } + + + @Test + void test_distributeBlueprintReturnSucess() { + + when(deploymentArtifactService.findDeploymentArtifactById(BP_DISTRIBUTION_MODEL_ID)).thenReturn(deploymentArtifact); + when(blueprintDistributionUtils.getBlueprintDashboardURL(BP_DISTRIBUTION_ENV)).thenReturn("/url"); + when(blueprintDistributionUtils.getBlueprintDashboardUserName(BP_DISTRIBUTION_ENV)).thenReturn(BP_DISTRIBUTION_USER); + when(blueprintDistributionUtils.getBlueprintDashboardPassword(BP_DISTRIBUTION_ENV)).thenReturn(BP_DISTRIBUTION_PWD); + + ResponseEntity expected = mockBlueprintDistributionServiceImpl.distributeBlueprint(BP_DISTRIBUTION_MODEL_ID,BP_DISTRIBUTION_ENV); + + assertThat(expected.getStatusCode()).isEqualTo(HttpStatus.OK); + verify(deploymentArtifactService, times(1)).findDeploymentArtifactById(BP_DISTRIBUTION_MODEL_ID); + verify(blueprintDistributionUtils, times(2)).getBlueprintDashboardURL(BP_DISTRIBUTION_ENV); + verify(blueprintDistributionUtils, times(1)).getBlueprintDashboardUserName(BP_DISTRIBUTION_ENV); + verify(blueprintDistributionUtils, times(1)).getBlueprintDashboardPassword(BP_DISTRIBUTION_ENV); + verify(deploymentArtifactGateway, times(1)).save(any()); + + } + + @Test + void test_distributeBlueprintReturnBadRequest() { + + when(deploymentArtifactService.findDeploymentArtifactById(BP_DISTRIBUTION_MODEL_ID)).thenReturn(deploymentArtifact); + when(blueprintDistributionUtils.getBlueprintDashboardURL(BP_DISTRIBUTION_ENV)).thenReturn("/url"); + when(blueprintDistributionUtils.getBlueprintDashboardUserName(BP_DISTRIBUTION_ENV)).thenReturn(BP_DISTRIBUTION_USER); + when(blueprintDistributionUtils.getBlueprintDashboardPassword(BP_DISTRIBUTION_ENV)).thenReturn(BP_DISTRIBUTION_PWD); + when(restTemplate.postForObject(blueprintDistributionUtils.getBlueprintDashboardURL(BP_DISTRIBUTION_ENV), + HttpEntity.class,String.class)).thenReturn("Bad request"); + + ResponseEntity expected = mockBlueprintDistributionServiceImpl.distributeBlueprint(BP_DISTRIBUTION_MODEL_ID,BP_DISTRIBUTION_ENV); + + assertThat(expected.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + verify(deploymentArtifactService, times(1)).findDeploymentArtifactById(BP_DISTRIBUTION_MODEL_ID); + verify(blueprintDistributionUtils, times(3)).getBlueprintDashboardURL(BP_DISTRIBUTION_ENV); + verify(blueprintDistributionUtils, times(1)).getBlueprintDashboardUserName(BP_DISTRIBUTION_ENV); + verify(blueprintDistributionUtils, times(1)).getBlueprintDashboardPassword(BP_DISTRIBUTION_ENV); + verify(deploymentArtifactGateway, times(1)).save(any()); + + } + + + +} \ No newline at end of file diff --git a/releases/1.2.1-runtimeapi-container.yaml b/releases/1.2.1-runtimeapi-container.yaml new file mode 100644 index 0000000..c6e04fc --- /dev/null +++ b/releases/1.2.1-runtimeapi-container.yaml @@ -0,0 +1,9 @@ +distribution_type: 'container' +container_release_tag: '1.2.1' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-runtimeapi-merge-java/26' +ref: 898cf07d59c3586180b43bc4b1289d5c20d019fd +containers: + - name: 'org.onap.dcaegen2.platform.mod.runtime-web' + version: '1.2.1-SNAPSHOT-20210129T134650Z' +git_tag: '1.2.1-mod-runtimeapi' diff --git a/releases/1.2.2-runtimeapi-container.yaml b/releases/1.2.2-runtimeapi-container.yaml new file mode 100644 index 0000000..587b1d2 --- /dev/null +++ b/releases/1.2.2-runtimeapi-container.yaml @@ -0,0 +1,9 @@ +distribution_type: 'container' +container_release_tag: '1.2.2' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-runtimeapi-merge-java/27' +ref: 9bb10e0147e582b6272b40473abbb44fc361d29f +containers: + - name: 'org.onap.dcaegen2.platform.mod.runtime-web' + version: '1.2.2-SNAPSHOT-20210210T222108Z' +git_tag: '1.2.2-mod-runtimeapi' diff --git a/releases/1.2.3-runtimeapi-container.yaml b/releases/1.2.3-runtimeapi-container.yaml new file mode 100644 index 0000000..9af2f10 --- /dev/null +++ b/releases/1.2.3-runtimeapi-container.yaml @@ -0,0 +1,9 @@ +distribution_type: 'container' +container_release_tag: '1.2.3' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-runtimeapi-merge-java/28' +ref: fede209351277913be6b8fca3f031d14964cfacc +containers: + - name: 'org.onap.dcaegen2.platform.mod.runtime-web' + version: '1.2.3-SNAPSHOT-20210225T170632Z' +git_tag: '1.2.3-mod-runtimeapi' diff --git a/releases/1.7.2-blueprint-generator.yaml b/releases/1.7.2-blueprint-generator.yaml new file mode 100644 index 0000000..7d979a9 --- /dev/null +++ b/releases/1.7.2-blueprint-generator.yaml @@ -0,0 +1,4 @@ +distribution_type: 'maven' +version: '1.7.2' +project: 'dcaegen2/platform' +log_dir: 'dcaegen2-platform-mod-bpgenerator-maven-stage-master/362' diff --git a/releases/1.7.3-blueprint-generator.yaml b/releases/1.7.3-blueprint-generator.yaml new file mode 100644 index 0000000..4f0f441 --- /dev/null +++ b/releases/1.7.3-blueprint-generator.yaml @@ -0,0 +1,5 @@ +distribution_type: 'maven' +version: '1.7.3' +project: 'dcaegen2/platform' +log_dir: 'dcaegen2-platform-mod-bpgenerator-maven-stage-master/388' +git_tag: '1.7.3-bpgenerator' diff --git a/releases/2.12.4-onboardingapi-container.yaml b/releases/2.12.4-onboardingapi-container.yaml new file mode 100644 index 0000000..67e33d8 --- /dev/null +++ b/releases/2.12.4-onboardingapi-container.yaml @@ -0,0 +1,9 @@ +distribution_type: 'container' +container_release_tag: '2.12.4' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-onboardingapi-docker-merge-master/53' +ref: 59a85d1e280b011d05416ac3dbe6d823f60834f6 +containers: + - name: 'org.onap.dcaegen2.platform.mod.onboardingapi' + version: '2.12.4-SNAPSHOT-20210128T161153Z' +git_tag: '2.12.4-mod-onboardingapi' diff --git a/releases/2.12.5-onboardingapi-container.yaml b/releases/2.12.5-onboardingapi-container.yaml new file mode 100644 index 0000000..a485636 --- /dev/null +++ b/releases/2.12.5-onboardingapi-container.yaml @@ -0,0 +1,9 @@ +distribution_type: 'container' +container_release_tag: '2.12.5' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-onboardingapi-docker-merge-master/57' +ref: ed1d04cf7ac4371ead557a0d564f948174ca5597 +containers: + - name: 'org.onap.dcaegen2.platform.mod.onboardingapi' + version: '2.12.5-SNAPSHOT-20210216T095425Z' +git_tag: '2.12.5-mod-onboardingapi'