Search in sources :

Example 6 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method testChangeComponent2AtomicActions.

/**
 * Replace component action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testChangeComponent2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final ChangeRepositoryComponentAction changeComponentAction;
    // Change component specific setup
    this.redeploymentModel.changeRepositoryCompBxToCompBy();
    this.initializeModelGraphs();
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
    redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc1().getId(), this.redeploymentModelGraph.getComponents());
    changeComponentAction = AssemblyContextActionFactory.generateChangeRepositoryComponentAction(runtimeNode, redeploymentNode);
    systemAdaptationModel.getActions().add(changeComponentAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(7));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof DeployComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof MigrateComponentStateAction);
    Assert.assertTrue(executionPlan.getActions().get(2) instanceof ConnectComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(3) instanceof BlockRequestsToComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(4) instanceof FinishComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(5) instanceof DisconnectComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(6) instanceof UndeployComponentAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) UndeployComponentAction(org.iobserve.adaptation.executionplan.UndeployComponentAction) BlockRequestsToComponentAction(org.iobserve.adaptation.executionplan.BlockRequestsToComponentAction) MigrateComponentStateAction(org.iobserve.adaptation.executionplan.MigrateComponentStateAction) ConnectComponentAction(org.iobserve.adaptation.executionplan.ConnectComponentAction) FinishComponentAction(org.iobserve.adaptation.executionplan.FinishComponentAction) DisconnectComponentAction(org.iobserve.adaptation.executionplan.DisconnectComponentAction) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) ChangeRepositoryComponentAction(org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction) DeployComponentAction(org.iobserve.adaptation.executionplan.DeployComponentAction) Test(org.junit.Test)

Example 7 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method testMigrateAction2AtomicActions.

/**
 * migrate action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testMigrateAction2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final MigrateAction migrateAction;
    // Migration specific setup
    this.redeploymentModel.migrateCompBToRc2();
    this.initializeModelGraphs();
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
    redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc1().getId(), this.redeploymentModelGraph.getComponents());
    migrateAction = AssemblyContextActionFactory.generateMigrateAction(runtimeNode, redeploymentNode);
    systemAdaptationModel.getActions().add(migrateAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(7));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof DeployComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof MigrateComponentStateAction);
    Assert.assertTrue(executionPlan.getActions().get(2) instanceof ConnectComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(3) instanceof BlockRequestsToComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(4) instanceof FinishComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(5) instanceof DisconnectComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(6) instanceof UndeployComponentAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) UndeployComponentAction(org.iobserve.adaptation.executionplan.UndeployComponentAction) BlockRequestsToComponentAction(org.iobserve.adaptation.executionplan.BlockRequestsToComponentAction) MigrateComponentStateAction(org.iobserve.adaptation.executionplan.MigrateComponentStateAction) ConnectComponentAction(org.iobserve.adaptation.executionplan.ConnectComponentAction) FinishComponentAction(org.iobserve.adaptation.executionplan.FinishComponentAction) DisconnectComponentAction(org.iobserve.adaptation.executionplan.DisconnectComponentAction) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction) DeployComponentAction(org.iobserve.adaptation.executionplan.DeployComponentAction) Test(org.junit.Test)

Example 8 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode 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()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction) Test(org.junit.Test)

Example 9 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode 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()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) ReplicateAction(org.iobserve.planning.systemadaptation.ReplicateAction) Test(org.junit.Test)

Aggregations

ComponentNode (org.iobserve.adaptation.data.graph.ComponentNode)9 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)8 Test (org.junit.Test)8 AdaptationData (org.iobserve.adaptation.data.AdaptationData)4 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)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 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)2 DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)2 MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)2 ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)2 AssemblyContextAction (org.iobserve.planning.systemadaptation.AssemblyContextAction)1