Commit ab54690d authored by Alexander Diewald's avatar Alexander Diewald

Merge branch '4008' into 'master'

Test case generator for DSE problems

See merge request !337
parents 37ec5a85 892ceb04
......@@ -15,5 +15,5 @@ NonQuantifiedExpressionTransformator.java 9ee437aeaf518d94b81e34a275cd01b87cfca1
QuantifiedExpressionTransformator.java 01e7162b24d16adb23f646cf02340879e8a18205 GREEN
SMTTransformationUtils.java 376da0f5dafb350b49004c7d75fb8858b53d3b7d GREEN
ScheduleRun.java 43d869a9adfbebe34c34f1ebb0bc8e0600f45b9d GREEN
SolverRun.java be9794b2be0fd203a31435548abe9d9945bc2160 GREEN
SolverRun.java 7b60b4cc2095baaba914e6d5278c19273602ce6c GREEN
TimingConstraintDefinition.java 92281277d99bb52b72c1cb898bba944b3b9a24f7 GREEN
......@@ -57,7 +57,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.exploration.ExplorationActivator;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
......@@ -118,7 +118,7 @@ public abstract class SolverRun {
try {
join();
} catch(InterruptedException e) {
warning(ExplorationActivator.getDefault(),
warning(AF3ExplorationActivator.getDefault(),
"Z3 cancellation thread has been interrupted.", e);
}
return monitor.isCanceled();
......@@ -139,13 +139,13 @@ public abstract class SolverRun {
while(isRunning) {
if(monitor.isCanceled()) {
context.interrupt();
info(ExplorationActivator.getDefault(), "Z3 has been canceled.");
info(AF3ExplorationActivator.getDefault(), "Z3 has been canceled.");
return;
}
try {
sleep(INTERVAL_MS);
} catch(InterruptedException e) {
warning(ExplorationActivator.getDefault(),
warning(AF3ExplorationActivator.getDefault(),
"Z3 cancellation thread has been interrupted.", e);
return;
}
......@@ -524,7 +524,7 @@ public abstract class SolverRun {
*/
private void logZ3info(final String msg) {
if(isDebugVerboseEnabled()) {
info(ExplorationActivator.getDefault(), "[Z3] " + msg);
info(AF3ExplorationActivator.getDefault(), "[Z3] " + msg);
}
}
......
......@@ -3,6 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="generated-src"/>
<classpathentry kind="src" path="test-src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
......
......@@ -9,7 +9,7 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.fortiss.af3.exploration.ExplorationActivator
Bundle-Activator: org.fortiss.af3.exploration.AF3ExplorationActivator
Export-Package: org.fortiss.af3.exploration,
org.fortiss.af3.exploration.compositor,
org.fortiss.af3.exploration.dseml.model,
......@@ -33,6 +33,7 @@ Export-Package: org.fortiss.af3.exploration,
org.fortiss.af3.exploration.dseml.model.function.util,
org.fortiss.af3.exploration.dseml.model.impl,
org.fortiss.af3.exploration.lang,
org.fortiss.af3.exploration.migration,
org.fortiss.af3.exploration.model,
org.fortiss.af3.exploration.model.arithmetic.impl,
org.fortiss.af3.exploration.model.booleanp.allocation.impl,
......@@ -59,6 +60,8 @@ Export-Package: org.fortiss.af3.exploration,
org.fortiss.af3.exploration.solutionconverter,
org.fortiss.af3.exploration.solutionconverter.partition,
org.fortiss.af3.exploration.solutionconverter.platform,
org.fortiss.af3.exploration.testgenerator,
org.fortiss.af3.exploration.testgenerator.util,
org.fortiss.af3.exploration.util
Require-Bundle: org.fortiss.af3.project;visibility:=reexport,
org.fortiss.af3.task;visibility:=reexport,
......
......@@ -6,6 +6,7 @@ bin.includes = .,\
plugin.xml,\
plugin.properties
source.. = generated-src/,\
res/,\
src/,\
test-src/
output.. = build/
This source diff could not be displayed because it is too large. You can view the blob instead.
Exploration.java b0a5be69a42b39e9c6e6a8401f4340de3a87a93b GREEN
ExplorationActivator.java c4a018273f54015cc1abf34a082fbf77c460dddf GREEN
AF3Exploration.java c3c1ac801d302ff2c7d79cbcbe459a4f087a4093 GREEN
AF3ExplorationActivator.java bd4ea80561dbd7256d15a832d3c7ddb9611c5c36 GREEN
......@@ -23,7 +23,7 @@ import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
*
* @author diewald
*/
public final class Exploration {
public final class AF3Exploration {
/** Initialize the explortion services. */
public static void initialize() {
IDSEBackendService.getInstance().initializeService();
......
......@@ -16,8 +16,7 @@
package org.fortiss.af3.exploration;
import org.eclipse.core.runtime.Plugin;
import org.fortiss.af3.exploration.cli.ExecuteDSECommandLineHandler;
import org.fortiss.af3.exploration.cli.ValidateDSESolutionCommandLineInterface;
import org.fortiss.af3.exploration.cli.TestCaseGenerationCommandLineHandler;
import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
import org.fortiss.af3.exploration.solutionconverter.RouteConverter;
import org.fortiss.af3.exploration.solutionconverter.ScheduleConverter;
......@@ -38,27 +37,25 @@ import org.osgi.framework.BundleContext;
*
* @author barner
*/
public class ExplorationActivator extends Plugin {
public class AF3ExplorationActivator extends Plugin {
/** The plug-in ID. */
public static final String PLUGIN_ID = ExplorationActivator.class.getPackage().getName();
public static final String PLUGIN_ID = AF3ExplorationActivator.class.getPackage().getName();
/** The shared instance. */
private static ExplorationActivator plugin;
private static AF3ExplorationActivator plugin;
/** {@inheritDoc} */
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// Register the command line parser for executing a DSE.
ICommandLineInterfaceService cliService = ICommandLineInterfaceService.getInstance();
cliService.registerHandler("--execDSE", new ExecuteDSECommandLineHandler());
cliService.registerHandler("--validateDSE", new ValidateDSESolutionCommandLineInterface());
// We can lazily register converters since they are only used when the exploration was
// already loaded (--> DSE perspective).
registerDSESolutionConverters();
ICommandLineInterfaceService cliService = ICommandLineInterfaceService.getInstance();
cliService.registerHandler("--gen-dse-testcases",
new TestCaseGenerationCommandLineHandler());
}
/** {@inheritDoc} */
......@@ -69,7 +66,7 @@ public class ExplorationActivator extends Plugin {
}
/** Returns the shared instance. */
public static ExplorationActivator getDefault() {
public static AF3ExplorationActivator getDefault() {
return plugin;
}
......
ExecuteDSECommandLineHandler.java 80e1780496fac6b8a02566b994d0c715d00a3ee3 GREEN
ValidateDSESolutionCommandLineInterface.java 848a6dcb1f3de889ba0107b041eef970ca396559 GREEN
ExecuteDSECommandLineHandler.java 4e704418d35cba540d35c7ec6949137669459720 GREEN
TestCaseGenerationCommandLineHandler.java ccd942515f5490ff9ed6ece891f3ade206333a08 GREEN
ValidateDSESolutionCommandLineInterface.java fe22edc178a4255dca54d083d3869c9142b7d304 GREEN
......@@ -35,7 +35,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.fortiss.af3.exploration.ExplorationActivator;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE;
......@@ -88,7 +88,7 @@ public final class ExecuteDSECommandLineHandler implements ICommandLineSwitchHan
Optional<IDSEBackend> z3Backend =
getFirst(dseService.findByArtifactAndName(solutionModels, "Z3 (SMT)"));
if(!z3Backend.isPresent()) {
error(ExplorationActivator.getDefault(),
error(AF3ExplorationActivator.getDefault(),
"Could not find the Z3 backend to perform the exploration.");
return;
}
......@@ -103,7 +103,7 @@ public final class ExecuteDSECommandLineHandler implements ICommandLineSwitchHan
dseService.explore(new DseCLISolutionAdapter(matchingDSE), timeoutMS);
} catch(Exception e) {
// The DSE produced an Exception --> Add log entry and do not store a solution.
error(ExplorationActivator.getDefault(),
error(AF3ExplorationActivator.getDefault(),
"The exploration failed due to an exception in the DSE backend.", e);
}
}
......@@ -146,7 +146,7 @@ public final class ExecuteDSECommandLineHandler implements ICommandLineSwitchHan
try {
modelCtx.doSave(new NullProgressMonitor());
} catch(CoreException | IOException e) {
error(ExplorationActivator.getDefault(), "Could not store the result of the " +
error(AF3ExplorationActivator.getDefault(), "Could not store the result of the " +
"Exploration. An exception occured while saving.", e);
}
}
......
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| 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. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.cli;
import static org.fortiss.af3.exploration.testgenerator.ExplorationTestCaseGenerator.generateTestCases;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import org.apache.commons.lang3.StringUtils;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.exploration.testgenerator.ExplorationTestCaseGenerator;
import org.fortiss.af3.expression.AF3ExpressionActivator;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.tooling.kernel.extension.ICommandLineSwitchHandler;
/**
* Generates a number of DSE test cases by a command line switch. See
* {@link ExplorationTestCaseGenerator} for details.
*
* @author diewald
*/
public class TestCaseGenerationCommandLineHandler implements ICommandLineSwitchHandler {
/**
* Number of randomly generated {@link ComponentArchitecture}s. The number of produced test
* cases is the cross product of {@link ComponentArchitecture}s and generated
* {@link PlatformArchitecture}s.
*/
private final int compArchNum = 1;
/** Minimal number of {@link Component}s per {@link ComponentArchitecture}. */
private final int minComponentNum = 10;
/** Maximum number of {@link Component}s per {@link ComponentArchitecture}. */
private final int maxComponentNum = 15;
/** {@inheritDoc} */
@Override
public boolean hasAdditionalArgument() {
return false;
}
/** {@inheritDoc} */
@Override
public void handleCLISwitch(String argument) {
if(!StringUtils.isEmpty(argument)) {
error(AF3ExplorationActivator.getDefault(), "The test case generation switch does " +
"not take any argument, but one has been provided.");
return;
}
try {
generateTestCases(compArchNum, minComponentNum, maxComponentNum);
} catch(Exception e) {
error(AF3ExpressionActivator.getDefault(),
"The DSE random test case generation failed.", e);
}
}
}
......@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.Set;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.exploration.ExplorationActivator;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.lang.ExplorationExpressionDeploymentValidator;
import org.fortiss.af3.exploration.model.project.DSE;
......@@ -73,8 +73,9 @@ public class ValidateDSESolutionCommandLineInterface implements ICommandLineSwit
ProcessStep currentStep = matchingDSE.getCurrentStep();
if(!(currentStep instanceof ExplorationStep)) {
error(ExplorationActivator.getDefault(), "The validator can only be executed if the " +
"current step of a DSE points to an ExplorationStep.");
error(AF3ExplorationActivator.getDefault(),
"The validator can only be executed if the " +
"current step of a DSE points to an ExplorationStep.");
return;
}
......@@ -89,14 +90,14 @@ public class ValidateDSESolutionCommandLineInterface implements ICommandLineSwit
try {
isSolutionValidated = validateSingleSolution(expStep, singleSolution);
} catch(Exception e1) {
error(ExplorationActivator.getDefault(), "The validator for the solver model.");
error(AF3ExplorationActivator.getDefault(), "The validator for the solver model.");
} finally {
if(isSolutionValidated) {
info(ExplorationActivator.getDefault(),
info(AF3ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" passed the validation of the produced SuperSets.");
} else {
error(ExplorationActivator.getDefault(),
error(AF3ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" did not pass the validation of the produced SuperSets.");
}
......@@ -106,15 +107,15 @@ public class ValidateDSESolutionCommandLineInterface implements ICommandLineSwit
isSolutionValidated =
validateTransformedSolution(expStep, solutionModels, singleSolution);
} catch(Exception e) {
error(ExplorationActivator.getDefault(),
error(AF3ExplorationActivator.getDefault(),
"The validator for the exported solution from the DSE failed.", e);
} finally {
if(isSolutionValidated) {
info(ExplorationActivator.getDefault(),
info(AF3ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" passed the validation of the produced model elements.");
} else {
error(ExplorationActivator.getDefault(),
error(AF3ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" did not pass the validation of the produced model elements.");
}
......
DSEStaticImpl.java ceaf5ecf8c77609d4ae13d40b88ac443fe6b09e9 GREEN
DSEStaticImpl.java 8dbcca69543c56dd6f646999de726fe7bb7575c1 GREEN
InitialInputDefinitionStepStaticImpl.java 574a20551eff4745bb24b682edd616368321de46 GREEN
ModelSnapshotStaticImpl.java 6db72d06363209e53e2dae7e0e0834a8239d3e7c GREEN
ProcessStepStaticImpl.java 13b80bb1fc56e3ed73d3449d911ae52453365938 GREEN
ProcessStepStaticImpl.java f8ba2886782505778fd0a16c895988d568d97491 GREEN
SolutionSelectionStepStaticImpl.java f62112f9d033b45294155eb8f77edfd74a633b07 GREEN
......@@ -33,11 +33,10 @@ public class DSEStaticImpl {
// Register the first step
currentStep = additionalStep;
} else {
if(currentStep instanceof ExplorationStep) {
if(additionalStep instanceof ExplorationStep) {
// Subsequent exploration runs should be added as siblings
currentStep = currentStep.getParent();
}
if(currentStep instanceof ExplorationStep &&
additionalStep instanceof ExplorationStep) {
// Subsequent exploration runs should be added as siblings
currentStep = currentStep.getParent();
}
currentStep.getSuccessors().add(additionalStep);
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.model.project.impl;
import static org.eclipse.emf.common.util.ECollections.unmodifiableEList;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createSuperSetMap;
import static org.fortiss.af3.exploration.util.ExplorationUtils.appendNonPresentSolutionSets;
import static org.fortiss.af3.exploration.util.ExplorationUtils.recursiveArtifactWalk;
......@@ -53,7 +54,7 @@ public class ProcessStepStaticImpl {
/** Static implementation of the method {@link ProcessStep#getInputArtifacts()}. */
public static EList<IInputArtifact> getInputArtifacts(ProcessStepImpl processStepImpl) {
EList<IInputArtifact> aggregateList = aggregateLatestSnapshots(processStepImpl);
return aggregateList;
return unmodifiableEList(aggregateList);
}
/** Static implementation of the method {@link ProcessStep#getParent()}. */
......@@ -145,7 +146,7 @@ public class ProcessStepStaticImpl {
};
EList<IExplorationTarget<?>> collectedTargets = new BasicEList<>();
recursiveTreeWalk(processStepImpl, collectExpTargets, collectedTargets);
return collectedTargets;
return unmodifiableEList(collectedTargets);
}
/**
......@@ -224,7 +225,7 @@ public class ProcessStepStaticImpl {
};
EList<RuleSet> collectedRuleSets = new BasicEList<>();
recursiveTreeWalk(processStepImpl, collectExpTargets, collectedRuleSets);
return collectedRuleSets;
return unmodifiableEList(collectedRuleSets);
}
/** Static implementation of {@link ProcessStep#getModelSnapshots()} */
......
DSEBackendService.java f1f4edfca2104cd98546099bfcfd2f169fd1df69 GREEN
DSEBackendService.java fa1d5afe25cf672bd8cd4d74e924de08767066c5 GREEN
DSESolutionExporterService.java fa37b8d1e3379cce1f06f02d2f270a6177611e7f GREEN
......@@ -33,7 +33,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.emf.ecore.EReference;
import org.fortiss.af3.exploration.ExplorationActivator;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.SuperSetMap;
......@@ -180,7 +180,7 @@ public class DSEBackendService implements IDSEBackendService, IIntrospectiveKern
cachedExplorationSolution = dseSolution.get();
}
} catch(Exception e) {
return createExceptionStatus(e, ExplorationActivator.PLUGIN_ID,
return createExceptionStatus(e, AF3ExplorationActivator.PLUGIN_ID,
"DSE:\n" + e.getMessage());
}
return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
......
ArchitectureGraph.java 4f1539b6997b7a71d744ef750aa2f102097f211d GREEN
ExplorationTestCaseGenerator.java 583c4679996e0c8c277c23da4f5285dea849b650 GREEN
package org.fortiss.af3.exploration.testgenerator;
import static org.jgrapht.Graphs.addAllVertices;
import java.util.Collection;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.DirectedWeightedPseudograph;
import com.google.common.collect.Table;
/**
* Graph of an architecture with the vertices {@code V}. Multiple, weighted connections between
* vertices are supported.
*
* @author diewald
*/
public class ArchitectureGraph<V> extends DirectedWeightedPseudograph<V, DefaultWeightedEdge> {
/** Constructor. */
public ArchitectureGraph() {
super(DefaultWeightedEdge.class);
}
/** Constructor for a graph with the given vertices and edges. */
public ArchitectureGraph(Collection<V> vertices, Table<V, V, Integer> edges) {
this();
addAllVertices(this, vertices);
edges.cellSet().forEach(edgeEntry -> {
if(edgeEntry != null) {
int createdConnectionNum = 0;
while(createdConnectionNum < edgeEntry.getValue()) {
addEdge(edgeEntry.getRowKey(), edgeEntry.getColumnKey());
}
}
});
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| 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. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.testgenerator;
import static org.fortiss.af3.exploration.testgenerator.util.AnnotationGenerationUtils.expandArchitecturesByAnnotations;
import static org.fortiss.af3.exploration.testgenerator.util.CompArchGeneratonUtil.generateLogicalArchitectures;
import static org.fortiss.af3.exploration.testgenerator.util.DseUtils.expandByDseProblems;
import static org.fortiss.af3.exploration.testgenerator.util.FileWriterUtil.write;
import static org.fortiss.af3.exploration.testgenerator.util.GraphMetricUtils.getGraphMetrics;
import static org.fortiss.af3.exploration.testgenerator.util.ProjectUtils.createAF3Projects;
import static org.fortiss.af3.exploration.testgenerator.util.ProjectUtils.saveFileProjects;
import static org.fortiss.af3.exploration.util.ExplorationUtils.isDumpTestgenGraphmetricsEnabled;
import static org.fortiss.af3.project.utils.TestCaseProjectUtils.loadTestProject;
import static org.fortiss.tooling.base.utils.AnnotationUtils.instantiateAnnotationsRecursive;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.info;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.task.model.TaskArchitecture;
/**
* Generator for DSE test case {@link FileProject}s. It creates deployment problems with generated
* {@link ComponentArchitecture}s having a random structure and randomly assigned annotation values
* for generated {@link TaskArchitecture}s and {@link PlatformArchitecture}s.
*
* @author munaro
* @author diewald
*/
public class ExplorationTestCaseGenerator {
/**
* Generates a set of {@link FileProject}s in the workspace that contain a deployment problem
* for the DSE.
* A given number of {@link ComponentArchitecture}s is randomly generated. Their corresponding
* {@link TaskArchitecture}s shall be mapped onto a predefined set of
* {@link PlatformArchitecture}s. In addition a number of randomly generated deployment
* constraints is added to the problem.
*/
public static void generateTestCases(int compArchNum, int minComponentNum, int maxComponentNum)
throws Exception {
// Import platform architectures.
FileProject templateProject = loadTestProject(AF3ExplorationActivator.PLUGIN_ID,
"/res/org/fortiss/af3/exploration/testgeneration/TemplateArchitectures.af3_23");
Collection<PlatformArchitecture> platformArchitectures =
copy(pickInstanceOf(PlatformArchitecture.class, templateProject.getRootElements()));
// Generate component Architectures
Collection<ComponentArchitecture> genCompArchs =
generateLogicalArchitectures(compArchNum, minComponentNum, maxComponentNum);
if(isDumpTestgenGraphmetricsEnabled()) {
dumpGraphMetrics(genCompArchs);
}
Collection<FileProject> fileProjects =
createAF3Projects(genCompArchs, platformArchitectures, "DSE_Generated_TestCase");
fileProjects = expandArchitecturesByAnnotations(fileProjects);
fileProjects = expandByDseProblems(fileProjects);
info(AF3ExplorationActivator.getDefault(),
"Test cases are generated in the runtime Workspace.");
// Instantiate missing annotations.
fileProjects.forEach(fp -> instantiateAnnotationsRecursive(fp));
saveFileProjects(fileProjects);
}
/** Dumps the graph metrics of each generated {@link ComponentArchitecture}. */
private static void dumpGraphMetrics(Collection<ComponentArchitecture> compArchs)
throws Exception {
// Setup the parallel graph metric calculation by callables.
Set<Callable<Map<ComponentArchitecture, Map<String, Double>>>> graphMetricsCallables =
new HashSet<Callable<Map<ComponentArchitecture, Map<String, Double>>>>();
compArchs.stream().forEach(componentArchitecture -> graphMetricsCallables
.add(new Callable<Map<ComponentArchitecture, Map<String, Double>>>() {
@Override
public Map<ComponentArchitecture, Map<String, Double>> call() throws Exception {
Map<ComponentArchitecture, Map<String, Double>> graphMetrics =
new HashMap<ComponentArchitecture, Map<String, Double>>();
graphMetrics.put(componentArchitecture,
getGraphMetrics(componentArchitecture));
return graphMetrics;
}
}));
// Execute the callables in parallel.
ExecutorService graphMetricsExecutor = Executors.newFixedThreadPool(4);
List<Future<Map<ComponentArchitecture, Map<String, Double>>>> futureGraphMetrics =
graphMetricsExecutor.invokeAll(graphMetricsCallables);
Map<ComponentArchitecture, Map<String, Double>> graphMetrics =
new HashMap<ComponentArchitecture, Map<String, Double>>();
for(Future<Map<ComponentArchitecture, Map<String, Double>>> futureMetrics : futureGraphMetrics) {
graphMetrics.putAll(futureMetrics.get());
}
graphMetricsExecutor.shutdown();
write("graph-metrics.csv", graphMetrics);
}
}
AnnotationGenerationUtils.java 599f568c7e7da8555399ae7ee4eb922cb490effd GREEN
CompArchGeneratonUtil.java 0f1e3c048884fa4df6a35b6a110c46da58f59857 GREEN
DseUtils.java d81af0b7f649d2453aada362fc50572fce31ebc8 GREEN
FileWriterUtil.java 4a95559f571d41fa44e6236fc055ab5baac7c384 GREEN
GraphGenerationUtilities.java e637fd6a38339c60a6a7ac5af116db304266d345 GREEN
GraphMetricUtils.java 99a398d4ff9b15b3eeb35748e32aa34a9b197f07 GREEN
GraphUtils.java 4d59affe2bab3113f48d1a827ad0bc9599b3439e GREEN
ProjectUtils.java 5d4b2cbae16526bd99fedf38a10866d3b2eadde5 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| 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. |