use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.
the class ComposedActionComputationTest method testAllocateRule.
/**
* Test whether the allocation rule succeeds.
*
* @throws Exception
* on internal errors
*/
@Test
public void testAllocateRule() throws Exception {
final AdaptationData adaptationData;
final DeploymentNode redeploymentNode;
final SystemAdaptation actualOutput;
final AllocateAction actualAction;
final AllocateAction expectedAction;
// Perform allocation
this.redeploymentModel.allocateResourceContainerR3();
adaptationData = this.createAdaptationData();
// Create expected output
redeploymentNode = this.findDeploymentNodeByID(this.redeploymentModel.getRc3().getId(), adaptationData.getReDeploymentGraph().getServers());
expectedAction = ResourceContainerActionFactory.createAllocateAction(redeploymentNode);
// Execute stage
actualOutput = this.executeStage(adaptationData);
Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
Assert.assertTrue(actualOutput.getActions().get(0) instanceof AllocateAction);
actualAction = (AllocateAction) actualOutput.getActions().get(0);
Assert.assertThat(actualAction.getTargetResourceContainer(), Matchers.is(expectedAction.getTargetResourceContainer()));
Assert.assertThat(actualAction.getTargetLinkingResources(), Matchers.is(expectedAction.getTargetLinkingResources()));
}
use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.
the class ComposedActionComputationTest method testMigrationRule.
/**
* Test migration rule.
*
* @throws Exception
* on internal error
*/
@Test
public void testMigrationRule() throws Exception {
final AdaptationData adaptationData;
final ComponentNode runtimeNode;
final ComponentNode redeploymentNode;
final SystemAdaptation actualOutput;
final MigrateAction actualAction;
final MigrateAction expectedAction;
// Perform migration
this.redeploymentModel.migrateCompBToRc2();
adaptationData = this.createAdaptationData();
// Create expected output
runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), adaptationData.getRuntimeGraph().getComponents());
redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc1().getId(), adaptationData.getReDeploymentGraph().getComponents());
expectedAction = AssemblyContextActionFactory.generateMigrateAction(runtimeNode, redeploymentNode);
// Execute stage
actualOutput = this.executeStage(adaptationData);
Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
Assert.assertTrue(actualOutput.getActions().get(0) instanceof MigrateAction);
actualAction = (MigrateAction) actualOutput.getActions().get(0);
Assert.assertThat(actualAction.getTargetAllocationContext(), Matchers.is(expectedAction.getTargetAllocationContext()));
Assert.assertThat(actualAction.getTargetProvidingAllocationContexts(), Matchers.is(expectedAction.getTargetProvidingAllocationContexts()));
Assert.assertThat(actualAction.getTargetRequiringAllocationContexts(), Matchers.is(expectedAction.getTargetRequiringAllocationContexts()));
Assert.assertThat(actualAction.getSourceAllocationContext(), Matchers.is(expectedAction.getSourceAllocationContext()));
Assert.assertThat(actualAction.getSourceProvidingAllocationContexts(), Matchers.is(expectedAction.getSourceProvidingAllocationContexts()));
Assert.assertThat(actualAction.getSourceRequiringAllocationContexts(), Matchers.is(expectedAction.getSourceRequiringAllocationContexts()));
}
use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.
the class ComposedActionComputationTest method testReplicationRule.
/**
* test replication rule.
*
* @throws Exception
* on internal errors
*/
@Test
public void testReplicationRule() throws Exception {
final AdaptationData adaptationData;
final ComponentNode runtimeNode;
final ComponentNode redeploymentNode;
final SystemAdaptation actualOutput;
final ReplicateAction actualAction;
final ReplicateAction expectedAction;
// Perform replication
this.redeploymentModel.replicateCompBToRc2();
adaptationData = this.createAdaptationData();
// Create expected output
runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), adaptationData.getRuntimeGraph().getComponents());
redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc2().getId(), adaptationData.getReDeploymentGraph().getComponents());
expectedAction = AssemblyContextActionFactory.generateReplicateAction(runtimeNode, redeploymentNode);
// Execute stage
actualOutput = this.executeStage(adaptationData);
Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
Assert.assertTrue(actualOutput.getActions().get(0) instanceof ReplicateAction);
actualAction = (ReplicateAction) actualOutput.getActions().get(0);
Assert.assertThat(actualAction.getTargetAllocationContext(), Matchers.is(expectedAction.getTargetAllocationContext()));
Assert.assertThat(actualAction.getTargetProvidingAllocationContexts(), Matchers.is(expectedAction.getTargetProvidingAllocationContexts()));
Assert.assertThat(actualAction.getTargetRequiringAllocationContexts(), Matchers.is(expectedAction.getTargetRequiringAllocationContexts()));
Assert.assertThat(actualAction.getSourceAllocationContext(), Matchers.is(expectedAction.getSourceAllocationContext()));
}
use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.
the class ComposedActionComputationTest method executeStage.
private SystemAdaptation executeStage(final AdaptationData adaptationData) {
final InitialElementProducer<AdaptationData> producer = new InitialElementProducer<>(adaptationData);
final ComposedActionComputation composedActionComputation = new ComposedActionComputation();
final CollectorSink<SystemAdaptation> collector = new CollectorSink<>();
final ComposedActionComputationTestConfig configuration = new ComposedActionComputationTestConfig(producer, this.actionFactoryInitializer, composedActionComputation, collector);
final Execution<ComposedActionComputationTestConfig> execution = new Execution<>(configuration);
execution.executeBlocking();
return collector.getElements().get(0);
}
use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.
the class ComposedActionComputation method execute.
@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
final HostComponentAllocationGraph runtimeGraph = adaptationData.getRuntimeGraph();
final HostComponentAllocationGraph redeploymentGraph = adaptationData.getReDeploymentGraph();
final List<Command<?>> workingMemoryInserts = new ArrayList<>();
final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
// Add system adaptation model (its list of actions will be filled with by the rule engine)
workingMemoryInserts.add(this.kieCommands.newInsert(systemAdaptationModel));
// Add component nodes and deployment nodes of runtime and redeployment model graph
this.addToWorkingMemoryInserts(workingMemoryInserts, runtimeGraph.getComponents());
this.addToWorkingMemoryInserts(workingMemoryInserts, runtimeGraph.getServers());
this.addToWorkingMemoryInserts(workingMemoryInserts, redeploymentGraph.getComponents());
this.addToWorkingMemoryInserts(workingMemoryInserts, redeploymentGraph.getServers());
// Execute rule engine which will add actions to composedAdaptationActions
this.kSession.execute(this.kieCommands.newBatchExecution(workingMemoryInserts));
this.outputPort.send(systemAdaptationModel);
}
Aggregations