diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.classpath b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.classpath new file mode 100644 index 000000000..81fe078c2 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.gitignore b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.gitignore new file mode 100644 index 000000000..ae3c17260 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.project b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.project new file mode 100644 index 000000000..6693e659e --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.project @@ -0,0 +1,28 @@ + + + org.palladiosimulator.simulizar.monitorrepository.map.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..9154beff7 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/META-INF/MANIFEST.MF b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..dff7b79de --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Tests +Bundle-SymbolicName: org.palladiosimulator.simulizar.monitorrepository.map.tests +Bundle-Version: 5.2.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Require-Bundle: org.palladiosimulator.simulizar.monitorrepository.map;bundle-version="5.2.0", + org.junit, + org.palladiosimulator.monitorrepository.map;bundle-version="1.0.0", + org.palladiosimulator.simulizar.runtimemeasurement, + org.palladiosimulator.measurementframework, + org.palladiosimulator.simulizar;bundle-version="2.0.8", + org.jscience diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/build.properties b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/org.palladiosimulator.simulizar.monitorrepository.map.tests.launch b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/org.palladiosimulator.simulizar.monitorrepository.map.tests.launch new file mode 100644 index 000000000..ae2701371 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/org.palladiosimulator.simulizar.monitorrepository.map.tests.launch @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/src/org/palladiosimulator/simulizar/monitorrepository/map/runtimemeasurement/tests/MonitorRepositoryMapRuntimeMeasurementsRecorderTest.java b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/src/org/palladiosimulator/simulizar/monitorrepository/map/runtimemeasurement/tests/MonitorRepositoryMapRuntimeMeasurementsRecorderTest.java new file mode 100644 index 000000000..dfb44f53f --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.monitorrepository.map.tests/src/org/palladiosimulator/simulizar/monitorrepository/map/runtimemeasurement/tests/MonitorRepositoryMapRuntimeMeasurementsRecorderTest.java @@ -0,0 +1,147 @@ +package org.palladiosimulator.simulizar.monitorrepository.map.runtimemeasurement.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.util.List; + +import javax.measure.Measure; +import javax.measure.quantity.Duration; +import javax.measure.unit.NonSI; +import javax.measure.unit.SI; + +import org.junit.Before; +import org.junit.Test; +import org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint; +import org.palladiosimulator.edp2.models.measuringpoint.MeasuringpointFactory; +import org.palladiosimulator.measurementframework.MeasuringValue; +import org.palladiosimulator.measurementframework.TupleMeasurement; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.monitorrepository.MeasurementSpecification; +import org.palladiosimulator.monitorrepository.Monitor; +import org.palladiosimulator.monitorrepository.MonitorRepositoryFactory; +import org.palladiosimulator.monitorrepository.map.ExponentialSmoothing; +import org.palladiosimulator.monitorrepository.map.Map; +import org.palladiosimulator.monitorrepository.map.MapFactory; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurement; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurementFactory; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurementModel; +import org.palladiosimulator.simulizar.monitorrepository.map.runtimemeasurement.MonitorRepositoryMapRuntimeMeasurementsRecorder; + +public class MonitorRepositoryMapRuntimeMeasurementsRecorderTest { + + private static final double DELTA = Math.pow(10, -8); + + private Map mapProcessingType; + private ExponentialSmoothing exponentialSmoothing; + private RuntimeMeasurementModel rmModel; + private MeasuringPoint measuringPoint; + private Monitor monitor; + private MeasurementSpecification spec; + private Measure pointInTime; + private MeasuringValue wrongMetricMeasurement; + private MeasuringValue correctMeasurement; + + private InternalRuntimeMeasurementsRecorder rtMeasurementsRecorderUnderTest; + + @Before + public void setUp() throws Exception { + this.measuringPoint = MeasuringpointFactory.eINSTANCE.createResourceURIMeasuringPoint(); + this.measuringPoint.setStringRepresentation("MeasuringPoint"); + + this.monitor = MonitorRepositoryFactory.eINSTANCE.createMonitor(); + this.monitor.setMeasuringPoint(this.measuringPoint); + + this.spec = MonitorRepositoryFactory.eINSTANCE.createMeasurementSpecification(); + this.spec.setMetricDescription(MetricDescriptionConstants.RESPONSE_TIME_METRIC); + this.spec.setMonitor(this.monitor); + + this.exponentialSmoothing = MapFactory.eINSTANCE.createExponentialSmoothing(); + this.exponentialSmoothing.setSmoothingFactor(0.5); // computes the arithmetic mean then + + this.mapProcessingType = MapFactory.eINSTANCE.createMap(); + this.mapProcessingType.setEntityName("Map Processing Type Response Time"); + this.mapProcessingType.setMapper(this.exponentialSmoothing); + this.mapProcessingType.setOutputMetricDescription(MetricDescriptionConstants.RESPONSE_TIME_METRIC); + this.mapProcessingType.setMeasurementSpecification(this.spec); + + this.rmModel = RuntimeMeasurementFactory.eINSTANCE.createRuntimeMeasurementModel(); + + this.rtMeasurementsRecorderUnderTest = new InternalRuntimeMeasurementsRecorder(this.rmModel, + this.mapProcessingType); + + this.pointInTime = Measure.valueOf(10d, SI.SECOND); + this.correctMeasurement = new TupleMeasurement(MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, + this.pointInTime, Measure.valueOf(1d / 60, NonSI.MINUTE)); // 1 second = 1/60 min + this.wrongMetricMeasurement = new TupleMeasurement(MetricDescriptionConstants.POWER_CONSUMPTION_TUPLE, + this.pointInTime, Measure.valueOf(42d, SI.WATT)); + } + + @Test(expected = NullPointerException.class) + public void testCtorNullArgument() { + new MonitorRepositoryMapRuntimeMeasurementsRecorder(null, this.mapProcessingType); + } + + @Test(expected = NullPointerException.class) + public void testCtorNullArgument2() { + new MonitorRepositoryMapRuntimeMeasurementsRecorder(this.rmModel, null); + } + + @Test(expected = IllegalStateException.class) + public void testCtorIllegalStateArgument() { + // use the response time metric set description to trigger the exception + this.mapProcessingType.setOutputMetricDescription(MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE); + new MonitorRepositoryMapRuntimeMeasurementsRecorder(this.rmModel, this.mapProcessingType); + } + + @Test(expected = NullPointerException.class) + public void testNewMeasurementAvailableNullArgument() { + this.rtMeasurementsRecorderUnderTest.newMeasurementAvailable(null); + } + + @Test(expected = IllegalStateException.class) + public void testNewMeasurementAvailableWrongMetric() { + this.rtMeasurementsRecorderUnderTest.newMeasurementAvailable(this.wrongMetricMeasurement); + } + + @Test + public void testNewMeasurementAvailableCompatibleMetric() { + this.rtMeasurementsRecorderUnderTest.newMeasurementAvailable(this.correctMeasurement); + RuntimeMeasurement measurement = this.rtMeasurementsRecorderUnderTest.getMeasurement(); + + assertEquals(this.spec.getId(), measurement.getMeasurementSpecification().getId()); + assertEquals(this.measuringPoint.getStringRepresentation(), + measurement.getMeasuringPoint().getStringRepresentation()); + assertEquals(0.5, measurement.getMeasuringValue(), DELTA); // 0.5s + + this.rtMeasurementsRecorderUnderTest.newMeasurementAvailable(this.correctMeasurement); + measurement = this.rtMeasurementsRecorderUnderTest.getMeasurement(); + assertEquals(0.75, measurement.getMeasuringValue(), DELTA); + } + + @Test + public void testPreUnregister() { + List allMeasurements = this.rtMeasurementsRecorderUnderTest.getModel().getMeasurements(); + int size = allMeasurements.size(); + this.rtMeasurementsRecorderUnderTest.preUnregister(); + + assertEquals(size - 1, this.rtMeasurementsRecorderUnderTest.getModel().getMeasurements().size()); + assertFalse(this.rmModel.getMeasurements().contains(this.rtMeasurementsRecorderUnderTest.getMeasurement())); + } + + private class InternalRuntimeMeasurementsRecorder extends MonitorRepositoryMapRuntimeMeasurementsRecorder { + + public InternalRuntimeMeasurementsRecorder(final RuntimeMeasurementModel rmModel, final Map mapProcessingType) { + super(rmModel, mapProcessingType); + } + + public RuntimeMeasurement getMeasurement() { + return super.getPRMMeasurement(); + } + + public RuntimeMeasurementModel getModel() { + return super.getPrmModel(); + } + + } +} diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/.classpath b/tests/org.palladiosimulator.simulizar.reliability.tests/.classpath new file mode 100644 index 000000000..675a5e296 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/.project b/tests/org.palladiosimulator.simulizar.reliability.tests/.project new file mode 100644 index 000000000..628c2ad2f --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/.project @@ -0,0 +1,28 @@ + + + org.palladiosimulator.simulizar.reliability.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.palladiosimulator.simulizar.reliability.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62ef3488c --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/META-INF/MANIFEST.MF b/tests/org.palladiosimulator.simulizar.reliability.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..87e05600e --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Reliability Extension Tests +Bundle-SymbolicName: org.palladiosimulator.simulizar.reliability.tests +Bundle-Version: 5.2.0.qualifier +Fragment-Host: org.palladiosimulator.simulizar.reliability;bundle-version="5.2.0" +Automatic-Module-Name: org.palladiosimulator.simulizar.reliability.tests +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Require-Bundle: org.palladiosimulator.simulizar.test.commons;bundle-version="5.0.0", + tools.mdsd.junit5utils;bundle-version="0.1.0", + de.uka.ipd.sdq.workflow, + org.palladiosimulator.metricspec, + org.palladiosimulator.edp2, + tools.mdsd.library.standalone.initialization;bundle-version="0.2.0", + org.palladiosimulator.pcm.resources;bundle-version="4.3.0", + de.uka.ipd.sdq.simulation.abstractsimengine.desmoj;bundle-version="4.3.0", + de.uka.ipd.sdq.errorhandling;bundle-version="4.3.0", + de.desmoj;bundle-version="2.3.3" +Import-Package: org.hamcrest;version="2.2.0", + org.junit.jupiter.api;version="5.7.0" diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/build.properties b/tests/org.palladiosimulator.simulizar.reliability.tests/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/src/org/palladiosimulator/simulizar/reliability/tests/ExecutionResultTest.java b/tests/org.palladiosimulator.simulizar.reliability.tests/src/org/palladiosimulator/simulizar/reliability/tests/ExecutionResultTest.java new file mode 100644 index 000000000..22216dbc9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/src/org/palladiosimulator/simulizar/reliability/tests/ExecutionResultTest.java @@ -0,0 +1,47 @@ +package org.palladiosimulator.simulizar.reliability.tests; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils.allMeasurementsOfMetric; +import static org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils.getMeasurementOfAt; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.measurementframework.measure.IdentifierMeasure; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.reliability.di.DaggerReliabilityExtensionComponent; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.annotation.UseSimuLizarExtension; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class ExecutionResultTest { + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.reliability.tests", basePath = "testmodels/simulizar151", modelFiles = { + "default.allocation", "default.usagemodel", "My.monitorrepository" }) + @UseSimuLizarExtension(DaggerReliabilityExtensionComponent.class) + @SimulationConfig(simulateReliability = true) + @RunSimuLizar + void testExecutionResultRecording(UsageScenario usageScenarion,ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var resultMeasurement = getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.EXECUTION_RESULT_TYPE_TUPLE, usageScenarion); + assertTrue(resultMeasurement.isPresent()); + + var results = allMeasurementsOfMetric(resultMeasurement.get(), MetricDescriptionConstants.EXECUTION_RESULT_TYPE); + + var noSuccesses = results.stream().map(IdentifierMeasure.class::cast).map(m -> m.getValue().getLiteral()) + .filter(lit -> lit.equals(MetricDescriptionConstants.EXECUTION_RESULT_TYPE_SUCCESS.getLiteral())).count(); + assertThat(noSuccesses * 1.0 / results.size(), is(closeTo(0.7d, 0.1))); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/src/org/palladiosimulator/simulizar/reliability/tests/ReliabilityTest.java b/tests/org.palladiosimulator.simulizar.reliability.tests/src/org/palladiosimulator/simulizar/reliability/tests/ReliabilityTest.java new file mode 100644 index 000000000..8dbebe7a6 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/src/org/palladiosimulator/simulizar/reliability/tests/ReliabilityTest.java @@ -0,0 +1,55 @@ +package org.palladiosimulator.simulizar.reliability.tests; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils.allMeasurementsOfMetric; +import static org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils.getMeasurementOfAt; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.seff.ExternalCallAction; +import org.palladiosimulator.simulizar.reliability.di.DaggerReliabilityExtensionComponent; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.Named; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.annotation.UseSimuLizarExtension; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class ReliabilityTest { + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.reliability.tests", basePath = "testmodels/simulizar148", modelFiles = { + "default.allocation", "default.usagemodel", "default.monitorrepository" }) + @UseSimuLizarExtension(DaggerReliabilityExtensionComponent.class) + @SimulationConfig(simulateReliability = true) + @RunSimuLizar + void testReliabilityExtension(@Named("ExternalCallActionFoo") ExternalCallAction fooCallAction, + @Named("ExternalCallActionBar") ExternalCallAction barCallAction, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var fooMeasurement = getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, fooCallAction); + assertTrue(fooMeasurement.isPresent()); + + var barMeasurement = getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, barCallAction); + assertTrue(barMeasurement.isPresent()); + + var fooCalls = allMeasurementsOfMetric(fooMeasurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC); + var barCalls = allMeasurementsOfMetric(barMeasurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC); + + assertThat(fooCalls, hasSize(greaterThan(100))); + assertThat(barCalls, hasSize(greaterThan(100))); + assertThat(barCalls.size() * 1.0 / fooCalls.size(), is(closeTo(0.5d, 0.1))); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.allocation b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.allocation new file mode 100644 index 000000000..70ec68972 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.allocation @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.measuringpoint b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.measuringpoint new file mode 100644 index 000000000..259abba92 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.measuringpoint @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.monitorrepository b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.monitorrepository new file mode 100644 index 000000000..93d353cad --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.monitorrepository @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.repository b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.repository new file mode 100644 index 000000000..7bae82505 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.repository @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.resourceenvironment b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.resourceenvironment new file mode 100644 index 000000000..d5283efad --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.resourceenvironment @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.system b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.system new file mode 100644 index 000000000..bd06cce53 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.system @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.usagemodel b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.usagemodel new file mode 100644 index 000000000..886ed5d95 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar148/default.usagemodel @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/.project b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/.project new file mode 100644 index 000000000..377c65fe6 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/.project @@ -0,0 +1,12 @@ + + + simulizar151 + + + + + + + org.eclipse.sirius.nature.modelingproject + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.measuringpoint b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.measuringpoint new file mode 100644 index 000000000..d1a69c074 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.measuringpoint @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.monitorrepository b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.monitorrepository new file mode 100644 index 000000000..837c3b3b8 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.monitorrepository @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.resourceenvironment b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.resourceenvironment new file mode 100644 index 000000000..3c9b45859 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/My.resourceenvironment @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.allocation b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.allocation new file mode 100644 index 000000000..38c81fd43 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.allocation @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.repository b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.repository new file mode 100644 index 000000000..09f5301a0 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.repository @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.system b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.system new file mode 100644 index 000000000..e855e7dc9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.system @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.usagemodel b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.usagemodel new file mode 100644 index 000000000..6caac8003 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/default.usagemodel @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/representations.aird b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/representations.aird new file mode 100644 index 000000000..3cfe62a04 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.reliability.tests/testmodels/simulizar151/representations.aird @@ -0,0 +1,954 @@ + + + + My.resourceenvironment + pathmap://PCM_MODELS/Palladio.resourcetype + default.allocation + default.system + default.repository + default.usagemodel + pathmap://PCM_MODELS/FailureTypes.repository + pathmap://PCM_MODELS/PrimitiveTypes.repository + My.measuringpoint + My.monitorrepository + pathmap://METRIC_SPEC_MODELS/commonMetrics.metricspec + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.classpath b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.classpath new file mode 100644 index 000000000..81fe078c2 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.project b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.project new file mode 100644 index 000000000..78ad151f9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.project @@ -0,0 +1,28 @@ + + + org.palladiosimulator.simulizar.slidingwindow.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..9154beff7 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/META-INF/MANIFEST.MF b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..d46dd62d5 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/META-INF/MANIFEST.MF @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Simulizar Sliding Window Tests +Bundle-SymbolicName: org.palladiosimulator.simulizar.slidingwindow.tests +Bundle-Version: 5.2.0.qualifier +Bundle-Activator: org.palladiosimulator.simulizar.slidingwindow.impl.tests.Activator +Require-Bundle: org.eclipse.core.runtime, + org.junit;bundle-version="4.11.0", + de.uka.ipd.sdq.simulation.abstractsimengine, + de.uka.ipd.sdq.simucomframework, + org.palladiosimulator.edp2, + de.uka.ipd.sdq.simucomframework.simucomstatus, + org.palladiosimulator.probeframework, + org.palladiosimulator.simulizar, + org.palladiosimulator.simulizar.slidingwindow, + org.palladiosimulator.experimentanalysis, + de.uka.ipd.sdq.scheduler;bundle-version="1.0.0", + org.palladiosimulator.experimentanalysis.tests, + org.jscience, + org.palladiosimulator.edp2.dao;bundle-version="1.0.0", + org.palladiosimulator.edp2.repository.local;bundle-version="1.0.0", + org.palladiosimulator.metricspec.resources;bundle-version="1.0.0", + org.palladiosimulator.recorderframework.edp2;bundle-version="2.0.2", + org.palladiosimulator.recorderframework;bundle-version="2.0.1", + org.palladiosimulator.simulizar.runtimemeasurement, + org.palladiosimulator.measurementframework +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Bundle-ActivationPolicy: lazy diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/build.properties b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/org.palladiosimulator.simulizar.slidingwindow.tests.launch b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/org.palladiosimulator.simulizar.slidingwindow.tests.launch new file mode 100644 index 000000000..11699d6f8 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/org.palladiosimulator.simulizar.slidingwindow.tests.launch @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/ArithmeticMeanAggregatorTest.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/ArithmeticMeanAggregatorTest.java new file mode 100644 index 000000000..194c84563 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/ArithmeticMeanAggregatorTest.java @@ -0,0 +1,29 @@ +package org.palladiosimulator.simulizar.slidingwindow.aggregators.tests; + +import javax.measure.Measure; +import javax.measure.quantity.Duration; +import javax.measure.unit.SI; + +import org.palladiosimulator.metricspec.NumericalBaseMetricDescription; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.ArithmeticMeanAggregator; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.StatisticalCharacterizationAggregator; + +public class ArithmeticMeanAggregatorTest extends SlidingWindowStatisticalCharacterizationAggregatorTest { + + @Override + protected StatisticalCharacterizationAggregator getStatisticalCharacterizationAggregator( + NumericalBaseMetricDescription expectedMetric) { + return new ArithmeticMeanAggregator(expectedMetric); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeFirstTest() { + return Measure.valueOf(452.025, SI.SECOND); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeSecondTest() { + return Measure.valueOf(362.72, SI.SECOND); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/GeometricMeanAggregatorTest.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/GeometricMeanAggregatorTest.java new file mode 100644 index 000000000..329105c6c --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/GeometricMeanAggregatorTest.java @@ -0,0 +1,29 @@ +package org.palladiosimulator.simulizar.slidingwindow.aggregators.tests; + +import javax.measure.Measure; +import javax.measure.quantity.Duration; +import javax.measure.unit.SI; + +import org.palladiosimulator.metricspec.NumericalBaseMetricDescription; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.GeometricMeanAggregator; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.StatisticalCharacterizationAggregator; + +public class GeometricMeanAggregatorTest extends SlidingWindowStatisticalCharacterizationAggregatorTest { + + @Override + protected StatisticalCharacterizationAggregator getStatisticalCharacterizationAggregator( + NumericalBaseMetricDescription expectedMetric) { + return new GeometricMeanAggregator(expectedMetric); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeFirstTest() { + return Measure.valueOf(7.0533234616974002588733413490183, SI.SECOND); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeSecondTest() { + return Measure.valueOf(6.7110052498303912116958243874521, SI.SECOND); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/HarmonicMeanAggregatorTest.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/HarmonicMeanAggregatorTest.java new file mode 100644 index 000000000..95cf73608 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/HarmonicMeanAggregatorTest.java @@ -0,0 +1,31 @@ +package org.palladiosimulator.simulizar.slidingwindow.aggregators.tests; + +import javax.measure.Measure; +import javax.measure.quantity.Duration; +import javax.measure.unit.SI; + +import org.palladiosimulator.metricspec.NumericalBaseMetricDescription; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.HarmonicMeanAggregator; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.StatisticalCharacterizationAggregator; + +public class HarmonicMeanAggregatorTest extends SlidingWindowStatisticalCharacterizationAggregatorTest { + + @Override + protected StatisticalCharacterizationAggregator getStatisticalCharacterizationAggregator( + NumericalBaseMetricDescription expectedMetric) { + return new HarmonicMeanAggregator(expectedMetric); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeFirstTest() { + double sumOfInverses = 1 / 0.1 + 1 / 5.5 + 1 / 2.5 + 1 / 1800; + return Measure.valueOf(4d / sumOfInverses, SI.SECOND); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeSecondTest() { + double sumOfInverses = 1 / 0.1 + 2 / 5.5 + 1 / 2.5 + 1 / 1800; + return Measure.valueOf(5 / sumOfInverses, SI.SECOND); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/MedianAggregatorTest.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/MedianAggregatorTest.java new file mode 100644 index 000000000..16c5c7f5a --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/MedianAggregatorTest.java @@ -0,0 +1,29 @@ +package org.palladiosimulator.simulizar.slidingwindow.aggregators.tests; + +import javax.measure.Measure; +import javax.measure.quantity.Duration; +import javax.measure.unit.SI; + +import org.palladiosimulator.metricspec.NumericalBaseMetricDescription; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.MedianAggregator; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.StatisticalCharacterizationAggregator; + +public class MedianAggregatorTest extends SlidingWindowStatisticalCharacterizationAggregatorTest { + + @Override + protected StatisticalCharacterizationAggregator getStatisticalCharacterizationAggregator( + NumericalBaseMetricDescription expectedMetric) { + return new MedianAggregator(expectedMetric); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeFirstTest() { + return Measure.valueOf(4d, SI.SECOND); + } + + @Override + protected Measure getExpectedAggregatedResponseTimeSecondTest() { + return Measure.valueOf(5.5, SI.SECOND); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/SlidingWindowStatisticalCharacterizationAggregatorTest.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/SlidingWindowStatisticalCharacterizationAggregatorTest.java new file mode 100644 index 000000000..91ee1d266 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/aggregators/tests/SlidingWindowStatisticalCharacterizationAggregatorTest.java @@ -0,0 +1,161 @@ +package org.palladiosimulator.simulizar.slidingwindow.aggregators.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.measure.Measure; +import javax.measure.quantity.Dimensionless; +import javax.measure.quantity.Duration; +import javax.measure.unit.NonSI; +import javax.measure.unit.SI; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.palladiosimulator.experimentanalysis.windowaggregators.tests.SlidingWindowAggregatorTest; +import org.palladiosimulator.measurementframework.MeasuringValue; +import org.palladiosimulator.measurementframework.TupleMeasurement; +import org.palladiosimulator.metricspec.MetricSetDescription; +import org.palladiosimulator.metricspec.NumericalBaseMetricDescription; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.monitorrepository.statisticalcharacterization.StatisticalCharacterizationAggregator; +import org.palladiosimulator.simulizar.slidingwindow.aggregators.SlidingWindowStatisticalCharacterizationAggregator; + +public abstract class SlidingWindowStatisticalCharacterizationAggregatorTest extends SlidingWindowAggregatorTest { + + private static final MetricSetDescription WINDOW_DATA_METRIC = MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE; + private static final NumericalBaseMetricDescription RESULT_METRIC = (NumericalBaseMetricDescription) MetricDescriptionConstants.RESPONSE_TIME_METRIC; + + private Measure almostZeroResponseTime; + private Measure secondsResponseTime; + private Measure milliSecondsResponseTime; + private Measure minsResponseTime; + + protected MeasuringValue exepectedAggregatedResponseTimeMeasuringValueFirstTest; + protected MeasuringValue exepectedAggregatedResponseTimeMeasuringValueSecondTest; + + // constant that denotes the maximum delta between double values for which both numbers are + // still considered equal + private static final double DELTA = Math.pow(10, -4); + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + this.aggregatorUnderTest = new SlidingWindowStatisticalCharacterizationAggregator(this.dummyRecorder, + getStatisticalCharacterizationAggregator(RESULT_METRIC)); + this.almostZeroResponseTime = Measure.valueOf(0.1d, SI.SECOND); + this.secondsResponseTime = Measure.valueOf(5.5d, SI.SECOND); + this.milliSecondsResponseTime = Measure.valueOf(2500d, SI.MILLI(SI.SECOND)); + this.minsResponseTime = Measure.valueOf(30d, NonSI.MINUTE); + + this.exepectedAggregatedResponseTimeMeasuringValueFirstTest = createResponseTimeTupleMeasurement( + getExpectedAggregatedResponseTimeFirstTest()); + this.exepectedAggregatedResponseTimeMeasuringValueSecondTest = createResponseTimeTupleMeasurement( + getExpectedAggregatedResponseTimeSecondTest()); + } + + protected abstract StatisticalCharacterizationAggregator getStatisticalCharacterizationAggregator( + NumericalBaseMetricDescription expectedMetric); + + /** + * Response times to aggregate: 0.1s, 5.5s, 2500ms, 30min + * + * @return + */ + protected abstract Measure getExpectedAggregatedResponseTimeFirstTest(); + + /** + * Response times to aggregate: 0.1s, 5.5s, 5.5s 2500ms, 30min + * + * @return + */ + protected abstract Measure getExpectedAggregatedResponseTimeSecondTest(); + + @Override + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + private MeasuringValue createResponseTimeTupleMeasurement(final Measure responseTime) { + + Measure pointInTimeMeasure = Measure + .valueOf(this.currentLowerBound.getValue() + this.windowLength.getValue(), SI.SECOND); + return new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, responseTime); + } + + private void addResponseTimeTupleMeasurements() { + // window position: [0-10] + + Measure pointInTimeMeasure = Measure.valueOf(0d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.almostZeroResponseTime)); + + pointInTimeMeasure = Measure.valueOf(3d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.milliSecondsResponseTime)); + + pointInTimeMeasure = Measure.valueOf(4d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.minsResponseTime)); + + pointInTimeMeasure = Measure.valueOf(9d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.secondsResponseTime)); + } + + private void addResponseTimeTupleMeasurementsOddNumber() { + // window position: [0-10] + + Measure pointInTimeMeasure = Measure.valueOf(0d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.almostZeroResponseTime)); + + pointInTimeMeasure = Measure.valueOf(3d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.milliSecondsResponseTime)); + + pointInTimeMeasure = Measure.valueOf(4d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.minsResponseTime)); + + pointInTimeMeasure = Measure.valueOf(5d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.secondsResponseTime)); + + pointInTimeMeasure = Measure.valueOf(8d, SI.SECOND); + this.data.addLast(new TupleMeasurement(WINDOW_DATA_METRIC, pointInTimeMeasure, this.secondsResponseTime)); + } + + private void assertLastRecordedMeasurementEquals(final MeasuringValue expected) { + MeasuringValue lastMeasurement = this.dummyRecorder.getLastMeasurement(); + assertNotNull(lastMeasurement); + assertMeasurementsEqual(expected, lastMeasurement); + } + + private static void assertMeasurementsEqual(final MeasuringValue expected, final MeasuringValue actual) { + Measure expectedResponseTime = expected.getMeasureForMetric(RESULT_METRIC); + Measure actualResponseTime = actual.getMeasureForMetric(RESULT_METRIC); + + assertEquals(expectedResponseTime.getValue(), actualResponseTime.getValue(), DELTA); + } + + @Test + public void testOnSlidingWindowFullEmptyData() { + this.aggregatorUnderTest.onSlidingWindowFull(this.data, this.currentLowerBound, this.windowLength); + assertLastRecordedMeasurementEquals(createResponseTimeTupleMeasurement(Measure.valueOf(0d, SI.SECOND))); + } + + @Test + public void testOnSlidingWindowFull() { + addResponseTimeTupleMeasurements(); + this.aggregatorUnderTest.onSlidingWindowFull(this.data, this.currentLowerBound, this.windowLength); + assertLastRecordedMeasurementEquals(this.exepectedAggregatedResponseTimeMeasuringValueFirstTest); + } + + @Test + public void testOnSlidingWindowFullOddNumber() { + addResponseTimeTupleMeasurementsOddNumber(); + this.aggregatorUnderTest.onSlidingWindowFull(this.data, this.currentLowerBound, this.windowLength); + assertLastRecordedMeasurementEquals(this.exepectedAggregatedResponseTimeMeasuringValueSecondTest); + } + + @Test + public final void testGetExpectedWindowDataMetric() { + assertEquals(RESULT_METRIC, this.aggregatorUnderTest.getExpectedWindowDataMetric()); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/impl/tests/Activator.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/impl/tests/Activator.java new file mode 100644 index 000000000..b6441a989 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/impl/tests/Activator.java @@ -0,0 +1,30 @@ +package org.palladiosimulator.simulizar.slidingwindow.impl.tests; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/impl/tests/SimulizarSlidingWindowTest.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/impl/tests/SimulizarSlidingWindowTest.java new file mode 100644 index 000000000..4b8b9bb5c --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/impl/tests/SimulizarSlidingWindowTest.java @@ -0,0 +1,144 @@ +package org.palladiosimulator.simulizar.slidingwindow.impl.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import javax.measure.Measure; +import javax.measure.quantity.Duration; +import javax.measure.unit.SI; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.palladiosimulator.experimentanalysis.tests.SlidingWindowTest; +import org.palladiosimulator.simulizar.slidingwindow.impl.SimulizarSlidingWindow; +import org.palladiosimulator.simulizar.slidingwindow.tests.utils.SimuComModelMock; + +import de.uka.ipd.sdq.scheduler.resources.active.IResourceTableManager; +import de.uka.ipd.sdq.scheduler.resources.active.ResourceTableManager; +import de.uka.ipd.sdq.simucomframework.model.SimuComModel; + +public class SimulizarSlidingWindowTest extends SlidingWindowTest { + + private SimuComModel model = null; + private IResourceTableManager resourceTableManager; + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + + this.resourceTableManager = new ResourceTableManager(); + this.model = SimuComModelMock.obtainMockModel(this.tempFolder, resourceTableManager); + this.slidingWindowUnderTest = new SimulizarSlidingWindow(windowLength, increment, windowMetricDescription, + dummyStrategy, this.model); + } + + @Override + @After + public void tearDown() throws Exception { + SimuComModelMock.releaseMockModel(); + this.model = null; + super.tearDown(); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorNoMetricDefined() { + new SimulizarSlidingWindow(windowLength, increment, null, dummyStrategy, this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorNoMoveOnStrategyDefined() { + new SimulizarSlidingWindow(windowLength, increment, windowMetricDescription, null, this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorNoWindowLengthDefined() { + new SimulizarSlidingWindow(null, increment, windowMetricDescription, dummyStrategy, this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorIllegalWindowLengthDefinedNegativeValue() { + new SimulizarSlidingWindow(Measure.valueOf(-10d, SI.SECOND), increment, windowMetricDescription, dummyStrategy, + this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorIllegalWindowLengthDefinedNaNValue() { + new SimulizarSlidingWindow(Measure.valueOf(Double.NaN, SI.SECOND), increment, measurementsMetricDescription, + dummyStrategy, this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorIllegalWindowLengthDefinedInfiniteValue() { + new SimulizarSlidingWindow(Measure.valueOf(Double.NEGATIVE_INFINITY, SI.SECOND), increment, + measurementsMetricDescription, dummyStrategy, this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorNoIncrementDefined() { + new SimulizarSlidingWindow(windowLength, null, measurementsMetricDescription, dummyStrategy, this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorIllegalIncrementDefined() { + new SimulizarSlidingWindow(windowLength, Measure.valueOf(-10d, SI.SECOND), measurementsMetricDescription, + dummyStrategy, this.model); + } + + @Test(expected = IllegalArgumentException.class) + public void testCtorNoModelDefined() { + new SimulizarSlidingWindow(windowLength, Measure.valueOf(10d, SI.SECOND), measurementsMetricDescription, + dummyStrategy, null); + } + + @Override + @Test + public void testGetCurrentUpperBound() { + super.testGetCurrentUpperBound(); + // sim time is Double.MAX_VALUE now according to mocked model + this.model.getSimulationControl().setMaxSimTime(5); // window is longer than simulation now + // hence, check if upper bound has been adjusted + Measure expected = Measure + .valueOf(this.model.getSimulationControl().getCurrentSimulationTime(), SI.SECOND); + assertEquals(expected, this.slidingWindowUnderTest.getCurrentUpperBound()); + } + + @Override + @Test + public void testGetEffectiveWindowLength() { + super.testGetEffectiveWindowLength(); + // sim time is Double.MAX_VALUE now according to mocked model + this.model.getSimulationControl().setMaxSimTime(5); // window is longer than simulation now + // thus, check if length has been adjusted + assertTrue(this.slidingWindowUnderTest.getEffectiveWindowLength().compareTo(this.windowLength) < 0); + assertEquals(this.model.getSimulationControl().getCurrentSimulationTime(), + this.slidingWindowUnderTest.getEffectiveWindowLength().getValue(), Double.MIN_NORMAL); + } + + @Override + @Test + public void testMoveOn() { + super.testMoveOn(); + // mock periodic window full/move on event controlled by model + ((SimuComModelMock) this.model).triggerMockWindowMoveOn((SimulizarSlidingWindow) this.slidingWindowUnderTest); + // assert that the window bounds have been adjusted (moved forward) correctly + Measure expectedNewUpperBound = Measure.valueOf( + this.currentLowerBound.getValue() + this.increment.getValue() + this.windowLength.getValue(), + SI.SECOND); + assertEquals(expectedNewUpperBound, this.slidingWindowUnderTest.getCurrentUpperBound()); + + // test with different units + SimulizarSlidingWindow window = new SimulizarSlidingWindow(Measure.valueOf(1d, SI.SECOND), + Measure.valueOf(500d, SI.MILLI(SI.SECOND)), measurementsMetricDescription, this.dummyStrategy, + this.model); + ((SimuComModelMock) this.model).triggerMockWindowMoveOn(window); + expectedNewUpperBound = Measure.valueOf(1.5d, SI.SECOND); + assertEquals(expectedNewUpperBound, window.getCurrentUpperBound()); + } +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/runtimemeasurement/tests/SlidingWindowRuntimeMeasurementsRecorderTest.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/runtimemeasurement/tests/SlidingWindowRuntimeMeasurementsRecorderTest.java new file mode 100644 index 000000000..f136ec9aa --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/runtimemeasurement/tests/SlidingWindowRuntimeMeasurementsRecorderTest.java @@ -0,0 +1,116 @@ +package org.palladiosimulator.simulizar.slidingwindow.runtimemeasurement.tests; + +import static org.junit.Assert.assertEquals; + +import javax.measure.Measure; +import javax.measure.quantity.Dimensionless; +import javax.measure.unit.NonSI; +import javax.measure.unit.SI; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint; +import org.palladiosimulator.edp2.models.measuringpoint.MeasuringpointFactory; +import org.palladiosimulator.measurementframework.BasicMeasurement; +import org.palladiosimulator.measurementframework.MeasuringValue; +import org.palladiosimulator.measurementframework.TupleMeasurement; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.monitorrepository.MeasurementSpecification; +import org.palladiosimulator.monitorrepository.Monitor; +import org.palladiosimulator.monitorrepository.MonitorRepositoryFactory; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurement; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurementFactory; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurementModel; +import org.palladiosimulator.simulizar.slidingwindow.runtimemeasurement.SlidingWindowRuntimeMeasurementsRecorder; + +public class SlidingWindowRuntimeMeasurementsRecorderTest { + + private RuntimeMeasurementModel rmModel; + private MeasuringPoint measuringPoint; + private Monitor monitor; + private MeasurementSpecification spec; + private MeasuringValue wrongMetricMeasurement; + private MeasuringValue correctMeasurement; + + private InternalSlidingWindowRuntimeMeasurementsRecorder recorderUnderTest; + + @Before + public void setUp() throws Exception { + this.rmModel = RuntimeMeasurementFactory.eINSTANCE.createRuntimeMeasurementModel(); + this.spec = MonitorRepositoryFactory.eINSTANCE.createMeasurementSpecification(); + this.measuringPoint = MeasuringpointFactory.eINSTANCE.createResourceURIMeasuringPoint(); + this.monitor = MonitorRepositoryFactory.eINSTANCE.createMonitor(); + this.monitor.setMeasuringPoint(this.measuringPoint); + this.spec.setMetricDescription(MetricDescriptionConstants.UTILIZATION_OF_ACTIVE_RESOURCE_TUPLE); + this.spec.setMonitor(this.monitor); + + Measure timeMeasure = Measure.valueOf(42.0, SI.SECOND); + Measure utilizationMeasure = Measure.valueOf(0.42, Dimensionless.UNIT); + this.wrongMetricMeasurement = new BasicMeasurement<>(Measure.valueOf(3.5d, NonSI.HOUR), + MetricDescriptionConstants.WAITING_TIME_METRIC); + this.correctMeasurement = new TupleMeasurement(MetricDescriptionConstants.UTILIZATION_OF_ACTIVE_RESOURCE_TUPLE, + timeMeasure, utilizationMeasure); + + this.recorderUnderTest = new InternalSlidingWindowRuntimeMeasurementsRecorder(this.rmModel, this.spec); + } + + @After + public void tearDown() throws Exception { + } + + @Test(expected = NullPointerException.class) + public void testCtorNullArgument() { + RuntimeMeasurementModel m = null; + new SlidingWindowRuntimeMeasurementsRecorder(m, this.spec); + } + + @Test(expected = NullPointerException.class) + public void testCtorNullArgument2() { + new SlidingWindowRuntimeMeasurementsRecorder(this.rmModel, null); + } + + @Test(expected = NullPointerException.class) + public void testNewMeasurementAvailableNull() { + this.recorderUnderTest.newMeasurementAvailable(null); + } + + @Test(expected = IllegalArgumentException.class) + public void testNewMeasurementAvailableWrongMetric() { + this.recorderUnderTest.newMeasurementAvailable(this.wrongMetricMeasurement); + } + + @Test + public void testNewMeasurementAvailableCompatibleMetric() { + this.recorderUnderTest.newMeasurementAvailable(this.correctMeasurement); + RuntimeMeasurement rmMeasurement = this.recorderUnderTest.getLastMeasurement(); + + assertEquals(0.42, rmMeasurement.getMeasuringValue(), Math.pow(10, -8)); + assertEquals(this.spec.getId(), rmMeasurement.getMeasurementSpecification().getId()); + } + + @Test + public void testNewMeasurementAvailableSubsumedMetric() { + // slightly change metric + this.spec.setMetricDescription(MetricDescriptionConstants.UTILIZATION_OF_ACTIVE_RESOURCE); + this.recorderUnderTest = new InternalSlidingWindowRuntimeMeasurementsRecorder(this.rmModel, this.spec); + + this.recorderUnderTest.newMeasurementAvailable(this.correctMeasurement); + RuntimeMeasurement rmMeasurement = this.recorderUnderTest.getLastMeasurement(); + + assertEquals(0.42, rmMeasurement.getMeasuringValue(), Math.pow(10, -8)); + assertEquals(this.spec.getId(), rmMeasurement.getMeasurementSpecification().getId()); + } + + private class InternalSlidingWindowRuntimeMeasurementsRecorder extends SlidingWindowRuntimeMeasurementsRecorder { + + public InternalSlidingWindowRuntimeMeasurementsRecorder(final RuntimeMeasurementModel rmModel, + final MeasurementSpecification measurementSpecification) { + super(rmModel, measurementSpecification); + } + + private RuntimeMeasurement getLastMeasurement() { + return this.getPRMMeasurement(); + } + } +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/tests/utils/SimEngineFactoryMock.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/tests/utils/SimEngineFactoryMock.java new file mode 100644 index 000000000..aed3a370e --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/tests/utils/SimEngineFactoryMock.java @@ -0,0 +1,95 @@ +package org.palladiosimulator.simulizar.slidingwindow.tests.utils; + +import java.util.Observer; + +import de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator; +import de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimProcessDelegator; +import de.uka.ipd.sdq.simulation.abstractsimengine.IEntity; +import de.uka.ipd.sdq.simulation.abstractsimengine.ISimEngineFactory; +import de.uka.ipd.sdq.simulation.abstractsimengine.ISimEvent; +import de.uka.ipd.sdq.simulation.abstractsimengine.ISimProcess; +import de.uka.ipd.sdq.simulation.abstractsimengine.ISimRunnable; +import de.uka.ipd.sdq.simulation.abstractsimengine.ISimulationControl; +import de.uka.ipd.sdq.simulation.abstractsimengine.ISimulationModel; +import de.uka.ipd.sdq.simulation.abstractsimengine.SimCondition; + +final class SimEngineFactoryMock implements ISimEngineFactory { + + @Override + public void setModel(ISimulationModel model) { + + } + + @Override + public ISimulationControl createSimulationControl() { + return new ISimulationControl() { + + private double simTime = Double.MAX_VALUE; + + @Override + public void stop() { + } + + @Override + public void start() { + } + + @Override + public void setMaxSimTime(long simTime) { + this.simTime = simTime; + } + + @Override + public boolean isRunning() { + //this mock is always running, whether or not it is has been started + return true; + } + + @Override + public double getCurrentSimulationTime() { + //always return the specified max simulation time here + return simTime; + } + + @Override + public void addTimeObserver(Observer observer) { + } + + @Override + public void addStopCondition(SimCondition maxMeasurementsStopCondition) { + } + }; + } + + @Override + public ISimProcess createSimProcess( + AbstractSimProcessDelegator myProcess, String name) { + return null; + } + + @Override + public ISimEvent createSimEvent( + ISimRunnable myEvent, String name) { + return new ISimEvent() { + + @Override + public void schedule(E entity, double delay) { + } + + @Override + public void removeEvent() { + } + + @Override + public double scheduledAtTime() { + return 0; + } + }; + } + + @Override + public IEntity createEntity(AbstractSimEntityDelegator e, String name) { + return null; + } + +} diff --git a/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/tests/utils/SimuComModelMock.java b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/tests/utils/SimuComModelMock.java new file mode 100644 index 000000000..1bfbe30d9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.slidingwindow.tests/src/org/palladiosimulator/simulizar/slidingwindow/tests/utils/SimuComModelMock.java @@ -0,0 +1,136 @@ +package org.palladiosimulator.simulizar.slidingwindow.tests.utils; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.junit.rules.TemporaryFolder; +import org.palladiosimulator.edp2.impl.RepositoryManager; +import org.palladiosimulator.edp2.models.Repository.Repository; +import org.palladiosimulator.edp2.repository.local.LocalDirectoryRepositoryHelper; +import org.palladiosimulator.experimentanalysis.SlidingWindow; +import org.palladiosimulator.probeframework.ProbeFrameworkContext; +import org.palladiosimulator.probeframework.calculator.ExtensibleCalculatorFactoryDelegatingFactory; +import org.palladiosimulator.simulizar.simulationevents.PeriodicallyTriggeredSimulationEntity; +import org.palladiosimulator.simulizar.slidingwindow.impl.SimulizarSlidingWindow; + +import de.uka.ipd.sdq.scheduler.resources.active.IResourceTableManager; +import de.uka.ipd.sdq.simucomframework.SimuComConfig; +import de.uka.ipd.sdq.simucomframework.model.SimuComModel; +import de.uka.ipd.sdq.simucomframework.simucomstatus.SimuComStatus; +import de.uka.ipd.sdq.simucomframework.simucomstatus.SimucomstatusFactory; +import de.uka.ipd.sdq.simulation.abstractsimengine.ISimEventFactory; + +public class SimuComModelMock extends SimuComModel { + + private static Repository repo = null; + private static String repoId = null; + + private static SimuComModelMock instance = null; + + private static void createRepository(TemporaryFolder repoFolder) throws IOException { + repo = LocalDirectoryRepositoryHelper.initializeLocalDirectoryRepository(repoFolder.newFolder("testRepo")); + repoId = repo.getId(); + RepositoryManager.addRepository(RepositoryManager.getCentralRepository(), repo); + } + + private static void deleteRepository() { + RepositoryManager.removeRepository(RepositoryManager.getCentralRepository(), repo); + repo = null; + repoId = null; + } + + private static Map createMockedConfiguration() { + + final Map configuration = new HashMap(); + configuration.put(SimuComConfig.SIMULATE_FAILURES, false); + configuration.put(SimuComConfig.SIMULATE_LINKING_RESOURCES, false); + configuration.put(SimuComConfig.VERBOSE_LOGGING, false); + configuration.put(SimuComConfig.VARIATION_ID, SimuComConfig.DEFAULT_VARIATION_NAME); + configuration.put(SimuComConfig.SIMULATOR_ID, "de.uka.ipd.sdq.codegen.simucontroller.simulizar"); + configuration.put(SimuComConfig.EXPERIMENT_RUN, SimuComConfig.DEFAULT_EXPERIMENT_RUN); + configuration.put(SimuComConfig.SIMULATION_TIME, SimuComConfig.DEFAULT_SIMULATION_TIME); + configuration.put(SimuComConfig.MAXIMUM_MEASUREMENT_COUNT, SimuComConfig.DEFAULT_MAXIMUM_MEASUREMENT_COUNT); + configuration.put(SimuComConfig.PERSISTENCE_RECORDER_NAME, "Experiment Data Persistency & Presentation (EDP2)"); + configuration.put(SimuComConfig.USE_FIXED_SEED, false); + configuration.put("EDP2RepositoryID", repoId); + + return configuration; + } + + private static SimuComStatus createSimuComStatus() { + return SimucomstatusFactory.eINSTANCE.createSimuComStatus(); + } + + public void triggerMockWindowMoveOn(final SimulizarSlidingWindow window) { + new MockWindowMoveOnTriggeredEvent(this.getSimEngineFactory(), window).triggerInternal(); + } + + public static SimuComModel obtainMockModel(TemporaryFolder repoFolder, IResourceTableManager resourceTableManager) throws IOException { + if (instance == null) { + createRepository(repoFolder); + instance = new SimuComModelMock(resourceTableManager); + } + return instance; + } + + public static void releaseMockModel() { + if (instance != null) { + deleteRepository(); + instance = null; + } + } + + private SimuComModelMock(IResourceTableManager resourceTableManager) { + super(new SimuComConfig(createMockedConfiguration(), false), createSimuComStatus(), new SimEngineFactoryMock(), + false, new ProbeFrameworkContext(new ExtensibleCalculatorFactoryDelegatingFactory()) + , resourceTableManager); + } + + private static class MockWindowMoveOnTriggeredEvent extends PeriodicallyTriggeredSimulationEntity { + private final SimulizarSlidingWindow window; + + private MockWindowMoveOnTriggeredEvent(final ISimEventFactory eventFactory, final SimulizarSlidingWindow window) { + super(eventFactory, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); + this.window = window; + } + + private Method obtainMoveOnMethod() { + Method moveOnMethod = null; + try { + moveOnMethod = SlidingWindow.class.getDeclaredMethod("moveOn", new Class[0]); + } catch (final NoSuchMethodException e) { + e.printStackTrace(); + } catch (final SecurityException e) { + e.printStackTrace(); + } + return moveOnMethod; + } + + private void invokeMoveOn() { + // dirty hack;) + final Method moveOnMethod = obtainMoveOnMethod(); + if (moveOnMethod != null) { + moveOnMethod.setAccessible(true); + try { + moveOnMethod.invoke(this.window, new Object[0]); + } catch (final IllegalAccessException e) { + e.printStackTrace(); + } catch (final IllegalArgumentException e) { + e.printStackTrace(); + } catch (final InvocationTargetException e) { + e.printStackTrace(); + } + } else { + throw new NoSuchMethodError("Method not found: moveOn() of class " + this.window.getClass().getName()); + } + } + + @Override + protected void triggerInternal() { + invokeMoveOn(); + } + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/.classpath b/tests/org.palladiosimulator.simulizar.tests/.classpath new file mode 100644 index 000000000..9099bea15 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/.enable_dagger_annotation_processing b/tests/org.palladiosimulator.simulizar.tests/.enable_dagger_annotation_processing new file mode 100644 index 000000000..e69de29bb diff --git a/tests/org.palladiosimulator.simulizar.tests/.gitignore b/tests/org.palladiosimulator.simulizar.tests/.gitignore new file mode 100644 index 000000000..e674f805b --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/.gitignore @@ -0,0 +1,2 @@ +/bin/ +*.html \ No newline at end of file diff --git a/tests/org.palladiosimulator.simulizar.tests/.project b/tests/org.palladiosimulator.simulizar.tests/.project new file mode 100644 index 000000000..04cf5fc68 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/.project @@ -0,0 +1,34 @@ + + + org.palladiosimulator.simulizar.tests + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/tests/org.palladiosimulator.simulizar.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.palladiosimulator.simulizar.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..6558ab78f --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/org.palladiosimulator.simulizar.tests/META-INF/MANIFEST.MF b/tests/org.palladiosimulator.simulizar.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..83aa02410 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/META-INF/MANIFEST.MF @@ -0,0 +1,41 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: SimuLizar Tests +Bundle-SymbolicName: org.palladiosimulator.simulizar.tests;singleton:=true +Bundle-Version: 5.2.0.qualifier +Bundle-Vendor: palladiosimulator.org +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Fragment-Host: org.palladiosimulator.simulizar +Require-Bundle: org.eclipse.xtext.xbase.lib, + org.eclipse.xtend.lib, + org.eclipse.xtend.lib.macro, + org.palladiosimulator.simulizar.reconfiguration.qvto;bundle-version="5.1.0", + org.palladiosimulator.edp2.repository.local;bundle-version="4.3.0", + org.palladiosimulator.pcm.resources;bundle-version="4.3.0", + de.uka.ipd.sdq.simulation.abstractsimengine.desmoj;bundle-version="4.3.0", + de.uka.ipd.sdq.errorhandling;bundle-version="4.3.0", + tools.mdsd.library.standalone.initialization;bundle-version="0.1.0", + de.desmoj;bundle-version="2.3.3", + tools.mdsd.junit5utils;bundle-version="0.1.0", + org.palladiosimulator.examples.package;bundle-version="4.3.0", + org.palladiosimulator.simulizar.test.commons;bundle-version="5.1.0", + org.palladiosimulator.simulizar.events, + org.palladiosimulator.simulizar.monitorrepository.feedthrough;bundle-version="5.1.0" +Import-Package: com.google.common.util.concurrent.internal;version="1.0.1", + net.bytebuddy.dynamic.loading;version="1.6.0", + org.hamcrest;version="2.2.0", + org.hamcrest.collection;version="2.2.0", + org.hamcrest.core;version="2.2.0", + org.junit.jupiter.api;version="5.4.2", + org.junit.jupiter.api.extension;version="5.4.2", + org.junit.jupiter.api.function;version="5.4.2", + org.junit.jupiter.api.io;version="5.4.2", + org.junit.jupiter.params;version="5.4.2", + org.junit.jupiter.params.provider;version="5.4.2", + org.junit.platform.commons;version="1.4.0", + org.junit.platform.commons.support;version="1.4.0", + org.mockito, + org.mockito.invocation, + org.mockito.junit.jupiter, + org.mockito.stubbing, + org.objenesis;version="2.6.0" diff --git a/tests/org.palladiosimulator.simulizar.tests/build.properties b/tests/org.palladiosimulator.simulizar.tests/build.properties new file mode 100644 index 000000000..c867a950d --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/build.properties @@ -0,0 +1,7 @@ +source.. = src/,\ + xtend-gen/,\ + src-gen/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + testmodels/ diff --git a/tests/org.palladiosimulator.simulizar.tests/org.palladiosimulator.simulizar.tests.launch b/tests/org.palladiosimulator.simulizar.tests/org.palladiosimulator.simulizar.tests.launch new file mode 100644 index 000000000..a4cda0730 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/org.palladiosimulator.simulizar.tests.launch @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/GenericExtensionComponentTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/GenericExtensionComponentTest.java new file mode 100644 index 000000000..89e7ba8f3 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/GenericExtensionComponentTest.java @@ -0,0 +1,160 @@ +package org.palladiosimulator.simulizar.di.extension; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; + +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.simulizar.modelobserver.IModelObserver; +import org.palladiosimulator.simulizar.runtimestate.RuntimeStateEntityObserver; + +import com.google.common.collect.ImmutableSet; + +class GenericExtensionComponentTest { + + @Test + void testComponentWithoutExtension() { + var underTest = new GenericExtensionComponent(new ExtensionComponent() { + }); + assertThat(underTest.getExtensions(IModelObserver.class).get(), is(empty())); + } + + @Test + void testSingleExtension() { + var observer = new IModelObserver() { + }; + + var underTest = new GenericExtensionComponent(new ExtensionComponent() { + @SuppressWarnings("unused") + public IModelObserver provideObserver() { + return observer; + } + }); + + assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer)); + } + + @Test + void testMultipleSingleExtension() { + var observer = new IModelObserver() { + }; + var observer2 = new IModelObserver() { + }; + var observer3 = new IModelObserver() { + }; + + var underTest = new GenericExtensionComponent(new ExtensionComponent() { + @SuppressWarnings("unused") + public IModelObserver provideObserver1() { + return observer; + } + + @SuppressWarnings("unused") + public IModelObserver provideObserver2() { + return observer2; + } + + @SuppressWarnings("unused") + public IModelObserver provideObserver3() { + return observer3; + } + }); + + assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer, observer2, observer3)); + } + + @Test + void testSetExtension() { + var observer = new IModelObserver() { + }; + var observer2 = new IModelObserver() { + }; + var observer3 = new IModelObserver() { + }; + + var underTest = new GenericExtensionComponent(new ExtensionComponent() { + @SuppressWarnings("unused") + public Set provideObservers() { + return ImmutableSet.of(observer, observer2, observer3); + } + }); + + assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer, observer2, observer3)); + } + + + @Test + void testCombineSingleAndSetExtension() { + var observer = new IModelObserver() { + }; + var observer2 = new IModelObserver() { + }; + var observer3 = new IModelObserver() { + }; + var observer4 = new IModelObserver() { + }; + var observer5 = new IModelObserver() { + }; + + var underTest = new GenericExtensionComponent(new ExtensionComponent() { + @SuppressWarnings("unused") + public Set provideObservers() { + return ImmutableSet.of(observer, observer2); + } + + @SuppressWarnings("unused") + public Set provideObservers2() { + return ImmutableSet.of(observer3); + } + + @SuppressWarnings("unused") + public IModelObserver provideObserver4() { + return observer4; + } + + @SuppressWarnings("unused") + public IModelObserver provideObserver5() { + return observer5; + } + }); + + assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer, observer2, observer3, observer4, observer5)); + } + + static class MergedExtensionType implements IModelObserver, RuntimeStateEntityObserver { + @Override + public void initialize() { + } + } + + @Test + void testExtentionWithTwoTypesAdheresToStaticTypeSignature() { + var mergedExtension = new MergedExtensionType(); + + var underTest = new GenericExtensionComponent(new ExtensionComponent() { + @SuppressWarnings("unused") + public MergedExtensionType provide() { + return mergedExtension; + } + }); + + assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(mergedExtension)); + assertThat(underTest.getExtensions(RuntimeStateEntityObserver.class).get(), containsInAnyOrder(mergedExtension)); + + underTest = new GenericExtensionComponent(new ExtensionComponent() { + @SuppressWarnings("unused") + public IModelObserver provide() { + return mergedExtension; + } + }); + + assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(mergedExtension)); + assertThat(underTest.getExtensions(RuntimeStateEntityObserver.class).get(), is(empty())); + + + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/TestExtensionComponentDepencencyResolution.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/TestExtensionComponentDepencencyResolution.java new file mode 100644 index 000000000..804c459f1 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/TestExtensionComponentDepencencyResolution.java @@ -0,0 +1,88 @@ +package org.palladiosimulator.simulizar.di.extension; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; +import static org.hamcrest.collection.IsIterableWithSize.iterableWithSize; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.palladiosimulator.simulizar.di.extension.sample.ComponentA; +import org.palladiosimulator.simulizar.di.extension.sample.ComponentB; +import org.palladiosimulator.simulizar.di.extension.sample.ComponentC; +import org.palladiosimulator.simulizar.di.extension.sample.DaggerComponentA; +import org.palladiosimulator.simulizar.di.extension.sample.DaggerComponentB; +import org.palladiosimulator.simulizar.di.extension.sample.DaggerComponentC; +import org.palladiosimulator.simulizar.di.extension.sample.ModuleA; + +import com.google.common.collect.ImmutableSet; + +import dagger.Component; + +class TestExtensionComponentDepencencyResolution { + + @Test + void testNoExtensionNoErrors() { + var underTest = new ExtensionComponentDependencyResolution(ImmutableSet.of(), ImmutableSet.of()); + assertThat(underTest.getExtensionComponents(), is(empty())); + } + + @Test + void testSingleComponentNoDependencies() throws Exception { + var underTest = new ExtensionComponentDependencyResolution(ImmutableSet.of(), + ImmutableSet.of(DaggerComponentA.factory())); + var result = underTest.getExtensionComponents(); + assertThat(result, containsInAnyOrder(instanceOf(ComponentA.class))); + } + + @Test + void testSimpleComponentDependencies() throws Exception { + var underTest = new ExtensionComponentDependencyResolution(ImmutableSet.of(), + ImmutableSet.of(DaggerComponentA.factory(), DaggerComponentB.factory())); + var result = underTest.getExtensionComponents(); + assertThat(result, containsInAnyOrder(instanceOf(ComponentA.class), instanceOf(ComponentB.class))); + } + + @Test + void testBootstrappedComponentDependencies() throws Exception { + var underTest = new ExtensionComponentDependencyResolution(ImmutableSet.of(DaggerComponentA.create()), + ImmutableSet.of(DaggerComponentB.factory(), DaggerComponentC.factory())); + var result = underTest.getExtensionComponents(); + assertThat(result, containsInAnyOrder(instanceOf(ComponentB.class), instanceOf(ComponentC.class))); + } + + @Test + void testMissingDependenciesDoNotCauseErrors() throws Exception { + var underTest = new ExtensionComponentDependencyResolution(ImmutableSet.of(), + ImmutableSet.of(DaggerComponentB.factory(), DaggerComponentC.factory())); + var result = underTest.getExtensionComponents(); + assertThat(result, is(iterableWithSize(0))); + + underTest = new ExtensionComponentDependencyResolution(ImmutableSet.of(), + ImmutableSet.of(DaggerComponentA.factory(), DaggerComponentC.factory())); + result = underTest.getExtensionComponents(); + assertThat(result, containsInAnyOrder(instanceOf(ComponentA.class))); + } + + // We need to introduce the dependency in a subclass, as otherwise dagger will detect the cycle during compile-time + @Component(dependencies = ComponentB.class, modules = ModuleA.class) + public static interface AWithDependencyToB extends ComponentA { + @Component.Factory + public static interface Factory extends ExtensionComponent.Factory { + AWithDependencyToB create(ComponentB b); + } + } + + @Test + void testCyclesAreDetected() throws Exception { + var underTest = new ExtensionComponentDependencyResolution(ImmutableSet.of(), + ImmutableSet.of(DaggerComponentB.factory(), DaggerTestExtensionComponentDepencencyResolution_AWithDependencyToB.factory())); + + Assertions.assertThrows(IllegalStateException.class, () -> { + underTest.getExtensionComponents(); + }); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/TestGenericComponentFactory.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/TestGenericComponentFactory.java new file mode 100644 index 000000000..88b0731e6 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/TestGenericComponentFactory.java @@ -0,0 +1,73 @@ +package org.palladiosimulator.simulizar.di.extension; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.isA; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; +import static org.junit.jupiter.api.Assertions.assertIterableEquals; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.simulizar.di.extension.sample.ComponentA; +import org.palladiosimulator.simulizar.di.extension.sample.ComponentB; +import org.palladiosimulator.simulizar.di.extension.sample.ComponentC; +import org.palladiosimulator.simulizar.di.extension.sample.DaggerComponentA; +import org.palladiosimulator.simulizar.di.extension.sample.DaggerComponentA2; +import org.palladiosimulator.simulizar.di.extension.sample.DaggerComponentB; +import org.palladiosimulator.simulizar.di.extension.sample.DaggerComponentC; + +import com.google.common.collect.ImmutableList; + +class TestGenericComponentFactory { + + @Test + void testNoDependencies() { + var factory = DaggerComponentA.factory(); + var underTest = new GenericComponentFactory(factory); + assertIterableEquals(underTest.getUnfullfilledRequirements(), ImmutableList.of()); + } + + @Test + void testDependenciesToOneComponent() { + var factory = DaggerComponentB.factory(); + var underTest = new GenericComponentFactory(factory); + assertIterableEquals(underTest.getUnfullfilledRequirements(), ImmutableList.of(ComponentA.class)); + var componentA = DaggerComponentA.factory().create(); + underTest.fulfillRequirement(() -> componentA); + assertIterableEquals(underTest.getUnfullfilledRequirements(), ImmutableList.of()); + var created = underTest.get(); + assertThat(created, isA(ComponentB.class)); + } + + @Test + void testMultipleDependencies() { + var factory = DaggerComponentC.factory(); + var underTest = new GenericComponentFactory(factory); + assertThat(underTest.getUnfullfilledRequirements(), containsInAnyOrder(ComponentA.class, ComponentB.class)); + var componentA = DaggerComponentA.factory().create(); + underTest.fulfillRequirement(() -> componentA); + assertIterableEquals(underTest.getUnfullfilledRequirements(), ImmutableList.of(ComponentB.class)); + underTest.fulfillRequirement(() -> DaggerComponentB.factory().create(componentA)); + assertIterableEquals(underTest.getUnfullfilledRequirements(), ImmutableList.of()); + var created = underTest.get(); + assertThat(created, isA(ComponentC.class)); + assertThat(created.name(), is("A")); + } + + @Test + void testDependencyToSuperComponent() { + var factory = DaggerComponentC.factory(); + var underTest = new GenericComponentFactory(factory); + assertThat(underTest.getUnfullfilledRequirements(), containsInAnyOrder(ComponentA.class, ComponentB.class)); + var componentA = DaggerComponentA2.factory().create(); + underTest.fulfillRequirement(() -> componentA); + assertIterableEquals(underTest.getUnfullfilledRequirements(), ImmutableList.of(ComponentB.class)); + underTest.fulfillRequirement(() -> DaggerComponentB.factory().create(componentA)); + assertIterableEquals(underTest.getUnfullfilledRequirements(), ImmutableList.of()); + var created = underTest.get(); + assertThat(created, isA(ComponentC.class)); + assertThat(created.name(), is("A2")); + } + + + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentA.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentA.java new file mode 100644 index 000000000..689edd5be --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentA.java @@ -0,0 +1,19 @@ +package org.palladiosimulator.simulizar.di.extension.sample; + +import javax.inject.Named; + +import org.palladiosimulator.simulizar.di.extension.ExtensionComponent; + +import dagger.Component; + +@Component(modules = ModuleA.class) +public interface ComponentA extends ExtensionComponent { + + @Named("name") String name(); + + @Component.Factory + public static interface Factory extends ExtensionComponent.Factory { + ComponentA create(); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentA2.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentA2.java new file mode 100644 index 000000000..cd5e4346a --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentA2.java @@ -0,0 +1,27 @@ +package org.palladiosimulator.simulizar.di.extension.sample; + +import javax.inject.Named; + +import org.palladiosimulator.simulizar.di.extension.ExtensionComponent; + +import dagger.Component; +import dagger.Provides; + +@Component(modules = ComponentA2.Module.class) +public interface ComponentA2 extends ComponentA { + + @Component.Factory + public static interface Factory extends ExtensionComponent.Factory { + ComponentA2 create(); + } + + @dagger.Module + public static interface Module { + @Named("name") + @Provides + static String provideName() { + return "A2"; + } + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentB.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentB.java new file mode 100644 index 000000000..9afa19ef3 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentB.java @@ -0,0 +1,15 @@ +package org.palladiosimulator.simulizar.di.extension.sample; + +import org.palladiosimulator.simulizar.di.extension.ExtensionComponent; + +import dagger.Component; + +@Component(dependencies = ComponentA.class) +public interface ComponentB extends ExtensionComponent{ + + @Component.Factory + public static interface Factory extends ExtensionComponent.Factory { + ComponentB create(ComponentA compA); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentC.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentC.java new file mode 100644 index 000000000..da677b715 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ComponentC.java @@ -0,0 +1,19 @@ +package org.palladiosimulator.simulizar.di.extension.sample; + +import javax.inject.Named; + +import org.palladiosimulator.simulizar.di.extension.ExtensionComponent; + +import dagger.Component; + +@Component(dependencies = { ComponentA.class, ComponentB.class} ) +public interface ComponentC extends ExtensionComponent { + + @Named("name") String name(); + + @Component.Factory + public static interface Factory extends ExtensionComponent.Factory { + ComponentC create(ComponentA a, ComponentB b); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ModuleA.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ModuleA.java new file mode 100644 index 000000000..c8e40b9b7 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/di/extension/sample/ModuleA.java @@ -0,0 +1,17 @@ +package org.palladiosimulator.simulizar.di.extension.sample; + +import javax.inject.Named; + +import dagger.Module; +import dagger.Provides; + +@Module +public interface ModuleA { + + @Named("name") + @Provides + static String provideName() { + return "A"; + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/DemandCalculatorTestBase.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/DemandCalculatorTestBase.java new file mode 100644 index 000000000..a1039948b --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/DemandCalculatorTestBase.java @@ -0,0 +1,98 @@ +package org.palladiosimulator.simulizar.interpreter.linking.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.function.Supplier; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.palladiosimulator.simulizar.interpreter.linking.ITransmissionPayloadDemandCalculator; + +import de.uka.ipd.sdq.probfunction.math.IRandomGenerator; +import de.uka.ipd.sdq.probfunction.math.impl.ProbabilityFunctionFactoryImpl; +import de.uka.ipd.sdq.simucomframework.variables.EvaluationProxy; +import de.uka.ipd.sdq.simucomframework.variables.cache.StoExCache; +import de.uka.ipd.sdq.simucomframework.variables.stackframe.SimulatedStackframe; +import tools.mdsd.junit5utils.extensions.PlatformStandaloneExtension; + +@ExtendWith(PlatformStandaloneExtension.class) +abstract class DemandCalculatorTestBase { + protected enum TestCases { + EMPTY(() -> new SimulatedStackframe<>()), + + STACKFRAME_WITH_SINGLE_ELEMENT_WITH_BYTESIZE_100(() -> { + var res = new SimulatedStackframe<>(); + res.addValue("some.variable.with.BYTESIZE", 100); + return res; + }), + + STACKFRAME_WITH_THREE_ELEMENTS_WITH_BYTESIZE_100_200_NONE(() -> { + var res = new SimulatedStackframe<>(); + res.addValue("some.variable.with.BYTESIZE", 100); + res.addValue("some.variable.with.another.BYTESIZE", new EvaluationProxy("200", res)); + res.addValue("some.value.without.bytesize.characterization", 300); + return res; + }), + + STACKFRAME_WITH_THREE_ELEMENTS_WITH_INNER_BYTESIZES(() -> { + var res = new SimulatedStackframe<>(); + res.addValue("some.variable.with.BYTESIZE", 100); + res.addValue("some.variable.with.another.INNER.BYTESIZE", 100); + res.addValue("some.value.without.bytesize.characterization", 100); + res.addValue("some.value.without.bytesize.characterization.BYTESIZE", 100); + return res; + }), + + STACKFRAME_WITH_THREE_ELEMENTS_WITH_INNER_BYTESIZES_WITH_STREAM(() -> { + var res = new SimulatedStackframe<>(); + res.addValue("some.variable.with.BYTESIZE", 100); + res.addValue("some.variable.with.another.INNER.BYTESIZE", 100); + res.addValue("some.value.without.bytesize.characterization", 100); + res.addValue("some.value.without.bytesize.characterization.BYTESIZE", 100); + res.addValue("stream.BYTESIZE", 100); + return res; + }); + + + private SimulatedStackframe stackFrame; + + private TestCases(Supplier> testScenarioProvider) { + stackFrame = testScenarioProvider.get(); + } + } + + protected abstract double getExpectedResult(TestCases testCase); + + protected abstract ITransmissionPayloadDemandCalculator, Double> createCalculatorUnderTest(); + + @BeforeAll + static void initStoExCache() { + + var probFunctionFactory = ProbabilityFunctionFactoryImpl.getInstance(); + probFunctionFactory.setRandomGenerator(new IRandomGenerator() { + + @Override + public double random() { + return Math.random(); + } + + @Override + public void dispose() { + } + }); + StoExCache.initialiseStoExCache(probFunctionFactory); + } + + @ParameterizedTest + @EnumSource(TestCases.class) + protected void testCase(TestCases testCase) { + var calculator = createCalculatorUnderTest(); + validate(testCase, getExpectedResult(testCase), () -> calculator.calculatePayloadDemand(testCase.stackFrame)); + } + + protected void validate(TestCases testCase, Double expected, Supplier result) { + assertEquals(expected, result.get()); + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/MiddlewareCompletionAwareCalculatorTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/MiddlewareCompletionAwareCalculatorTest.java new file mode 100644 index 000000000..71ccedb39 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/MiddlewareCompletionAwareCalculatorTest.java @@ -0,0 +1,59 @@ +package org.palladiosimulator.simulizar.interpreter.linking.impl; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.Arrays; +import java.util.function.Supplier; + +import org.palladiosimulator.simulizar.interpreter.linking.ITransmissionPayloadDemandCalculator; + +import de.uka.ipd.sdq.simucomframework.variables.exceptions.StochasticExpressionEvaluationFailedException; +import de.uka.ipd.sdq.simucomframework.variables.stackframe.SimulatedStackframe; + +public class MiddlewareCompletionAwareCalculatorTest extends DemandCalculatorTestBase { + + @Override + protected void validate(TestCases testCase, Double expected, Supplier result) { + // In the following cases there is no "stream.BYTESIZE" characteristic present + // as this points to an error in the previous completion transformation, we expect + // an exception to be thrown here. + if (Arrays + .asList(TestCases.EMPTY, + TestCases.STACKFRAME_WITH_SINGLE_ELEMENT_WITH_BYTESIZE_100, + TestCases.STACKFRAME_WITH_THREE_ELEMENTS_WITH_BYTESIZE_100_200_NONE, + TestCases.STACKFRAME_WITH_THREE_ELEMENTS_WITH_INNER_BYTESIZES) + .contains(testCase)) { + assertThrows(StochasticExpressionEvaluationFailedException.class, () -> result.get()); + } else { + super.validate(testCase, expected, result); + } + } + + @Override + protected double getExpectedResult(TestCases testCase) { + /* + * This switch case has intentionally no default case. Only then will Eclipse suggest + * missing cases. + */ + switch (testCase) { + case EMPTY: + return 0.0; + case STACKFRAME_WITH_SINGLE_ELEMENT_WITH_BYTESIZE_100: + return 0.0; + case STACKFRAME_WITH_THREE_ELEMENTS_WITH_BYTESIZE_100_200_NONE: + return 0.0; + case STACKFRAME_WITH_THREE_ELEMENTS_WITH_INNER_BYTESIZES: + return 0.0; + case STACKFRAME_WITH_THREE_ELEMENTS_WITH_INNER_BYTESIZES_WITH_STREAM: + return 100.0; + } + throw new UnsupportedOperationException( + "This case has been added without adding the expected result to " + getClass().getName()); + } + + @Override + protected ITransmissionPayloadDemandCalculator, Double> createCalculatorUnderTest() { + return new MiddlewareCompletionAwareDemandCalculator(); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/NoDemandCalculatorTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/NoDemandCalculatorTest.java new file mode 100644 index 000000000..e97a94f6f --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/NoDemandCalculatorTest.java @@ -0,0 +1,18 @@ +package org.palladiosimulator.simulizar.interpreter.linking.impl; + +import org.palladiosimulator.simulizar.interpreter.linking.ITransmissionPayloadDemandCalculator; + +import de.uka.ipd.sdq.simucomframework.variables.stackframe.SimulatedStackframe; + +class NoDemandCalculatorTest extends DemandCalculatorTestBase { + @Override + protected ITransmissionPayloadDemandCalculator, Double> createCalculatorUnderTest() { + return new NoDemandCalculator(); + } + + @Override + protected double getExpectedResult(TestCases testCase) { + return 0.0; + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/ResourceEnvironmentObservingRouterTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/ResourceEnvironmentObservingRouterTest.java new file mode 100644 index 000000000..900a385d2 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/ResourceEnvironmentObservingRouterTest.java @@ -0,0 +1,143 @@ +package org.palladiosimulator.simulizar.interpreter.linking.impl; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition; +import org.palladiosimulator.pcm.resourceenvironment.LinkingResource; +import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; +import org.palladiosimulator.simulizar.entity.EntityReference; +import org.palladiosimulator.simulizar.entity.EntityReferenceFactory; +import org.palladiosimulator.simulizar.entity.SimuLizarEntityReferenceFactories; +import org.palladiosimulator.simulizar.interpreter.linking.ILinkingResourceRouter; +import org.palladiosimulator.simulizar.test.commons.annotation.MockSimulation; +import org.palladiosimulator.simulizar.test.commons.annotation.PCMInstanceFromSupplier; +import org.palladiosimulator.simulizar.test.commons.models.ResourceEnvironmentTestModels; + +import com.google.common.collect.Lists; + +@ExtendWith(MockitoExtension.class) +public class ResourceEnvironmentObservingRouterTest { + ILinkingResourceRouter, EntityReference> routerUnderTest; + EntityReferenceFactory rcRefFactory; + EntityReferenceFactory linkRefFactory; + + private void setUpRouter(PCMResourceSetPartition partition) { + linkRefFactory = new SimuLizarEntityReferenceFactories.LinkingResource(); + rcRefFactory = new SimuLizarEntityReferenceFactories.ResourceContainer(); + routerUnderTest = new ResourceEnvironmentObservingLegacyRouter(partition, linkRefFactory); + } + + /** + * Test, if model observer registers its adapter properly. + */ + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + final void testRegisterAdapter(PCMResourceSetPartition partition) { + var adapterCount = partition.getResourceEnvironment() + .eAdapters() + .size(); + + setUpRouter(partition); + + assertThat(partition.getResourceEnvironment() + .eAdapters(), hasSize(adapterCount + 1)); + } + + /** + * Test, if model observer registers its adapter properly. + */ + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + final void testSimpleLink(PCMResourceSetPartition partition) { + setUpRouter(partition); + + var res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CB")); + assertTrue(res.isPresent()); + var links = Lists.newArrayList(res.get()); + assertEquals(1, links.size()); + assertEquals("LC1", links.get(0).getId()); + } + + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + final void testLinkRemovalAndAdd(PCMResourceSetPartition partition) { + setUpRouter(partition); + + var res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CB")); + assertTrue(res.isPresent()); + var links = Lists.newArrayList(res.get()); + assertEquals(1, links.size()); + assertEquals("LC1", links.get(0).getId()); + + var link = partition.getResourceEnvironment().getLinkingResources__ResourceEnvironment().get(0); + partition.getResourceEnvironment().getLinkingResources__ResourceEnvironment().clear(); + res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CB")); + assertFalse(res.isPresent()); + + partition.getResourceEnvironment().getLinkingResources__ResourceEnvironment().add(link); + res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CB")); + assertTrue(res.isPresent()); + links = Lists.newArrayList(res.get()); + assertEquals(1, links.size()); + assertEquals("LC1", links.get(0).getId()); + } + + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithThreeContainersAndTwoLinks.class) + final void testNoTransitiveConnection(PCMResourceSetPartition partition) { + setUpRouter(partition); + + var res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CB")); + assertTrue(res.isPresent()); + var links = Lists.newArrayList(res.get()); + assertEquals(1, links.size()); + assertEquals("LC1", links.get(0).getId()); + + res = routerUnderTest.findRoute(rcRefFactory.create("CB"), rcRefFactory.create("CC")); + assertTrue(res.isPresent()); + links = Lists.newArrayList(res.get()); + assertEquals(1, links.size()); + assertEquals("LC2", links.get(0).getId()); + + res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CC")); + assertFalse(res.isPresent()); + } + + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithThreeContainersAndTwoLinks.class) + final void testAttachContainerToLinkingResource(PCMResourceSetPartition partition) { + setUpRouter(partition); + + var res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CC")); + assertFalse(res.isPresent()); + + linkRefFactory.create("LC1").getModelElement(partition).getConnectedResourceContainers_LinkingResource() + .add(rcRefFactory.create("CC").getModelElement(partition)); + + res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CC")); + assertTrue(res.isPresent()); + var links = Lists.newArrayList(res.get()); + assertEquals(1, links.size()); + assertEquals("LC1", links.get(0).getId()); + } + + + + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + final void testSameHost(PCMResourceSetPartition partition) { + setUpRouter(partition); + + var res = routerUnderTest.findRoute(rcRefFactory.create("CA"), rcRefFactory.create("CA")); + assertTrue(res.isPresent()); + var links = Lists.newArrayList(res.get()); + assertEquals(0, links.size()); + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/StackFrameBytesizeAccumulatingCalculatorTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/StackFrameBytesizeAccumulatingCalculatorTest.java new file mode 100644 index 000000000..828de8e80 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/interpreter/linking/impl/StackFrameBytesizeAccumulatingCalculatorTest.java @@ -0,0 +1,32 @@ +package org.palladiosimulator.simulizar.interpreter.linking.impl; + +import org.palladiosimulator.simulizar.interpreter.linking.ITransmissionPayloadDemandCalculator; + +import de.uka.ipd.sdq.simucomframework.variables.stackframe.SimulatedStackframe; + +public class StackFrameBytesizeAccumulatingCalculatorTest extends DemandCalculatorTestBase { + + @Override + protected double getExpectedResult(TestCases testCase) { + /* This switch case has intentionally no default case. Only then will Eclipse suggest missing cases. */ + switch(testCase) { + case EMPTY: + return 0.0; + case STACKFRAME_WITH_SINGLE_ELEMENT_WITH_BYTESIZE_100: + return 100.0; + case STACKFRAME_WITH_THREE_ELEMENTS_WITH_BYTESIZE_100_200_NONE: + return 300.0; + case STACKFRAME_WITH_THREE_ELEMENTS_WITH_INNER_BYTESIZES: + return 300.0; + case STACKFRAME_WITH_THREE_ELEMENTS_WITH_INNER_BYTESIZES_WITH_STREAM: + return 400.0; + } + throw new UnsupportedOperationException("This case has been added without adding the expected result to " + getClass().getName()); + } + + @Override + protected ITransmissionPayloadDemandCalculator, Double> createCalculatorUnderTest() { + return new StackFrameBytesizeAccumulatingDemandCalculator(); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/launcher/jobs/ModelCompletionOrderingTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/launcher/jobs/ModelCompletionOrderingTest.java new file mode 100644 index 000000000..93d5280ad --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/launcher/jobs/ModelCompletionOrderingTest.java @@ -0,0 +1,170 @@ +package org.palladiosimulator.simulizar.launcher.jobs; + +import static org.junit.jupiter.api.Assertions.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; + +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.junit.jupiter.api.Test; + +import com.google.common.collect.ImmutableSet; + +import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; +import de.uka.ipd.sdq.workflow.jobs.IBlackboardInteractingJob; +import de.uka.ipd.sdq.workflow.jobs.IJob; +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; + +class ModelCompletionOrderingTest { + public static class MockJob implements IBlackboardInteractingJob { + @Override + public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + } + + @Override + public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + } + + @Override + public String getName() { + return "MockJob"; + } + + @Override + public void setBlackboard(MDSDBlackboard blackboard) { + } + } + + public static class MockJobWithOrdering extends MockJob implements Comparable { + @Override + public int compareTo(IJob o) { + return 0; + } + } + + public static class MockContributer implements ModelCompletionJobContributor { + private IBlackboardInteractingJob job; + + public MockContributer(IBlackboardInteractingJob job) { + this.job = job; + } + + @Override + public void contribute(Facade delegate) { + delegate.contribute(job); + } + + } + + @Test + void testNoOrdering() throws JobFailedException, UserCanceledException { + var mockJob1Executed = new AtomicBoolean(false); + var mockJob2Executed = new AtomicBoolean(false); + + var mockJob1 = new MockJob() { + public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + mockJob1Executed.set(true); + }; + }; + + var mockJob2 = new MockJob() { + public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + mockJob2Executed.set(true); + }; + }; + + var jobUnderTest = new ModelCompletionsJob(() -> ImmutableSet.of(new MockContributer(mockJob1), new MockContributer(mockJob2))); + jobUnderTest.setBlackboard(new MDSDBlackboard()); + jobUnderTest.execute(new NullProgressMonitor()); + + assertTrue(mockJob1Executed.get()); + assertTrue(mockJob2Executed.get()); + } + + @Test + void testSimpleOrdering() throws JobFailedException, UserCanceledException { + var executionOrder = new ConcurrentLinkedDeque(); + + var mockJob1 = new MockJob() { + public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + executionOrder.add(1); + }; + }; + + var mockJob2 = new MockJobWithOrdering() { + public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + executionOrder.add(2); + }; + @Override + public int compareTo(IJob o) { + if (o == mockJob1) return -1; + return super.compareTo(o); + } + }; + + var jobUnderTest = new ModelCompletionsJob(() -> ImmutableSet.of(new MockContributer(mockJob1), new MockContributer(mockJob2))); + jobUnderTest.setBlackboard(new MDSDBlackboard()); + jobUnderTest.execute(new NullProgressMonitor()); + assertThat(executionOrder, contains(2, 1)); + } + + @Test + void testBothJobsProvideOrdering() throws JobFailedException, UserCanceledException { + var executionOrder = new ConcurrentLinkedDeque(); + + var mockJob1 = new MockJobWithOrdering() { + public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + executionOrder.add(1); + }; + @Override + public int compareTo(IJob o) { + return 1; + } + }; + + var mockJob2 = new MockJobWithOrdering() { + public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + executionOrder.add(2); + }; + @Override + public int compareTo(IJob o) { + if (o == mockJob1) return -1; + return super.compareTo(o); + } + }; + + var jobUnderTest = new ModelCompletionsJob(() -> ImmutableSet.of(new MockContributer(mockJob1), new MockContributer(mockJob2))); + jobUnderTest.setBlackboard(new MDSDBlackboard()); + jobUnderTest.execute(new NullProgressMonitor()); + assertThat(executionOrder, contains(2, 1)); + } + + @Test + void testJobsProvideConflictingOrder() throws JobFailedException, UserCanceledException { + var mockJob1 = new MockJobWithOrdering() { + @Override + public int compareTo(IJob o) { + return -1; + } + }; + + var mockJob2 = new MockJobWithOrdering() { + @Override + public int compareTo(IJob o) { + if (o == mockJob1) return -1; + return super.compareTo(o); + } + }; + + var jobUnderTest = new ModelCompletionsJob(() -> ImmutableSet.of(new MockContributer(mockJob1), new MockContributer(mockJob2))); + jobUnderTest.setBlackboard(new MDSDBlackboard()); + assertThrows(IllegalStateException.class, () -> jobUnderTest.execute(new NullProgressMonitor())); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/modelobserver/tests/AllocationLookupSyncerTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/modelobserver/tests/AllocationLookupSyncerTest.java new file mode 100644 index 000000000..c9e183061 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/modelobserver/tests/AllocationLookupSyncerTest.java @@ -0,0 +1,110 @@ +package org.palladiosimulator.simulizar.modelobserver.tests; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition; +import org.palladiosimulator.pcm.allocation.Allocation; +import org.palladiosimulator.pcm.allocation.AllocationFactory; +import org.palladiosimulator.pcm.core.composition.CompositionFactory; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; +import org.palladiosimulator.pcm.system.System; +import org.palladiosimulator.simulizar.entity.EntityReferenceFactory; +import org.palladiosimulator.simulizar.entity.SimuLizarEntityReferenceFactories; +import org.palladiosimulator.simulizar.modelobserver.AllocationLookupSyncer; +import org.palladiosimulator.simulizar.runtimestate.AssemblyAllocationManager; +import org.palladiosimulator.simulizar.runtimestate.FQComponentID; +import org.palladiosimulator.simulizar.test.commons.annotation.PCMInstanceFromSupplier; +import org.palladiosimulator.simulizar.test.commons.models.AllocationLookupSyncerTestModels; + +@ExtendWith(MockitoExtension.class) +class AllocationLookupSyncerTest { + EntityReferenceFactory rcf = new SimuLizarEntityReferenceFactories.ResourceContainer(); + + @PCMInstanceFromSupplier(AllocationLookupSyncerTestModels.TrivialAllocation.class) + @Test + void test(PCMResourceSetPartition partition, BasicComponent comp, + System system, Allocation allocation, ResourceContainer rc, @Mock AssemblyAllocationManager manager) { + var syncerUnderTest = new AllocationLookupSyncer(rcf, partition, manager); + + syncerUnderTest.initialize(); + verify(manager).allocateAssembly(AllocationLookupSyncerTestModels.TrivialAllocation.AssemblyCtxId, + rcf.create(AllocationLookupSyncerTestModels.TrivialAllocation.RCId)); + + var ctx2 = CompositionFactory.eINSTANCE.createAssemblyContext(); + ctx2.setEncapsulatedComponent__AssemblyContext(comp); + system.getAssemblyContexts__ComposedStructure().add(ctx2); + + var alloc2 = AllocationFactory.eINSTANCE.createAllocationContext(); + alloc2.setAssemblyContext_AllocationContext(ctx2); + alloc2.setResourceContainer_AllocationContext(rc); + + allocation.getAllocationContexts_Allocation().add(alloc2); + + verify(manager).allocateAssembly(ctx2.getId(), rcf.create(AllocationLookupSyncerTestModels.TrivialAllocation.RCId)); + + } + + @PCMInstanceFromSupplier(AllocationLookupSyncerTestModels.CompositeComponentAllocation.class) + @Test + void testCompositeAllocation(PCMResourceSetPartition partition, @Mock AssemblyAllocationManager manager) { + var syncerUnderTest = new AllocationLookupSyncer(rcf, partition, manager); + var rcref = rcf.create(AllocationLookupSyncerTestModels.CompositeComponentAllocation.RCId); + + syncerUnderTest.initialize(); + verify(manager).allocateAssembly(AllocationLookupSyncerTestModels.CompositeComponentAllocation.AssemblyCtx1Id, + rcref); + verify(manager).allocateAssembly(Arrays + .asList(AllocationLookupSyncerTestModels.CompositeComponentAllocation.AssemblyCtx1Id, + AllocationLookupSyncerTestModels.CompositeComponentAllocation.NestedAssemblyCtxId) + .stream() + .collect(Collectors.joining(FQComponentID.SEPARATOR)), rcref); + verify(manager).allocateAssembly(AllocationLookupSyncerTestModels.CompositeComponentAllocation.AssemblyCtx2Id, + rcref); + verify(manager).allocateAssembly(Arrays + .asList(AllocationLookupSyncerTestModels.CompositeComponentAllocation.AssemblyCtx2Id, + AllocationLookupSyncerTestModels.CompositeComponentAllocation.NestedAssemblyCtxId) + .stream() + .collect(Collectors.joining(FQComponentID.SEPARATOR)), rcref); + verifyNoMoreInteractions(manager); + } + + @PCMInstanceFromSupplier(AllocationLookupSyncerTestModels.SubsystemWhiteboxAllocation.class) + @Test + void testSubsystemWhiteboxAllocation(PCMResourceSetPartition partition, @Mock AssemblyAllocationManager manager) { + var syncerUnderTest = new AllocationLookupSyncer(rcf, partition, manager); + var rcref = rcf.create(AllocationLookupSyncerTestModels.CompositeComponentAllocation.RCId); + + syncerUnderTest.initialize(); + verify(manager).allocateAssembly(Arrays + .asList(AllocationLookupSyncerTestModels.SubsystemWhiteboxAllocation.AssemblyCtx1Id, + AllocationLookupSyncerTestModels.SubsystemWhiteboxAllocation.NestedAssemblyCtxId) + .stream() + .collect(Collectors.joining(FQComponentID.SEPARATOR)), rcref); + verifyNoMoreInteractions(manager); + } + + @PCMInstanceFromSupplier(AllocationLookupSyncerTestModels.SubsystemWhiteboxAllocation.class) + @Test + void testExceptionOnAmbiguousSubsystemWhiteboxAllocation(PCMResourceSetPartition partition, @Mock AssemblyAllocationManager manager, + System system, ResourceContainer rc) { + var syncerUnderTest = new AllocationLookupSyncer(rcf, partition, manager); + + var nesting1 = system.getAssemblyContexts__ComposedStructure().get(0); + var ctx2 = CompositionFactory.eINSTANCE.createAssemblyContext(); + ctx2.setEncapsulatedComponent__AssemblyContext(nesting1.getEncapsulatedComponent__AssemblyContext()); + system.getAssemblyContexts__ComposedStructure().add(ctx2); + + assertThrows(IllegalStateException.class, () -> syncerUnderTest.initialize()); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/modelobserver/tests/ResourceEnvironmentSyncerTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/modelobserver/tests/ResourceEnvironmentSyncerTest.java new file mode 100644 index 000000000..0a9fc9e8a --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/modelobserver/tests/ResourceEnvironmentSyncerTest.java @@ -0,0 +1,217 @@ +package org.palladiosimulator.simulizar.modelobserver.tests; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.mockito.Mockito.verify; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition; +import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification; +import org.palladiosimulator.pcm.resourceenvironment.LinkingResource; +import org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification; +import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; +import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; +import org.palladiosimulator.simulizar.legacy.CalculatorFactoryFacade; +import org.palladiosimulator.simulizar.modelobserver.ResourceEnvironmentSyncer; +import org.palladiosimulator.simulizar.test.commons.annotation.Identified; +import org.palladiosimulator.simulizar.test.commons.annotation.MockSimulation; +import org.palladiosimulator.simulizar.test.commons.annotation.Named; +import org.palladiosimulator.simulizar.test.commons.annotation.PCMInstanceFromSupplier; +import org.palladiosimulator.simulizar.test.commons.models.ResourceEnvironmentTestModels; +import org.palladiosimulator.simulizar.test.commons.models.TestModelBase; + +import de.uka.ipd.sdq.simucomframework.ResourceRegistry; +import de.uka.ipd.sdq.simucomframework.resources.ScheduledResource; +import de.uka.ipd.sdq.simucomframework.resources.SimulatedLinkingResource; +import de.uka.ipd.sdq.simucomframework.resources.SimulatedLinkingResourceContainer; +import de.uka.ipd.sdq.simucomframework.resources.SimulatedResourceContainer; +import de.uka.ipd.sdq.stoex.StoexPackage; + +@ExtendWith(MockitoExtension.class) +class ResourceEnvironmentSyncerTest { + ResourceEnvironmentSyncer syncerUnderTest; + + private void setUpSyncer(PCMResourceSetPartition partition) { + setUpSyncer(partition, Mockito.mock(ResourceRegistry.class)); + } + + private void setUpSyncer(PCMResourceSetPartition partition, + ResourceRegistry resourceRegistry) { + syncerUnderTest = new ResourceEnvironmentSyncer(partition, + resourceRegistry, Mockito.mock(CalculatorFactoryFacade.class)); + syncerUnderTest.initialize(); + } + + /** + * Test, if model observer registers its adapter properly. + */ + @Test + @PCMInstanceFromSupplier(TestModelBase.Empty.class) + @MockSimulation + final void testRegisterAdapter(PCMResourceSetPartition partition) { + var adapterCount = partition.getResourceEnvironment() + .eAdapters() + .size(); + + setUpSyncer(partition); + + assertThat(partition.getResourceEnvironment() + .eAdapters(), hasSize(adapterCount + 1)); + } + + /** + * Test, if adding a single resource container to an otherwise empty resource environment + * triggers the expected actions by the observer. + */ + @Test + @PCMInstanceFromSupplier(TestModelBase.Empty.class) + @MockSimulation + final void testAddResourceContainer(PCMResourceSetPartition partition, + ResourceRegistry resourceRegistry) { + setUpSyncer(partition, resourceRegistry); + var container = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); + partition.getResourceEnvironment() + .getResourceContainer_ResourceEnvironment() + .add(container); + verify(resourceRegistry).createResourceContainer(container.getId()); + verify(resourceRegistry, Mockito.never()).getResourceContainer(container.getId()); + } + + /** + * Test, if adding a single linking resource to an otherwise empty resource environment triggers + * the expected actions by the observer. + */ + @Test + @PCMInstanceFromSupplier(TestModelBase.Empty.class) + @MockSimulation + final void testAddLinkingResource(PCMResourceSetPartition partition, + ResourceRegistry resourceRegistry) { + setUpSyncer(partition, resourceRegistry); + var link = ResourceenvironmentFactory.eINSTANCE.createLinkingResource(); + partition.getResourceEnvironment() + .getLinkingResources__ResourceEnvironment() + .add(link); + verify(resourceRegistry).createLinkingResourceContainer(link.getId()); + } + + /** + * Test, if syncer initializes properly for non-empty resource environment. + */ + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + @MockSimulation + final void testInitialize(PCMResourceSetPartition partition, + ResourceRegistry resourceRegistry, @Named("Container A") ResourceContainer rca, + @Named("Container B") ResourceContainer rcb, @Named("Link 1") LinkingResource link, + @Identified("A1") ProcessingResourceSpecification specRca, + @Identified("B1") ProcessingResourceSpecification specRcb) { + setUpSyncer(partition, resourceRegistry); + + verify(resourceRegistry).createResourceContainer(rca.getId()); + verify(resourceRegistry).createResourceContainer(rcb.getId()); + verify(resourceRegistry).createLinkingResourceContainer(link.getId()); + + var srca = (SimulatedResourceContainer) resourceRegistry.getResourceContainer(rca.getId()); + verify(srca).addActiveResourceWithoutCalculators(Mockito.eq(specRca), Mockito.any(), Mockito.eq(rca.getId()), + Mockito.anyString()); + + var srcb = (SimulatedResourceContainer) resourceRegistry.getResourceContainer(rcb.getId()); + verify(srcb).addActiveResourceWithoutCalculators(Mockito.eq(specRcb), Mockito.any(), Mockito.eq(rcb.getId()), + Mockito.anyString()); + + var slink = (SimulatedLinkingResourceContainer) resourceRegistry.getResourceContainer(link.getId()); + verify(slink).addActiveResourceWithoutCalculators(link, link.getId()); + } + + /** + * Test, if syncer does not try to create simulation entities, if they do already exist. + */ + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + @MockSimulation(initializeRegistry = true) + final void testNoUnnecessaryInitialize(PCMResourceSetPartition partition, + ResourceRegistry resourceRegistry) { + + setUpSyncer(partition, resourceRegistry); + + verify(resourceRegistry, Mockito.never()).createResourceContainer(Mockito.anyString()); + verify(resourceRegistry, Mockito.never()).createLinkingResourceContainer(Mockito.anyString()); + } + + /** + * Test various ways of updating the processing rate within the model and check, if the changes + * are properly reflected. + */ + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + @MockSimulation(initializeRegistry = true) + final void testSyncProcessingRate(PCMResourceSetPartition partition, ResourceRegistry resourceRegistry, + @Named("Container A") ResourceContainer rca, @Identified("A1") ProcessingResourceSpecification specRca) { + + setUpSyncer(partition, resourceRegistry); + + var schedResource = (ScheduledResource) resourceRegistry.getResourceContainer(rca.getId()) + .getAllActiveResources() + .get(specRca.getActiveResourceType_ActiveResourceSpecification() + .getId()); + + // Test setting the specification string directly + specRca.getProcessingRate_ProcessingResourceSpecification() + .setSpecification("2000"); + verify(schedResource).setProcessingRate("2000"); + + // Test setting the entire stoex + specRca.setProcessingRate_ProcessingResourceSpecification(TestModelBase.stoex("3000")); + verify(schedResource).setProcessingRate("3000"); + + // Test setting the stoex, but via its container reference + TestModelBase.stoex("4000") + .setProcessingResourceSpecification_processingRate_PCMRandomVariable(specRca); + verify(schedResource).setProcessingRate("4000"); + + // lastly check setting via EMF reflections + specRca.getProcessingRate_ProcessingResourceSpecification() + .eSet(StoexPackage.Literals.RANDOM_VARIABLE__SPECIFICATION, "5000"); + verify(schedResource).setProcessingRate("5000"); + + } + + /** + * Test various ways of updating linking resource parameters within the model and check, if the + * changes are properly reflected. + */ + @Test + @PCMInstanceFromSupplier(ResourceEnvironmentTestModels.WithTwoContainersAndOneLink.class) + @MockSimulation(initializeRegistry = true) + final void testSyncLinkingResource(PCMResourceSetPartition partition, ResourceRegistry resourceRegistry, + @Named("Link 1") LinkingResource link, @Identified("L1") CommunicationLinkResourceSpecification specLink) { + + setUpSyncer(partition, resourceRegistry); + + var schedResource = (SimulatedLinkingResource) resourceRegistry.getResourceContainer(link.getId()) + .getAllActiveResources() + .get(specLink.getCommunicationLinkResourceType_CommunicationLinkResourceSpecification() + .getId()); + + // Test setting the specification string directly + specLink.getThroughput_CommunicationLinkResourceSpecification() + .setSpecification("2000"); + verify(schedResource).setThroughput("2000"); + + specLink.getLatency_CommunicationLinkResourceSpecification() + .setSpecification("300"); + verify(schedResource).setLatency("300"); + + // Test setting the entire stoex + specLink.setThroughput_CommunicationLinkResourceSpecification(TestModelBase.stoex("3000")); + verify(schedResource).setThroughput("3000"); + + // Test setting the stoex, but via its container reference + TestModelBase.stoex("4000") + .setCommunicationLinkResourceSpecifcation_throughput_PCMRandomVariable(specLink); + verify(schedResource).setThroughput("4000"); + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/AcquireReleaseExample.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/AcquireReleaseExample.java new file mode 100644 index 000000000..4d6f95bdf --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/AcquireReleaseExample.java @@ -0,0 +1,91 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.firstMeasurementMatchesDifferentlyThanTheRest; + +import javax.measure.unit.SI; +import javax.measure.unit.Unit; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.repository.PassiveResource; +import org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class AcquireReleaseExample { + + /** + * This test runs and validates the results as described in the manual test case SIMULIZAR-109. + */ + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.examples.package", basePath = "initiatorTemplates/Acquire_Example", modelFiles = { + "AllocationExample.allocation", "AquireExample.usagemodel" }) + @SimulationConfig(maxMeasurements = "10") + @RunSimuLizar + void testAcquireReleaseExample(PassiveResource pResource, ProcessingResourceSpecification aCPU, UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + // Test step 5 + // The response time of the first four requests should be 10, 20, 30, and 40. Then, the response time should be constant at 50. + var usageScenarioMeasurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(usageScenarioMeasurement.isPresent()); + + MeasurementTestUtils.allDoubleMeasurementValuesMatch(usageScenarioMeasurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(10.0, 0.001), + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(20.0, 0.001), + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(30.0, 0.001), + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(40.0, 0.001), + closeTo(50.0, 0.001)))))); + + // Test step 6 + // The utilization of CPU should be 100% with 1 job. + var soarMeasurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.STATE_OF_ACTIVE_RESOURCE_METRIC_TUPLE, aCPU); + assertTrue(soarMeasurement.isPresent()); + var buckets = MeasurementTestUtils.calculateIntBucketsBasedOnStateDuration(soarMeasurement.get(), + MetricDescriptionConstants.STATE_OF_ACTIVE_RESOURCE_METRIC, Unit.ONE); + assertThat(buckets.get(0), is(closeTo(0.0, 0.01))); + var bucketSum = buckets.entrySet().stream().filter(e -> e.getKey() != 0).mapToDouble(e -> e.getValue()).sum(); + assertThat(bucketSum, is(closeTo(100.0, 0.1))); + + // Test step 7 + // The utilization should be 100% with the state "0", meaning no resource is available. + var soprMeasurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.STATE_OF_PASSIVE_RESOURCE_METRIC_TUPLE, pResource); + assertTrue(soprMeasurement.isPresent()); + buckets = MeasurementTestUtils.calculateIntBucketsBasedOnStateDuration(soprMeasurement.get(), + MetricDescriptionConstants.STATE_OF_PASSIVE_RESOURCE_METRIC, Unit.ONE); + assertThat(buckets.get(0), is(closeTo(100.0, 0.01))); + bucketSum = buckets.entrySet().stream().filter(e -> e.getKey() != 0).mapToDouble(e -> e.getValue()).sum(); + assertThat(bucketSum, is(closeTo(0.0, 0.1))); + + // Test step 8 + // The wait time of the first four requests should be 0, 10, 20, and 30. Then, the wait time should be constant at 40. + var waitingTimeMeasurement = expRun.getMeasurement().stream().filter(m -> m.getMeasuringType().getMetric().getId().equals( + MetricDescriptionConstants.WAITING_TIME_METRIC_TUPLE.getId())).findAny(); + assertTrue(waitingTimeMeasurement.isPresent()); + MeasurementTestUtils.allDoubleMeasurementValuesMatch(waitingTimeMeasurement.get(), + MetricDescriptionConstants.WAITING_TIME_METRIC, SI.SECOND, + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(0.0, 0.001), + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(10.0, 0.001), + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(20.0, 0.001), + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(30.0, 0.001), + closeTo(40.0, 0.001)))))); + + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/AssemblyOperationMeasurementTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/AssemblyOperationMeasurementTest.java new file mode 100644 index 000000000..0e60f1369 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/AssemblyOperationMeasurementTest.java @@ -0,0 +1,99 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.asDoubleIn; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.match; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.withProbability; +import static org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils.allMeasurementsOfMetric; + +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.core.composition.AssemblyContext; +import org.palladiosimulator.pcm.repository.OperationProvidedRole; +import org.palladiosimulator.pcm.repository.OperationSignature; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.pcmmeasuringpoint.PcmmeasuringpointFactory; +import org.palladiosimulator.simulizar.test.commons.annotation.Identified; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.Named; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +/** + * This test validats the functionality of response time measurements at Assembly Operation Measuring Points. + * + * The feature was requested by SIMULIZAR-111. + * + * @author Sebastian Krach + * + */ +@PluginTestOnly +class AssemblyOperationMeasurementTest { + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.tests", basePath = "testmodels/simulizar111", modelFiles = { + "default.allocation", "default.monitorrepository", "default.usagemodel" }) + @SimulationConfig(maxMeasurements = "1000") + @RunSimuLizar + void testAssemblyOperationMeasurements(UsageScenario scenario, + @Named("AComponent1") AssemblyContext acomponent1, + @Named("AComponent2") AssemblyContext acomponent2, + @Named("do") OperationSignature signature, + @Identified("_qZKs0CHbEd62GabW1zGSBw") OperationProvidedRole role, + ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + /* First validate, that the simulated load balancer distributed the load evenly */ + assertThat(allMeasurementsOfMetric(measurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC), + match(withProbability(closeTo(0.5, 0.1), asDoubleIn(SI.SECOND, is(closeTo(1, 0.0001)))), + withProbability(closeTo(0.5, 0.1), asDoubleIn(SI.SECOND, is(closeTo(2, 0.0001)))))); + + var aCom1MPt = PcmmeasuringpointFactory.eINSTANCE.createAssemblyOperationMeasuringPoint(); + aCom1MPt.setAssembly(acomponent1); + aCom1MPt.setOperationSignature(signature); + aCom1MPt.setRole(role); + + var comp1measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, aCom1MPt); + assertTrue(comp1measurement.isPresent()); + + /* All user requests processed by the first assembly take 1 unit to execute */ + MeasurementTestUtils.allDoubleMeasurementValuesMatch(comp1measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + is(closeTo(1, 0.0001))); + + var aCom2MPt = PcmmeasuringpointFactory.eINSTANCE.createAssemblyOperationMeasuringPoint(); + aCom2MPt.setAssembly(acomponent2); + aCom2MPt.setOperationSignature(signature); + aCom2MPt.setRole(role); + + var comp2measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, aCom2MPt); + assertTrue(comp2measurement.isPresent()); + + /* All user requests processed by the second assembly take 2 time units to execute, + * as the server is half as fast as the first on */ + MeasurementTestUtils.allDoubleMeasurementValuesMatch(comp2measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + is(closeTo(2, 0.0001))); + + } + + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/BaseMediaStoreSimulationTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/BaseMediaStoreSimulationTest.java new file mode 100644 index 000000000..1267ef401 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/BaseMediaStoreSimulationTest.java @@ -0,0 +1,47 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.*; +import static org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils.allMeasurementsOfMetric; + +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class BaseMediaStoreSimulationTest { + + /** + * Tests simulation of case: https://palladio-simulator.atlassian.net/browse/SIMULIZAR-110 + * Tests fix of https://palladio-simulator.atlassian.net/browse/SIMULIZAR-166 + */ + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.examples.package", basePath = "initiatorTemplates/MediaStore3_Model", modelFiles = { + "ms_cache.allocation", "ms_cache_usage_all.usagemodel" }) + @SimulationConfig(maxMeasurements = "1000", simulateReliability = false) + @RunSimuLizar + void testMSCacheAll1k(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + assertThat(allMeasurementsOfMetric(measurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC), + match(withProbability(lessThan(0.1), asDoubleIn(SI.SECOND, is(anyOf(lessThan(14000.0), greaterThan(32000.0))))), + withProbability(closeTo(1.0, 0.1), asDoubleIn(SI.SECOND, is(both(greaterThan(14000.0)).and(lessThan(32000.0))))))); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/EntryLevelSystemCallSimulationTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/EntryLevelSystemCallSimulationTest.java new file mode 100644 index 000000000..0a4620841 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/EntryLevelSystemCallSimulationTest.java @@ -0,0 +1,47 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +public class EntryLevelSystemCallSimulationTest { + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.tests", basePath = "testmodels/entry-level-system-call-return-testmodel", modelFiles = { + "default.allocation", "default.measuringpoint", "default.monitorrepository", "default.repository", + "default.resourceenvironment", "default.slo", "default.system", "default.usagemodel" }) + @SimulationConfig(maxMeasurements = "100") + @RunSimuLizar + void testEntryLevelSystemCallResultSimulation(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var metric = MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE; + + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), metric, scenario); + + assertTrue(measurement.isPresent()); + + assertThat(MeasurementTestUtils.allMeasurementsOfMetric(measurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC), not(empty())); + + MeasurementTestUtils.allDoubleMeasurementValuesMatch(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, is(equalTo(315.0))); + + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/EventExtensionTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/EventExtensionTest.java new file mode 100644 index 000000000..9f5db3d04 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/EventExtensionTest.java @@ -0,0 +1,51 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.*; +import static org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils.*; + +import javax.measure.unit.SI; +import org.junit.jupiter.api.Test; +import org.palladiosimulator.analyzer.workflow.ConstantsContainer; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.events.DaggerEventExtensionComponent; +import org.palladiosimulator.simulizar.events.EventsTransformationConfiguration; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SetConfigProperty; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.annotation.UseSimuLizarExtension; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class EventExtensionTest { + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.examples.package", basePath = "initiatorTemplates/MinimumEvent_Example", modelFiles = { + "default.allocation", "default.usagemodel" }) + @UseSimuLizarExtension(DaggerEventExtensionComponent.class) + @SimulationConfig(maxMeasurements = "1000") + @SetConfigProperty(id = EventsTransformationConfiguration.SIMULATE_EVENTS, value = "true") + @SetConfigProperty(id = EventsTransformationConfiguration.EVENT_MIDDLEWARE_FILE, value = ConstantsContainer.DEFAULT_EVENT_MIDDLEWARE_FILE) + @SetConfigProperty(id = EventsTransformationConfiguration.STORE_TRANSFORMED_MODELS, value = "false") + @RunSimuLizar + void testEventExtension(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + assertThat(allMeasurementsOfMetric(measurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC), + match(withProbability(closeTo(0.5, 0.1), asDoubleIn(SI.SECOND, is(closeTo(5, 0.0001)))), + withProbability(closeTo(0.5, 0.1), asDoubleIn(SI.SECOND, is(closeTo(4, 0.0001)))), + withProbability(lessThan(0.05), asDoubleIn(SI.SECOND, is(lessThan(3.999)))))); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/LinkingResourceSimulationTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/LinkingResourceSimulationTest.java new file mode 100644 index 000000000..6beffc9cb --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/LinkingResourceSimulationTest.java @@ -0,0 +1,63 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class LinkingResourceSimulationTest { + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.examples.package", basePath = "initiatorTemplates/LinkingResource_Test", modelFiles = { + "default.allocation", "default.measuringpoint", "default.monitorrepository", "default.repository", + "default.resourceenvironment", "default.slo", "default.system", "default.usagemodel" }) + @SimulationConfig(simulateLinkThroughput = true, maxMeasurements = "100") + @RunSimuLizar + void testLinkingResourceThroughputSimulation(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + MeasurementTestUtils.allDoubleMeasurementValuesMatch(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + is(allOf(greaterThan(184.0), lessThan(185.0)))); + + } + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.examples.package", basePath = "initiatorTemplates/LinkingResource_Test", modelFiles = { + "default.allocation", "default.measuringpoint", "default.monitorrepository", "default.repository", + "default.resourceenvironment", "default.slo", "default.system", "default.usagemodel" }) + @SimulationConfig(simulateLinkThroughput = false, maxMeasurements = "100") + @RunSimuLizar + void testNoLinkingResourceSimulation(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + MeasurementTestUtils.allDoubleMeasurementValuesMatch(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + is(allOf(greaterThan(1.0), lessThan(2.0)))); + + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/ReconfigurationSimulationTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/ReconfigurationSimulationTest.java new file mode 100644 index 000000000..2817a42c9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/ReconfigurationSimulationTest.java @@ -0,0 +1,67 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.asDoubleIn; + +import javax.measure.quantity.Duration; +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.launcher.SimulizarConstants; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SetConfigProperty; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.annotation.UseSimuLizarExtension; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; +import org.palladiosimulator.simulizar.reconfiguration.qvto.DaggerQVTOReconfigurationComponent; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +public class ReconfigurationSimulationTest { + + /** + * Tests fix of https://palladio-simulator.atlassian.net/browse/SIMULIZAR-169 + * + * The reconfiguration increments the resource demand of the internal action after each user by + * 1. + * + * The resulting response time of the usage scenario should be 1 for the first user, 2.0 for the + * second one, 3 for the 3rd one, and so on. + * + * If the test fails with each scenario taking 1.0 time units, the reconfiguration is not + * executed. + */ + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.tests", basePath = "testmodels/reconfiguration", modelFiles = { + "default.allocation", "default.usagemodel", "default.monitorrepository" }) + @UseSimuLizarExtension(DaggerQVTOReconfigurationComponent.class) + @SetConfigProperty(id = SimulizarConstants.RECONFIGURATION_RULES_FOLDER, value = "platform:/plugin/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/reconfigs") + @SimulationConfig(maxMeasurements = "10") + @RunSimuLizar + void testReconfiguratedModelIsPickedUpByNewUsers(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + var values = MeasurementTestUtils. allMeasurementsOfMetric(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC); + var counter = 1; + for (var val : values) { + assertThat(val, asDoubleIn(SI.SECOND, is(closeTo(counter++, 0.0001)))); + } + + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/SimuLizar154Test.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/SimuLizar154Test.java new file mode 100644 index 000000000..ada3f5d2f --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/SimuLizar154Test.java @@ -0,0 +1,51 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.hamcrest.Matchers.closeTo; +import static org.palladiosimulator.simulizar.test.commons.hamcrest.Matchers.*; + +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class SimuLizar154Test { + + /** + * Tests fix of https://palladio-simulator.atlassian.net/browse/SIMULIZAR-154 + */ + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.tests", basePath = "testmodels/simulizar154", modelFiles = { + "default.allocation", "default.usagemodel", "default.monitorrepository" }) + @SimulationConfig(maxMeasurements = "20") + @RunSimuLizar + void testSimulizar154Fix(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + // The simulated scenario starts runs a closed workload with one user. The user first issues + // a demand of 1 Units to the CPU with a processing rate of 2. Hence, + // it takes 0.5 time units to finish. Thereafter a async thread is spun of, in which again a + // demand of 1 is issued. + // Result: We expect the first user to finish within 0.5s. Due to the processing of + // the asynchronously issues demand, all of the remaining users only receive 50% of the cpu + // processing capability. Cosequently, the remaining users take 1.0s to finish. + MeasurementTestUtils.allDoubleMeasurementValuesMatch(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + firstMeasurementMatchesDifferentlyThanTheRest(closeTo(0.5, 0.001), closeTo(1.0, 0.001))); + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/SubsystemTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/SubsystemTest.java new file mode 100644 index 000000000..d7a1be671 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/SubsystemTest.java @@ -0,0 +1,61 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class SubsystemTest { + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.examples.package", basePath = "initiatorTemplates/Subsystem_Test", modelFiles = { + "nestedSubsystems.allocation", "nestedSubsystems.monitorrepository", "nestedSubSystem.usagemodel" }) + @SimulationConfig(maxMeasurements = "100") + @RunSimuLizar + void testNestedSubsystemAllocation(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + MeasurementTestUtils.allDoubleMeasurementValuesMatch(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + is(anyOf(closeTo(0.1, 0.0001), closeTo(0.2, 0.0001)))); + + } + + + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.examples.package", basePath = "initiatorTemplates/Subsystem_Test", modelFiles = { + "default.allocation", "default.monitorrepository", "default.usagemodel" }) + @SimulationConfig(maxMeasurements = "100") + @RunSimuLizar + void testDefault(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + MeasurementTestUtils.allDoubleMeasurementValuesMatch(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, + is(anyOf(closeTo(0.1, 0.0001), closeTo(0.2, 0.0001)))); + + } + +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/UsageevolutionTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/UsageevolutionTest.java new file mode 100644 index 000000000..0206ab1a6 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/simulation/tests/UsageevolutionTest.java @@ -0,0 +1,141 @@ +package org.palladiosimulator.simulizar.simulation.tests; + +import static org.hamcrest.Matchers.closeTo; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; + +import javax.measure.Measure; +import javax.measure.quantity.Duration; +import javax.measure.unit.SI; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.edp2.models.ExperimentData.ExperimentRun; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.pcm.usagemodel.UsageScenario; +import org.palladiosimulator.simulizar.test.commons.annotation.LoadPCMInstanceFromBundle; +import org.palladiosimulator.simulizar.test.commons.annotation.RunSimuLizar; +import org.palladiosimulator.simulizar.test.commons.annotation.SimulationConfig; +import org.palladiosimulator.simulizar.test.commons.util.MeasurementTestUtils; + +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; + +@PluginTestOnly +class UsageevolutionTest { + + /** + * Tests Usageevolution with a simple deterministic example. This test only tests the correct + * responste time evolution. + */ + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.tests", basePath = "testmodels/usageevolutionTest", modelFiles = { + "default.allocation", "default.usagemodel", "default.repository", "default.usageevolution" }) + @SimulationConfig(maxMeasurements = "100") + @RunSimuLizar + void testUsageevolutionResponseTimeVariation(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + List> responseTimeMeasurements = MeasurementTestUtils + .allMeasurementsOfMetric(measurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC); + List> timeMeasurements = MeasurementTestUtils.allMeasurementsOfMetric(measurement.get(), + MetricDescriptionConstants.POINT_IN_TIME_METRIC); + assertEquals(responseTimeMeasurements.size(), timeMeasurements.size()); + + // The simulated test scenario evolves response time and user amount. + // Population is 1 and Think Time is 99.0 + // It evolves in 3 stages. + // Stage 1: 2000s with constant 1.0 20 measurements in 20 timesteps + // Stage 2: 2000s with constant 2.0 (Leads to Response Time 4.0 as both values evolve) + // 40 Measurements in 20 Timesteps (two parallel) + // Stage 3: 6000s with constant 1.0 40 measurements in 40 timesteps + // It is important to know, that this constant evolves the user requests from 1 to 2 aswell + // as the response time. + // ^ + // | ...[20]... + // | + // | + // |...[20].. ....[40]..... + // ----------------------------------------> + // Number in Brackets means total 20 measuring Points + // In Stage 2 every Point is representing two measurements as both values evolved to 2 they + // have the exact same + // resonse time at the same point in time. + for (int i = 0; i < 100; i++) { + if ((i < 20)) { + assertEquals(responseTimeMeasurements.get(i) + .doubleValue(SI.SECOND), 1.0, 0.001); + } + if (i >= 20 && i < 60) { + assertEquals(responseTimeMeasurements.get(i) + .doubleValue(SI.SECOND), 4.0, 0.001); + } + if (i >= 60) { + assertEquals(responseTimeMeasurements.get(i) + .doubleValue(SI.SECOND), 1.0, 0.001); + } + + // Test Measurement Time Stamps + assertEquals((Double) timeMeasurements.get(19) + .doubleValue(SI.SECOND), 1901.0, 0.001); + assertEquals((Double) timeMeasurements.get(20) + .doubleValue(SI.SECOND), 2004.0, 0.001); + assertEquals((Double) timeMeasurements.get(21) + .doubleValue(SI.SECOND), 2004.0, 0.001); + assertEquals((Double) timeMeasurements.get(22) + .doubleValue(SI.SECOND), 2107.0, 0.001); + // Section 1 -> Section 2 matching evolution of response time + assertEquals((Double) responseTimeMeasurements.get(19) + .doubleValue(SI.SECOND), 1.0, 0.001); + assertEquals((Double) responseTimeMeasurements.get(20) + .doubleValue(SI.SECOND), 4.0, 0.001); + assertEquals((Double) responseTimeMeasurements.get(21) + .doubleValue(SI.SECOND), 4.0, 0.001); + assertEquals((Double) responseTimeMeasurements.get(22) + .doubleValue(SI.SECOND), 4.0, 0.001); + // Stage 2 -> Stage 3 same as above but with Section 3 only having 1 user again. + assertEquals((Double) timeMeasurements.get(59) + .doubleValue(SI.SECOND), 3961.0, 0.001); + assertEquals((Double) timeMeasurements.get(60) + .doubleValue(SI.SECOND), 4061.0, 0.001); + assertEquals((Double) timeMeasurements.get(61) + .doubleValue(SI.SECOND), 4161.0, 0.001); + assertEquals((Double) responseTimeMeasurements.get(59) + .doubleValue(SI.SECOND), 4.0, 0.001); + assertEquals((Double) responseTimeMeasurements.get(60) + .doubleValue(SI.SECOND), 1.0, 0.001); + assertEquals((Double) responseTimeMeasurements.get(61) + .doubleValue(SI.SECOND), 1.0, 0.001); + } + } + + /** + * Tests how the values behave if the usageevolution model is not loaded. This means it is + * tested, whether no evolution happens without usage evolution. + */ + @Test + @LoadPCMInstanceFromBundle(bundleName = "org.palladiosimulator.simulizar.tests", basePath = "testmodels/usageevolutionTest", modelFiles = { + "default.allocation", "default.usagemodel", "default.repository" }) + @SimulationConfig(maxMeasurements = "100") + @RunSimuLizar + void testNoEvolutionWithoutUsageEvolution(UsageScenario scenario, ExperimentRun expRun) + throws JobFailedException, UserCanceledException { + var measurement = MeasurementTestUtils.getMeasurementOfAt(expRun.getMeasurement(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC_TUPLE, scenario); + assertTrue(measurement.isPresent()); + + List> responseTimeMeasurements = MeasurementTestUtils + .allMeasurementsOfMetric(measurement.get(), MetricDescriptionConstants.RESPONSE_TIME_METRIC); + List> timeMeasurements = MeasurementTestUtils.allMeasurementsOfMetric(measurement.get(), + MetricDescriptionConstants.POINT_IN_TIME_METRIC); + assertEquals(responseTimeMeasurements.size(), timeMeasurements.size()); + // No Evolution means, that the response time stays the same for the all measurements at 1.0 + MeasurementTestUtils.allDoubleMeasurementValuesMatch(measurement.get(), + MetricDescriptionConstants.RESPONSE_TIME_METRIC, SI.SECOND, closeTo(1.0, 0.001)); + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/tests/QVToReconfigurationTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/tests/QVToReconfigurationTest.java new file mode 100644 index 000000000..55a04f79b --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/tests/QVToReconfigurationTest.java @@ -0,0 +1,451 @@ +package org.palladiosimulator.simulizar.tests; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.eclipse.emf.common.CommonPlugin; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.palladiosimulator.analyzer.workflow.ConstantsContainer; +import org.palladiosimulator.analyzer.workflow.blackboard.PCMResourceSetPartition; +import org.palladiosimulator.metricspec.constants.MetricDescriptionConstants; +import org.palladiosimulator.monitorrepository.MeasurementSpecification; +import org.palladiosimulator.monitorrepository.MonitorRepositoryFactory; +import org.palladiosimulator.monitorrepository.StatisticalCharacterization; +import org.palladiosimulator.monitorrepository.TimeDrivenAggregation; +import org.palladiosimulator.pcm.allocation.Allocation; +import org.palladiosimulator.pcm.allocation.AllocationContext; +import org.palladiosimulator.pcm.allocation.util.AllocationResourceFactoryImpl; +import org.palladiosimulator.pcm.core.composition.AssemblyConnector; +import org.palladiosimulator.pcm.core.composition.AssemblyContext; +import org.palladiosimulator.pcm.core.composition.Connector; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.repository.util.RepositoryResourceFactoryImpl; +import org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification; +import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; +import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; +import org.palladiosimulator.pcm.resourceenvironment.util.ResourceenvironmentResourceFactoryImpl; +import org.palladiosimulator.pcm.seff.ProbabilisticBranchTransition; +import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; +import org.palladiosimulator.pcm.seff.ServiceEffectSpecification; +import org.palladiosimulator.pcm.system.util.SystemResourceFactoryImpl; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurement; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurementFactory; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurementModel; +import org.palladiosimulator.runtimemeasurement.RuntimeMeasurementPackage; +import org.palladiosimulator.simulizar.reconfiguration.qvto.QVTOReconfigurator; +import org.palladiosimulator.simulizar.reconfiguration.qvto.QVTOReconfigurationLoader; +import org.palladiosimulator.simulizar.reconfigurationrule.ModelTransformation; +import org.palladiosimulator.simulizar.runconfig.SimuLizarWorkflowConfiguration; +import org.palladiosimulator.simulizar.utils.PCMPartitionManager; + +import com.google.common.collect.Streams; + +import de.uka.ipd.sdq.scheduler.resources.active.IResourceTableManager; +import de.uka.ipd.sdq.scheduler.resources.active.ResourceTableManager; +import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; +import de.uka.ipd.sdq.workflow.mdsd.blackboard.ResourceSetPartition; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; +import tools.mdsd.junit5utils.extensions.PlatformStandaloneExtension; + +@ExtendWith(PlatformStandaloneExtension.class) +@PluginTestOnly +public class QVToReconfigurationTest { + + private static final String PCM_TEST_MODEL_SEFF_BRANCH_ACTION_ID = "_1P7G0LwGEeSxGbiYbg6Waw"; + private static final String MEASUREMENT_SPECIFICATION_ID = "_sEx-cMLAEeSZr8oGpigbHA"; + + private final static String REPOSITORY_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.repository"; + private final static String RESOURCE_ENVIRONMENT_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.resourceenvironment"; + private final static String SYSTEM_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.system"; + private final static String ALLOCATION_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.allocation"; + private final static String MONITOR_REPOSITORY_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/monitors/server.monitorrepository"; + + private final static String TRANSFORMATION_RULES_ADD_DUPLICATED_SERVER_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addClonedServer"; + private final static String TRANSFORMATION_RULES_ADD_SERVER_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addNewServer"; + private final static String TRANSFORMATION_RULES_OUTSOURCE_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/outsource"; + private final static String TRANSFORMATION_RULES_SCALE_UP_PATH = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/scaleUp"; + + private final static String WF_CONFIGURATION_KEY_ALLOCATION_FILE = "allocationFile"; + private final static String REPOSITORY_EXTENSION = "repository"; + private final static String RESOURCE_ENVIRONMENT_EXTENSION = "resourceenvironment"; + private final static String SYSTEM_EXTENSION = "system"; + private final static String ALLOCATION_EXTENSION = "allocation"; + + private final static String BRANCH_2_ENTITY_NAME = "branch2"; + private final static double BRANCH_2_EXPECTED_VALUE_AFTER_OUTSOURCING = 0.1; + private final static double BRANCH_2_EXPECTED_VALUE_BEFORE_OUTSOURCING = 0.0; + private final static double MEASUREMENT_BELOW_THRESHOLD = 1.0; + private final static double MEASUREMENT_OVER_THRESHOLD = 5.0; + private final static String SERVER_RESOURCE_CONTAINER_NAME = "server"; + private final static double SERVER_EXPECTED_PROCESSING_RATE_AFTER_SCALING = 1100.0; + private final static double SERVER_EXPECTED_PROCESSING_RATE_BEFORE_SCALING = 1000.0; + private final static int EXPECTED_NUMBER_OF_SERVERS_BEFORE_ADDING = 1; + private final static int EXPECTED_NUMBER_OF_SERVERS_AFTER_ADDING = 2; + + private static URI systemURI; + private static URI resourceEnvironmentURI; + private static URI repositoryURI; + private static URI allocationURI; + private static URI monitorURI; + + private static IResourceTableManager resourceTableManager; + + @BeforeAll + public static void setUpBeforeClass() { + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap() + .put(REPOSITORY_EXTENSION, new RepositoryResourceFactoryImpl()); + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap() + .put(RESOURCE_ENVIRONMENT_EXTENSION, new ResourceenvironmentResourceFactoryImpl()); + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap() + .put(SYSTEM_EXTENSION, new SystemResourceFactoryImpl()); + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap() + .put(ALLOCATION_EXTENSION, new AllocationResourceFactoryImpl()); + Map uriMap = URIConverter.URI_MAP; + uriMap.put(URI.createURI("pathmap://METRIC_SPEC_MODELS/commonMetrics.metricspec"), + URI.createURI("platform:/plugin/org.palladiosimulator.metricspec.resources/commonMetrics.metricspec")); + + repositoryURI = URI.createPlatformPluginURI(REPOSITORY_PATH, true); + repositoryURI = CommonPlugin.resolve(repositoryURI); + resourceEnvironmentURI = URI.createPlatformPluginURI(RESOURCE_ENVIRONMENT_PATH, true); + resourceEnvironmentURI = CommonPlugin.resolve(resourceEnvironmentURI); + systemURI = URI.createPlatformPluginURI(SYSTEM_PATH, true); + systemURI = CommonPlugin.resolve(systemURI); + allocationURI = URI.createPlatformPluginURI(ALLOCATION_PATH, true); + allocationURI = CommonPlugin.resolve(allocationURI); + monitorURI = URI.createPlatformPluginURI(MONITOR_REPOSITORY_PATH, true); + monitorURI = CommonPlugin.resolve(monitorURI); + + resourceTableManager = new ResourceTableManager(); + + } + + + @Test + void testPerformOutsourceReconfigurationIfMeasuredValueExceedsThreshold() throws Exception { + PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_OVER_THRESHOLD, TRANSFORMATION_RULES_OUTSOURCE_PATH, resourceTableManager); + + double actualResult = checkOutsourceReconfiguration(pcmResourceSet, BRANCH_2_ENTITY_NAME); + assertEquals(BRANCH_2_EXPECTED_VALUE_AFTER_OUTSOURCING, actualResult, 0.0, "The branch probability was not changed as expected!"); + } + + + @Test + void testSkipOutsourceReconfigurationIfMeasuredValueBelowThreshold() throws Exception { + PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_BELOW_THRESHOLD, TRANSFORMATION_RULES_OUTSOURCE_PATH, resourceTableManager); + + double actualResult = checkOutsourceReconfiguration(pcmResourceSet, BRANCH_2_ENTITY_NAME); + assertEquals(BRANCH_2_EXPECTED_VALUE_BEFORE_OUTSOURCING, actualResult, 0.0, "The branch probability has not remained as it was expected!"); + } + + + @Test + void testPerformScaleUpReconfigurationIfMeasuredValueExceedsThreshold() throws Exception { + PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_OVER_THRESHOLD, TRANSFORMATION_RULES_SCALE_UP_PATH, resourceTableManager); + + double actualResult = checkScaleUpReconfiguration(pcmResourceSet, SERVER_RESOURCE_CONTAINER_NAME); + assertEquals(SERVER_EXPECTED_PROCESSING_RATE_AFTER_SCALING, actualResult, 0.0, "Processing resources have not scaled as expected!"); + } + + + @Test + void testSkipScaleUpReconfigurationIfMeasuredValueBelowThreshold() throws Exception { + final PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_BELOW_THRESHOLD, TRANSFORMATION_RULES_SCALE_UP_PATH, resourceTableManager); + + double actualResult = checkScaleUpReconfiguration(pcmResourceSet, SERVER_RESOURCE_CONTAINER_NAME); + assertEquals(SERVER_EXPECTED_PROCESSING_RATE_BEFORE_SCALING, actualResult, 0.0, "Processing resources have not remained as it was expected!"); + } + + + @Test + void testPerformAddNewServerReconfigurationIfMeasuredValueExceedsThreshold() throws Exception { + PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_OVER_THRESHOLD, TRANSFORMATION_RULES_ADD_SERVER_PATH, resourceTableManager); + + int actualResult = checkAddNewServerReconfiguration(pcmResourceSet, "server1", "server2", "client"); + assertEquals(EXPECTED_NUMBER_OF_SERVERS_AFTER_ADDING, actualResult, "The server was not added!"); + } + + + @Test + void testSkipAddNewServerUpReconfigurationIfMeasuredValueBelowThreshold() throws Exception { + PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_BELOW_THRESHOLD, TRANSFORMATION_RULES_ADD_SERVER_PATH, resourceTableManager); + + int actualResult = checkAddNewServerReconfiguration(pcmResourceSet, "server1", "server2", "client"); + assertEquals(EXPECTED_NUMBER_OF_SERVERS_BEFORE_ADDING, actualResult, "The number of servers is not as expected!"); + + } + + + @Test + void testPerformAddClonedServerReconfigurationIfMeasuredValueExceedsThreshold() throws Exception { + PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_OVER_THRESHOLD, TRANSFORMATION_RULES_ADD_DUPLICATED_SERVER_PATH, resourceTableManager); + + int actualResult = checkAddClonedServerReconfiguration(pcmResourceSet, "server1", "client"); + assertEquals(EXPECTED_NUMBER_OF_SERVERS_AFTER_ADDING, actualResult, "The server was not added!"); + } + + + @Test + void testSkipAddClonedServerUpReconfigurationIfMeasuredValueBelowThreshold() throws Exception { + PCMResourceSetPartition pcmResourceSet = runReconfiguration(MEASUREMENT_BELOW_THRESHOLD, TRANSFORMATION_RULES_ADD_DUPLICATED_SERVER_PATH, resourceTableManager); + + int actualResult = checkAddClonedServerReconfiguration(pcmResourceSet, "server1", "client"); + assertEquals(EXPECTED_NUMBER_OF_SERVERS_BEFORE_ADDING, actualResult, "The number of servers is not as expected!"); + } + + + private int checkAddNewServerReconfiguration(PCMResourceSetPartition pcmResourceSet, String expectedProvidedAssemblyContextEntityName1, + String expectedProvidedAssemblyContextEntityName2, String expectedRequiredAssemblyContextEntityName) { + final Allocation allocation = pcmResourceSet.getAllocation(); + int numOfServer1Client = 0, numOfServer2Client = 0; + for (final Connector connector : allocation.getSystem_Allocation().getConnectors__ComposedStructure()) { + if (connector instanceof AssemblyConnector) { + final AssemblyConnector assemblyConnector = (AssemblyConnector) connector; + final AssemblyContext assemblyContextProviding = assemblyConnector.getProvidingAssemblyContext_AssemblyConnector(); + final AssemblyContext assemblyContextRequiring = assemblyConnector.getRequiringAssemblyContext_AssemblyConnector(); + + if (assemblyContextProviding.getEncapsulatedComponent__AssemblyContext().getEntityName().equals(expectedProvidedAssemblyContextEntityName1) + && assemblyContextRequiring.getEncapsulatedComponent__AssemblyContext().getEntityName().equals(expectedRequiredAssemblyContextEntityName)) { + numOfServer1Client++; + } + + if (assemblyContextProviding.getEncapsulatedComponent__AssemblyContext().getEntityName().equals(expectedProvidedAssemblyContextEntityName2) + && assemblyContextRequiring.getEncapsulatedComponent__AssemblyContext().getEntityName().equals(expectedRequiredAssemblyContextEntityName)) { + numOfServer2Client++; + } + } + } + return numOfServer1Client + numOfServer2Client; + } + + private int checkAddClonedServerReconfiguration(PCMResourceSetPartition pcmResourceSet, String expectedProvidedAssemblyContextEntityName, String expectedRequiredAssemblyContextEntityName) { + final Allocation allocation = pcmResourceSet.getAllocation(); + int numOfIServerProviders = 0; + for (Connector connector : allocation.getSystem_Allocation().getConnectors__ComposedStructure()) { + if (connector instanceof AssemblyConnector) { + AssemblyConnector assemblyConnector = (AssemblyConnector) connector; + AssemblyContext assemblyContextProviding = assemblyConnector.getProvidingAssemblyContext_AssemblyConnector(); + AssemblyContext assemblyContextRequiring = assemblyConnector.getRequiringAssemblyContext_AssemblyConnector(); + + if (assemblyContextProviding.getEncapsulatedComponent__AssemblyContext().getEntityName().equals(expectedProvidedAssemblyContextEntityName) + && assemblyContextRequiring.getEncapsulatedComponent__AssemblyContext().getEntityName().equals(expectedRequiredAssemblyContextEntityName)) { + numOfIServerProviders++; + } + } + } + return numOfIServerProviders; + } + + /** + * Performs scaling up with the measurement passed as parameter. If the measurement is over the + * threshold the scaling up should be performed, otherwise not. + * @param m + * measurement that defines whether the scaling up is performed or not. + * + * @return processing resource of the server that is to be scaled up. + */ + private double checkScaleUpReconfiguration(PCMResourceSetPartition pcmResourceSet, String expectedResourcContainerEntityName) { + final Allocation allocation = pcmResourceSet.getAllocation(); + final ResourceEnvironment resourceEnvironment = allocation.getTargetResourceEnvironment_Allocation(); + final Iterator iteratorResourceContainer = resourceEnvironment.getResourceContainer_ResourceEnvironment().iterator(); + while (iteratorResourceContainer.hasNext()) { + final ResourceContainer resourceContainer = iteratorResourceContainer.next(); + if (resourceContainer.getEntityName().equals(expectedResourcContainerEntityName)) { + final Iterator iteratorProcessingResourceSpecification = resourceContainer.getActiveResourceSpecifications_ResourceContainer().iterator(); + while (iteratorProcessingResourceSpecification.hasNext()) { + final ProcessingResourceSpecification processingResourceSpecification = iteratorProcessingResourceSpecification.next(); + return Double.parseDouble(processingResourceSpecification.getProcessingRate_ProcessingResourceSpecification().getSpecification()); + } + } + } + fail("The test reached the end!"); + return Double.NaN; + } + + /** + * Performs outsourcing with the measurement passed as parameter. If the measurement is over the + * threshold the outsourcing should be performed, otherwise not. + * @return branch probability that is to be increased. + */ + private double checkOutsourceReconfiguration(PCMResourceSetPartition pcmResourceSet, String expectedBranchEntityName) { + final TreeIterator pcmModelIterator = pcmResourceSet.getAllocation().eAllContents(); + /* + * Iterate over all the elements of the allocation diagram. + */ + while (pcmModelIterator.hasNext()) { + final EObject root = pcmModelIterator.next(); + /* + * We are interested in AllocationContexts only because we can get to the server which + * contains the SEFF that is of our interest. + */ + if (root instanceof AllocationContext) { + final AllocationContext serverAllocationContext = (AllocationContext) root; + final AssemblyContext serverAssemblyContext = serverAllocationContext + .getAssemblyContext_AllocationContext(); + /* + * The server that contains our SEFF is of type BasicComponent. + */ + if (serverAssemblyContext.getEncapsulatedComponent__AssemblyContext() instanceof BasicComponent) { + final BasicComponent serverBasicComponent = (BasicComponent) serverAssemblyContext + .getEncapsulatedComponent__AssemblyContext(); + final EList serverSeffs = serverBasicComponent + .getServiceEffectSpecifications__BasicComponent(); + /* + * We iterate all the SEFFs within the BasicComponent. + */ + for (final ServiceEffectSpecification seff : serverSeffs) { + /* + * ResourceDemandingSEFF in particular are of our interest. + */ + if (seff instanceof ResourceDemandingSEFF) { + final TreeIterator seffIterator = seff.eAllContents(); + /* + * We now iterate every ResourceDemandingSEFF in attempt to find + * ProbabilisticBranchTransition. + */ + while (seffIterator.hasNext()) { + final EObject seffObject = seffIterator.next(); + /* + * Once we find our ProbabilisticBranchTransitions we compare their + * values with the expected ones. + */ + if (seffObject instanceof ProbabilisticBranchTransition) { + final ProbabilisticBranchTransition branchTransition = (ProbabilisticBranchTransition) seffObject; + if (branchTransition.getEntityName().equals(expectedBranchEntityName)) { + return branchTransition.getBranchProbability(); + } + } + } + } + } + } + } + } + fail("The test reached the end!"); + return Double.NaN; + } + + /** + * Creates a measurement out of parameter "m", reads in the PCM model from the folder + * "testmodel", performs the QVTo rules that are placed in the folder "testmodel/rules" and + * returns the resulting PCM model. The PCM model could be changed or not, depending on the + * parameter "measuredValue". + * + * @param measuredValue measurement. + * @return The PCM model after the rules from "testmodel/rules" have been applied. + */ + private PCMResourceSetPartition runReconfiguration(double measuredValue, + String reconfigurationRulesFolderPath, IResourceTableManager resourceTableManager) { + + final PCMResourceSetPartition pcmResourceSet = loadPcmResources(); + EObject monitoredElement = assignMonitorToModelElement(pcmResourceSet, PCM_TEST_MODEL_SEFF_BRANCH_ACTION_ID); + + SimuLizarWorkflowConfiguration workflowConfig = createWorkflowConfiguration(allocationURI, reconfigurationRulesFolderPath); + PCMPartitionManager pcmPartitionManager = loadPcmModelsIntoBlackboard(workflowConfig, pcmResourceSet, reconfigurationRulesFolderPath); + + RuntimeMeasurement responeTimeRuntimeMeasurement = createResponeTimeMeasurement(measuredValue); + recordRuntimeMeasurement(pcmPartitionManager, responeTimeRuntimeMeasurement); + + executeTransformation(workflowConfig, pcmPartitionManager, monitoredElement); + + return pcmResourceSet; + } + + + private PCMResourceSetPartition loadPcmResources() { + final PCMResourceSetPartition pcmResourceSet = new PCMResourceSetPartition(); + pcmResourceSet.loadModel(repositoryURI); + pcmResourceSet.loadModel(resourceEnvironmentURI); + pcmResourceSet.loadModel(systemURI); + pcmResourceSet.loadModel(allocationURI); + pcmResourceSet.loadModel(monitorURI); + return pcmResourceSet; + } + + + private EObject assignMonitorToModelElement(PCMResourceSetPartition pcmResourceSet, String modelElementId) { + var result = pcmResourceSet.getRepositories().stream().map(EObject::eAllContents).flatMap(Streams::stream) + .filter(element -> { + final EAttribute id = element.eClass() + .getEIDAttribute(); + final Object idAttribute = element.eGet(id); + + return idAttribute.toString().equals(modelElementId); + }) + .findAny(); + assertTrue(result.isPresent()); + return result.get(); + } + + + private SimuLizarWorkflowConfiguration createWorkflowConfiguration(URI allocationURI, String reconfigurationRulesFolderPath) { + Map configuration = new HashMap(); + configuration.put(WF_CONFIGURATION_KEY_ALLOCATION_FILE, Paths.get(allocationURI.path()).toAbsolutePath().toString()); + + SimuLizarWorkflowConfiguration swfc = new SimuLizarWorkflowConfiguration(configuration); + URI reconfRulesURI = URI.createPlatformPluginURI(reconfigurationRulesFolderPath, false); + swfc.setReconfigurationRulesFolder(reconfRulesURI.toString()); + return swfc; + } + + + private PCMPartitionManager loadPcmModelsIntoBlackboard(SimuLizarWorkflowConfiguration workflowConfig, ResourceSetPartition pcmResourceSet, String reconfigurationRulesFolderPath) { + final MDSDBlackboard blackboard = new MDSDBlackboard(); + blackboard.addPartition(ConstantsContainer.DEFAULT_PCM_INSTANCE_PARTITION_ID, pcmResourceSet); + final PCMPartitionManager pcmPartitionManager = new PCMPartitionManager(blackboard, workflowConfig); + pcmPartitionManager.initialize(); + return pcmPartitionManager; + } + + + private RuntimeMeasurement createResponeTimeMeasurement(final double responeTimeMeasurement) { + final MeasurementSpecification measurementSpecification = MonitorRepositoryFactory.eINSTANCE.createMeasurementSpecification(); + measurementSpecification.setId(MEASUREMENT_SPECIFICATION_ID); + measurementSpecification.setMetricDescription(MetricDescriptionConstants.RESPONSE_TIME_METRIC); + StatisticalCharacterization statisticalCharacterization = MonitorRepositoryFactory.eINSTANCE.createArithmeticMean(); + TimeDrivenAggregation timeDrivenAggregation = MonitorRepositoryFactory.eINSTANCE.createTimeDrivenAggregation(); + timeDrivenAggregation.setStatisticalCharacterization(statisticalCharacterization); + timeDrivenAggregation.setMeasurementSpecification(measurementSpecification); + timeDrivenAggregation.setWindowIncrement(10d); + timeDrivenAggregation.setWindowLength(10d); + + final RuntimeMeasurement responeTimeRuntimeMeasurement = RuntimeMeasurementFactory.eINSTANCE.createRuntimeMeasurement(); + responeTimeRuntimeMeasurement.setId(""); + responeTimeRuntimeMeasurement.setMeasuringValue(responeTimeMeasurement); + responeTimeRuntimeMeasurement.setMeasurementSpecification(measurementSpecification); + + return responeTimeRuntimeMeasurement; + } + + + private void recordRuntimeMeasurement(PCMPartitionManager pcmPartitionManager, RuntimeMeasurement responeTimeRuntimeMeasurement) { + RuntimeMeasurementModel rmModel = pcmPartitionManager.findModel(RuntimeMeasurementPackage.eINSTANCE.getRuntimeMeasurementModel()); + rmModel.getMeasurements().add(responeTimeRuntimeMeasurement); + } + + + + private void executeTransformation(SimuLizarWorkflowConfiguration wfConfig, PCMPartitionManager pcmPartitionManager, EObject monitoredElement) { + QVTOReconfigurator reconfigurator = new QVTOReconfigurator(wfConfig, pcmPartitionManager); + QVTOReconfigurationLoader reconfigurationLoader = new QVTOReconfigurationLoader(); + reconfigurationLoader.load(wfConfig); + EList> transformations = new BasicEList<>(reconfigurationLoader.getTransformations()); + boolean checkedAndExceuted = reconfigurator.runExecute(transformations, monitoredElement, resourceTableManager); + assertTrue(checkedAndExceuted, "Reconfiguration was not executed!"); + } +} \ No newline at end of file diff --git a/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/tests/SimulizarRunConfigTest.java b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/tests/SimulizarRunConfigTest.java new file mode 100644 index 000000000..e3a8d4016 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/src/org/palladiosimulator/simulizar/tests/SimulizarRunConfigTest.java @@ -0,0 +1,221 @@ +package org.palladiosimulator.simulizar.tests; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.palladiosimulator.edp2.impl.RepositoryManager; +import org.palladiosimulator.edp2.models.Repository.Repository; +import org.palladiosimulator.edp2.repository.local.LocalDirectoryRepositoryHelper; +import org.palladiosimulator.simulizar.di.component.dependency.SimEngineComponent.Factory; +import org.palladiosimulator.simulizar.di.modules.component.extensions.ExtensionComponentsModule; +import org.palladiosimulator.simulizar.di.modules.stateless.core.RootComponentFactoriesModule; +import org.palladiosimulator.simulizar.di.modules.stateless.mdsd.MDSDBlackboardProvidingModule; +import org.palladiosimulator.simulizar.launcher.SimulizarConstants; +import org.palladiosimulator.simulizar.runconfig.SimuLizarWorkflowConfiguration; +import org.palladiosimulator.simulizar.test.commons.di.components.DaggerTestSimEngineComponent; +import org.palladiosimulator.simulizar.test.commons.di.components.DaggerTestSimuLizarRootComponent; + +import de.uka.ipd.sdq.simucomframework.SimuComConfig; +import de.uka.ipd.sdq.workflow.jobs.IJob; +import tools.mdsd.junit5utils.annotations.InitializationTaskProvider; +import tools.mdsd.junit5utils.annotations.PluginTestOnly; +import tools.mdsd.junit5utils.extensions.PlatformStandaloneExtension; +import tools.mdsd.library.standalone.initialization.InitializationTask; + +@ExtendWith(PlatformStandaloneExtension.class) +public class SimulizarRunConfigTest { + + private static final String MODEL_FOLDER = "/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/"; + private static final String ALLOCATION_PATH = MODEL_FOLDER + "/server.allocation"; + private static final String USAGE_MODEL_PATH = MODEL_FOLDER + "/server.usagemodel"; + private static final String MONITOR_REPO_PATH = MODEL_FOLDER + "/monitors/server.monitorrepository"; + private static final String RECONFIGURATION_RULES_FOLDER = MODEL_FOLDER + "/rules/"; + private static final String USAGE_EVOLUTION_MODEL_PATH = MODEL_FOLDER + "/usageevolution/server.usageevolution"; + private static final String EMPTY_USAGE_EVOLUTION_MODEL_PATH = MODEL_FOLDER + + "/usageevolution/empty.usageevolution"; + private static final String SLO_REPO_PATH = MODEL_FOLDER + "/slo/server.slo"; + + private static final String PALLADIO_RESOURCETYPES_PATHMAP = "pathmap://PCM_MODELS/Palladio.resourcetype"; + private static final String PALLADIO_RESOURCETYPES_PATHMAP_TARGET = "platform:/plugin/org.palladiosimulator.pcm.resources/defaultModels/Palladio.resourcetype"; + private static final String PRIMITIVE_TYPES_REPO_PATHMAP = "pathmap://PCM_MODELS/PrimitiveTypes.repository"; + private static final String PRIMITIVE_TYPES_REPO_PATHMAP_TARGET = "platform:/plugin/org.palladiosimulator.pcm.resources/defaultModels/PrimitiveTypes.repository"; + + private SimuLizarWorkflowConfiguration simulizarConfiguration; + private IJob simulizarJob; + + private Repository repo = null; + + private static URI allocationUri; + private static URI usageModelUri; + private static URI monitorRepoUri; + private static URI reconfigurationRulesUri; + private static URI usageEvolutionModelUri; + private static URI emptyUsageEvolutionModelUri; + private static URI sloRepoUri; + + @InitializationTaskProvider + public static InitializationTask initOnStandalone() { + return () -> { + final Map uriMap = URIConverter.URI_MAP; + uriMap.put(URI.createURI(PALLADIO_RESOURCETYPES_PATHMAP), URI.createURI(PALLADIO_RESOURCETYPES_PATHMAP_TARGET)); + uriMap.put(URI.createURI(PRIMITIVE_TYPES_REPO_PATHMAP), URI.createURI(PRIMITIVE_TYPES_REPO_PATHMAP_TARGET)); + }; + } + + @BeforeAll + public static void setUpBeforeClass() { + allocationUri = URI.createPlatformPluginURI(ALLOCATION_PATH, true); + usageModelUri = URI.createPlatformPluginURI(USAGE_MODEL_PATH, true); + monitorRepoUri = URI.createPlatformPluginURI(MONITOR_REPO_PATH, true); + reconfigurationRulesUri = URI.createPlatformPluginURI(RECONFIGURATION_RULES_FOLDER, true); + usageEvolutionModelUri = URI.createPlatformPluginURI(USAGE_EVOLUTION_MODEL_PATH, true); + emptyUsageEvolutionModelUri = URI.createPlatformPluginURI(EMPTY_USAGE_EVOLUTION_MODEL_PATH, true); + sloRepoUri = URI.createPlatformPluginURI(SLO_REPO_PATH, true); + } + + @BeforeEach + public void setUp(@TempDir File localRepositoryDirectory) throws IOException { + this.repo = LocalDirectoryRepositoryHelper + .initializeLocalDirectoryRepository(localRepositoryDirectory); + RepositoryManager.addRepository(RepositoryManager.getCentralRepository(), this.repo); + + final Map properties = createSimulationProperties(); + + this.simulizarConfiguration = new SimuLizarWorkflowConfiguration(properties); + this.simulizarConfiguration.setAllocationFiles(Arrays.asList(allocationUri.toString())); + this.simulizarConfiguration.setUsageModelFile(usageModelUri.toString()); + this.simulizarConfiguration.setMonitorRepositoryFile(monitorRepoUri.toString()); + this.simulizarConfiguration.setServiceLevelObjectivesFile(SimulizarConstants.DEFAULT_SERVICELEVELOBJECTIVE_FILE); + this.simulizarConfiguration.setUsageEvolutionFile(SimulizarConstants.DEFAULT_USAGEEVOLUTION_FILE); + this.simulizarConfiguration.setSimuComConfiguration(new SimuComConfig(properties, false)); + + this.simulizarJob = DaggerTestSimuLizarRootComponent.factory() + .create(simulizarConfiguration, new RootComponentFactoriesModule() { + @Override + public Factory providesSimEngineComponentFactory() { + return DaggerTestSimEngineComponent.factory(); + } + }, new ExtensionComponentsModule(), new MDSDBlackboardProvidingModule()) + .rootJob(); + } + + @AfterEach + public void tearDown() { + RepositoryManager.removeRepository(RepositoryManager.getCentralRepository(), this.repo); + } + + @Test + public void testSuccessfulSimulationRunWithoutOptionalArguments() throws Exception { + // run the simulation with no optional arguments such as SLO file, action repo, + // reconfigurations + // the simulation should finish properly + runSuccessfulSimulation(); + } + + @Test + public void testSuccessfulSimulationRunWithSLO() throws Exception { + // run the simulation with just the service level objects defined + // the simulation should finish properly + this.simulizarConfiguration.setServiceLevelObjectivesFile(sloRepoUri.toString()); + runSuccessfulSimulation(); + } + + @Test + @PluginTestOnly + public void testSuccessfulSimulationRunWithReconfigurationFolder() throws Exception { + // run the simulation with just the reconfigurations defined + // the simulation should finish properly + this.simulizarConfiguration.setReconfigurationRulesFolder(reconfigurationRulesUri.toString()); + runSuccessfulSimulation(); + } + + @Test + public void testSuccessfulSimulationRunWithEmptyReconfigurationFolder(@TempDir File emptyRulesFolder) throws Exception { + URI emptyRulesURI = URI.createFileURI(emptyRulesFolder.toPath().normalize().toAbsolutePath().toString()); + this.simulizarConfiguration + .setReconfigurationRulesFolder(emptyRulesURI.toString()); + runSuccessfulSimulation(); + } + + @Test + public void testSuccessfulSimulationRunWithUsageEvolution() throws Exception { + // run the simulation with just the usage evolution defined + // the simulation should finish properly + this.simulizarConfiguration.setUsageEvolutionFile(usageEvolutionModelUri.toString()); + runSuccessfulSimulation(); + } + + @Test + public void testSuccessfulSimulationRunWithUsageEvolutionNoParamEvolution() throws Exception { + // run the simulation with just an empty usage evolution defined + // the simulation should finish properly + this.simulizarConfiguration.setUsageEvolutionFile(emptyUsageEvolutionModelUri.toString()); + runSuccessfulSimulation(); + } + + @Test + public void testSuccessfulSimulationRunWithMonitorRepository() throws Exception { + // run the simulation with just the monitors defined + // the simulation should finish properly + this.simulizarConfiguration.setMonitorRepositoryFile(monitorRepoUri.toString()); + runSuccessfulSimulation(); + } + + @Test + @PluginTestOnly + public void testSuccessfulSimulationRunWithMonitorRepositoryAndReconfigurationFolder() throws Exception { + this.simulizarConfiguration.setReconfigurationRulesFolder(reconfigurationRulesUri.toString()); + this.simulizarConfiguration.setMonitorRepositoryFile(monitorRepoUri.toString()); + runSuccessfulSimulation(); + } + + private Map createSimulationProperties() { + final Map properties = new HashMap<>(); + + properties.put(SimuComConfig.SIMULATE_FAILURES, false); + properties.put(SimuComConfig.SIMULATE_LINKING_RESOURCES, false); + properties.put(SimuComConfig.USE_FIXED_SEED, false); + properties.put(SimuComConfig.PERSISTENCE_RECORDER_NAME, + org.palladiosimulator.recorderframework.edp2.Activator.EDP2_ID); + properties.put("EDP2RepositoryID", this.repo.getId()); + properties.put(SimuComConfig.SIMULATOR_ID, "de.uka.ipd.sdq.codegen.simucontroller.simulizar"); + properties.put(SimuComConfig.EXPERIMENT_RUN, SimuComConfig.DEFAULT_EXPERIMENT_RUN); + properties.put(SimuComConfig.SIMULATION_TIME, "2000"); + properties.put(SimuComConfig.MAXIMUM_MEASUREMENT_COUNT, SimuComConfig.DEFAULT_MAXIMUM_MEASUREMENT_COUNT); + properties.put(SimuComConfig.VERBOSE_LOGGING, true); + properties.put(SimuComConfig.VARIATION_ID, SimuComConfig.DEFAULT_VARIATION_NAME); + properties.put(SimulizarConstants.RECONFIGURATION_RULES_FOLDER, + SimulizarConstants.DEFAULT_RECONFIGURATION_RULES_FOLDER); + properties.put("de.uka.ipd.sdq.workflowengine.debuglevel", "1"); // Log level DEBUG + + return properties; + } + + private void runSuccessfulSimulation() throws Exception { + final IProgressMonitor progressMonitor = new NullProgressMonitor(); + this.simulizarJob.execute(progressMonitor); + } + + private static String stacktraceToString(final Throwable exception) { + final StringBuilder result = new StringBuilder(); + if (exception.getStackTrace() != null) { + for (final StackTraceElement element : exception.getStackTrace()) { + result.append(element.toString() + "\n"); + } + } + return result.toString().trim(); + } +} diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/.project b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/.project new file mode 100644 index 000000000..92b4e48c4 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/.project @@ -0,0 +1,12 @@ + + + entry-level-system-call-return-testmodel + + + + + + + org.eclipse.sirius.nature.modelingproject + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.allocation b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.allocation new file mode 100644 index 000000000..dc476dd86 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.allocation @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.measuringpoint b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.measuringpoint new file mode 100644 index 000000000..eed58a1e5 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.measuringpoint @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.monitorrepository b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.monitorrepository new file mode 100644 index 000000000..162d3df7c --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.monitorrepository @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.repository b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.repository new file mode 100644 index 000000000..3442ced63 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.repository @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.resourceenvironment b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.resourceenvironment new file mode 100644 index 000000000..12c9c66f0 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.resourceenvironment @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.slo b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.slo new file mode 100644 index 000000000..6e4b21062 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.slo @@ -0,0 +1,2 @@ + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.system b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.system new file mode 100644 index 000000000..ef2807eea --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.system @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.usagemodel b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.usagemodel new file mode 100644 index 000000000..fdfe289b8 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/default.usagemodel @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/representations.aird b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/representations.aird new file mode 100644 index 000000000..26fa93a58 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/entry-level-system-call-return-testmodel/representations.aird @@ -0,0 +1,1583 @@ + + + + pathmap://PCM_MODELS/Palladio.resourcetype + default.allocation + default.system + default.repository + default.usagemodel + pathmap://PCM_MODELS/FailureTypes.repository + pathmap://PCM_MODELS/PrimitiveTypes.repository + default.monitorrepository + default.measuringpoint + default.slo + pathmap://METRIC_SPEC_MODELS/models/commonMetrics.metricspec + default.resourceenvironment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/My.resourceenvironment b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/My.resourceenvironment new file mode 100644 index 000000000..6a4ca4ad3 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/My.resourceenvironment @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.allocation b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.allocation new file mode 100644 index 000000000..38c81fd43 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.allocation @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.measuringpoint b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.measuringpoint new file mode 100644 index 000000000..907e098ed --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.measuringpoint @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.monitorrepository b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.monitorrepository new file mode 100644 index 000000000..75ddcd258 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.monitorrepository @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.repository b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.repository new file mode 100644 index 000000000..36f3f24e3 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.repository @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.system b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.system new file mode 100644 index 000000000..e855e7dc9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.system @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.usagemodel b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.usagemodel new file mode 100644 index 000000000..627c87fea --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/default.usagemodel @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/reconfigs/adapt.qvto b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/reconfigs/adapt.qvto new file mode 100644 index 000000000..97c5e8705 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/reconfiguration/reconfigs/adapt.qvto @@ -0,0 +1,36 @@ + +modeltype RUNTIMEMEASUREMENT uses 'http://simulizar.palladiosimulator.org/RuntimeMeasurement/1.0'; +modeltype PCM_REP uses 'http://palladiosimulator.org/PalladioComponentModel/Repository/5.2'; +modeltype PCM_SEFF uses 'http://palladiosimulator.org/PalladioComponentModel/SEFF/5.2'; +modeltype PCM_CORE uses 'http://palladiosimulator.org/PalladioComponentModel/Core/5.2'; +modeltype PCM_ENTITY uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Entity/5.2'; +modeltype PCM_STOEX uses 'http://sdq.ipd.uka.de/StochasticExpressions/2.2'; + +transformation incrementForTest(in runtimeMeasurement : RUNTIMEMEASUREMENT, + inout pcmRepository : PCM_REP) { + + /** + * The main transformation. + * This is the entry point to the overall transformation. + */ + main() { + + log('SimuLizar Increment Demand'); + pcmRepository.rootObjects()[Repository]->forEach(repo) { + var demand = repo.getDemandToAdapt(); + if (not demand.oclIsUndefined()) { + demand.specification := demand.specification + " + 1"; + } + } + } + + query Repository::getDemandToAdapt(): RandomVariable { + return self.components__Repository[BasicComponent] + .serviceEffectSpecifications__BasicComponent[ResourceDemandingSEFF] + .steps_Behaviour[InternalAction]->any(entityName = "InternalActionWhichShouldBeAdapted") + .resourceDemand_Action->any(true) + .specification_ParametericResourceDemand; + } + + +} \ No newline at end of file diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/monitors/server.measuringpoint b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/monitors/server.measuringpoint new file mode 100644 index 000000000..937f15f21 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/monitors/server.measuringpoint @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/monitors/server.monitorrepository b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/monitors/server.monitorrepository new file mode 100644 index 000000000..1a740ae4a --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/monitors/server.monitorrepository @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addClonedServer/addClonedServer.qvto b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addClonedServer/addClonedServer.qvto new file mode 100644 index 000000000..1b8d3ffda --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addClonedServer/addClonedServer.qvto @@ -0,0 +1,168 @@ +/* + * This simple QVTO SimuLizar reconfiguration rule clones the existing server and adds it + * as a provider of the interface required by the client. + * + */ + +/* + * Two modeltypes are declared. The http NS URIs correspond to those used to register the + * Ecore models in the environment. Alternatively, a workspace metamodel may be used + * in conjunction with mappings defined in the project properties. + */ +modeltype RUNTIMEMEASUREMENT uses 'http://simulizar.palladiosimulator.org/RuntimeMeasurement/1.0'; +modeltype PCM_ALLOC uses 'http://palladiosimulator.org/PalladioComponentModel/Allocation/5.2'; +modeltype PCM_REP uses 'http://palladiosimulator.org/PalladioComponentModel/Repository/5.2'; +modeltype PCM_SEFF uses 'http://palladiosimulator.org/PalladioComponentModel/SEFF/5.2'; +modeltype PCM_SYS uses 'http://palladiosimulator.org/PalladioComponentModel/System/5.2'; +modeltype PCM_RES_ENV uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceEnvironment/5.2'; +modeltype PCM_RES_TYPE uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceType/5.2'; +modeltype PCM_USAGE uses 'http://palladiosimulator.org/PalladioComponentModel/UsageModel/5.2'; +modeltype PCM_FEATURE_CONF uses 'http://sdq.ipd.uka.de/FeatureConfig/2.0'; +modeltype PCM_FEATURE_MOD uses 'http://sdq.ipd.uka.de/FeatureModel/2.0'; +modeltype PCM_CORE uses 'http://palladiosimulator.org/PalladioComponentModel/Core/5.2'; +modeltype PCM_COMP uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Composition/5.2'; +modeltype PCM_ENTITY uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Entity/5.2'; +modeltype PCM_PARAM uses 'http://palladiosimulator.org/PalladioComponentModel/Parameter/5.2'; +modeltype PCM_STOEX uses 'http://sdq.ipd.uka.de/StochasticExpressions/2.2'; + +/* + * The transformation signature declares that a PRM modeltype is required as input, while a PCM + * modeltype is transformed inplace. The PRM modeltype is referenced as 'prm' throughout the + * transformation definition, while no name is needed for the output PCM modeltype. Note that OCL + * type and namespace notation are used in operational QVT (: and :: respectively). + */ +transformation addClonedServer(in runtimeMeasurement : RUNTIMEMEASUREMENT, + in pcmAllocation : PCM_ALLOC) { + + + /* + * Defines when the transformation is going to occur. + */ + property threshold : Real = 3.0; + + /** + * The main transformation. + * This is the entry point to the overall transformation. + */ + main() { + + + log('SimuLizar addClonedServer Rule Transformation started'); + + assert fatal(runtimeMeasurement.rootObjects()[RuntimeMeasurement]->size() > 0) + with log ("No Measurements found!"); + + assert fatal(pcmAllocation.rootObjects()[Allocation]->size() > 0) + with log ("Allocation Model is empty!"); + + var runtimeMeasurements = runtimeMeasurement.rootObjects()[RuntimeMeasurement]; + + var allocations = pcmAllocation.rootObjects()![Allocation]; + + /* + * Add a server if one of the measurements is over the threshold. + */ + runtimeMeasurements->forEach(measurement){ + if(measurement.measuringValue > threshold){ + allocations->forEach(allocation){ + addDuplicatedServer(allocation); + }; + } + } + } + + /* + * Adds a server. + * @param allocation PCM model which is to be transformed. + */ + helper addDuplicatedServer(allocation : Allocation){ + /* + * Elements needed for creating a connection (AssemblyConnector) between the Client and + * the Server to be added. + */ + var requiringAssemblyContext : AssemblyContext = null; + var requiredRole : OperationRequiredRole = null; + var providingAssemblyContext : AssemblyContext = null; + var providedRole : OperationProvidedRole = null; + + /* + * Traversing the PCM model ... + * Current state: + * (Left side) Client - RequiredRole --- AssemblyConnector --- ProvidedRole - Server1 (Right side) + * + * The state after the transformation: + * RequiredRole --- AssemblyConnector --- ProvidedRole - Server1 (Right side) + * / + * (Left side) Client + * \ + * RequiredRole --- AssemblyConnector --- ProvidedRole - Server1 (Right side) + */ + allocation.allocationContexts_Allocation->forEach(allocationContext) { + + // Find the "Client" (AllocationContext) defined in the .allocation diagram. + if(allocationContext.assemblyContext_AllocationContext.entityName = "Client"){ + // Left side of the AssemblyConnector (Client). + requiringAssemblyContext := allocationContext.assemblyContext_AllocationContext; + + /* + * Get to the RequiredRole of the Client. + * All the roles are contained in the Client's underlying RepositoryComponent. + */ + var repositoryComponentClient : RepositoryComponent = requiringAssemblyContext.encapsulatedComponent__AssemblyContext; + var clientAllRequiredRoles : Bag(OperationRequiredRole) = repositoryComponentClient.requiredRoles_InterfaceRequiringEntity.oclAsType(OperationRequiredRole); + clientAllRequiredRoles->forEach(operationRequiredRole){ + // RequiredRole on the left side of the AssemblyConnector. + if(operationRequiredRole.entityName = "Required_process_client2"){ + requiredRole := operationRequiredRole; + }; + } + }; + + // Find the "Server1" (AllocationContext) defined in the .allocation diagram. The one to be copied. + if(allocationContext.assemblyContext_AllocationContext.entityName = "Server_1"){ + // Right side of the AssemblyConnector (Server1). + var serverToCopyAssemblyContext : AssemblyContext = allocationContext.assemblyContext_AllocationContext; + var serverToCopyRepositoryComponent : RepositoryComponent = serverToCopyAssemblyContext.encapsulatedComponent__AssemblyContext; + providingAssemblyContext := new AssemblyContext(serverToCopyRepositoryComponent); + + /* + * Get to the ProvidedRole of the Server1. + * All the roles are contained in the Server1's underlying RepositoryComponent. + */ + var serverAllProvidedRoles : Bag(OperationProvidedRole) = serverToCopyRepositoryComponent.providedRoles_InterfaceProvidingEntity.oclAsType(OperationProvidedRole); + serverAllProvidedRoles->forEach(operationProvidedRole){ + // ProvidedRole on the right side of the AssemblyConnector. + if(operationProvidedRole.entityName = "Provided_process_server_1"){ + providedRole := operationProvidedRole; + }; + } + }; + + // Finally, creating the AssemblyConnector once all the necessary elements are cloned and collected. + if(providingAssemblyContext <> null and requiringAssemblyContext <> null){ + new AssemblyConnector(requiringAssemblyContext, requiredRole, providedRole, providingAssemblyContext); + } + } + }; + + constructor AssemblyConnector :: AssemblyConnector(requiringAssemblyContext : AssemblyContext,requiredRole:OperationRequiredRole, providedRole: OperationProvidedRole, providingAssemblyContext : AssemblyContext){ + log ('Start of assemblyConnector creation'); + var allocation : Allocation := pcmAllocation.rootObjects()![Allocation]; + var system : System := allocation.system_Allocation![System]; + entityName := requiringAssemblyContext.entityName + "_" + providingAssemblyContext.entityName; + //id := requiringAssemblyContext.id + "_" + providingAssemblyContext.id; + providingAssemblyContext_AssemblyConnector := providingAssemblyContext; + requiringAssemblyContext_AssemblyConnector := requiringAssemblyContext; + providedRole_AssemblyConnector := providedRole; + requiredRole_AssemblyConnector := requiredRole; + parentStructure__Connector := system; + } + + constructor AssemblyContext :: AssemblyContext(bc : RepositoryComponent) { + entityName := "Assembly_"+bc.entityName; + encapsulatedComponent__AssemblyContext := bc; + var allocation : Allocation := pcmAllocation.rootObjects()![Allocation]; + var system : System := allocation.system_Allocation![System]; + parentStructure__AssemblyContext := system; + } +} \ No newline at end of file diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addNewServer/addNewServer.qvto b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addNewServer/addNewServer.qvto new file mode 100644 index 000000000..eb5dc99dc --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/addNewServer/addNewServer.qvto @@ -0,0 +1,197 @@ +/* + * This simple QVTO SimuLizar reconfiguration rule creates a new server and adds it + * as a provider of the interface required by the client. + * + */ + +/* + * Two modeltypes are declared. The http NS URIs correspond to those used to register the + * Ecore models in the environment. Alternatively, a workspace metamodel may be used + * in conjunction with mappings defined in the project properties. + */ +modeltype RUNTIMEMEASUREMENT uses 'http://simulizar.palladiosimulator.org/RuntimeMeasurement/1.0'; +modeltype PCM_ALLOC uses 'http://palladiosimulator.org/PalladioComponentModel/Allocation/5.2'; +modeltype PCM_REP uses 'http://palladiosimulator.org/PalladioComponentModel/Repository/5.2'; +modeltype PCM_SEFF uses 'http://palladiosimulator.org/PalladioComponentModel/SEFF/5.2'; +modeltype PCM_SYS uses 'http://palladiosimulator.org/PalladioComponentModel/System/5.2'; +modeltype PCM_RES_ENV uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceEnvironment/5.2'; +modeltype PCM_RES_TYPE uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceType/5.2'; +modeltype PCM_USAGE uses 'http://palladiosimulator.org/PalladioComponentModel/UsageModel/5.2'; +modeltype PCM_FEATURE_CONF uses 'http://sdq.ipd.uka.de/FeatureConfig/2.0'; +modeltype PCM_FEATURE_MOD uses 'http://sdq.ipd.uka.de/FeatureModel/2.0'; +modeltype PCM_CORE uses 'http://palladiosimulator.org/PalladioComponentModel/Core/5.2'; +modeltype PCM_COMP uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Composition/5.2'; +modeltype PCM_ENTITY uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Entity/5.2'; +modeltype PCM_PARAM uses 'http://palladiosimulator.org/PalladioComponentModel/Parameter/5.2'; +modeltype PCM_STOEX uses 'http://sdq.ipd.uka.de/StochasticExpressions/2.2'; + +/* + * The transformation signature declares that a PRM modeltype is required as input, while a PCM + * modeltype is transformed inplace. The PRM modeltype is referenced as 'prm' throughout the + * transformation definition, while no name is needed for the output PCM modeltype. Note that OCL + * type and namespace notation are used in operational QVT (: and :: respectively). + */ +transformation addNewServer(in runtimeMeasurement : RUNTIMEMEASUREMENT, + in pcmAllocation : PCM_ALLOC) { + + + /* + * Defines when the transformation is going to occur. + */ + property threshold : Real = 3.0; + + /** + * The main transformation. + * This is the entry point to the overall transformation. + */ + main() { + + + log('SimuLizar addServer Rule Transformation started'); + + assert fatal(runtimeMeasurement.rootObjects()[RuntimeMeasurement]->size() > 0) + with log ("No Measurements found!"); + + assert fatal(pcmAllocation.rootObjects()[Allocation]->size() > 0) + with log ("Allocation Model is empty!"); + + var runtimeMeasurements = runtimeMeasurement.rootObjects()[RuntimeMeasurement]; + + var allocations = pcmAllocation.rootObjects()![Allocation]; + + /* + * Add a server if one of the measurements is over the threshold. + */ + runtimeMeasurements->forEach(measurement){ + if(measurement.measuringValue > threshold){ + allocations->forEach(allocation){ + addServer(allocation); + }; + } + } + } + + /* + * Adds a server. + * @param allocation PCM model which is to be transformed. + */ + helper addServer(allocation : Allocation) { + /* + * Elements needed for creating a connection (AssemblyConnector) between the Client and + * the Server to be added. + */ + var requiringAssemblyContext : AssemblyContext = null; + var requiredRole : OperationRequiredRole = null; + var providingAssemblyContext : AssemblyContext = null; + var providedRole : OperationProvidedRole = null; + + /* + * Traversing the PCM model ... + * Current state: + * (Left side) Client - RequiredRole --- AssemblyConnector --- ProvidedRole - Server1 (Right side) + * + * The state after the transformation: + * RequiredRole --- AssemblyConnector --- ProvidedRole - Server1 (Right side) + * / + * (Left side) Client + * \ + * RequiredRole --- AssemblyConnector --- ProvidedRole - Server2 (Right side) + */ + log('addNewServer: Iterating over the allocation contexts'); + allocation.allocationContexts_Allocation->forEach(allocationContext){ + log('addNewServer: Examining AssemblyContext: ' + allocationContext.assemblyContext_AllocationContext.entityName); + // Find the "Client" (AllocationContext) defined in the .allocation diagram. + if(allocationContext.assemblyContext_AllocationContext.entityName = "Client") { + log('addNewServer: Found AssemblyContext: Client'); + // Left side of the AssemblyConnector (Client). + requiringAssemblyContext := allocationContext.assemblyContext_AllocationContext; + + /* + * Get to the RequiredRole of the Client. + * All the roles are contained in the Client's underlying RepositoryComponent. + */ + var repositoryComponentClient : RepositoryComponent = requiringAssemblyContext.encapsulatedComponent__AssemblyContext; + var clientAllRequiredRoles : Bag(OperationRequiredRole) = repositoryComponentClient.requiredRoles_InterfaceRequiringEntity.oclAsType(OperationRequiredRole); + clientAllRequiredRoles->forEach(operationRequiredRole) { + // RequiredRole on the left side of the AssemblyConnector. + if(operationRequiredRole.entityName = "Required_process_client2"){ + log('addNewServer: Found the Client\'s required role: Required_process_client2'); + requiredRole := operationRequiredRole; + }; + }; + + /* + * Navigate to the repository in order to find the RepositoryComponent for the Server2. + * Use that RepositoryComponent to create a new AssemblyContext for the Server2. + */ + var r : Repository = repositoryComponentClient.repository__RepositoryComponent; + r.components__Repository->forEach(repositoryComponent){ + + if(repositoryComponent.entityName = "server2"){ + log('addNewServer: Found repository component for Server2: server2'); + // Right side of the AssemblyConnector (Server2). + providingAssemblyContext := new AssemblyContext(repositoryComponent); + log('addNewServer: Created AssemblyContext for Server2'); + + /* + * Get to the ProvidedRole of the Server2. + * All the roles are contained in the Server2's underlying RepositoryComponent. + */ + var serverAllProvidedRoles : Bag(OperationProvidedRole) = repositoryComponent.providedRoles_InterfaceProvidingEntity.oclAsType(OperationProvidedRole); + serverAllProvidedRoles->forEach(operationProvidedRole) { + // ProvidedRole on the right side of the AssemblyConnector. + if(operationProvidedRole.entityName = "Provided_process_server_2"){ + log('addNewServer: Found the Server2\'s provided role: Provided_process_server_2'); + providedRole := operationProvidedRole; + }; + } + } + } + }; + + if(requiringAssemblyContext <> null){ + log('addNewServer: requiringAssemblyContext'); + }; + if(requiredRole <> null){ + log('addNewServer: requiredRole'); + }; + if(providingAssemblyContext <> null){ + log('addNewServer: providingAssemblyContext'); + }; + if(providedRole <> null){ + log('addNewServer: providedRole'); + }; + // Finally, creating the AssemblyConnector once all the necessary elements are collected and created. + if(providingAssemblyContext <> null and requiringAssemblyContext <> null){ + log('addNewServer: Connecting the newly created AssemblyContext for Server2'); + new AssemblyConnector(requiringAssemblyContext, requiredRole, providedRole, providingAssemblyContext); + // Reseting the values for new iteration + requiringAssemblyContext := null; + requiredRole := null; + providingAssemblyContext := null; + providedRole := null; + } + } + }; + + constructor AssemblyConnector :: AssemblyConnector(requiringAssemblyContext : AssemblyContext,requiredRole:OperationRequiredRole, providedRole: OperationProvidedRole, providingAssemblyContext : AssemblyContext){ + log ('Start of assemblyConnector creation'); + var allocation : Allocation := pcmAllocation.rootObjects()![Allocation]; + var system : System := allocation.system_Allocation![System]; + entityName := requiringAssemblyContext.entityName + "_" + providingAssemblyContext.entityName; + //id := requiringAssemblyContext.id + "_" + providingAssemblyContext.id; + providingAssemblyContext_AssemblyConnector := providingAssemblyContext; + requiringAssemblyContext_AssemblyConnector := requiringAssemblyContext; + providedRole_AssemblyConnector := providedRole; + requiredRole_AssemblyConnector := requiredRole; + parentStructure__Connector := system; + } + + constructor AssemblyContext :: AssemblyContext(bc : RepositoryComponent) { + entityName := "Assembly_"+bc.entityName; + encapsulatedComponent__AssemblyContext := bc; + var allocation : Allocation := pcmAllocation.rootObjects()![Allocation]; + var system : System := allocation.system_Allocation![System]; + parentStructure__AssemblyContext := system; + } +} \ No newline at end of file diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/outsource/outsource.qvto b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/outsource/outsource.qvto new file mode 100644 index 000000000..4cd32de86 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/outsource/outsource.qvto @@ -0,0 +1,108 @@ +/* + * This simple QVTO SimuLizar reconfiguration rule forwards more requests to the second branch + * by increasing its BranchProbability. + * + */ + +/* + * Two modeltypes are declared. The http NS URIs correspond to those used to register the + * Ecore models in the environment. Alternatively, a workspace metamodel may be used + * in conjunction with mappings defined in the project properties. + */ +modeltype RUNTIMEMEASUREMENT uses 'http://simulizar.palladiosimulator.org/RuntimeMeasurement/1.0'; +modeltype PCM_ALLOC uses 'http://palladiosimulator.org/PalladioComponentModel/Allocation/5.2'; +modeltype PCM_REP uses 'http://palladiosimulator.org/PalladioComponentModel/Repository/5.2'; +modeltype PCM_SEFF uses 'http://palladiosimulator.org/PalladioComponentModel/SEFF/5.2'; +modeltype PCM_SYS uses 'http://palladiosimulator.org/PalladioComponentModel/System/5.2'; +modeltype PCM_RES_ENV uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceEnvironment/5.2'; +modeltype PCM_RES_TYPE uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceType/5.2'; +modeltype PCM_USAGE uses 'http://palladiosimulator.org/PalladioComponentModel/UsageModel/5.2'; +modeltype PCM_FEATURE_CONF uses 'http://sdq.ipd.uka.de/FeatureConfig/2.0'; +modeltype PCM_FEATURE_MOD uses 'http://sdq.ipd.uka.de/FeatureModel/2.0'; +modeltype PCM_CORE uses 'http://palladiosimulator.org/PalladioComponentModel/Core/5.2'; +modeltype PCM_COMP uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Composition/5.2'; +modeltype PCM_ENTITY uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Entity/5.2'; +modeltype PCM_PARAM uses 'http://palladiosimulator.org/PalladioComponentModel/Parameter/5.2'; +modeltype PCM_STOEX uses 'http://sdq.ipd.uka.de/StochasticExpressions/2.2'; + +/* + * The transformation signature declares that a PRM modeltype is required as input, while a PCM + * modeltype is transformed inplace. The PRM modeltype is referenced as 'prm' throughout the + * transformation definition, while no name is needed for the output PCM modeltype. Note that OCL + * type and namespace notation are used in operational QVT (: and :: respectively). + */ +transformation outsource(in runtimeMeasurement : RUNTIMEMEASUREMENT, + in pcmAllocation : PCM_ALLOC) { + + + /* + * Defines when the transformation is going to occur + * and by how much the probability is going to be increased. + */ + property threshold : Real = 3.0; + property outsourceFactor = 0.1; + + /** + * The main transformation. + * This is the entry point to the overall transformation. + */ + main() { + log('SimuLizar outsource Rule Transformation started'); + + assert fatal(runtimeMeasurement.rootObjects()[RuntimeMeasurement]->size() > 0) + with log ("No Measurements found!"); + + assert fatal(pcmAllocation.rootObjects()[Allocation]->size() > 0) + with log ("Allocation Model is empty!"); + + var runtimeMeasurements = runtimeMeasurement.rootObjects()[RuntimeMeasurement]; + + var allocations = pcmAllocation.rootObjects()[Allocation]; + + /* + * Increase the branch probability if one of the measurements is over the threshold. + */ + runtimeMeasurements->forEach(measurement){ + if(measurement.measuringValue > threshold){ + allocations->forEach(allocation){ + increaseBranchProbability(allocation); + }; + } + } + } + + /* + * Increase the branch probability. + * @param allocation PCM model which is to be transformed. + */ + helper increaseBranchProbability(allocation : Allocation){ + /* + * Traversing the PCM model ... + */ + allocation.allocationContexts_Allocation->forEach(allocationContext){ + + /* + * We are interested only in AssemblyContexts with the name "Server_1" + * because that is where the branch is. + */ + if(allocationContext.assemblyContext_AllocationContext.entityName = "Server_1"){ + // Get to the SEFF where the branch is. + var assemblyContext : AssemblyContext = allocationContext.assemblyContext_AllocationContext; + var seffs = assemblyContext. + encapsulatedComponent__AssemblyContext.oclAsType(BasicComponent). + serviceEffectSpecifications__BasicComponent; + + seffs->forEach(seff){ + if(seff.oclIsTypeOf(ResourceDemandingSEFF)){ + /* + * Search all objects within the RDSEFF to find the ProbabilisticBranchTransition "branch2". + * Change its probability. + */ + var branch2 : ProbabilisticBranchTransition = seff.allSubobjects()[ProbabilisticBranchTransition]->any(entityName="branch2"); + branch2.branchProbability := branch2.branchProbability + outsourceFactor; + } + } + } + }; + } +} \ No newline at end of file diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/scaleUp/scaleUp.qvto b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/scaleUp/scaleUp.qvto new file mode 100644 index 000000000..2f0444721 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/rules/scaleUp/scaleUp.qvto @@ -0,0 +1,103 @@ +/* + * This simple QVTO SimuLizar reconfiguration rule increases the processing rate of all + * resources in case the monitored mean response time is greater than 3.0 (seconds). + * + */ + +/* + * Two modeltypes are declared. The http NS URIs correspond to those used to register the + * Ecore models in the environment. Alternatively, a workspace metamodel may be used + * in conjunction with mappings defined in the project properties. + */ +modeltype RUNTIMEMEASUREMENT uses 'http://simulizar.palladiosimulator.org/RuntimeMeasurement/1.0'; +modeltype PCM_ALLOC uses 'http://palladiosimulator.org/PalladioComponentModel/Allocation/5.2'; +modeltype PCM_REP uses 'http://palladiosimulator.org/PalladioComponentModel/Repository/5.2'; +modeltype PCM_SEFF uses 'http://palladiosimulator.org/PalladioComponentModel/SEFF/5.2'; +modeltype PCM_SYS uses 'http://palladiosimulator.org/PalladioComponentModel/System/5.2'; +modeltype PCM_RES_ENV uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceEnvironment/5.2'; +modeltype PCM_RES_TYPE uses 'http://palladiosimulator.org/PalladioComponentModel/ResourceType/5.2'; +modeltype PCM_USAGE uses 'http://palladiosimulator.org/PalladioComponentModel/UsageModel/5.2'; +modeltype PCM_FEATURE_CONF uses 'http://sdq.ipd.uka.de/FeatureConfig/2.0'; +modeltype PCM_FEATURE_MOD uses 'http://sdq.ipd.uka.de/FeatureModel/2.0'; +modeltype PCM_CORE uses 'http://palladiosimulator.org/PalladioComponentModel/Core/5.2'; +modeltype PCM_COMP uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Composition/5.2'; +modeltype PCM_ENTITY uses 'http://palladiosimulator.org/PalladioComponentModel/Core/Entity/5.2'; +modeltype PCM_PARAM uses 'http://palladiosimulator.org/PalladioComponentModel/Parameter/5.2'; +modeltype PCM_STOEX uses 'http://sdq.ipd.uka.de/StochasticExpressions/2.2'; + +/* + * The transformation signature declares that a PRM modeltype is required as input, while an PCM + * modeltype is transformed inplace. The PRM modeltype is referenced as 'prm' throughout the + * transformation definition, while no name is needed for the output PCM modeltype. Note that OCL + * type and namespace notation are used in operational QVT (: and :: respectively). + */ +transformation scaleUp(in runtimeMeasurement : RUNTIMEMEASUREMENT, + in pcmAllocation : PCM_ALLOC) { + + + /* + * Defines when the transformation is going to occur + * and by how much the processing rate is going to be increased. + */ + property scaleAmount = 100; + property threshold : Real = 3.0; + + /** + * The main transformation. + * This is the entry point to the overall transformation. + */ + main() { + + + log('SimuLizar scaleUp Rule Transformation started'); + + assert fatal(runtimeMeasurement.rootObjects()[RuntimeMeasurement]->size() > 0) + with log ("No Measurements found!"); + + assert fatal(pcmAllocation.rootObjects()[Allocation]->size() > 0) + with log ("Allocation Model is empty!"); + + var runtimeMeasurements = runtimeMeasurement.rootObjects()[RuntimeMeasurement]; + + var allocations = pcmAllocation.rootObjects()[Allocation]; + + /* + * Increase the branch probability if one of the measurements is over the threshold. + */ + runtimeMeasurements->forEach(measurement){ + if(measurement.measuringValue > threshold){ + allocations->forEach(allocation){ + scaleUpProcessingResources(allocation.targetResourceEnvironment_Allocation); + }; + } + } + } + + /* + * Increase the processing rate. + * @param allocation PCM model which is to be transformed. + */ + helper scaleUpProcessingResources(resourceEnvironment : ResourceEnvironment) { + // Traverse all ResourceContainers. + resourceEnvironment.resourceContainer_ResourceEnvironment->forEach(resourceContainer){ + scaleUpResourceContainer(resourceContainer); + } + } + + helper scaleUpResourceContainer(resourceContainer : ResourceContainer) { + // Only the processing rate of the ResourceContainer named "server" is increased. + if(resourceContainer.entityName = "server") { + resourceContainer.activeResourceSpecifications_ResourceContainer->forEach(processingResourceSpecification){ + // performing the actual increase. + var currentProcessingRate : String := processingResourceSpecification.processingRate_ProcessingResourceSpecification.specification; + var newProcessingRate : Real := currentProcessingRate.toReal() + scaleAmount; + processingResourceSpecification.processingRate_ProcessingResourceSpecification.specification := newProcessingRate.toString(); + } + }; + + // Recursive call in case this ResourceContainer contains other ResourceContainers. + resourceContainer.nestedResourceContainers__ResourceContainer->forEach(nestedResourceContainer){ + scaleUpResourceContainer(nestedResourceContainer); + }; + } +} \ No newline at end of file diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.allocation b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.allocation new file mode 100644 index 000000000..0203a2fc3 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.allocation @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.repository b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.repository new file mode 100644 index 000000000..248e72320 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.repository @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.resourceenvironment b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.resourceenvironment new file mode 100644 index 000000000..301552602 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.resourceenvironment @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.system b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.system new file mode 100644 index 000000000..330483cc6 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.system @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.usagemodel b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.usagemodel new file mode 100644 index 000000000..af3c8b559 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/server.usagemodel @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/slo/server.slo b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/slo/server.slo new file mode 100644 index 000000000..9aaa49fa8 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/slo/server.slo @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/OneYearTrend.dlim b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/OneYearTrend.dlim new file mode 100644 index 000000000..ffbdcf8bf --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/OneYearTrend.dlim @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/empty.usageevolution b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/empty.usageevolution new file mode 100644 index 000000000..4e7dd1c7f --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/empty.usageevolution @@ -0,0 +1,2 @@ + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/server.usageevolution b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/server.usageevolution new file mode 100644 index 000000000..1ce10d49a --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/runconfigtest/usageevolution/server.usageevolution @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/.project b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/.project new file mode 100644 index 000000000..099d9c638 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/.project @@ -0,0 +1,12 @@ + + + simulizar111 + + + + + + + org.eclipse.sirius.nature.modelingproject + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/My.resourceenvironment b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/My.resourceenvironment new file mode 100644 index 000000000..eb24cfc28 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/My.resourceenvironment @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.allocation b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.allocation new file mode 100644 index 000000000..08f23bfe9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.allocation @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.measuringpoint b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.measuringpoint new file mode 100644 index 000000000..1e2a801f6 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.measuringpoint @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.monitorrepository b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.monitorrepository new file mode 100644 index 000000000..60afe991d --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.monitorrepository @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.repository b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.repository new file mode 100644 index 000000000..7f9f885c9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.repository @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.system b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.system new file mode 100644 index 000000000..155a1d693 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.system @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.usagemodel b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.usagemodel new file mode 100644 index 000000000..c99c067bd --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/default.usagemodel @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/representations.aird b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/representations.aird new file mode 100644 index 000000000..25a9d4b06 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar111/representations.aird @@ -0,0 +1,2896 @@ + + + + My.resourceenvironment + pathmap://PCM_MODELS/Palladio.resourcetype + default.allocation + default.system + default.repository + default.measuringpoint + default.usagemodel + default.monitorrepository + pathmap://METRIC_SPEC_MODELS/commonMetrics.metricspec + pathmap://PCM_MODELS/PrimitiveTypes.repository + pathmap://PCM_MODELS/FailureTypes.repository + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/My.resourceenvironment b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/My.resourceenvironment new file mode 100644 index 000000000..689f1d31c --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/My.resourceenvironment @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.allocation b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.allocation new file mode 100644 index 000000000..38c81fd43 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.allocation @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.measuringpoint b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.measuringpoint new file mode 100644 index 000000000..907e098ed --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.measuringpoint @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.monitorrepository b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.monitorrepository new file mode 100644 index 000000000..750e1ccf8 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.monitorrepository @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.repository b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.repository new file mode 100644 index 000000000..6844ec470 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.repository @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.system b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.system new file mode 100644 index 000000000..e855e7dc9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.system @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.usagemodel b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.usagemodel new file mode 100644 index 000000000..c99c067bd --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/simulizar154/default.usagemodel @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/.project b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/.project new file mode 100644 index 000000000..1ad305e58 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/.project @@ -0,0 +1,12 @@ + + + usageevolutionTest + + + + + + + org.eclipse.sirius.nature.modelingproject + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/My.resourceenvironment b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/My.resourceenvironment new file mode 100644 index 000000000..6a4ca4ad3 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/My.resourceenvironment @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/UsageevolutionTest-Simulizar.launch b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/UsageevolutionTest-Simulizar.launch new file mode 100644 index 000000000..4efe8cc15 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/UsageevolutionTest-Simulizar.launch @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/constant.dlim b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/constant.dlim new file mode 100644 index 000000000..c40f0fc34 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/constant.dlim @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.allocation b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.allocation new file mode 100644 index 000000000..38c81fd43 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.allocation @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.dlim b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.dlim new file mode 100644 index 000000000..08ca3f0d8 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.dlim @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.repository b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.repository new file mode 100644 index 000000000..4b086c878 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.repository @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.system b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.system new file mode 100644 index 000000000..e855e7dc9 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.system @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.usageevolution b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.usageevolution new file mode 100644 index 000000000..9ed964743 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.usageevolution @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.usagemodel b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.usagemodel new file mode 100644 index 000000000..c088c7505 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/default.usagemodel @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/representations.aird b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/representations.aird new file mode 100644 index 000000000..af2e51386 --- /dev/null +++ b/tests/org.palladiosimulator.simulizar.tests/testmodels/usageevolutionTest/representations.aird @@ -0,0 +1,987 @@ + + + + My.resourceenvironment + pathmap://PCM_MODELS/Palladio.resourcetype + default.allocation + default.system + default.repository + default.usagemodel + pathmap://PCM_MODELS/FailureTypes.repository + pathmap://PCM_MODELS/PrimitiveTypes.repository + default.usageevolution + default.dlim + constant.dlim + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +