diff options
Diffstat (limited to 'sdc-distribution-ci/src/main')
22 files changed, 820 insertions, 1114 deletions
diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java b/sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java deleted file mode 100644 index a122ca0..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2017 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.test; - -import java.io.FileOutputStream; -import java.io.IOException; - -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; -import org.onap.sdc.utils.DistributionActionResultEnum; - -/** - * - * @author tg851x - * This is class used in testing and run locally in the IDE - * logging not needed it is monitored through the IDE console. - */ -public class AdvanceCallBack extends SimpleCallback{ - - public AdvanceCallBack(IDistributionClient client) { - super(client); - } - - @Override - protected void postDownloadLogic( IDistributionClientDownloadResult downloadResult) { - if( downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ - saveArtifactPayloadToDisk(downloadResult); - } - - } - - protected void saveFile(byte[] bs, String fileName) { - String downloadPath = SimpleConfiguration.downloadPath(); - try(FileOutputStream fileOuputStream = new FileOutputStream(downloadPath + fileName);) { - fileOuputStream.write(bs); - fileOuputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - protected void saveArtifactPayloadToDisk(IDistributionClientDownloadResult downloadResult) { - System.out.println("################ Downloaded Artifact Payload Start ################"); - String fileName = downloadResult.getArtifactFilename(); - saveFile(downloadResult.getArtifactPayload(), fileName); - System.out.println("################ Downloaded Artifact Payload End ################"); - } - - - - -} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java b/sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java deleted file mode 100644 index 24160b5..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2017 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.test; - -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.consumer.IComponentDoneStatusMessage; -import org.onap.sdc.api.consumer.IStatusCallback; -import org.onap.sdc.api.notification.INotificationData; -import org.onap.sdc.api.notification.IStatusData; -import org.onap.sdc.api.results.IDistributionClientResult; -import org.onap.sdc.impl.DistributionClientFactory; -import org.onap.sdc.utils.DistributionStatusEnum; - -public class ClientTest { - public static void main(String[] args) throws Exception { - - soWdListner(); - clientSender(); - - } - - private static void clientSender() { - IDistributionClient client = DistributionClientFactory.createDistributionClient(); - IDistributionClientResult result = client.init(new SimpleConfiguration(), new SimpleCallback(client)); - System.err.println("Init Status: " + result.toString()); - - IDistributionClientResult start = client.start(); - - System.err.println("Start Status: " + start.toString()); - for( int i = 0; i < 2; i++ ){ - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - client.sendComponentDoneStatus(new IComponentDoneStatusMessage() { - - @Override - public long getTimestamp() { - return System.currentTimeMillis(); - } - - @Override - public DistributionStatusEnum getStatus() { - return DistributionStatusEnum.COMPONENT_DONE_OK; - } - - @Override - public String getDistributionID() { - // TODO Auto-generated method stub - return ""; - } - - @Override - public String getConsumerID() { - return client.getConfiguration().getConsumerID(); - } - - @Override - public String getComponentName() { - return "MSO"; - } - }); - } - - } - - private static void soWdListner() { - IDistributionClient client = DistributionClientFactory.createDistributionClient(); - IDistributionClientResult result = client.init(new SimpleConfiguration() { - @Override - public boolean isConsumeProduceStatusTopic() { - return true; - } - }, new SimpleCallback(client) { - @Override - public void activateCallback(INotificationData data) { - System.err.println("Monitor Recieved Notification: " + data.toString()); - - } - }, new IStatusCallback() { - - @Override - public void activateCallback(IStatusData data) { - System.err.println("Monitor Recieved Status: " + data.toString()); - - } - }); - System.err.println("Init Status: " + result.toString()); - IDistributionClientResult start = client.start(); - - System.err.println("Start Status: " + start.toString()); - } - -} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java b/sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java deleted file mode 100644 index 1102150..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.onap.test; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.tosca.parser.impl.SdcTypes; -import org.onap.sdc.toscaparser.api.Group; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.elements.Metadata; -import org.onap.sdc.toscaparser.api.parameters.Input; -import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder; - -public class CsarToscaTester { - public static void main(String[] args) throws Exception { - System.out.println("CsarToscaParser - path to CSAR's Directory is " + Arrays.toString(args)); - SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); - - File folder = new File(args[0]); - File[] listOfFiles = folder.listFiles(); - Date now = new Date(); - SimpleDateFormat dateFormat = new SimpleDateFormat("d-MM-y-HH_mm_ss"); - String time = dateFormat.format(now); - String csarsDir = args[1] + "/csar-reports-" + time; - File dir = new File(csarsDir); - dir.mkdir(); - - - for (File file : listOfFiles) { - if (file.isFile()) { - System.out.println("File " + file.getAbsolutePath()); - String name = file.getName(); - String currentCsarDir = csarsDir+"/"+name+"-"+time; - dir = new File(currentCsarDir); - dir.mkdir(); - try { - processCsar(factory, file); - } catch (SdcToscaParserException e){ - System.out.println("SdcToscaParserException caught. Code: "+e.getCode()+", message: "+ e.getMessage()); - } - List<String> validationIssueReport = ThreadLocalsHolder.getCollector().getValidationIssueReport(); - System.out.println("Validation issues during CSAR parsing are: " + (validationIssueReport != null ? validationIssueReport.toString() : "none")); - - try { - generateReport(time, name, currentCsarDir, validationIssueReport, "validationIssues"); - - } catch (IOException ex) { - ex.printStackTrace(); - } - } - - } - } - - private static void processCsar(SdcToscaParserFactory factory, File file) throws SdcToscaParserException { - ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file.getAbsolutePath()); - //Service level - System.out.println("Invoking sdc-tosca methods on this CSAR...."); - String conformanceLevel = sdcCsarHelper.getConformanceLevel(); - System.out.println("getConformanceLevel() - conformance level is "+conformanceLevel); - String serviceSubstitutionMappingsTypeName = sdcCsarHelper.getServiceSubstitutionMappingsTypeName(); - System.out.println("serviceSubstitutionMappingsTypeName() - subst mappings type of service is "+serviceSubstitutionMappingsTypeName); - List<Input> serviceInputs = sdcCsarHelper.getServiceInputs(); - System.out.println("getServiceInputs() - service inputs are "+serviceInputs); - Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata(); - System.out.println("getServiceMetadata() - service metadata is "+serviceMetadata); - Map<String, Object> serviceMetadataProperties = sdcCsarHelper.getServiceMetadataProperties(); - System.out.println("getServiceMetadataProperties() - service metadata properties is "+serviceMetadataProperties); - List<NodeTemplate> allottedResources = sdcCsarHelper.getAllottedResources(); - System.out.println("getAllottedResources() - service allotted resources are "+allottedResources); - List<NodeTemplate> serviceVfList = sdcCsarHelper.getServiceVfList(); - System.out.println("getServiceVfList() - VF list is "+serviceVfList); - List<NodeTemplate> serviceNodeTemplateBySdcType = sdcCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF); - System.out.println("getServiceNodeTemplateBySdcType() - VF list is "+serviceNodeTemplateBySdcType); - List<NodeTemplate> serviceNodeTemplates = sdcCsarHelper.getServiceNodeTemplates(); - System.out.println("getServiceNodeTemplates() - all node templates list of service is "+serviceNodeTemplates); - - serviceVfList.forEach(x -> { - String nodeTemplateCustomizationUuid = sdcCsarHelper.getNodeTemplateCustomizationUuid(x); - System.out.println("getNodeTemplateCustomizationUuid() - VF ID is "+nodeTemplateCustomizationUuid); - String typeOfNodeTemplate = sdcCsarHelper.getTypeOfNodeTemplate(x); - System.out.println("getTypeOfNodeTemplate() - VF tosca type is "+typeOfNodeTemplate); - List<Group> vfModulesByVf = sdcCsarHelper.getVfModulesByVf(nodeTemplateCustomizationUuid); - System.out.println("getVfModulesByVf() - VF modules list is "+vfModulesByVf); - vfModulesByVf.forEach(y -> { - List<NodeTemplate> membersOfVfModule = sdcCsarHelper.getMembersOfVfModule(x, y); - System.out.println("getMembersOfVfModule() - members of VfModule are "+membersOfVfModule); - }); - List<NodeTemplate> vfcListByVf = sdcCsarHelper.getVfcListByVf(nodeTemplateCustomizationUuid); - System.out.println("getVfcListByVf() - VFC list is "+vfcListByVf); - vfcListByVf.forEach(z -> { - List<NodeTemplate> nodeTemplateBySdcType = sdcCsarHelper.getNodeTemplateBySdcType(z, SdcTypes.CP); - System.out.println("getNodeTemplateBySdcType() - CP children node templates of this VFC are "+nodeTemplateBySdcType); - Map<String, Map<String, Object>> cpPropertiesFromVfcAsObject = sdcCsarHelper.getCpPropertiesFromVfcAsObject(z); - System.out.println("getCpPropertiesFromVfcAsObject() - consolidated CP properties for this VFC are "+cpPropertiesFromVfcAsObject); - boolean hasTopology = sdcCsarHelper.hasTopology(z); - System.out.println("hasTopology() - this VFC is "+(hasTopology ? "nested" : "not nested")); - }); - }); - - } - - private static void generateReport(String time, String name, String currentCsarDir, List<String> criticalsReport, String type) - throws IOException { - FileWriter fw; - fw = new FileWriter(new File(currentCsarDir + "/" + criticalsReport.size() + "-"+type+"-" + name +"-"+time + ".txt")); - for (String exception : criticalsReport) { - fw.write(exception); - fw.write("\r\n"); - } - fw.close(); - } -} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java b/sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java deleted file mode 100644 index fc029ff..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Modifications copyright (C) 2019 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. - * 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.test; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.Base64; - -public class Decoder { - - public static String encode(byte[] byteArrayToEncode) { - return new String(Base64.getEncoder().encode(byteArrayToEncode)); - } - - public static String decode(String strEncoded) { - return new String(Base64.getDecoder().decode(strEncoded)); - } - - public static String readFileToString(String file) throws IOException { - - try (FileReader fileReader = new FileReader(file); BufferedReader reader = new BufferedReader(fileReader)) { - String line; - StringBuilder stringBuilder = new StringBuilder(); - String ls = System.getProperty("line.separator"); - - while ((line = reader.readLine()) != null) { - stringBuilder.append(line); - stringBuilder.append(ls); - } - - reader.close(); - fileReader.close(); - return stringBuilder.toString(); - } catch (IOException e) { - throw new IOException(e); - } - } -} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java deleted file mode 100644 index 547dde2..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java +++ /dev/null @@ -1,356 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2017 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.test; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.consumer.IDistributionStatusMessage; -import org.onap.sdc.api.consumer.INotificationCallback; -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.INotificationData; -import org.onap.sdc.api.notification.IResourceInstance; -import org.onap.sdc.api.notification.IVfModuleMetadata; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; -import org.onap.sdc.api.results.IDistributionClientResult; -import org.onap.sdc.utils.ArtifactTypeEnum; -import org.onap.sdc.utils.DistributionActionResultEnum; -import org.onap.sdc.utils.DistributionStatusEnum; - -/** - * - * @author tg851x - * This is class used in testing and run locally in the IDE - * logging not needed it is monitored through the IDE console. - */ -public class SimpleCallback implements INotificationCallback { - protected IDistributionClient client; - public List<IArtifactInfo> iArtifactInfo; - - public final Map<String, IDistributionClientResult> simpleCallbackResults = new HashMap<String, IDistributionClientResult>(); - - public Map<String, IDistributionClientResult> getSimpleCallbackResults() { - return simpleCallbackResults; - } - - public List<IArtifactInfo> getIArtifactInfo(){ - return iArtifactInfo; - } - public SimpleCallback(IDistributionClient client) { - this.client = client; - } - - - - - - public void activateCallback(INotificationData data) { - - List<IArtifactInfo> artifacts = getArtifacts(data); - - - for (IArtifactInfo iArtifactInfo : artifacts) { - - IArtifactInfo artifactMetadataByUUID = data.getArtifactMetadataByUUID(iArtifactInfo.getArtifactUUID()); - assertEquals("check artifact checksum", iArtifactInfo.getArtifactChecksum(), artifactMetadataByUUID.getArtifactChecksum()); - System.out.println(artifactMetadataByUUID.getArtifactURL()); - if (artifactMetadataByUUID.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA)){ - IDistributionClientDownloadResult download = client.download(iArtifactInfo); - if (download.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ - List<IVfModuleMetadata> decodeVfModuleArtifact = client.decodeVfModuleArtifact(download.getArtifactPayload()); -// assertEquals("decoded not equal to actual group amount ", decodeVfModuleArtifact.size(), 2); - if (!decodeVfModuleArtifact.isEmpty()){ - for (IVfModuleMetadata moduleMetadata : decodeVfModuleArtifact) { - List<String> moduleArtifacts = moduleMetadata.getArtifacts(); - if (moduleArtifacts != null) { - - for (String artifactId : moduleArtifacts) { - - IArtifactInfo artifactInfo = data.getArtifactMetadataByUUID(artifactId); - IDistributionClientDownloadResult downloadArt = client.download(artifactInfo); - assertEquals(downloadArt.getDistributionActionResult(), DistributionActionResultEnum.SUCCESS); - - } - - } - } - } - } - } - } - - - for (IArtifactInfo relevantArtifact : artifacts){ - // Download Artifact - IDistributionClientDownloadResult downloadResult = client.download(relevantArtifact); - - postDownloadLogic(downloadResult); - - - - simpleCallbackResults.put("downloadResult", downloadResult); - System.out.println("downloadResult: " + downloadResult.toString()); - System.out.println("<<<<<<<<<<< Artifact content >>>>>>>>>>"); - System.out.println(Decoder.encode(downloadResult.getArtifactPayload())); - - /////Print artifact content to console/////// - -// byte[] contentInBytes = BaseEncoding.base64().decode(Decoder.encode(downloadResult.getArtifactPayload())); -// try { -// System.out.println("Source content: " + new String(contentInBytes, "UTF-8")); -// } catch (UnsupportedEncodingException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } - System.out.println("ArtInfo_timeout: "+ relevantArtifact.getArtifactTimeout()); - System.out.println("ArtInfo_Art_description: "+ relevantArtifact.getArtifactDescription()); - System.out.println("ArtInfo_Art_CheckSum: "+ relevantArtifact.getArtifactChecksum()); - System.out.println("ArtInfo_Art_Url: "+ relevantArtifact.getArtifactURL()); - System.out.println("ArtInfo_Art_Type: "+ relevantArtifact.getArtifactType()); - System.out.println("ArtInfo_Art_Name: "+ relevantArtifact.getArtifactName()); - System.out.println("ArtInfo_UUID: " + relevantArtifact.getArtifactUUID()); - System.out.println("ArtInfo_Version: " + relevantArtifact.getArtifactVersion()); - System.out.println("ArtInfo_RelatedArtifacts: "+ relevantArtifact.getRelatedArtifacts()); - - System.out.println("ArtInfo_Serv_description: " + data.getServiceDescription()); - System.out.println("ArtInfo_Serv_Name: " + data.getServiceName()); - System.out.println("Get_serviceVersion: " + data.getServiceVersion()); - System.out.println("Get_Service_UUID: " + data.getServiceUUID()); - System.out.println("ArtInfo_DistributionId: " + data.getDistributionID()); - System.out.println("ArtInfo_ServiceInvariantUUID: " + data.getServiceInvariantUUID()); - - - // assertTrue("response code is not 200, returned :" + downloadResult.getDistributionActionResult(), downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); - - try { - String payload = new String(downloadResult.getArtifactPayload()); -// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); -// System.out.println(payload); -// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); - - } catch (Exception e) { - System.out.println("catch"); -// break; - // TODO: handle exception - } - - - - - if (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { - handleSuccessfullDownload(data, relevantArtifact, downloadResult.getArtifactPayload()); - } else { - handleFailedDownload(data, relevantArtifact); - } - } -// if (data != null){ -// iArtifactInfo.addAll(artifacts); -// } - - } - - private List<IArtifactInfo> getArtifacts(INotificationData data) { - List<IArtifactInfo> ret = new ArrayList<IArtifactInfo>(); - List<IResourceInstance> resources = data.getResources(); -// data.getArtifactMetadataByUUID(arg0) - List<String> relevantArtifactTypes = client.getConfiguration().getRelevantArtifactTypes(); - - List<IArtifactInfo> collect = resources.stream().flatMap( e -> e.getArtifacts().stream()).filter(p -> relevantArtifactTypes.contains(p.getArtifactType() )).collect(Collectors.toList()); -// if( resources != null ){ -// for( IResourceInstance resourceInstance : resources){ -// if( resourceInstance.getArtifacts() != null ){ -// -// -// -// ret.addAll(resourceInstance.getArtifacts()); -// -// -// } -// } -// } - ret.addAll(collect); - - List<IArtifactInfo> servicesArt = data.getServiceArtifacts(); - if( servicesArt != null ){ - ret.addAll(servicesArt); - } - - System.out.println("I am here: " + ret.toString()); - return ret; - } - - - - private void handleFailedDownload(INotificationData data, - IArtifactInfo relevantArtifact) { - // Send Download Status - IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_ERROR)); - postDownloadStatusSendLogic(sendDownloadStatus); - } - - private void handleSuccessfullDownload(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) { - // Send Download Status - IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_OK)); - - simpleCallbackResults.put("sendDownloadStatus", sendDownloadStatus); -// assertTrue("response code is not 200, returned :" + sendDownloadStatus.getDistributionActionResult(), sendDownloadStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); - - // Doing deployment ... - postDownloadStatusSendLogic(sendDownloadStatus); - boolean isDeployedSuccessfully = handleDeployment(data, relevantArtifact, payload); - IDistributionClientResult deploymentStatus; - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (isDeployedSuccessfully) { - deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_OK)); - - simpleCallbackResults.put("sendDeploymentStatus", deploymentStatus); -// assertTrue("response code is not 200, returned :" + deploymentStatus.getDistributionActionResult(), deploymentStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); - - } else { - deploymentStatus = handleFailedDeployment(data, relevantArtifact); - } - - postDeploymentStatusSendLogic(deploymentStatus); - } - - private IDistributionClientResult handleFailedDeployment(INotificationData data, IArtifactInfo relevantArtifact) { - IDistributionClientResult deploymentStatus; - boolean isAlreadyDeployed = checkIsDeployed(); - if (isAlreadyDeployed) { - deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.ALREADY_DEPLOYED)); - } else { - deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_ERROR)); - } - return deploymentStatus; - } - - protected void postDownloadLogic(IDistributionClientDownloadResult downloadResult) { - // TODO Auto-generated method stub - - } - - private void postDownloadStatusSendLogic( - IDistributionClientResult sendDownloadStatus) { - // TODO Auto-generated method stub - - } - - private void postDeploymentStatusSendLogic( - IDistributionClientResult deploymentStatus) { - // TODO Auto-generated method stub - - } - - private boolean checkIsDeployed() { - return false; - } - - private boolean handleDeployment(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) { - if (relevantArtifact.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())) { - - try { - List<IArtifactInfo> serviceArtifacts = data.getServiceArtifacts(); - List<IResourceInstance> resourcesArtifacts = data.getResources(); - - JSONArray jsonData = new JSONArray(new String(payload)); - boolean artifactIsFound = true; - for (int index = 0 ; index < jsonData.length(); index++) { - - JSONObject jsonObject = (JSONObject) jsonData.get(index); - JSONArray artifacts = (JSONArray) jsonObject.get("artifacts"); - for (int i = 0 ; i < artifacts.length(); i++) { - String artifact = artifacts.getString(i).toString(); - - Optional<IArtifactInfo> serviceArtifactFound = serviceArtifacts.stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst(); - - boolean isResourceFound = false; - for (int j = 0 ; j < resourcesArtifacts.size(); j++) { - Optional<IArtifactInfo> resourceArtifactFound = resourcesArtifacts.get(j).getArtifacts().stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst(); - isResourceFound = resourceArtifactFound.isPresent() || isResourceFound; - } - - if (!serviceArtifactFound.isPresent() && !isResourceFound) { - artifactIsFound = false; - System.out.println("################ Artifact: " + artifact + " NOT FOUND in Notification Data ################"); - } - } - } - return artifactIsFound; - - } catch (Exception e) { - System.out.println("################ Couldn't convert vf_modules_metadata.json to json : " + e.getMessage()); - return false; - } - } - else { - return true; - } - -// to return deploy_error use return false -// return false; - } - - public static IDistributionStatusMessage buildStatusMessage( - final IDistributionClient client, final INotificationData data, - final IArtifactInfo relevantArtifact, - final DistributionStatusEnum status) { - IDistributionStatusMessage statusMessage = new IDistributionStatusMessage() { - - public long getTimestamp() { - long currentTimeMillis = System.currentTimeMillis(); - return currentTimeMillis; - } - - public DistributionStatusEnum getStatus() { - return status; - } - - public String getDistributionID() { - return data.getDistributionID(); - } - - public String getConsumerID() { - return client.getConfiguration().getConsumerID(); - } - - public String getArtifactURL() { - return relevantArtifact.getArtifactURL(); - } - }; - return statusMessage; - } - - -} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java b/sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java deleted file mode 100644 index d22bcf2..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java +++ /dev/null @@ -1,204 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2017 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.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.onap.sdc.api.consumer.IConfiguration; - -public class SimpleConfiguration implements IConfiguration{ - - /*public String getUser() - { - return System.getProperty("user"); - } - - public List<String> getRelevantArtifactTypes() { - return ArtifactTypeEnum.getAllTypes(); - } - - public int getPollingTimeout() - { - return 20; - } - - public int getPollingInterval() - { - return 20; - } - - public String getPassword() - { - return System.getProperty("password"); - } - - public String getEnvironmentName() - { - return System.getProperty("env"); - } - - public String getConsumerID() - { - return System.getProperty("consumerID"); - } - - public String getConsumerGroup() - { - return System.getProperty("groupID"); - } - - public String getAsdcAddress() - { - return System.getProperty("beAddress"); - } - - public String getKeyStorePath() - { - return ""; - } - - public String getKeyStorePassword() - { - return "Aa123456"; - } - - public boolean activateServerTLSAuth() - { - return Boolean.parseBoolean(System.getProperty("auth")); -// res.add(ArtifactTypeEnum.HEAT_ARTIFACT); -// res.add(ArtifactTypeEnum.HEAT_ENV); -// res.add(ArtifactTypeEnum.MURANO_PKG); -// res.add(ArtifactTypeEnum.VF_LICENSE); -// res.add(ArtifactTypeEnum.APPC_CONFIG); -// res.add(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE); -// res.add(ArtifactTypeEnum.VNF_CATALOG); -// res.add(ArtifactTypeEnum.APPC_CONFIG); -// res.add(ArtifactTypeEnum.VF_MODULES_METADATA); -// return "PROD-Tedy-Only"; -// return "A-AI"; -// return "A-AI"; - } - - @Override - public boolean isFilterInEmptyResources() { - return false; - } - - public static String downloadPath() { - return "c:\\temp\\"; - } - - public static Boolean toDownload() { - return false; - }*/ - - public String getUser() { - return "ci"; - } - - public List<String> getRelevantArtifactTypes() { - -// List<String> res = new ArrayList<String>(); -// for (ArtifactTypeEnum type : AssetTypeEnum.values()){ -// res.add(type.name()); -// } - return ArtifactTypeEnum.getAllTypes(); - } - - - public int getPollingTimeout() { - return 20; - } - - public int getPollingInterval() { - return 20; - } - - public String getPassword() { - return "123456"; - } - - public String getEnvironmentName() { - return "PROD"; - } - - public String getConsumerID() { - return "consumerVasya"; - } - - public String getConsumerGroup() { - return "groupVasya"; - - } - - public static Boolean toDownload() { - return true; - } - - public static String downloadPath() { - return "c:\\temp\\"; - } - - public String getAsdcAddress() { - return "127.0.0.1:8443"; - } - - @Override - public List<String> getMsgBusAddress() { - return new ArrayList<>(); - } - - @Override - public String getKeyStorePath() { - return StringUtils.EMPTY; - } - - @Override - public String getKeyStorePassword() { - - return "Aa123456"; - } - - @Override - public boolean activateServerTLSAuth() { - - return false; - } - - @Override - public boolean isFilterInEmptyResources() { - return false; - } - - @Override - public Boolean isUseHttpsWithDmaap() { - return true; - } - - @Override - public boolean isConsumeProduceStatusTopic() { - return false; - } - -} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java index 1f5e799..64923c5 100644 --- a/sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java @@ -17,8 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - -package org.onap.test; +package org.onap.test.core.config; import java.util.ArrayList; import java.util.List; diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java new file mode 100644 index 0000000..be6f6a6 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java @@ -0,0 +1,343 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.core.config; + +import org.onap.sdc.api.consumer.IConfiguration; + +import java.util.ArrayList; +import java.util.List; + + +public class DistributionClientConfig implements IConfiguration { + + public static final String DEFAULT_ASDC_ADDRESS = "localhost:30206"; + public static final String DEFAULT_COMSUMER_ID = "dcae-openapi-manager"; + public static final String DEFAULT_CONSUMER_GROUP = "noapp"; + public static final String DEFAULT_ENVIRONMENT_NAME = "AUTO"; + public static final String DEFAULT_PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"; + public static final int DEFAULT_POLLING_INTERVAL = 20; + public static final int DEFAULT_POLLING_TIMEOUT = 20; + public static final String DEFAULT_USER = "dcae"; + public static final String DEFAULT_KEY_STORE_PATH = "etc/asdc-client.jks"; + public static final String DEFAULT_KEY_STORE_PASSWORD = "Aa123456"; + public static final boolean DEFAULT_ACTIVATE_SERVER_TLS_AUTH = false; + public static final boolean DEFAULT_IS_FILTER_IN_EMPTY_RESOURCES = false; + public static final boolean DEFAULT_USE_HTTPS_WITH_SDC = false; + public static final String DEFAULT_MSG_BUS_ADDRESS = "localhost"; + private String asdcAddress; + private String user; + private String password; + private int pollingInterval; + private int pollingTimeout; + private List<String> relevantArtifactTypes; + private String consumerGroup; + private String environmentName; + private String comsumerID; + private String keyStorePath; + private String keyStorePassword; + private boolean activateServerTLSAuth; + private boolean isFilterInEmptyResources; + private boolean useHttpsWithDmaap; + private boolean useHttpsWithSDC; + private List<String> msgBusAddress; + + public DistributionClientConfig(IConfiguration other) { + this.asdcAddress = other.getAsdcAddress(); + this.comsumerID = other.getConsumerID(); + this.consumerGroup = other.getConsumerGroup(); + this.environmentName = other.getEnvironmentName(); + this.password = other.getPassword(); + this.pollingInterval = other.getPollingInterval(); + this.pollingTimeout = other.getPollingTimeout(); + this.relevantArtifactTypes = other.getRelevantArtifactTypes(); + this.user = other.getUser(); + this.keyStorePath = other.getKeyStorePath(); + this.keyStorePassword = other.getKeyStorePassword(); + this.activateServerTLSAuth = other.activateServerTLSAuth(); + this.isFilterInEmptyResources = other.isFilterInEmptyResources(); + } + + public DistributionClientConfig() { + this.asdcAddress = DEFAULT_ASDC_ADDRESS; + this.comsumerID = DEFAULT_COMSUMER_ID; + this.consumerGroup = DEFAULT_CONSUMER_GROUP; + this.environmentName = DEFAULT_ENVIRONMENT_NAME; + this.password = DEFAULT_PASSWORD; + this.pollingInterval = DEFAULT_POLLING_INTERVAL; + this.pollingTimeout = DEFAULT_POLLING_TIMEOUT; + this.relevantArtifactTypes = new ArrayList<>(); + this.relevantArtifactTypes.add(ArtifactTypeEnum.HEAT.name()); + this.user = DEFAULT_USER; + this.keyStorePath = DEFAULT_KEY_STORE_PATH; + this.keyStorePassword = DEFAULT_KEY_STORE_PASSWORD; + this.activateServerTLSAuth = DEFAULT_ACTIVATE_SERVER_TLS_AUTH; + this.isFilterInEmptyResources = DEFAULT_IS_FILTER_IN_EMPTY_RESOURCES; + this.useHttpsWithSDC = DEFAULT_USE_HTTPS_WITH_SDC; + msgBusAddress = new ArrayList<>(); + msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); + msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); + msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); + } + + @Override + public String getAsdcAddress() { + return asdcAddress; + } + + @Override + public List<String> getMsgBusAddress() { + return msgBusAddress; + } + + @Override + public String getUser() { + return user; + } + + @Override + public String getPassword() { + return password; + } + + @Override + public int getPollingInterval() { + return pollingInterval; + } + + @Override + public int getPollingTimeout() { + return pollingTimeout; + } + + @Override + public List<String> getRelevantArtifactTypes() { + return relevantArtifactTypes; + } + + @Override + public String getConsumerGroup() { + return consumerGroup; + } + + @Override + public String getEnvironmentName() { + return environmentName; + } + + @Override + public String getConsumerID() { + return comsumerID; + } + + @Override + public String getKeyStorePath() { + return keyStorePath; + } + + @Override + public String getKeyStorePassword() { + return keyStorePassword; + } + + public String getComsumerID() { + return comsumerID; + } + + public void setComsumerID(String comsumerID) { + this.comsumerID = comsumerID; + } + + public void setAsdcAddress(String asdcAddress) { + this.asdcAddress = asdcAddress; + } + + public void setUser(String user) { + this.user = user; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setPollingInterval(int pollingInterval) { + this.pollingInterval = pollingInterval; + } + + public void setPollingTimeout(int pollingTimeout) { + this.pollingTimeout = pollingTimeout; + } + + public void setRelevantArtifactTypes(List<String> relevantArtifactTypes) { + this.relevantArtifactTypes = relevantArtifactTypes; + } + + public void setConsumerGroup(String consumerGroup) { + this.consumerGroup = consumerGroup; + } + + public void setEnvironmentName(String environmentName) { + this.environmentName = environmentName; + } + + public void setKeyStorePath(String keyStorePath) { + this.keyStorePath = keyStorePath; + } + + public void setKeyStorePassword(String keyStorePassword) { + this.keyStorePassword = keyStorePassword; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((asdcAddress == null) ? 0 : asdcAddress.hashCode()); + result = prime * result + ((comsumerID == null) ? 0 : comsumerID.hashCode()); + result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode()); + result = prime * result + ((environmentName == null) ? 0 : environmentName.hashCode()); + result = prime * result + ((password == null) ? 0 : password.hashCode()); + result = prime * result + pollingInterval; + result = prime * result + pollingTimeout; + result = prime * result + ((relevantArtifactTypes == null) ? 0 : relevantArtifactTypes.hashCode()); + result = prime * result + ((user == null) ? 0 : user.hashCode()); + return result; + } + + @Override + public boolean activateServerTLSAuth() { + + return activateServerTLSAuth; + } + + public void setactivateServerTLSAuth(boolean activateServerTLSAuth) { + this.activateServerTLSAuth = activateServerTLSAuth; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DistributionClientConfig other = (DistributionClientConfig) obj; + if (asdcAddress == null) { + if (other.asdcAddress != null) { + return false; + } + } else if (!asdcAddress.equals(other.asdcAddress)) { + return false; + } + if (comsumerID == null) { + if (other.comsumerID != null) { + return false; + } + } else if (!comsumerID.equals(other.comsumerID)) { + return false; + } + if (consumerGroup == null) { + if (other.consumerGroup != null) { + return false; + } + } else if (!consumerGroup.equals(other.consumerGroup)) { + return false; + } + if (environmentName == null) { + if (other.environmentName != null) { + return false; + } + } else if (!environmentName.equals(other.environmentName)) { + return false; + } + if (password == null) { + if (other.password != null) { + return false; + } + } else if (!password.equals(other.password)) { + return false; + } + if (pollingInterval != other.pollingInterval) { + return false; + } + if (pollingTimeout != other.pollingTimeout) { + return false; + } + if (relevantArtifactTypes == null) { + if (other.relevantArtifactTypes != null) { + return false; + } + } else if (!relevantArtifactTypes.equals(other.relevantArtifactTypes)) { + return false; + } + if (user == null) { + if (other.user != null) { + return false; + } + } else if (!user.equals(other.user)) { + return false; + } + if (keyStorePath == null) { + if (other.keyStorePath != null) { + return false; + } + } else if (!keyStorePath.equals(other.keyStorePath)) { + return false; + } + if (keyStorePassword == null) { + return other.keyStorePassword == null; + } else { + return keyStorePassword.equals(other.keyStorePassword); + } + } + + @Override + public String toString() { + return "TestConfiguration [asdcAddress=" + asdcAddress + ", user=" + user + ", password=" + password + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", relevantArtifactTypes=" + relevantArtifactTypes + + ", consumerGroup=" + consumerGroup + ", environmentName=" + environmentName + ", comsumerID=" + comsumerID + "]"; + } + + @Override + public boolean isFilterInEmptyResources() { + return isFilterInEmptyResources; + } + + + public void setFilterInEmptyResources(boolean isFilterInEmptyResources) { + this.isFilterInEmptyResources = isFilterInEmptyResources; + } + + @Override + public Boolean isUseHttpsWithDmaap() { + return this.useHttpsWithDmaap; + } + + + public Boolean isUseHttpsWithSDC() { + return this.useHttpsWithSDC; + } + + public void setUseHttpsWithSDC(Boolean useHttpsWithSDC) { + this.useHttpsWithSDC = useHttpsWithSDC; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java new file mode 100644 index 0000000..1e0623d --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.core.service; + +import org.apache.commons.io.FileUtils; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.notification.IResourceInstance; +import org.onap.sdc.http.SdcConnectorClient; +import org.onap.sdc.impl.DistributionClientDownloadResultImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + + +public class ArtifactsDownloader { + + private static final Logger log = LoggerFactory.getLogger(ArtifactsDownloader.class); + + private final String artifactsDownloadPath; + private final SdcConnectorClient sdcConnectorClient; + + public ArtifactsDownloader(String artifactsDownloadPath, + SdcConnectorClient sdcConnectorClient) { + this.artifactsDownloadPath = artifactsDownloadPath; + this.sdcConnectorClient = sdcConnectorClient; + } + + public List<DistributionClientDownloadResultImpl> pullArtifacts(INotificationData service) { + log.info("Downloading artifacts..."); + return service.getResources().stream() + .flatMap(this::getArtifactsStream) + .map(sdcConnectorClient::downloadArtifact) + .collect(Collectors.toList()); + } + + public void saveArtifacts(List<DistributionClientDownloadResultImpl> artifacts, String serviceName) { + artifacts.forEach(artifact -> saveArtifact(artifact, serviceName)); + } + + public String parseArtifactName(DistributionClientDownloadResultImpl artifact) { + return artifact.getArtifactName().split("\"")[1]; + } + + private String getArtifactPath(String serviceName, String artifactName) { + return String.format("%s/%s/%s", artifactsDownloadPath, serviceName, artifactName); + } + + private Stream<IArtifactInfo> getArtifactsStream(IResourceInstance resourceInstance) { + return resourceInstance.getArtifacts().stream(); + } + + private void saveArtifact(DistributionClientDownloadResultImpl artifact, String serviceName) { + String artifactName = parseArtifactName(artifact); + String path = getArtifactPath(serviceName, artifactName); + + try { + File file = new File(path); + FileUtils.writeByteArrayToFile(file, artifact.getArtifactPayload()); + } catch (IOException e) { + log.error("Couldn't save an artifact: " + path, e); + } + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java index 48fda0a..2972777 100644 --- a/sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * sdc-distribution-client * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 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. * 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. @@ -17,23 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +package org.onap.test.core.service; -package org.onap.test; - -import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.notification.INotificationData; -public class NotificationCallback extends SimpleCallback{ - INotificationData latestCallbackData; - public INotificationData getData() { - return latestCallbackData; - } - public NotificationCallback(IDistributionClient client) { - super(client); - } - - public void activateCallback(INotificationData data) { - this.latestCallbackData = data; - super.activateCallback(data); - } +import java.util.List; + +public interface ArtifactsValidator { + List<ValidationResult> validate(INotificationData service); } diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java new file mode 100644 index 0000000..64e6a6f --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.core.service; + +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.test.core.config.DistributionClientConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ClientInitializer { + + Logger log = LoggerFactory.getLogger(ClientInitializer.class); + public static final String SEPARATOR = "========================================"; + private final DistributionClientConfig clientConfig; + private final ClientNotifyCallback callback; + private final DistributionClientImpl client; + + + public ClientInitializer(DistributionClientConfig clientConfig, ClientNotifyCallback callback, DistributionClientImpl client) { + this.clientConfig = clientConfig; + this.callback = callback; + this.client = client; + } + + public void initialize() { + IDistributionClientResult initResult = client.init(clientConfig, callback); + log.info(initResult.getDistributionMessageResult()); + log.info(SEPARATOR); + log.info(SEPARATOR); + IDistributionClientResult startResult = client.start(); + log.info(startResult.getDistributionMessageResult()); + log.info(SEPARATOR); + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java new file mode 100644 index 0000000..7737457 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.core.service; + +import org.onap.sdc.api.consumer.IDistributionStatusMessage; +import org.onap.sdc.api.consumer.INotificationCallback; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.notification.IResourceInstance; +import org.onap.sdc.http.HttpAsdcClient; +import org.onap.sdc.http.SdcConnectorClient; +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.sdc.utils.DistributionStatusEnum; +import org.onap.test.core.config.DistributionClientConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Collection; +import java.util.List; + +public class ClientNotifyCallback implements INotificationCallback { + + private static final Logger log = LoggerFactory.getLogger(ClientNotifyCallback.class); + + private final List<ArtifactsValidator> validators; + private final DistributionClientImpl distributionClient; + DistributionClientConfig config = new DistributionClientConfig(); + HttpAsdcClient asdcClient = new HttpAsdcClient(config); + SdcConnectorClient sdcConnectorClient = new SdcConnectorClient(config,asdcClient); + ArtifactsDownloader artifactsDownloader = new ArtifactsDownloader("/app/path", sdcConnectorClient); + + public ClientNotifyCallback(List<ArtifactsValidator> validators, DistributionClientImpl distributionClient) { + this.validators = validators; + this.distributionClient = distributionClient; + } + + @Override + public void activateCallback(INotificationData inotificationData) { + logServiceInfo(inotificationData); + artifactsDownloader.pullArtifacts(inotificationData); + } + + private void logServiceInfo(INotificationData service) { + log.info("================================================="); + log.info("Distrubuted service information"); + log.info("Service UUID: {}", service.getServiceUUID()); + log.info("Service name: {}", service.getServiceName()); + List<IResourceInstance> resources = service.getResources(); + log.info("Service resources:"); + resources.forEach(resource -> { + log.info(" - Resource: {}", resource.getResourceName()); + log.info(" Artifacts:"); + resource.getArtifacts().forEach(artifact -> log.info(" - Name: {}", artifact.getArtifactName())); + }); + log.info("================================================="); + } + + private void validate(INotificationData service) { + validators.stream() + .map(validator -> validator.validate(service)) + .flatMap(Collection::stream) + .forEach(validationResult -> sendNotificationResponse(validationResult, service.getDistributionID())); + } + + private void sendNotificationResponse(ValidationResult validationResult, String distributionId) { + if (!validationResult.getMessage().equals(ValidationMessage.VALID)) { + log.warn("Artifact {} is invalid.", validationResult.getArtifact().getArtifactName()); + log.warn("Validation message: {}", validationResult.getMessage()); + + IDistributionStatusMessage message = getDistributionStatusMessage(validationResult, distributionId); + distributionClient.sendDeploymentStatus(message, "Schema reference is invalid."); + } + } + + private DistributionStatusMessage getDistributionStatusMessage(ValidationResult validationResult, String distributionId) { + return new DistributionStatusMessage( + validationResult.getArtifact().getArtifactURL(), + distributionId, + distributionClient.getConfiguration().getConsumerID(), + LocalDateTime.now().toEpochSecond(ZoneOffset.UTC), + DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR); + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java new file mode 100644 index 0000000..42d54a4 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.core.service; + +import org.onap.sdc.api.consumer.IDistributionStatusMessage; +import org.onap.sdc.utils.DistributionStatusEnum; + + +public class DistributionStatusMessage implements IDistributionStatusMessage { + + private String artifactUrl; + private String distributionId; + private String consumerId; + private long timestamp; + private DistributionStatusEnum status; + + public DistributionStatusMessage(String artifactUrl, String distributionId, String consumerId, long timestamp, DistributionStatusEnum status) { + this.artifactUrl = artifactUrl; + this.distributionId = distributionId; + this.consumerId = consumerId; + this.timestamp = timestamp; + this.status = status; + } + + @Override + public String getArtifactURL() { + return artifactUrl; + } + + @Override + public String getDistributionID() { + return distributionId; + } + + @Override + public String getConsumerID() { + return consumerId; + } + + @Override + public long getTimestamp() { + return timestamp; + } + + @Override + public DistributionStatusEnum getStatus() { + return status; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java new file mode 100644 index 0000000..107d814 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.core.service; + +public enum ValidationMessage { + VALID, + SCHEMA_REFERENCE_INVALID +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java new file mode 100644 index 0000000..57c6fce --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.core.service; + + +import org.onap.sdc.api.notification.IArtifactInfo; + +public class ValidationResult { + private IArtifactInfo artifact; + private ValidationMessage message; + + + public ValidationResult(IArtifactInfo artifact, ValidationMessage message) { + this.artifact = artifact; + this.message = message; + } + + public IArtifactInfo getArtifact() { + return artifact; + } + + public ValidationMessage getMessage() { + return message; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java b/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java new file mode 100644 index 0000000..58baec7 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * 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.test.it; + +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.test.core.config.DistributionClientConfig; +import org.onap.test.core.service.ArtifactsValidator; +import org.onap.test.core.service.ClientInitializer; +import org.onap.test.core.service.ClientNotifyCallback; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +public class RegisterToAsdcTopicIT { + + + public static void main(String[] args) { + DistributionClientConfig clientConfig = new DistributionClientConfig(); + List<ArtifactsValidator> validators = new ArrayList<>(); + DistributionClientImpl client = new DistributionClientImpl(); + ClientNotifyCallback callback = new ClientNotifyCallback(validators, client); + ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client); + clientInitializer.initialize(); + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + client.stop(); + System.out.println("Shutdown Hook is running !"); + } + }); + + } +} diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml deleted file mode 100644 index 65a38fa..0000000 --- a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml +++ /dev/null @@ -1,10 +0,0 @@ -packages: - - org.onap.sdc.ci.tests.execute.general - - org.onap.sdc.ci.tests.execute.user - - org.onap.sdc.ci.tests.execute.property - - org.onap.sdc.ci.tests.execute.lifecycle - - org.onap.sdc.ci.tests.execute.resource - - org.onap.sdc.ci.tests.execute.service - - org.onap.sdc.ci.tests.execute.artifacts - - org.onap.sdc.ci.tests.execute.imports - - org.onap.sdc.ci.tests.execute.category
\ No newline at end of file diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml deleted file mode 100644 index a9c449e..0000000 --- a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml +++ /dev/null @@ -1,35 +0,0 @@ -outputFolder: target -reportName: index.html -catalogBeHost: behost -catalogFeHost: fehost -esHost: eshost -disributionClientHost: disClient -catalogFePort: 8181 -catalogBePort: 8080 -disributionClientPort: 8181 -esPort: 9200 -neoHost: neoHost -neoPort: 7474 -neoDBusername: neo4j -neoDBpassword: 123456 - -resourceConfigDir: src/test/resources/CI/tests -componentsConfigDir: src/test/resources/CI/components -importResourceConfigDir: src/test/resources/CI/importResource -importResourceTestsConfigDir: src/test/resources/CI/importResourceTests -errorConfigurationFile: ../catalog-be/src/main/resources/config/error-configuration.yaml - -titanPropertiesFile: src/main/resources/ci/conf/titan.properties - -stopOnClassFailure: false - -#List of non-abstract resources to keep during titan cleanup between tests -#Only 1.0 version will be kept -resourcesNotToDelete: - - tosca.nodes.Compute - - tosca.nodes.Database - - tosca.nodes.ObjectStorage - - tosca.nodes.BlockStorage - - tosca.nodes.LoadBalancer - - org.openecomp.resource.cp.Port - - org.openecomp.resource.vl.Network
\ No newline at end of file diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties b/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties deleted file mode 100644 index bef72a9..0000000 --- a/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties +++ /dev/null @@ -1,34 +0,0 @@ -# Define the root logger with appender file -log4j.rootLogger = DEBUG, FILE, stdout - -# Define the file appender -log4j.appender.FILE=org.apache.log4j.RollingFileAppender -log4j.appender.FILE.File=${targetlog}logs/ci-log.out - -# Define the layout for file appender -log4j.appender.FILE.layout=org.apache.log4j.PatternLayout -log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p [%10c] : %m%n - -# Set the maximum file size before rollover -log4j.appender.FILE.maxFileSize=5MB - -# Set the the backup index -log4j.appender.FILE.maxBackupIndex=10 - - -############################################################# - -# Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -#log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %10c:%L - %m%n - -log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG -log4j.logger.com.thinkaurelius.titan.diskstorage.cassandra.CassandraTransaction=INFO, FILE, stdout - -log4j.logger.org.onap.sdc.ci.tests.utils=TRACE, FILE, stdout -log4j.additivity.org.onap.sdc.ci.tests.utils=false - - diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties b/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties deleted file mode 100644 index 691f4d6..0000000 --- a/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties +++ /dev/null @@ -1,5 +0,0 @@ -storage.backend=cassandra -storage.hostname=cassandrahost -storage.port=9160 - -cache.db-cache = false
\ No newline at end of file diff --git a/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh b/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh deleted file mode 100644 index 7fa5323..0000000 --- a/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -function usage { - echo "Usage: $0 <jar file>" -} - -function exitOnError() { - if [ $1 -ne 0 ] - then - echo "Failed running task $2" - exit 2 - fi -} - -if [ $# -lt 1 ] -then - usage - exit 2 -fi - -CURRENT_DIR=`pwd` -BASEDIR=$(dirname $0) - -if [ ${BASEDIR:0:1} = "/" ] -then - FULL_PATH=$BASEDIR -else - FULL_PATH=$CURRENT_DIR/$BASEDIR -fi - -LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties -############################################# -TARGET_DIR=${FULL_PATH}/target -CONF_FILE=${FULL_PATH}/conf/attsdc.yaml -DEBUG=true -MainClass=org.onap.sdc.ci.tests.run.StartTest - -JAR_FILE=$1 - -#TARGET_DIR=`echo ${TARGET_DIR} | sed 's/\//\//g'` -#echo $TARGET_DIR - -TESTS_DIR=/opt/app/sdc/ci/resources/tests -COMPONENTS_DIR=/opt/app/sdc/ci/resources/components - -#sed -i 's#\(outputFolder:\).*#\1 '${TARGET_DIR}'#g' $CONF_FILE -#sed -i 's#\(resourceConfigDir:\).*#\1 '${TESTS_DIR}'#g' $CONF_FILE -#sed -i 's#\(componentsConfigDir:\).*#\1 '${COMPONENTS_DIR}'#g' $CONF_FILE -TARGET_LOG_DIR="${TARGET_DIR}/" - -mkdir -p ${TARGET_DIR} -if [ -d ${TARGET_DIR} ] -then - rm -rf ${TARGET_DIR}/* - exitOnError $? "Failed_to_delete_target_dir" -fi - -debug_port=8800 -#JAVA_OPTION="-javaagent:/var/tmp/jacoco/lib/jacocoagent.jar=destfile=jacoco-it.exec" -JAVA_OPTION="" -case "$2" in - -debug) echo "Debug mode, Listen on port $debug_port"; JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;; - "") echo "Standard mode";; - *) echo "USAGE: startTest.sh [-debug]";; -esac - -cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass}" - -#echo $cmd -#console=`$cmd` - -if [ $DEBUG == "true" ] -then - $cmd -else - $cmd >> /dev/null -fi -status=`echo $?` - - - -echo "##################################################" -echo "################# status is ${status} #################" -echo "##################################################" - -exit $status - diff --git a/sdc-distribution-ci/src/main/resources/log4j2.properties b/sdc-distribution-ci/src/main/resources/log4j2.properties new file mode 100644 index 0000000..e94d551 --- /dev/null +++ b/sdc-distribution-ci/src/main/resources/log4j2.properties @@ -0,0 +1,44 @@ +# Copyright 2020 Huawei Technologies Co., Ltd. +# +# 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. +# By default, log4j2 will look for a configuration file named log4j2.xml on the classpath. +# reference: https://logging.apache.org/log4j/2.x/faq.html#troubleshooting +rootLogger.level=ERROR +rootLogger.appenderRefs=file +rootLogger.appenderRef.file.ref=RollingFile +logger.onap.name = org.onap +logger.onap.level=ERROR +logger.onap.additivity=false +logger.onap.appenderRef.stdout.ref=STDOUT +appenders=stdout, file +# Direct log messages to stdout +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.target=SYSTEM_OUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{yyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n +# Redirect log messages to a log file, support file rolling. +appender.file.type = RollingFile +appender.file.name = RollingFile +appender.file.fileName=./csar-validate.log +appender.file.filePattern=./csar-validate.%d{yyyy-MM-dd-HH:mm:ss}.log +appender.file.append=true +appender.file.policies.type=Policies +appender.file.policies.size.type=SizeBasedTriggeringPolicy +appender.file.policies.size.size=5MB +appender.file.strategy.type=DefaultRolloverStrategy +appender.file.strategy.max=10 +appender.file.layout.type=PatternLayout +appender.file.layout.pattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + + |