Search in sources :

Example 1 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method executeStage.

private ExecutionPlan executeStage(final SystemAdaptation systemAdaptationModel) {
    final InitialElementProducer<SystemAdaptation> producer = new InitialElementProducer<>(systemAdaptationModel);
    final AtomicActionComputation atomicActionComputation = new AtomicActionComputation();
    final CollectorSink<ExecutionPlan> collector = new CollectorSink<>();
    final AtomicActionComputationTestConfig configuration = new AtomicActionComputationTestConfig(producer, atomicActionComputation, collector);
    final Execution<AtomicActionComputationTestConfig> execution = new Execution<>(configuration);
    execution.executeBlocking();
    return collector.getElements().get(0);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) InitialElementProducer(teetime.stage.InitialElementProducer) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) Execution(teetime.framework.Execution) CollectorSink(teetime.stage.CollectorSink) AtomicActionComputation(org.iobserve.adaptation.stages.AtomicActionComputation)

Example 2 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method testReplicateAction2AtomicActions.

/**
 * replicate action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testReplicateAction2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final ReplicateAction replicateAction;
    // Replication specific setup
    this.redeploymentModel.replicateCompBToRc2();
    this.initializeModelGraphs();
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
    redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc2().getId(), this.redeploymentModelGraph.getComponents());
    replicateAction = AssemblyContextActionFactory.generateReplicateAction(runtimeNode, redeploymentNode);
    systemAdaptationModel.getActions().add(replicateAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(3));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof DeployComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof MigrateComponentStateAction);
    Assert.assertTrue(executionPlan.getActions().get(2) instanceof ConnectComponentAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) MigrateComponentStateAction(org.iobserve.adaptation.executionplan.MigrateComponentStateAction) ConnectComponentAction(org.iobserve.adaptation.executionplan.ConnectComponentAction) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) ReplicateAction(org.iobserve.planning.systemadaptation.ReplicateAction) DeployComponentAction(org.iobserve.adaptation.executionplan.DeployComponentAction) Test(org.junit.Test)

Example 3 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method testDeallocateAction2AtomicActions.

/**
 * deallocate action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testDeallocateAction2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final DeploymentNode runtimeNode;
    final DeallocateAction deallocateAction;
    // Deallocation specific setup ((simulated by an allocation in the runtime model)
    this.runtimeModel.allocateResourceContainerR3();
    this.initializeModelGraphs();
    runtimeNode = this.findDeploymentNodeByID(this.runtimeModel.getRc3().getId(), this.runtimeModelGraph.getServers());
    deallocateAction = ResourceContainerActionFactory.createDeallocateAction(runtimeNode);
    systemAdaptationModel.getActions().add(deallocateAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(2));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof DisconnectNodeAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof DeallocateNodeAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) DeallocateNodeAction(org.iobserve.adaptation.executionplan.DeallocateNodeAction) DeploymentNode(org.iobserve.adaptation.data.graph.DeploymentNode) DeallocateAction(org.iobserve.planning.systemadaptation.DeallocateAction) DisconnectNodeAction(org.iobserve.adaptation.executionplan.DisconnectNodeAction) Test(org.junit.Test)

Example 4 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method testChangeRepositoryRule.

/**
 * Test change repository rule.
 *
 * @throws Exception
 *             on internal errors.
 */
@Test
public void testChangeRepositoryRule() throws Exception {
    final AdaptationData adaptationData;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final SystemAdaptation actualOutput;
    final ChangeRepositoryComponentAction actualAction;
    final ChangeRepositoryComponentAction expectedAction;
    // Perform change of component
    this.redeploymentModel.changeRepositoryCompBxToCompBy();
    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.generateChangeRepositoryComponentAction(runtimeNode, redeploymentNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof ChangeRepositoryComponentAction);
    actualAction = (ChangeRepositoryComponentAction) 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()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) ChangeRepositoryComponentAction(org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction) Test(org.junit.Test)

Example 5 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method testDeallocateRule.

/**
 * Test whether the de-allocation rule succeeds.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testDeallocateRule() throws Exception {
    final AdaptationData adaptationData;
    final DeploymentNode runtimeNode;
    final SystemAdaptation actualOutput;
    final DeallocateAction actualAction;
    final DeallocateAction expectedAction;
    // Perform deallocation (simulated by an allocation in the runtime model)
    this.runtimeModel.allocateResourceContainerR3();
    adaptationData = this.createAdaptationData();
    // Create expected output
    runtimeNode = this.findDeploymentNodeByID(this.runtimeModel.getRc3().getId(), adaptationData.getRuntimeGraph().getServers());
    expectedAction = ResourceContainerActionFactory.createDeallocateAction(runtimeNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof DeallocateAction);
    actualAction = (DeallocateAction) actualOutput.getActions().get(0);
    Assert.assertThat(actualAction.getTargetResourceContainer(), Matchers.is(expectedAction.getTargetResourceContainer()));
    Assert.assertThat(actualAction.getTargetLinkingResources(), Matchers.is(expectedAction.getTargetLinkingResources()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) DeploymentNode(org.iobserve.adaptation.data.graph.DeploymentNode) DeallocateAction(org.iobserve.planning.systemadaptation.DeallocateAction) AdaptationData(org.iobserve.adaptation.data.AdaptationData) Test(org.junit.Test)

Aggregations

SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)16 Test (org.junit.Test)12 ComponentNode (org.iobserve.adaptation.data.graph.ComponentNode)8 AdaptationData (org.iobserve.adaptation.data.AdaptationData)7 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)7 DeploymentNode (org.iobserve.adaptation.data.graph.DeploymentNode)4 BlockRequestsToComponentAction (org.iobserve.adaptation.executionplan.BlockRequestsToComponentAction)3 ConnectComponentAction (org.iobserve.adaptation.executionplan.ConnectComponentAction)3 DeployComponentAction (org.iobserve.adaptation.executionplan.DeployComponentAction)3 DisconnectComponentAction (org.iobserve.adaptation.executionplan.DisconnectComponentAction)3 FinishComponentAction (org.iobserve.adaptation.executionplan.FinishComponentAction)3 MigrateComponentStateAction (org.iobserve.adaptation.executionplan.MigrateComponentStateAction)3 UndeployComponentAction (org.iobserve.adaptation.executionplan.UndeployComponentAction)3 AllocateAction (org.iobserve.planning.systemadaptation.AllocateAction)2 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)2 DeallocateAction (org.iobserve.planning.systemadaptation.DeallocateAction)2 DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)2 MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)2 ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)2 Execution (teetime.framework.Execution)2