aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool
diff options
context:
space:
mode:
authorcb478c <cb478c@att.com>2017-07-25 16:01:10 +0300
committerMichael Lando <ml636r@att.com>2017-07-30 21:03:28 +0300
commite280d7229f42210719b76775cd47bddb675c3c53 (patch)
treef9fe6f67cbff75b62bf59bf586ff1213d09978cc /asdctool
parenta521335db6949fb0fdd846a4f1faa0c26336b0a9 (diff)
[SDC]add information to final report.
Change-Id: I20eab3422e74e22606a763007641108cbb0856d1 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'asdctool')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java5
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java3
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java56
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java27
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java5
-rw-r--r--asdctool/src/main/resources/scripts/validationTool.sh2
6 files changed, 72 insertions, 26 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
index 16a479dc75..84d881c168 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
@@ -69,7 +69,10 @@ public class TopologyTemplateValidatorExecuter {
Set<String> failedTasks = new HashSet<>();
Set<String> successTasks = new HashSet<>();
boolean successAllVertices = true;
+ int vertexNum = 0;
+ int verticesSize = vertices.size();
for (GraphVertex vertex: vertices) {
+ vertexNum++;
boolean successAllTasks = true;
for (TopologyTemplateValidationTask task: tasks) {
ReportManager.reportStartTaskRun(vertex, task.getTaskName());
@@ -78,7 +81,7 @@ public class TopologyTemplateValidatorExecuter {
failedTasks.add(task.getTaskName());
successAllVertices = false;
successAllTasks = false;
- } else {
+ } else if (successAllTasks && vertexNum == verticesSize) {
successTasks.add(task.getTaskName());
}
reportValidateTaskStatus(task, success, vertex);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
index dfdeec8c67..dd79943885 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
@@ -33,6 +33,9 @@ public class ArtifactValidationUtils {
boolean isArtifactExist = isArtifcatInCassandra(artifact.getEsId());
String status = isArtifactExist ? "Artifact " + artifact.getEsId() + " is in Cassandra" :
"Artifact " + artifact.getEsId() + " doesn't exist in Cassandra";
+ if (!isArtifactExist) {
+ ReportManager.addFailedVertex(taskName, vertex.getUniqueId());
+ }
ReportManager.writeReportLineToFile(status);
if (!isArtifactExist) {
allArtifactsExist = false;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
index 675ac1f25d..f8de1d3264 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
@@ -1,7 +1,9 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.moduleJson;
import fj.data.Either;
+import org.apache.cassandra.cql3.CQL3Type;
import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask;
+import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
@@ -14,10 +16,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -28,6 +27,10 @@ public class ModuleJsonTask extends ServiceValidationTask {
@Autowired
private TopologyTemplateOperation topologyTemplateOperation;
+ public ModuleJsonTask() {
+ this.name = "Service Module json Validation Task";
+ }
+
@Override
public boolean validate(GraphVertex vertex) {
ComponentParametersView paramView = new ComponentParametersView();
@@ -41,33 +44,46 @@ public class ModuleJsonTask extends ServiceValidationTask {
}
TopologyTemplate element = (TopologyTemplate) toscaElementEither.left().value();
if (!isAfterSubmitForTesting(element)) {
- return false;
+ return true;
}
Map<String, MapGroupsDataDefinition> instGroups = element.getInstGroups();
Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = element.getInstDeploymentArtifacts();
- for (Map.Entry<String, MapGroupsDataDefinition> pair : instGroups.entrySet()) {
- String groupKey = pair.getKey();
+ for (Map.Entry<String, MapGroupsDataDefinition> pair : Optional.ofNullable(instGroups).orElse(Collections.emptyMap()).entrySet()) {
MapGroupsDataDefinition groups = pair.getValue();
if (groups != null && !groups.getMapToscaDataDefinition().isEmpty()) {
- MapArtifactDataDefinition deploymentsArtifacts = instDeploymentArtifacts.get(groupKey);
- if (deploymentsArtifacts != null && !deploymentsArtifacts.getMapToscaDataDefinition().isEmpty()) {
- List<ArtifactDataDefinition> moduleJsonArtifacts = deploymentsArtifacts.getMapToscaDataDefinition().values().stream().filter(artifact -> {
- String artifactName = artifact.getArtifactName();
- if (artifactName.startsWith(groupKey) && artifactName.endsWith("module.json")) {
- return true;
- }
- return false;
- }).collect(Collectors.toList());
- if (moduleJsonArtifacts.size() > 0) {
- return true;
- }
- }
+ return findCoordinateModuleJson(pair, instDeploymentArtifacts, vertex);
}
+ return true;
}
return true;
}
+ private boolean findCoordinateModuleJson(Map.Entry<String, MapGroupsDataDefinition> pair, Map<String, MapArtifactDataDefinition> instDeploymentArtifacts, GraphVertex vertex) {
+ String groupKey = pair.getKey();
+ String[] split = groupKey.split("\\.");
+ String instanceName = split[split.length-1];
+ MapArtifactDataDefinition deploymentsArtifacts = instDeploymentArtifacts.get(groupKey);
+ if (deploymentsArtifacts != null && !deploymentsArtifacts.getMapToscaDataDefinition().isEmpty()) {
+ List<ArtifactDataDefinition> moduleJsonArtifacts = deploymentsArtifacts.getMapToscaDataDefinition().values().stream().filter(artifact -> {
+ String artifactName = artifact.getArtifactName();
+ if (artifactName.startsWith(instanceName) && artifactName.endsWith("modules.json")) {
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
+ if (moduleJsonArtifacts.size() > 0) {
+ String status = "Instance "+instanceName+" has a corresponding modules.json file: "+moduleJsonArtifacts.get(0).getArtifactName();
+ ReportManager.writeReportLineToFile(status);
+ return true;
+ }
+ }
+ String status = "Instance "+instanceName+" doesn't have a corresponding modules.json file";
+ ReportManager.writeReportLineToFile(status);
+ ReportManager.addFailedVertex(getTaskName(), vertex.getUniqueId());
+ return false;
+ }
+
private boolean isAfterSubmitForTesting(TopologyTemplate element){
List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.READY_FOR_CERTIFICATION,
LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFIED));
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
index 1fdde7dd80..116883967a 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
@@ -9,9 +9,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
/**
* Created by chaya on 7/5/2017.
@@ -20,6 +18,7 @@ public class ReportManager {
private static List<ValidationTaskResult> taskResults;
private static String reportOutputFilePath;
+ private static Map<String, Set<String>> failedVerticesPerTask = new HashMap<>();
public ReportManager() {
try {
@@ -34,6 +33,15 @@ public class ReportManager {
}
}
+ public static void addFailedVertex (String taskName, String vertexId) {
+ Set<String> failedVertices = failedVerticesPerTask.get(taskName);
+ if (failedVertices == null) {
+ failedVertices = new HashSet<>();
+ }
+ failedVertices.add(vertexId);
+ failedVerticesPerTask.put(taskName, failedVertices);
+ }
+
public static void reportValidationTaskStatus(GraphVertex vertexScanned, String taskName, String taskResultMessage, boolean success) {
taskResults.add(new ValidationTaskResult(vertexScanned, taskName, taskResultMessage, success));
printValidationTaskStatus(vertexScanned, taskName, success);
@@ -90,4 +98,17 @@ public class ReportManager {
sb.appendln("-----------------------Vertex: "+vertex.getUniqueId()+", Task " + taskName + " Started-----------------------");
writeReportLineToFile(sb.toString());
}
+
+ public static void reportEndOfToolRun() {
+ StrBuilder sb = new StrBuilder();
+ sb.appendNewLine().appendNewLine();
+ sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------");
+ failedVerticesPerTask.forEach((taskName, failedVertices) -> {
+ sb.append("Task: " + taskName);
+ sb.appendNewLine();
+ sb.append("FailedVertices: " + failedVertices);
+ sb.appendNewLine();
+ });
+ writeReportLineToFile(sb.toString());
+ }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java
index 6b10615ad3..db87a66cd3 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java
@@ -4,6 +4,7 @@ import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationToolConfiguration;
import org.openecomp.sdc.asdctool.impl.migration.v1604.AppConfig;
+import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
@@ -29,7 +30,9 @@ public class ValidationTool {
ValidationToolBL validationToolBL = context.getBean(ValidationToolBL.class);
System.out.println("Start Validation Tool");
- if (validationToolBL.validateAll()) {
+ Boolean result = validationToolBL.validateAll();
+ ReportManager.reportEndOfToolRun();
+ if (result) {
System.out.println("Validation finished successfully");
System.exit(0);
} else {
diff --git a/asdctool/src/main/resources/scripts/validationTool.sh b/asdctool/src/main/resources/scripts/validationTool.sh
index fc82eee72d..23eaeb8da7 100644
--- a/asdctool/src/main/resources/scripts/validationTool.sh
+++ b/asdctool/src/main/resources/scripts/validationTool.sh
@@ -18,7 +18,7 @@ source ${FULL_PATH}/baseOperation.sh
mainClass="org.openecomp.sdc.asdctool.main.ValidationTool"
-command="java $JVM_LOG_FILE -cp $JARS $mainClass reportOutput.txt /apps/jetty/base/be/config/catalog-be/"
+command="java $JVM_LOG_FILE -cp $JARS $mainClass reportOutput.txt /home/vagrant/catalog-be/config/catalog-be/"
echo $command
$command